|
@@ -5,18 +5,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.BaseEntity;
|
|
|
import com.fjhx.entity.example.ExampleDetails;
|
|
|
import com.fjhx.entity.example.ExampleInfo;
|
|
|
+import com.fjhx.entity.process.ProcessNode;
|
|
|
+import com.fjhx.enums.ButtonNameEnum;
|
|
|
import com.fjhx.mapper.example.ExampleInfoMapper;
|
|
|
import com.fjhx.service.example.ExampleDetailsService;
|
|
|
import com.fjhx.service.example.ExampleInfoService;
|
|
|
-import com.fjhx.service.process.ProcessInfoService;
|
|
|
-import com.fjhx.service.process.ProcessNodeButtonService;
|
|
|
-import com.fjhx.service.process.ProcessTenantService;
|
|
|
+import com.fjhx.service.process.ProcessNodeService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
+import com.fjhx.utils.UserClientUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -30,13 +33,7 @@ import java.util.Map;
|
|
|
public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, ExampleInfo> implements ExampleInfoService {
|
|
|
|
|
|
@Autowired
|
|
|
- private ProcessTenantService processTenantService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ProcessInfoService processInfoService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ProcessNodeButtonService processNodeButtonService;
|
|
|
+ private ProcessNodeService processNodeService;
|
|
|
|
|
|
@Autowired
|
|
|
private ExampleDetailsService exampleDetailsService;
|
|
@@ -48,20 +45,80 @@ public class ExampleInfoServiceImpl extends ServiceImpl<ExampleInfoMapper, Examp
|
|
|
ExampleInfo exampleInfo = getOne(ExampleInfo::getFlowLinkNo, flowLinkNo);
|
|
|
|
|
|
// 查询已处理节点
|
|
|
- List<Map<String, Object>> list = exampleDetailsService.listMaps(
|
|
|
+ List<Map<String, Object>> result = exampleDetailsService.listMaps(
|
|
|
Wrappers.<ExampleDetails>query()
|
|
|
.select("handle_user_id userId", // 处理人id
|
|
|
"remarks", // 审批意见
|
|
|
+ "name_type type", // 处理类型
|
|
|
"process_node_id nodeId", // 节点id
|
|
|
- "name_type type" // 处理类型
|
|
|
+ "create_"
|
|
|
)
|
|
|
.lambda()
|
|
|
.eq(ExampleDetails::getExampleInfoId, exampleInfo.getId())
|
|
|
.orderByAsc(BaseEntity::getId)
|
|
|
);
|
|
|
|
|
|
- // 查询为处理节点
|
|
|
+ // 查询用户名称与岗位
|
|
|
+ List<Long> userId = result.stream().map(item -> (Long) item.get("userId")).collect(Collectors.toList());
|
|
|
+ Map<Long, Map<String, Object>> userNameAndPost = UserClientUtil.getUserNameAndPostByUserId(userId);
|
|
|
+
|
|
|
+
|
|
|
+ // 查询所有节点
|
|
|
+ List<ProcessNode> processNodeList = processNodeService.list(ProcessNode::getProcessTenantId, exampleInfo.getProcessTenantId());
|
|
|
+
|
|
|
+ // 根据节点id封装为map
|
|
|
+ Map<Long, ProcessNode> processNodeMap = processNodeList.stream().collect(Collectors.toMap(ProcessNode::getId, item -> item));
|
|
|
+ // 根据父节点id封装为map
|
|
|
+ Map<Long, List<ProcessNode>> parentProcessNodeMap = processNodeList.stream().collect(Collectors.groupingBy(ProcessNode::getParentId));
|
|
|
+
|
|
|
+ // 下一节点id
|
|
|
+ ProcessNode nextNode = null;
|
|
|
+
|
|
|
+ if (result.size() > 0) {
|
|
|
+
|
|
|
+ for (Map<String, Object> map : result) {
|
|
|
+
|
|
|
+ // 赋值节点名称
|
|
|
+ String nodeName = processNodeMap.get((Long) map.get("nodeId")).getName();
|
|
|
+ map.put("nodeName", nodeName);
|
|
|
+
|
|
|
+ // 处理类型名称
|
|
|
+ String typeName = ButtonNameEnum.get((Integer) map.get("type")).getName();
|
|
|
+ map.put("typeName", typeName);
|
|
|
+
|
|
|
+ // 赋值用户名称与岗位
|
|
|
+ Map<String, Object> userNameAndPostMap = userNameAndPost.get((Long) map.get("userId"));
|
|
|
+ if (userNameAndPostMap != null) {
|
|
|
+ map.putAll(userNameAndPostMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> map = result.get(result.size() - 1);
|
|
|
+ List<ProcessNode> processNodes = parentProcessNodeMap.get((Long) map.get("nodeId"));
|
|
|
+ if (processNodes != null && processNodes.size() == 1) {
|
|
|
+ nextNode = processNodes.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ nextNode = processNodeList.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 寻找之后未处理的节点
|
|
|
+ while (nextNode != null) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("type", 0);
|
|
|
+ map.put("typeName", "未开始");
|
|
|
+ map.put("nodeName", nextNode.getName());
|
|
|
+ map.put("nodeId", nextNode.getId());
|
|
|
+ result.add(map);
|
|
|
+
|
|
|
+ List<ProcessNode> processNodes = parentProcessNodeMap.get(nextNode.getId());
|
|
|
+ if (processNodes != null && processNodes.size() == 1) {
|
|
|
+ nextNode = processNodes.get(0);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|