Przeglądaj źródła

矿山域-流程管理

ltt 1 rok temu
rodzic
commit
59945aa3e2

+ 3 - 2
business-modules/business-mine/src/main/java/com/sckw/mine/controller/WorkFlowController.java

@@ -1,6 +1,7 @@
 package com.sckw.mine.controller;
 
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.mine.entity.req.StatusActionReq;
 import com.sckw.mine.entity.req.WorkFlowInsertParam;
 import com.sckw.mine.entity.req.WorkFlowPageListParam;
 import com.sckw.mine.entity.req.WorkFlowUpdateParam;
@@ -70,8 +71,8 @@ public class WorkFlowController {
      * @Date: 2024/5/31 14:46
      */
     @RequestMapping("/statusAction")
-    public HttpResult statusAction(@RequestParam("id") String id , @RequestParam("status") Integer status) {
-        return workFlowService.statusAction(id, status);
+    public HttpResult statusAction(@RequestBody StatusActionReq statusActionReq) {
+        return workFlowService.statusAction(statusActionReq.getId(), statusActionReq.getStatus());
     }
 
     /**

+ 1 - 1
business-modules/business-mine/src/main/java/com/sckw/mine/entity/KwBusinessMineralAggregate.java

@@ -50,7 +50,7 @@ public class KwBusinessMineralAggregate implements Serializable {
     /**
      * 矿料重量
      */
-    private Double weight;
+    private String weight;
 
     /**
      * 状态=1(正常)

+ 2 - 0
business-modules/business-mine/src/main/java/com/sckw/mine/entity/req/MineralAggPageListParam.java

@@ -29,4 +29,6 @@ public class MineralAggPageListParam {
     private Date startTime;
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endTime;
+
+    private String createBy;
 }

+ 2 - 0
business-modules/business-mine/src/main/java/com/sckw/mine/entity/req/NodePageListParam.java

@@ -22,4 +22,6 @@ public class NodePageListParam {
     private Integer nodeType;
 
     private Integer status;
+
+    private String createBy;
 }

+ 8 - 0
business-modules/business-mine/src/main/java/com/sckw/mine/entity/req/WorkFlowPageListParam.java

@@ -1,7 +1,10 @@
 package com.sckw.mine.entity.req;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
+import java.util.Date;
+
 /**
  * @desc:
  * @author: Lt
@@ -27,4 +30,9 @@ public class WorkFlowPageListParam {
     private String workName;
 
     private String tenantId;
+
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
 }

+ 1 - 1
business-modules/business-mine/src/main/java/com/sckw/mine/entity/res/MineOrderDetailRes.java

@@ -146,7 +146,7 @@ public class MineOrderDetailRes {
     /*
     矿料重量
      */
-    private BigDecimal mineWeight;
+    private String mineWeight;
 
     private String transportOrderNo;
 

+ 1 - 0
business-modules/business-mine/src/main/java/com/sckw/mine/mapper/WorkFlowNodeMapper.java

@@ -1,6 +1,7 @@
 package com.sckw.mine.mapper;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.mine.entity.KwBusinessWorkFlow;
 import com.sckw.mine.entity.KwBusinessWorkFlowNode;

+ 8 - 0
business-modules/business-mine/src/main/java/com/sckw/mine/service/MineService.java

@@ -65,6 +65,9 @@ public class MineService {
     @Autowired
     WorkFlowNodeMapper workFlowNodeMapper;
 
+    @Autowired
+    WorkFlowMapper workFlowMapper;
+
     @Autowired
     OrderDictService orderDictService;
 
@@ -110,6 +113,11 @@ public class MineService {
             //orderServerCommon.saveActionTrack(orderId, String.valueOf(1), "确认下单", "确认下单", true);
             orderServerCommon.saveActionTrack(orderId, String.valueOf(2), "订单审核", "订单审核", false);
 
+            //流程使用数+1
+            LambdaUpdateWrapper<KwBusinessWorkFlow> objectLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+            objectLambdaUpdateWrapper.eq(KwBusinessWorkFlow::getId, mineAddParam.getWorkFlow());
+            objectLambdaUpdateWrapper.setSql("use_order_count = use_order_count + 1");
+            workFlowMapper.update(null, objectLambdaUpdateWrapper);
             return "添加成功";
         } catch (Exception e) {
             throw new Exception(e.getMessage());

+ 64 - 1
business-modules/business-mine/src/main/java/com/sckw/mine/service/NodeService.java

@@ -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

+ 2 - 2
business-modules/business-mine/src/main/resources/mapper/KwBusinessActionTrackMapper.xml

@@ -56,10 +56,10 @@
             <if test="param.cgCompany != '' and param.cgCompany != null">
                 and o.cg_company like concat('%', #{param.cgCompany}, '%')
             </if>
-            <if test="param.startTime != '' and param.startTime != null">
+            <if test="param.startTime != null">
                 and tk.create_time >= #{param.startTime}
             </if>
-            <if test="param.endTime != '' and param.endTime != null">
+            <if test="param.endTime != null">
                 and tk.create_time  &lt;= #{param.endTime}
             </if>
             <if test="param.status != null">

+ 2 - 2
business-modules/business-mine/src/main/resources/mapper/MineOrderMapper.xml

@@ -47,10 +47,10 @@
             <if test="param.orderSource != '' and param.orderSource != null">
                 and o.order_source  = #{param.orderSource}
             </if>
-            <if test="param.startTime != '' and param.startTime != null">
+            <if test="param.startTime != null">
                 and o.create_time  >=  #{param.startTime}
             </if>
-            <if test="param.endTime != '' and param.endTime != null">
+            <if test="param.endTime != null">
                 and o.create_time  &lt; #{param.endTime}
             </if>
             <if test="param.tenantId != '' and param.tenantId != null">

+ 7 - 4
business-modules/business-mine/src/main/resources/mapper/MineralAggregateMapper.xml

@@ -41,11 +41,14 @@
             <if test="param.status != null">
                 and `status` = #{param.status}
             </if>
-            <if test="param.startTime != '' and param.startTime != null">
-                and o.create_time  >=  #{param.startTime}
+            <if test="param.startTime != null">
+                and create_time  >=  #{param.startTime}
             </if>
-            <if test="param.endTime != '' and param.endTime != null">
-                and o.create_time  &lt; #{param.endTime}
+            <if test="param.endTime != null">
+                and create_time  &lt; #{param.endTime}
+            </if>
+            <if test="param.createBy != '' and param.createBy != null">
+                and create_by like concat('%',#{param.createBy},'%')
             </if>
         </where>
         order by create_time desc

+ 3 - 0
business-modules/business-mine/src/main/resources/mapper/NodeMapper.xml

@@ -37,6 +37,9 @@
             <if test="param.status != null">
                 and `status` = #{param.status}
             </if>
+            <if test="param.createBy != null and param.createBy != ''">
+                and create_by like concat('%',#{param.createBy},'%')
+            </if>
         </where>
         order by node_sort desc,create_time desc
     </select>

+ 6 - 0
business-modules/business-mine/src/main/resources/mapper/WorkFlowMapper.xml

@@ -51,6 +51,12 @@
             <if test="param.id != null">
                 and id = #{param.id}
             </if>
+            <if test="param.startTime != null">
+                and create_time >= #{param.startTime}
+            </if>
+            <if test="param.endTime != null">
+                and create_time &lt; #{param.endTime}
+            </if>
         </where>
 
         order by create_time desc