From b864148d2a9afd5e1627b761da923cca8f8dfbd2 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期五, 07 三月 2025 14:44:56 +0800
Subject: [PATCH] 修改产品结构树新增删除同步结构树表,新增刀具信息与设备类

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java |   98 ++++++++++++++++++++++++------------------------
 1 files changed, 49 insertions(+), 49 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 58c024a..4dffb5e 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,7 +45,7 @@
     @Autowired
     private IProcessStreamService processStreamService;
     @Autowired
-    private IDocInfoService docInfoService;
+    private IProductMixService productMixService;
     @Autowired
     private IDocRelativeService iDocRelativeService;
     @Autowired
@@ -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,10 +78,10 @@
             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);
         }
@@ -98,17 +92,17 @@
             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);
             });
         }
@@ -118,7 +112,7 @@
                 ExceptionCast.cast(CommonCode.FAIL);
         }
         if(!componentDepartPermList.isEmpty()) {
-            b = permissionStreamService.saveBatch(componentDepartPermList);
+            b = permissionStreamNewService.saveBatch(componentDepartPermList);
             if(!b)
                 ExceptionCast.cast(CommonCode.FAIL);
         }
@@ -126,13 +120,16 @@
         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
@@ -166,13 +163,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;
     }
@@ -227,10 +224,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());
@@ -273,11 +270,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);
     }
@@ -300,7 +300,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) {
@@ -309,12 +309,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);
             }
         });
@@ -325,7 +325,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.saveBatch(permissionStreamList);
+            boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -339,13 +339,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);
             }
@@ -361,7 +361,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.removeByCollection(permissionStreamList);
+            boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -375,7 +375,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) {
@@ -384,12 +384,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);
             }
         });
@@ -400,7 +400,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.saveBatch(permissionStreamList);
+            boolean b = permissionStreamNewService.saveBatch(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -414,13 +414,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);
             }
@@ -432,7 +432,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