From ea704e018a27c26ef6deeaea4adc8a28b4d0b27e Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期五, 17 一月 2025 17:15:29 +0800
Subject: [PATCH] 修改指派设备

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java |   91 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 80 insertions(+), 11 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
index 9d079ff..5d03027 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProductInfoServiceImpl.java
@@ -1,7 +1,9 @@
 package org.jeecg.modules.dnc.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.shiro.SecurityUtils;
@@ -65,6 +67,8 @@
     @Autowired
     @Lazy
     private IProcessStreamService processStreamService;
+    @Autowired
+    private IWorkStepService workStepService;
     @Autowired
     private IDocInfoService docInfoService;
     @Autowired
@@ -163,16 +167,27 @@
 
     @Override
     public List<CommonGenericTree> loadProductTree(String userId) {
+        //浜у搧
         List<ProductInfo> productInfoList = getByUserPerms(userId);
         if(productInfoList == null || productInfoList.isEmpty())
             return Collections.emptyList();
+        //閮ㄤ欢
         List<ComponentExt> componentInfoList = componentInfoService.getByUserPermsAs(userId);
         if(componentInfoList == null)
             componentInfoList = Collections.emptyList();
+        //闆朵欢
         List<PartsInfo> partsInfos = partsInfoService.getByUserPerms(userId);
         if(partsInfos == null)
             partsInfos = Collections.emptyList();
-        return ProductTreeWrapper.loadTree(productInfoList, componentInfoList, partsInfos);
+        //宸ュ簭
+        List<ProcessStream> processStreams=processStreamService.getByuserPerms(userId);
+        if(processStreams==null)
+            processStreams = Collections.emptyList();
+        //宸ユ
+        List<WorkStep> workStepList=workStepService.getByUserPerms(userId);
+        if(workStepList==null)
+            workStepList = Collections.emptyList();
+        return ProductTreeWrapper.loadTree(productInfoList, componentInfoList, partsInfos,processStreams,workStepList);
     }
 
     @Override
@@ -1312,21 +1327,32 @@
     @Override
     public List<String> getDepartIdsByParams(Integer nodeType, String paramId) {
         List<String> departIds = new ArrayList<>();
-        if(nodeType == 2) {
-            ComponentInfo en = componentInfoService.getById(paramId);
-            if(en == null)
+        //5-宸ュ簭
+        if(nodeType == 5) {
+            ProcessStream processStream= processStreamService.getById(paramId);
+            if(processStream == null)
                 return null;
-            List<PermissionStream> permissionStreamList = permissionStreamService.getByComponentId(en.getProductId(), en.getComponentId());
+            List<PermissionStream> permissionStreamList = permissionStreamService.list(new QueryWrapper<PermissionStream>()
+                    .eq(StrUtil.isNotEmpty(processStream.getProductId()),"product_id", processStream.getProductId())
+                    .eq(StrUtil.isNotEmpty(processStream.getComponentId()),"component_id",processStream.getComponentId())
+                    .eq(StrUtil.isNotEmpty(processStream.getPartsId()),"parts_id", processStream.getPartsId())
+                    .eq(StrUtil.isNotEmpty(processStream.getProcessId()),"process_id",processStream.getProcessId()));
             if(permissionStreamList == null || permissionStreamList.isEmpty())
                 return null;
             permissionStreamList.forEach(item -> {
                 departIds.add(item.getDepartId());
             });
-        }else if(nodeType == 3) {
-            PartsInfo en = partsInfoService.getById(paramId);
-            if(en == null)
+            //6-宸ユ
+        }else if(nodeType == 6) {
+            WorkStep workStep = workStepService.getById(paramId);
+            if(workStep == null)
                 return null;
-            List<PermissionStream> permissionStreamList = permissionStreamService.getByPartsId(en.getProductId(), en.getComponentId(), en.getPartsId());
+            List<PermissionStream> permissionStreamList = permissionStreamService.list(new QueryWrapper<PermissionStream>()
+                    .eq(StrUtil.isNotEmpty(workStep.getProductId()),"product_id", workStep.getProductId())
+                    .eq(StrUtil.isNotEmpty(workStep.getComponentId()),"component_id",workStep.getComponentId())
+                    .eq(StrUtil.isNotEmpty(workStep.getPartsId()),"parts_id", workStep.getPartsId())
+                    .eq(StrUtil.isNotEmpty(workStep.getProcessId()),"process_id",workStep.getProcessId())
+                    .eq(StrUtil.isNotEmpty(workStep.getId()),"step_id", workStep.getId()));
             if(permissionStreamList == null || permissionStreamList.isEmpty())
                 return null;
             permissionStreamList.forEach(item -> {
@@ -1335,6 +1361,10 @@
         }else {
             return null;
         }
+        //鍘婚噸
+        Set<String> set = new HashSet<>(departIds);
+        departIds.clear();
+        departIds.addAll(set);
         return departIds;
     }
 
@@ -1427,7 +1457,8 @@
         List<ProductInfo> productInfos = this.getByUserPerms(userId, queryParam);
         List<ComponentInfo> componentInfos = componentInfoService.getByUserPerms(userId, queryParam);
         List<PartsInfo> partsInfos = partsInfoService.getByUserPerms(userId, null, queryParam);
-
+        List<ProcessStream> processStreams=processStreamService.getByuserPerms(userId, queryParam);
+        List<WorkStep> workSteps=workStepService.getByUserPerms(userId, queryParam);
         List<ComponentInfo> componentInfoList = new ArrayList<>();
         List<ProductInfo> productInfoList = new ArrayList<>();
 
@@ -1462,6 +1493,44 @@
 
             if(!componentInfoMap.containsKey(p.getComponentId())) {
                 component = componentInfoService.getById(p.getComponentId());
+                if(component != null) {
+                    componentInfoMap.put(component.getComponentId(), component);
+                    componentInfoList.add(component);
+                }
+
+            }
+        }
+
+        for (ProcessStream processStream : processStreams) {
+            if (!productInfoMap.containsKey(processStream.getProductId())) {
+                product  = super.getById(processStream.getProductId());
+                if(product != null) {
+                    productInfoMap.put(product.getProductId(), product);
+                    productInfoList.add(product);
+                }
+            }
+
+            if(!componentInfoMap.containsKey(processStream.getComponentId())) {
+                component = componentInfoService.getById(processStream.getComponentId());
+                if(component != null) {
+                    componentInfoMap.put(component.getComponentId(), component);
+                    componentInfoList.add(component);
+                }
+
+            }
+        }
+
+        for (WorkStep workStep :workSteps){
+            if (!productInfoMap.containsKey(workStep.getProductId())) {
+                product  = super.getById(workStep.getProductId());
+                if(product != null) {
+                    productInfoMap.put(product.getProductId(), product);
+                    productInfoList.add(product);
+                }
+            }
+
+            if(!componentInfoMap.containsKey(workStep.getComponentId())) {
+                component = componentInfoService.getById(workStep.getComponentId());
                 if(component != null) {
                     componentInfoMap.put(component.getComponentId(), component);
                     componentInfoList.add(component);
@@ -1515,6 +1584,6 @@
         //杞崲鏁版嵁
         List<ComponentExt> componentExtList = ComponentExt.convertToExtList(componentInfoList);
 
-        return ProductTreeWrapper.loadTree(productInfoList, componentExtList, partsInfos);
+        return ProductTreeWrapper.loadTree(productInfoList, componentExtList, partsInfos,processStreams,workSteps);
     }
 }

--
Gitblit v1.9.3