From fd523aa5694b7f9350f87b30cab6bb3ae34e1c77 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 08 十月 2024 11:01:46 +0800
Subject: [PATCH] log4j2.yml配置文件中增加删除过期日志文件配置

---
 pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java |   76 +++++++++++++++++++++++++++++++-------
 1 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
index 37ca3a5..54ff76d 100644
--- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/process/ProcessSv.java
@@ -3,18 +3,12 @@
 import com.dy.common.webFilter.UserTokenContext;
 import com.dy.common.webUtil.QueryResultVo;
 import com.dy.pmsGlobal.daoOth.OthFileMapper;
-import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
-import com.dy.pmsGlobal.daoPr.PrProductionNodeMapper;
-import com.dy.pmsGlobal.daoPr.PrProductionProcessMapper;
-import com.dy.pmsGlobal.daoPr.PrWorkingInstructionMapper;
+import com.dy.pmsGlobal.daoPr.*;
 import com.dy.pmsGlobal.dyFile.FileOperate;
 import com.dy.pmsGlobal.dyFile.FileRestVo;
 import com.dy.pmsGlobal.pojoBa.BaUser;
 import com.dy.pmsGlobal.pojoOth.OthFile;
-import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
-import com.dy.pmsGlobal.pojoPr.PrProductionNode;
-import com.dy.pmsGlobal.pojoPr.PrProductionProcess;
-import com.dy.pmsGlobal.pojoPr.PrWorkingInstruction;
+import com.dy.pmsGlobal.pojoPr.*;
 import com.dy.pmsGlobal.util.UserUtil;
 import com.dy.pmsProduct.taskPlan.PlanStatusEnum;
 import lombok.extern.slf4j.Slf4j;
@@ -29,6 +23,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -38,6 +33,7 @@
     private PrProductionProcessMapper processDao;
     private PrProductionNodeMapper nodeDao;
     private PrWorkingInstructionMapper workDao;
+    private PrBillOfMaterialMapper billDao;
     private UserUtil userUtil;
     private FileOperate fileOperate;
     private OthFileMapper othFileMapper;
@@ -78,6 +74,10 @@
     public void setOthFileMapper(OthFileMapper othFileMapper) {
         this.othFileMapper = othFileMapper;
     }
+    @Autowired
+    public void setBillDao(PrBillOfMaterialMapper billDao) {
+        this.billDao = billDao;
+    }
 
     @Transactional
     public int save(PrProductionProcess process) {
@@ -105,12 +105,12 @@
         List<PrAssemblyPlan> onlinePlanList = planList.stream().filter(plan -> plan.getStatus() == PlanStatusEnum.NORMAL.getCode()).collect(Collectors.toList());
         if (CollectionUtils.isNotEmpty(planList)) {
             if (planList.stream().anyMatch(plan -> plan.getInputNumber() > 0)) { //瀛樺湪浠诲姟宸茬粡鎶曞叆鐢熶骇
-                if (!originProductionProcess.getProName().equals(process.getProName())) {
-                    throw new RuntimeException("瀛樺湪宸茬粡鎶曞叆鐢熶骇缁戝畾鐨勪换鍔�,浜у搧涓嶈兘淇敼");
+                if (!originProductionProcess.getProId().equals(process.getProId())) {
+                    throw new RuntimeException("瀛樺湪宸茬粡鎶曞叆鐢熶骇鐨勭粦瀹氫换鍔�,浜у搧涓嶈兘淇敼");
                 }
                 //鑺傜偣id涓嶈兘鍒犻櫎
-                if (!originProductionProcess.getNodes().stream().allMatch(node -> process.getNodes().stream().anyMatch(node::equals))) {
-                    throw new RuntimeException("瀛樺湪宸茬粡鎶曞叆鐢熶骇缁戝畾鐨勪换鍔�,鑺傜偣涓嶈兘鍒犻櫎");
+                if (!originProductionProcess.getNodes().stream().allMatch(node -> process.getNodes().stream().anyMatch(newNode ->  node.getId().equals(newNode.getId())))) {
+                    throw new RuntimeException("宸叉湁缁戝畾鐨勪换鍔℃姇鍏ョ敓浜�,鑺傜偣涓嶈兘鍒犻櫎");
                 }
             } else if (CollectionUtils.isNotEmpty(onlinePlanList)) {
                 //鍏堝皢缁勮浠诲姟缃负鏆傚仠鐘舵��
@@ -130,7 +130,13 @@
                 .collect(Collectors.toList());
         if (CollectionUtils.isNotEmpty(nodeIdsToDelete)) {
             nodeDao.deleteByNodeId(nodeIdsToDelete);
-            workDao.deleteByNodeId(nodeIdsToDelete);
+        }
+        //鍘熸潵鑺傜偣鐨凷OP鍏ㄩ儴鍒犻櫎
+        List<Long> originNodeIds = originProductionProcess.getNodes().stream()
+                .map(PrProductionNode::getId) // 鏄犲皠鑺傜偣鍒板叾ID
+                .collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(originNodeIds)) {
+            workDao.deleteByNodeId(originNodeIds);
         }
         saveNodesAndInstructions(process);
         return count;
@@ -144,10 +150,21 @@
         if (loginUser != null) {
             process.creator = loginUser.id;
         }
+        AtomicInteger startCount = new AtomicInteger();
+        AtomicInteger endCount = new AtomicInteger();
         process.nodes.forEach(node -> {
             node.processId = process.id;
             node.deleted = false;
+            if(node.isStart){
+                startCount.getAndIncrement();
+            }
+            if(node.isEnd){
+                endCount.getAndIncrement();
+            }
         });
+        if (startCount.get() != 1 || endCount.get() != 1) {
+            throw new RuntimeException("寮�濮嬭妭鐐瑰拰缁撴潫鑺傜偣鏈変笖鍙兘鏈変竴涓�");
+        }
     }
 
     // 灏嗚妭鐐瑰拰宸ヤ綔鎸囩ず鐨勪繚瀛橀�昏緫灏佽鍒颁竴涓柟娉曚腑
@@ -185,6 +202,17 @@
         if (CollectionUtils.isNotEmpty(workList)) {
             workDao.insertMany(workList);
         }
+
+        List<PrBillOfMaterial> billList = process.nodes.stream().map(node -> {
+            if (node.bill != null) {
+                node.bill.nodeId = node.id;
+                return node.bill;
+            }
+            return null;
+        }).filter(bill -> bill != null).toList();
+        if (CollectionUtils.isNotEmpty(billList)) {
+            billDao.insertMany(billList);
+        }
     }
 
     public int delete(Long id) {
@@ -197,6 +225,9 @@
             process.nodes.forEach(node -> {
                 if (node.instruction != null) {
                     addUrl(node.instruction);
+                }
+                if (node.bill != null) {
+                    addBillUrl(node.bill);
                 }
             });
         }
@@ -220,6 +251,9 @@
                 if (node.instruction != null) {
                     addUrl(node.instruction);
                 }
+                if (node.bill != null) {
+                    addBillUrl(node.bill);
+                }
             });
         });
         return rsVo;
@@ -238,8 +272,22 @@
             return;
         }
         FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
-        ins.webUrl = fileRestVo.fileSysRestUrl + fileRestVo.fileWebDownloadPath + ins.fileId;
+        ins.webUrl = fileRestVo.fileWebDownloadPath + ins.fileId;
         ins.orgName = file.orgName;
         ins.extName = file.extName;
     }
+
+    private void addBillUrl(PrBillOfMaterial bill) {
+        if (bill == null || bill.fileId == null) {
+            return;
+        }
+        OthFile file = othFileMapper.selectByPrimaryKey(bill.fileId);
+        if (file == null) {
+            return;
+        }
+        FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash);
+        bill.webUrl = fileRestVo.fileWebDownloadPath + bill.fileId;
+        bill.orgName = file.orgName;
+        bill.extName = file.extName;
+    }
 }

--
Gitblit v1.8.0