Commit cd830380 by zhouhaibao

[+]流程树查询

1 parent b68032e5
...@@ -3,6 +3,8 @@ package cn.com.glsx.process.modules.entity; ...@@ -3,6 +3,8 @@ package cn.com.glsx.process.modules.entity;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
@Table(name = "sop_inst_node") @Table(name = "sop_inst_node")
public class SopInstNode { public class SopInstNode {
...@@ -104,6 +106,17 @@ public class SopInstNode { ...@@ -104,6 +106,17 @@ public class SopInstNode {
@Column(name = "node_status") @Column(name = "node_status")
private Integer nodeStatus; private Integer nodeStatus;
@Transient
private List<SopInstNode> sopInstNodeList;
public List<SopInstNode> getSopInstNodeList() {
return sopInstNodeList;
}
public void setSopInstNodeList(List<SopInstNode> sopInstNodeList) {
this.sopInstNodeList = sopInstNodeList;
}
/** /**
* 获取实例节点id * 获取实例节点id
* *
......
...@@ -3,7 +3,11 @@ package cn.com.glsx.process.modules.mapper; ...@@ -3,7 +3,11 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstLink; import cn.com.glsx.process.modules.entity.SopInstLink;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface SopInstLinkMapper extends CommonBaseMapper<SopInstLink> { public interface SopInstLinkMapper extends CommonBaseMapper<SopInstLink> {
List<SopInstLink> findByInstId(@Param("instId") String instId);
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,11 @@ package cn.com.glsx.process.modules.mapper; ...@@ -3,7 +3,11 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstNode; import cn.com.glsx.process.modules.entity.SopInstNode;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> { public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> {
List<SopInstNode> findByInstId(@Param("instId") String instId);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.service; package cn.com.glsx.process.modules.service;
import cn.com.glsx.process.modules.entity.SopInstNode;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstLink; import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.mapper.SopInstLinkMapper; import cn.com.glsx.process.modules.mapper.SopInstLinkMapper;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class SopInstLinkService { public class SopInstLinkService {
@Autowired @Autowired
private SopInstLinkMapper sopInstMapper; private SopInstLinkMapper sopInstMapper;
@Autowired
private SopInstNodeService sopInstNodeService;
/** /**
* 根据id查询 * 根据id查询
* *
...@@ -59,4 +67,31 @@ public class SopInstLinkService { ...@@ -59,4 +67,31 @@ public class SopInstLinkService {
} }
return false; return false;
} }
/**
* 根据id查询
*
* @param instId
* @return
*/
public List<SopInstNode> findByInstId(String instId) {
List<SopInstLink> byInstId = sopInstMapper.findByInstId(instId);
List<SopInstNode> sopInstNodes = sopInstNodeService.findByInstId(instId);
List<SopInstNode> collected = sopInstNodes.stream().filter(index -> index.getNodeId().intValue() == 1).collect(Collectors.toList());
setchildren(collected, byInstId, sopInstNodes);
return collected;
}
private void setchildren(List<SopInstNode> sopInstNode, List<SopInstLink> byInstId, List<SopInstNode> sopInstNodes) {
for (SopInstNode instNode : sopInstNode) {
Integer nodeId = instNode.getNodeId();
List<Integer> collect = byInstId.stream().filter(index -> index.getSourceId().intValue() == nodeId).map(SopInstLink::getTargetId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
instNode.setSopInstNodeList(sopInstNodes.stream().filter(index -> collect.contains(index.getNodeId())).collect(Collectors.toList()));
setchildren(instNode.getSopInstNodeList(), byInstId, sopInstNodes);
}
continue;
}
}
} }
...@@ -6,6 +6,8 @@ import org.springframework.stereotype.Service; ...@@ -6,6 +6,8 @@ import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstNode; import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.mapper.SopInstNodeMapper; import cn.com.glsx.process.modules.mapper.SopInstNodeMapper;
import java.util.List;
@Service @Service
public class SopInstNodeService { public class SopInstNodeService {
...@@ -59,4 +61,8 @@ public class SopInstNodeService { ...@@ -59,4 +61,8 @@ public class SopInstNodeService {
} }
return false; return false;
} }
public List<SopInstNode> findByInstId(String instId) {
return sopInstNodeMapper.findByInstId( instId);
}
} }
...@@ -60,4 +60,5 @@ public class SopTplLinkService { ...@@ -60,4 +60,5 @@ public class SopTplLinkService {
return false; return false;
} }
} }
...@@ -16,4 +16,9 @@ ...@@ -16,4 +16,9 @@
--> -->
link_id, inst_id, source_id, target_id link_id, inst_id, source_id, target_id
</sql> </sql>
<select id="findByInstId" resultMap="BaseResultMap"
parameterType="java.lang.String">
SELECT * FROM sop_inst_link WHERE inst_id=#{instId}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -28,4 +28,11 @@ ...@@ -28,4 +28,11 @@
inst_node_id, inst_id, node_id, node_name, node_type, node_label, node_key, node_show, inst_node_id, inst_id, node_id, node_name, node_type, node_label, node_key, node_show,
node_param, node_content, node_visible, node_skip, node_cron, node_expire_cron, node_status node_param, node_content, node_visible, node_skip, node_cron, node_expire_cron, node_status
</sql> </sql>
<select id="findByInstId" resultMap="BaseResultMap"
parameterType="java.lang.String">
SELECT
node_id, node_name,node_type
FROM sop_inst_node WHERE inst_id=#{instId}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -7,6 +7,9 @@ import java.util.concurrent.CyclicBarrier; ...@@ -7,6 +7,9 @@ import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import cn.com.glsx.process.modules.service.SopInstLinkService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -45,6 +48,9 @@ public class TestApplication { ...@@ -45,6 +48,9 @@ public class TestApplication {
@Autowired @Autowired
private SopInstNodeExecuteJobHandler sopInstNodeExecuteJobHandler; private SopInstNodeExecuteJobHandler sopInstNodeExecuteJobHandler;
@Autowired
private SopInstLinkService sopInstLinkService;
@Test @Test
public void test() throws SQLException { public void test() throws SQLException {
SopDataSource byId = sopDataSourceService.findByDataSourceId("SOP_CDP"); SopDataSource byId = sopDataSourceService.findByDataSourceId("SOP_CDP");
...@@ -137,5 +143,11 @@ public class TestApplication { ...@@ -137,5 +143,11 @@ public class TestApplication {
JSON execute = ControllerHttpDemo.execute(jsonObject); JSON execute = ControllerHttpDemo.execute(jsonObject);
System.out.println(execute); System.out.println(execute);
} }
@Test
public void findByInstId() {
List<SopInstNode> xblc7 = sopInstLinkService.findByInstId("xblc7");
String listString = JSON.toJSONString(xblc7, SerializerFeature.DisableCircularReferenceDetect);
System.out.println(listString);
}
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!