From fccfe7d50f42f5be4c4612d61b7ae852e2ef37cd Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期四, 17 四月 2025 15:26:09 +0800
Subject: [PATCH] 优化指派设备与审签设备的权限校验查询,新增导入电子样板触发审签流程,新增电子样板指派设备功能

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java |  168 ++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 114 insertions(+), 54 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..9b22567 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,7 @@
 package org.jeecg.modules.dnc.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -8,31 +9,27 @@
 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;
+import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
+import org.jeecg.modules.dnc.request.TreeInfoRequest;
 import org.jeecg.modules.dnc.response.CommonCode;
 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;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ComponentInfoSeServiceImpl extends ServiceImpl<ComponentInfoMapper, ComponentInfo> implements IComponentInfoService {
@@ -41,21 +38,25 @@
     @Autowired
     public ProductInfoMapper productInfoMapper;
     @Autowired
-    private IPermissionStreamService permissionStreamService;
+    private IPermissionStreamNewService permissionStreamNewService;
     @Autowired
     private IComponentDepartmentService componentDepartmentService;
     @Autowired
     @Lazy
     private IPartsInfoService partsInfoService;
     @Autowired
+    private IProcessSpecVersionService processSpecVersionService;
+    @Autowired
     private IProcessStreamService processStreamService;
     @Autowired
-    private IDocInfoService docInfoService;
+    private IProductMixService productMixService;
     @Autowired
     private IDocRelativeService iDocRelativeService;
     @Autowired
     private IProductPermissionService productPermissionService;
-
+    @Autowired
+    @Lazy
+    private IDocInfoService docInfoService;
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public boolean addComponentInfo(ComponentInfo componentInfo) {
@@ -74,8 +75,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 +84,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 +98,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 +118,7 @@
                 ExceptionCast.cast(CommonCode.FAIL);
         }
         if(!componentDepartPermList.isEmpty()) {
-            b = permissionStreamService.saveBatch(componentDepartPermList);
+            b = permissionStreamNewService.saveBatch(componentDepartPermList);
             if(!b)
                 ExceptionCast.cast(CommonCode.FAIL);
         }
@@ -126,13 +126,23 @@
         if (!b) {
             ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
         }
-        //鍘婚櫎榛樿鏂板宸ュ簭锛岃浆涓烘墜鍔ㄦ坊鍔�
+        //娣诲姞缁撴瀯鏍�
+        ProductMix productMix=null;
+        if (componentInfo.getParentId() != null) {
+            //瀛愰儴浠�
+            productMix = new ProductMix(Long.parseLong(componentInfo.getComponentId()),Long.parseLong(componentInfo.getParentId())
+                    ,componentInfo.getComponentName(),componentInfo.getComponentCode(),2,new Date());
+        }else {
+            productMix = new ProductMix(Long.parseLong(componentInfo.getComponentId()),Long.parseLong(productInfo.getProductId())
+                    ,componentInfo.getComponentName(),componentInfo.getComponentCode(),2,new Date());
+        }
+        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.addPermissionStreamNew(stream);
     }
 
     @Override
@@ -155,6 +165,11 @@
         componentInfo.setRankLevel(null);
         componentInfo.setProductId(null);
         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);
@@ -166,13 +181,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 +242,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 +288,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 +318,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 +327,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 +343,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 +357,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 +379,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 +393,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 +402,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 +418,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 +432,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 +450,7 @@
             }
         }
         if(!permissionStreamList.isEmpty()) {
-            boolean b = permissionStreamService.removeByCollection(permissionStreamList);
+            boolean b = permissionStreamNewService.deletePermissionStreamNewByList(permissionStreamList);
             if(!b) {
                 ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
             }
@@ -506,4 +524,46 @@
         queryWrapper.orderByAsc(ComponentInfo::getCreateTime);
         return super.list(queryWrapper);
     }
+
+    /**
+     * 閫氳繃闆朵欢鍙枫�佹潗璐ㄧ瓑鏌ヨ瀵瑰簲鐢靛瓙鏍锋澘
+     * @param treeInfoRequest
+     * @return
+     */
+    @Override
+    public List<DocInfo> getByComponentInfo(TreeInfoRequest treeInfoRequest){
+        LambdaQueryWrapper<ComponentInfo> queryWrapper = new LambdaQueryWrapper<>();
+        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
+            queryWrapper.in(ComponentInfo::getProductId, treeInfoRequest.getProductIds());
+        }
+        if (treeInfoRequest.getAttributionType()==2){
+            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ComponentInfo::getComponentId,treeInfoRequest.getAttributionId());
+        }
+
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ComponentInfo::getComponentCode, treeInfoRequest.getTreeCode());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ComponentInfo::getComponentName, treeInfoRequest.getTreeName());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getStructureType()),ComponentInfo::getStructureType, treeInfoRequest.getStructureType());
+        queryWrapper.orderByDesc(ComponentInfo::getCreateTime);
+        List<ComponentInfo> list = super.list(queryWrapper);
+        List<DocInfo> docInfos = new ArrayList<>();
+        if (list != null && !list.isEmpty()) {
+            String ids=list.stream().map(ComponentInfo::getComponentId).collect(Collectors.joining(","));
+            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
+            BeanUtil.copyProperties(treeInfoRequest,docQuery);
+            docQuery.setAttributionIds(ids);
+            docQuery.setDocClassCode("OTHER");
+            docQuery.setAttributionType(2);
+            docInfos=docInfoService.findListByDocQuery(docQuery);
+        }
+        if (treeInfoRequest.getAttributionType()==2){
+            List<String> id =new ArrayList<>();
+            id.add(treeInfoRequest.getAttributionId());
+            treeInfoRequest.setComponentIds(id);
+            List<DocInfo> partsInfos = partsInfoService.getByPartsInfo(treeInfoRequest);
+            docInfos.addAll(partsInfos);
+            List<DocInfo> processSpecVersions = processSpecVersionService.getByProcessSpecVersion(treeInfoRequest);
+            docInfos.addAll(processSpecVersions);
+        }
+        return docInfos;
+    }
 }

--
Gitblit v1.9.3