|
|
@@ -2,6 +2,7 @@ package com.sckw.mine.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
@@ -13,15 +14,20 @@ import com.sckw.core.utils.TenantUtil;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.mine.common.OrderServerCommon;
|
|
|
import com.sckw.mine.entity.KwBusinessNode;
|
|
|
+import com.sckw.mine.entity.KwBusinessWorkFlowNode;
|
|
|
import com.sckw.mine.entity.req.*;
|
|
|
import com.sckw.mine.entity.res.NodeDetailRes;
|
|
|
import com.sckw.mine.entity.res.NodePageListRes;
|
|
|
import com.sckw.mine.enums.NodeTypeEnum;
|
|
|
import com.sckw.mine.mapper.NodeMapper;
|
|
|
+import com.sckw.mine.mapper.WorkFlowNodeMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @desc:
|
|
|
@@ -37,6 +43,9 @@ public class NodeService {
|
|
|
@Autowired
|
|
|
OrderServerCommon orderServerCommon;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ WorkFlowNodeMapper workFlowNodeMapper;
|
|
|
+
|
|
|
/*
|
|
|
矿料添加
|
|
|
*/
|
|
|
@@ -98,7 +107,7 @@ public class NodeService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public HttpResult pageList(NodePageListParam param) {
|
|
|
+ public HttpResult pageList_old(NodePageListParam param) {
|
|
|
|
|
|
String tenant = TenantUtil.getTenant();
|
|
|
if (StringUtils.isNotBlank(tenant)) {
|
|
|
@@ -109,10 +118,64 @@ public class NodeService {
|
|
|
businessTruckPageListRes.forEach(e -> {
|
|
|
e.setNodeTypeStr(NodeTypeEnum.getNameByCode(e.getNodeType()));
|
|
|
e.setStatusStr(e.getStatus()==1?"启用":"禁用");
|
|
|
+ final QueryWrapper<KwBusinessWorkFlowNode> objectQueryWrapper = new QueryWrapper<>();
|
|
|
+ objectQueryWrapper.eq("node_id", e.getId()).eq("del_flag", Global.NUMERICAL_ZERO);
|
|
|
+ e.setNodeUseCount(Math.toIntExact(workFlowNodeMapper.selectCount(objectQueryWrapper)));
|
|
|
+ });
|
|
|
+ return HttpResult.ok(new PageRes<>(new PageInfo<>(businessTruckPageListRes)));
|
|
|
+ }
|
|
|
+
|
|
|
+ public HttpResult pageList(NodePageListParam param) {
|
|
|
+
|
|
|
+ // Fetch tenant and set to param if present
|
|
|
+ String tenant = TenantUtil.getTenant();
|
|
|
+ if (StringUtils.isNotBlank(tenant)) {
|
|
|
+ param.setTenantId(tenant);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Start pagination
|
|
|
+ PageHelper.startPage(param.getPage(), param.getPageSize());
|
|
|
+
|
|
|
+ // Fetch the list of nodes
|
|
|
+ List<NodePageListRes> businessTruckPageListRes = nodeMapper.nodePageList(param);
|
|
|
+
|
|
|
+ // Prepare to collect node IDs for batch querying
|
|
|
+ List<String> nodeIds = businessTruckPageListRes.stream()
|
|
|
+ .map(NodePageListRes::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // Fetch node use counts in one go
|
|
|
+ Map<String, Integer> nodeUseCounts = getNodeUseCounts(nodeIds);
|
|
|
+
|
|
|
+ // Process each node
|
|
|
+ businessTruckPageListRes.forEach(e -> {
|
|
|
+ e.setNodeTypeStr(NodeTypeEnum.getNameByCode(e.getNodeType()));
|
|
|
+ e.setStatusStr(e.getStatus() == 1 ? "启用" : "禁用");
|
|
|
+ e.setNodeUseCount(nodeUseCounts.getOrDefault(e.getId(), 0));
|
|
|
});
|
|
|
+
|
|
|
+ // Return paginated result
|
|
|
return HttpResult.ok(new PageRes<>(new PageInfo<>(businessTruckPageListRes)));
|
|
|
}
|
|
|
|
|
|
+ // Helper method to get node use counts
|
|
|
+ private Map<String, Integer> getNodeUseCounts(List<String> nodeIds) {
|
|
|
+ if (nodeIds.isEmpty()) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<KwBusinessWorkFlowNode> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("node_id", nodeIds).eq("del_flag", Global.NUMERICAL_ZERO);
|
|
|
+
|
|
|
+ List<KwBusinessWorkFlowNode> nodes = workFlowNodeMapper.selectList(queryWrapper);
|
|
|
+ return nodes.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ KwBusinessWorkFlowNode::getNodeId,
|
|
|
+ node -> 1,
|
|
|
+ Integer::sum
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @Description: 状态操作(停用 启用) 1=启用 2=禁用
|
|
|
* @Author: Lt
|