From 103f52ade0f77e420dec306ea3b51d0a3c0ac3ee Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期三, 19 三月 2025 13:23:12 +0800
Subject: [PATCH] art: 设备管理-系统业务编码生成,工艺参数维护功能修改

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java |  154 ++++++++++++++++++++-------------------------------
 1 files changed, 60 insertions(+), 94 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
index ef7d501..c8a6245 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
@@ -1,6 +1,5 @@
 package org.jeecg.modules.dnc.service.impl;
 
-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;
@@ -8,7 +7,7 @@
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.dnc.dto.ComponentExt;
-
+import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.dnc.exception.ExceptionCast;
 import org.jeecg.modules.dnc.mapper.ComponentInfoMapper;
 import org.jeecg.modules.dnc.mapper.ProductInfoMapper;
@@ -16,14 +15,10 @@
 import org.jeecg.modules.dnc.response.ComponentInfoCode;
 import org.jeecg.modules.dnc.response.ProductInfoCode;
 import org.jeecg.modules.dnc.response.UcenterCode;
-
 import org.jeecg.modules.dnc.service.*;
-import org.jeecg.modules.dnc.ucenter.Department;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
-import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.entity.SysUser;
-import org.jeecg.modules.dnc.entity.ComponentInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -41,7 +36,7 @@
     @Autowired
     public ProductInfoMapper productInfoMapper;
     @Autowired
-    private IPermissionStreamService permissionStreamService;
+    private IPermissionStreamNewService permissionStreamNewService;
     @Autowired
     private IComponentDepartmentService componentDepartmentService;
     @Autowired
@@ -50,11 +45,11 @@
     @Autowired
     private IProcessStreamService processStreamService;
     @Autowired
-    private IDocInfoService docInfoService;
-    @Autowired
-    private INcLogInfoService iNcLogInfoService;
+    private IProductMixService productMixService;
     @Autowired
     private IDocRelativeService iDocRelativeService;
+    @Autowired
+    private IProductPermissionService productPermissionService;
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
@@ -74,8 +69,7 @@
         String userId = user.getId();
         if(!ValidateUtil.validateString(userId))
             ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
-
-        List<PermissionStream> oldPermissionList;
+        List<PermissionStreamNew> oldPermissionList;
         ProductInfo productInfo = productInfoMapper.selectById(componentInfo.getProductId());
         if(productInfo == null)
             ExceptionCast.cast(ComponentInfoCode.COMPONENT_PRODUCT_NONE);
@@ -84,40 +78,31 @@
             if(en == null) {
                 ExceptionCast.cast(ComponentInfoCode.COMPONENT_PARENT_NOT_EXIST);
             }
-            oldPermissionList = permissionStreamService.getByComponentId(en.getProductId(), en.getComponentId());
+            oldPermissionList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(en.getComponentId(),"2","1");
             componentInfo.setRankLevel(en.getRankLevel() + 1);
         } else {
-            oldPermissionList = permissionStreamService.getByProductId(productInfo.getProductId());
+            oldPermissionList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(productInfo.getProductId(),"1","1");
             componentInfo.setParentId(null);
             componentInfo.setRankLevel(1);
         }
 
         componentInfo.setComponentStatus(1);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("閮ㄤ欢鍚嶇О锛�"+componentInfo.getComponentName()+"锛岄儴浠朵唬鍙凤細"+componentInfo.getComponentCode());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.save(componentInfo);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
         //閮ㄩ棬鏉冮檺
         List<ComponentDepartment> componentDepartmentList = new ArrayList<>();
-        List<PermissionStream> componentDepartPermList = new ArrayList<>();
+        List<PermissionStreamNew> componentDepartPermList = new ArrayList<>();
         if(oldPermissionList != null && !oldPermissionList.isEmpty()) {
             oldPermissionList.forEach(item -> {
                 ComponentDepartment componentDepartment = new ComponentDepartment();
                 componentDepartment.setComponentId(componentInfo.getComponentId());
                 componentDepartment.setDepartId(item.getDepartId());
                 componentDepartmentList.add(componentDepartment);
-                PermissionStream permissionStream = new PermissionStream();
-                permissionStream.setProductId(componentInfo.getProductId());
-                permissionStream.setComponentId(componentInfo.getComponentId());
+                PermissionStreamNew permissionStream = new PermissionStreamNew();
+                permissionStream.setBusinessId(componentInfo.getComponentId());
                 permissionStream.setDepartId(item.getDepartId());
+                permissionStream.setBusinessType("2");
                 componentDepartPermList.add(permissionStream);
             });
         }
@@ -127,40 +112,24 @@
                 ExceptionCast.cast(CommonCode.FAIL);
         }
         if(!componentDepartPermList.isEmpty()) {
-            b = permissionStreamService.saveBatch(componentDepartPermList);
+            b = permissionStreamNewService.saveBatch(componentDepartPermList);
             if(!b)
                 ExceptionCast.cast(CommonCode.FAIL);
         }
-        ComponentPermission permission = new ComponentPermission();
-        permission.setComponentId(componentInfo.getComponentId());
-        permission.setUserId(userId);
-        b = componentPermissionService.save(permission);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
-        //鍘婚櫎榛樿鏂板宸ュ簭锛岃浆涓烘墜鍔ㄦ坊鍔�
-        /*/娣诲姞榛樿宸ュ簭
-        ProcessStream processStream = new ProcessStream();
-        processStream.setProductId(componentInfo.getProductId());
-        processStream.setComponentId(componentInfo.getComponentId());
-        processStream.setProcessCode("1");
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfogx = new NcLogInfo();
-        //妯″潡
-        ncLogInfogx.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfogx.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfogx.setLogContent("閮ㄤ欢鍚嶇О锛�"+componentInfo.getComponentName()+"鐢熸垚榛樿宸ュ簭锛屽伐搴忓彿锛�"+processStream.getProcessCode());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfogx);
-        b = processStreamService.save(processStream);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);*/
+        b = productPermissionService.add(componentInfo.getComponentId(), userId,"2");
+        if (!b) {
+            ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
+        }
+        //娣诲姞缁撴瀯鏍�
+        ProductMix productMix = new ProductMix(Long.parseLong(componentInfo.getComponentId()),Long.parseLong(productInfo.getProductId())
+                ,componentInfo.getComponentName(),componentInfo.getComponentCode(),2);
+        productMixService.save(productMix);
         //娣诲姞鏉冮檺
-        PermissionStream stream = new PermissionStream();
+        PermissionStreamNew stream = new PermissionStreamNew();
         stream.setUserId(userId);
-        stream.setProductId(componentInfo.getProductId());
-        stream.setComponentId(componentInfo.getComponentId());
-        return permissionStreamService.save(stream);
+        stream.setBusinessId(componentInfo.getComponentId());
+        stream.setBusinessType("2");
+        return permissionStreamNewService.save(stream);
     }
 
     @Override
@@ -182,18 +151,12 @@
         componentInfo.setComponentStatus(null);
         componentInfo.setRankLevel(null);
         componentInfo.setProductId(null);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(3);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("淇敼閮ㄤ欢鍚嶇О锛�"+productInfoMapper.selectById(en.getProductId()).getProductName()+"瀛愰泦閮ㄤ欢");
-        //淇敼淇濆瓨澶囨敞
-        ncLogInfo.setRemark(JSONObject.toJSONString(en));
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.updateById(componentInfo);
+        //鍚屾淇敼缁撴瀯鏍�
+        ProductMix productMix = productMixService.getById(Long.parseLong(id));
+        productMix.setName(componentInfo.getComponentName());
+        productMix.setCode(componentInfo.getComponentCode());
+        productMixService.updateById(productMix);
         if(!b)
             return false;
         ComponentPermission permission = componentPermissionService.getByComponentIdAndUserId(id, userId);
@@ -205,13 +168,13 @@
             if(!b)
                 return false;
         }
-        PermissionStream stream = permissionStreamService.getByComponentIdAndUserId(en.getProductId(), id, userId);
+        PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,"2");
         if(stream == null) {
-            stream = new PermissionStream();
+            stream = new PermissionStreamNew();
             stream.setUserId(userId);
-            stream.setProductId(en.getProductId());
-            stream.setComponentId(id);
-            return permissionStreamService.save(stream);
+            stream.setBusinessId(id);
+            stream.setBusinessType("2");
+            return permissionStreamNewService.save(stream);
         }
         return b;
     }
@@ -266,10 +229,10 @@
             b = componentDepartmentService.deleteByComponentId(item.getComponentId());
             if(!b)
                 ExceptionCast.cast(ComponentInfoCode.COMPONENT_DELETE_PERM_NONE);
-            b = permissionStreamService.deleteUserPermsByComponentId(item.getProductId(), item.getComponentId());
+            b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getComponentId(),"2","0");
             if(!b)
                 ExceptionCast.cast(ComponentInfoCode.COMPONENT_DELETE_PERM_NONE);
-            b = permissionStreamService.deleteDepartPermsByComponentId(item.getProductId(), item.getComponentId());
+            b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(item.getComponentId(),"2","1");
             if(!b)
                 ExceptionCast.cast(ComponentInfoCode.COMPONENT_DELETE_PERM_NONE);
             b = super.removeById(item.getComponentId());
@@ -312,11 +275,14 @@
         b = componentDepartmentService.deleteByComponentId(id);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        b = permissionStreamService.deleteUserPermsByComponentId(componentInfo.getProductId(), componentInfo.getComponentId());
+        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","0");
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        b = permissionStreamService.deleteDepartPermsByComponentId(componentInfo.getProductId(), componentInfo.getComponentId());
+        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(componentInfo.getComponentId(),"2","1");
         if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = productMixService.removeById(id);
+        if (!b)
             ExceptionCast.cast(CommonCode.FAIL);
         return super.removeById(id);
     }
@@ -339,7 +305,7 @@
         if(componentInfo == null || userList == null || userList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<ComponentPermission> permissionList = new ArrayList<>();
-        List<PermissionStream> permissionStreamList = new ArrayList<>();
+        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
         userList.forEach(item -> {
             ComponentPermission en = componentPermissionService.getByComponentIdAndUserId(componentInfo.getComponentId(), item.getId());
             if(en == null) {
@@ -348,12 +314,12 @@
                 en.setComponentId(componentInfo.getComponentId());
                 permissionList.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByComponentIdAndUserId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId());
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(), "2 ");
             if(stream == null) {
-                stream = new PermissionStream();
+                stream = new PermissionStreamNew();
                 stream.setUserId(item.getId());
-                stream.setProductId(componentInfo.getProductId());
-                stream.setComponentId(componentInfo.getComponentId());
+                stream.setBusinessId(componentInfo.getComponentId());
+                stream.setBusinessType("2");
                 permissionStreamList.add(stream);
             }
         });
@@ -364,7 +330,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.saveBatch(permissionStreamList);
+            boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -378,13 +344,13 @@
         if(componentInfo == null || userList == null || userList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<ComponentPermission> permissionList = new ArrayList<>();
-        List<PermissionStream> permissionStreamList = new ArrayList<>();
+        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
         userList.forEach(item -> {
             ComponentPermission en = componentPermissionService.getByComponentIdAndUserId(componentInfo.getComponentId(), item.getId());
             if(en != null) {
                 permissionList.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByComponentIdAndUserId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId());
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(), "2 ");
             if(stream != null) {
                 permissionStreamList.add(stream);
             }
@@ -400,7 +366,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.removeByCollection(permissionStreamList);
+            boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -414,7 +380,7 @@
         if(componentInfo == null || departmentList == null || departmentList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<ComponentDepartment> componentDepartments = new ArrayList<>();
-        List<PermissionStream> permissionStreamList = new ArrayList<>();
+        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
         departmentList.forEach(item -> {
             ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getId());
             if(en == null) {
@@ -423,12 +389,12 @@
                 en.setComponentId(componentInfo.getComponentId());
                 componentDepartments.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId());
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(),"2");
             if(stream == null) {
-                stream = new PermissionStream();
+                stream = new PermissionStreamNew();
                 stream.setDepartId(item.getId());
-                stream.setProductId(componentInfo.getProductId());
-                stream.setComponentId(componentInfo.getComponentId());
+                stream.setBusinessId(componentInfo.getComponentId());
+                stream.setBusinessType("2");
                 permissionStreamList.add(stream);
             }
         });
@@ -439,7 +405,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.saveBatch(permissionStreamList);
+            boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -453,13 +419,13 @@
         if(componentInfo == null || departmentList == null || departmentList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<ComponentDepartment> componentDepartments = new ArrayList<>();
-        List<PermissionStream> permissionStreamList = new ArrayList<>();
+        List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
         departmentList.forEach(item -> {
             ComponentDepartment en = componentDepartmentService.getByComponentIdAndDepartId(componentInfo.getComponentId(), item.getId());
             if(en != null) {
                 componentDepartments.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByComponentIdAndDepartId(componentInfo.getProductId(), componentInfo.getComponentId(), item.getId());
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(componentInfo.getComponentId(), item.getId(),"2");
             if(stream != null) {
                 permissionStreamList.add(stream);
             }
@@ -471,7 +437,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.removeByCollection(permissionStreamList);
+            boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }

--
Gitblit v1.9.3