Commit 29d22f3c by tiger

sop加载

1 parent e56e3468
......@@ -22,7 +22,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "sop模板")
@RestController
@RequestMapping(value = "/sop/api/sop-tpl")
@RequestMapping(value = "/sop/sop-tpl")
@ResponseResultBody
public class SopTplApiController {
......@@ -32,11 +32,10 @@ public class SopTplApiController {
@Resource
private EchoCenterFeignClient echoCenterFeignClient;
@Override
@Operation(summary = "本地调用")
@GetMapping(value = "/info/{id}")
public SopStruct info(@PathVariable("tplId") String tplId) {
SopStruct sop = sopService.loadSop(tplId);
@Operation(summary = "查询实例")
@GetMapping(value = "/inst/{instId}")
public SopStruct inst(@PathVariable("instId") String instId) {
SopStruct sop = sopService.loadSop(instId);
return sop;
}
......
......@@ -2,6 +2,7 @@ package cn.com.glsx.process.modules.service;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
......@@ -9,10 +10,13 @@ import javax.annotation.Resource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.alibaba.nacos.shaded.com.google.common.collect.Sets;
import com.glsx.plat.jwt.util.JwtUtils;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopTpl;
import cn.com.glsx.process.modules.entity.SopTplGrant;
......@@ -26,6 +30,7 @@ import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
import cn.com.glsx.process.modules.mapper.SopTplMapper;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
import cn.com.glsx.process.modules.model.inst.SopStruct;
import cn.hutool.core.lang.Pair;
import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
......@@ -83,7 +88,7 @@ public class SopService {
SopTpl tpl = tplMapper.selectByPrimaryKey(grant.getTplId());
List<SopTplNode> tplNodes = tplNodeMapper
.selectByExample(Example.builder(SopTplNode.class).where(Sqls.custom().andEqualTo("tplId", grant.getTplId())));
.selectByExample(Example.builder(SopTplNode.class).where(Sqls.custom().andEqualTo("tplId", grant.getTplId())).build());
Map<Integer, SopTplNode> tplNodeMap = tplNodes.stream().collect(Collectors.toMap(SopTplNode::getNodeId, obj -> obj, (key1, key2) -> key1));
SopStruct sop = new SopStruct();
......@@ -93,13 +98,31 @@ public class SopService {
sop.setGrant(grant);
List<SopInstNode> instNodes = instNodeMapper
.selectByExample(Example.builder(SopInstNode.class).where(Sqls.custom().andEqualTo("tplId", grant.getTplId())));
.selectByExample(Example.builder(SopInstNode.class).where(Sqls.custom().andEqualTo("instId", inst.getInstId())).build());
Map<Integer, SopInstNode> instNodeMap = instNodes.stream()
.collect(Collectors.toMap(SopInstNode::getInstNodeId, obj -> obj, (key1, key2) -> key1));
sop.setInst(inst);
sop.setInstNodeMap(instNodeMap);
List<SopInstLink> instLinks = instLinkMapper
.selectByExample(Example.builder(SopInstLink.class).where(Sqls.custom().andEqualTo("instId", inst.getInstId())).build());
Map<Integer, Pair<Set<Integer>, Set<Integer>>> linkMap = Maps.newHashMap();
for (SopInstLink sl : instLinks) {
// 找出每个节点的上下节点
Pair<Set<Integer>, Set<Integer>> src = linkMap.getOrDefault(sl.getSourceId(),
new Pair<Set<Integer>, Set<Integer>>(Sets.newHashSet(), Sets.newHashSet()));
Pair<Set<Integer>, Set<Integer>> tgt = linkMap.getOrDefault(sl.getTargetId(),
new Pair<Set<Integer>, Set<Integer>>(Sets.newHashSet(), Sets.newHashSet()));
linkMap.put(sl.getSourceId(), src);
linkMap.put(sl.getTargetId(), tgt);
src.getValue().add(sl.getTargetId());
tgt.getKey().add(sl.getSourceId());
}
sop.setInstLinkMap(linkMap);
SopInstBatch batch = instBatchMapper.selectByPrimaryKey(inst.getBatchNo());
sop.setBatch(batch);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!