From 2fb6c67b2c0c72195eef6fe5f7904d739b46e2c0 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期三, 25 六月 2025 11:57:28 +0800
Subject: [PATCH] Merge branch 'mdc_hyjs_master'

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java |  116 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 78 insertions(+), 38 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java
index cd089c4..3df5489 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessSpecVersionServiceImpl.java
@@ -8,6 +8,7 @@
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
 import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.dnc.exception.ExceptionCast;
 import org.jeecg.modules.dnc.mapper.ComponentInfoMapper;
@@ -35,7 +36,7 @@
     @Autowired
     private ComponentInfoMapper componentInfoMapper;
     @Autowired
-    private PartsInfoMapper processSpecVersionMapper;
+    private PartsInfoMapper partsInfoMapper;
     @Autowired
     private IPermissionStreamNewService permissionStreamNewService;
     @Autowired
@@ -90,56 +91,65 @@
 
     /**
      * 鏂板宸ヨ壓瑙勭▼鐗堟湰琛ㄤ俊鎭�
-     * @param ProcessSpecVersion
+     * @param processSpecVersion
      * @return
      */
     @Override
-    public boolean addProcessSpecVersion(ProcessSpecVersion ProcessSpecVersion){
-        if(ProcessSpecVersion == null)
+    public boolean addProcessSpecVersion(ProcessSpecVersion processSpecVersion){
+        if(processSpecVersion == null)
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionName()))
+        if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionName()))
             ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_NONE);
-        if(!ValidateUtil.validateString(ProcessSpecVersion.getProductId()))
+        if(!ValidateUtil.validateString(processSpecVersion.getProductId()))
             ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
-        if(!ValidateUtil.validateString(ProcessSpecVersion.getComponentId()))
+        if(!ValidateUtil.validateString(processSpecVersion.getComponentId()))
             ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
-        if(!ValidateUtil.validateString(ProcessSpecVersion.getPartsId()))
+        if(!ValidateUtil.validateString(processSpecVersion.getPartsId()))
             ExceptionCast.cast(ProcessInfoCode.PROCESS_PARTS_NONE);
-        if(!ValidateUtil.validateString(ProcessSpecVersion.getProcessSpecVersionCode()))
+        if(!ValidateUtil.validateString(processSpecVersion.getProcessSpecVersionCode()))
             ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_CODE_NONE);
-        ProcessSpecVersion en = getByCode(ProcessSpecVersion.getPartsId(),ProcessSpecVersion.getProcessSpecVersionCode());
+        ProcessSpecVersion en = getByCode(processSpecVersion.getPartsId(),processSpecVersion.getProcessSpecVersionCode());
         if(en != null)
             ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = user.getId();
         if(!ValidateUtil.validateString(userId))
             ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
-        ProductInfo productInfo = productInfoMapper.selectById(ProcessSpecVersion.getProductId());
+        ProductInfo productInfo = productInfoMapper.selectById(processSpecVersion.getProductId());
         if(productInfo == null)
             ExceptionCast.cast(PartsInfoCode.PARTS_PRODUCT_NONE);
-        ComponentInfo componentInfo = componentInfoMapper.selectById(ProcessSpecVersion.getComponentId());
+        ComponentInfo componentInfo = componentInfoMapper.selectById(processSpecVersion.getComponentId());
         if(componentInfo == null)
             ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
-        PartsInfo processSpecVersion = processSpecVersionMapper.selectById(ProcessSpecVersion.getPartsId());
-        if(processSpecVersion == null)
+        PartsInfo partsInfo = partsInfoMapper.selectById(processSpecVersion.getPartsId());
+        if(partsInfo == null)
             ExceptionCast.cast(PartsInfoCode.PARTS_NOT_EXIST);
-        boolean b = super.save(ProcessSpecVersion);
+        //鐩稿悓闆朵欢鍙蜂笅闈㈢増鏈彿涓嶈兘閲嶅
+        List<ProcessSpecVersion> list = super.list(new LambdaQueryWrapper<ProcessSpecVersion>().eq(ProcessSpecVersion::getPartsId,partsInfo.getPartsId()));
+        if (list != null && list.size() > 0) {
+            list.forEach(processSpecVersion1 -> {
+                if (processSpecVersion1.getProcessSpecVersionCode().equals(processSpecVersion.getProcessSpecVersionCode())) {
+                    ExceptionCast.cast(PartsInfoCode.PROCESSSPECVERSION_IS_EXIST);
+                }
+            });
+        }
+        boolean b = super.save(processSpecVersion);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
         //娣诲姞閮ㄩ棬鏉冮檺
-        List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(ProcessSpecVersion.getPartsId(),"3","1");
+        List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(processSpecVersion.getPartsId(), DocAttributionTypeEnum.PARTS.getCode().toString(),"1");
         if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
             List<ProcessSpecVersionDepartment> processSpecVersionDepartmentList = new ArrayList<>();
             List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
             oldDepartPermList.forEach(item -> {
                 ProcessSpecVersionDepartment pd = new ProcessSpecVersionDepartment();
                 pd.setDepartId(item.getDepartId());
-                pd.setPsvId(ProcessSpecVersion.getId());
+                pd.setPsvId(processSpecVersion.getId());
                 processSpecVersionDepartmentList.add(pd);
                 PermissionStreamNew perm = new PermissionStreamNew();
                 perm.setDepartId(item.getDepartId());
-                perm.setBusinessId(ProcessSpecVersion.getId());
-                perm.setBusinessType("4");
+                perm.setBusinessId(processSpecVersion.getId());
+                perm.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
                 permissionStreamList.add(perm);
             });
             if(!processSpecVersionDepartmentList.isEmpty()) {
@@ -154,19 +164,19 @@
             }
         }
         //娣诲姞鐢ㄦ埛鏉冮檺
-        b = productPermissionService.add(ProcessSpecVersion.getId(), userId,"4");
+        b = productPermissionService.add(processSpecVersion.getId(), userId,DocAttributionTypeEnum.OPERATION.getCode().toString());
         if (!b) {
             ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
         }
         //娣诲姞缁撴瀯鏍�
-        ProductMix productMix = new ProductMix(Long.parseLong(ProcessSpecVersion.getId()),Long.parseLong(ProcessSpecVersion.getPartsId())
-                ,ProcessSpecVersion.getProcessSpecVersionName(),
-                ProcessSpecVersion.getProcessSpecVersionCode(),4,new Date());
+        ProductMix productMix = new ProductMix(Long.parseLong(processSpecVersion.getId()),Long.parseLong(processSpecVersion.getPartsId())
+                ,processSpecVersion.getProcessSpecVersionName(),
+                processSpecVersion.getProcessSpecVersionCode(),DocAttributionTypeEnum.OPERATION.getCode(),new Date());
         productMixService.save(productMix);
         //娣诲姞鐢ㄦ埛鏉冮檺
         PermissionStreamNew stream = new PermissionStreamNew();
-        stream.setBusinessId(ProcessSpecVersion.getId());
-        stream.setBusinessType("4");
+        stream.setBusinessId(processSpecVersion.getId());
+        stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
         stream.setUserId(userId);
         return permissionStreamNewService.addPermissionStreamNew(stream);
     }
@@ -195,8 +205,8 @@
         boolean b = super.updateById(processSpecVersion);
         //鍚屾淇敼缁撴瀯鏍�
         ProductMix productMix = productMixService.getById(Long.parseLong(id));
-        productMix.setName(processSpecVersion.getProcessSpecVersionName());
-        productMix.setCode(processSpecVersion.getProcessSpecVersionCode());
+        productMix.setTreeName(processSpecVersion.getProcessSpecVersionName());
+        productMix.setTreeCode(processSpecVersion.getProcessSpecVersionCode());
         productMixService.updateById(productMix);
         if(!b)
             return false;
@@ -207,7 +217,7 @@
             if(!b)
                 return false;
         }
-        PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,"4");
+        PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(id, userId,DocAttributionTypeEnum.OPERATION.getCode().toString());
         if(stream == null) {
             stream = new PermissionStreamNew();
             stream.setBusinessId(id);
@@ -238,10 +248,10 @@
         b = processSpecVersionDepartmentService.deleteByPsvId(processSpecVersion.getId());
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","0");
+        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"0");
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),"4","1");
+        b = permissionStreamNewService.deletePermissionStreamNewByBusinessId(processSpecVersion.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString(),"1");
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
         b = productMixService.removeById(processSpecVersion.getId());
@@ -311,12 +321,12 @@
                 en.setPsvId(processSpecVersion.getId());
                 permissionList.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),"4");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
             if(stream == null) {
                 stream = new PermissionStreamNew();
                 stream.setUserId(item.getId());
                 stream.setBusinessId(processSpecVersion.getId());
-                stream.setBusinessType("4");
+                stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
                 permissionStreamList.add(stream);
             }
         });
@@ -353,7 +363,7 @@
             if(en != null) {
                 permissionList.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),"4");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
             if(stream != null) {
                 permissionStreamList.add(stream);
             }
@@ -393,12 +403,12 @@
                 en.setPsvId(processSpecVersion.getId());
                 partsDepartments.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),"4");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(processSpecVersion.getId(), item.getId(),DocAttributionTypeEnum.OPERATION.getCode().toString());
             if(stream == null) {
                 stream = new PermissionStreamNew();
                 stream.setDepartId(item.getId());
                 stream.setBusinessId(processSpecVersion.getId());
-                stream.setBusinessType("4");
+                stream.setBusinessType(DocAttributionTypeEnum.OPERATION.getCode().toString());
                 permissionStreamList.add(stream);
             }
         });
@@ -483,13 +493,14 @@
         if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
             queryWrapper.in(ProcessSpecVersion::getPartsId, treeInfoRequest.getPartsIds());
         }
-        if (treeInfoRequest.getAttributionType()==4){
+        if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){
             queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),ProcessSpecVersion::getId,treeInfoRequest.getAttributionId());
         }
         queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),ProcessSpecVersion::getProcessSpecVersionName, treeInfoRequest.getTreeName());
         queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),ProcessSpecVersion::getProcessSpecVersionCode, treeInfoRequest.getTreeName());
         queryWrapper.orderByDesc(ProcessSpecVersion::getCreateTime);
         List<ProcessSpecVersion> list = super.list(queryWrapper);
+        List<DocInfo> docInfos;
         if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){
             return new ArrayList<>();
         }else {
@@ -498,8 +509,37 @@
             BeanUtil.copyProperties(treeInfoRequest,docQuery);
             docQuery.setAttributionIds(ids);
             docQuery.setDocClassCode("OTHER");
-            docQuery.setAttributionType(4);
-            return docInfoService.findListByDocQuery(docQuery);
+            docQuery.setAttributionType(DocAttributionTypeEnum.OPERATION.getCode());
+            docInfos=docInfoService.findListByDocQuery(docQuery);
+            if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.OPERATION.getCode())){
+                List<String> id =new ArrayList<>();
+                id.add(treeInfoRequest.getAttributionId());
+                treeInfoRequest.setPsvIds(id);
+                //宸ュ簭
+                List<DocInfo> processStreams = processStreamService.getByProcessStreamOtherFile(treeInfoRequest);
+                docInfos.addAll(processStreams);
+                //宸ユ
+                List<DocInfo> workSteps = workStepService.getByWorkStepOtherFile(treeInfoRequest);
+                docInfos.addAll(workSteps);
+            }
+        }
+        return docInfos;
+    }
+
+    @Override
+    public boolean assignPermission(Object entity, Collection<SysUser> userList, boolean isAdd){
+        if (isAdd) {
+            return assignAddUser((ProcessSpecVersion) entity, userList);
+        } else {
+            return assignRemoveUser((ProcessSpecVersion) entity, userList);
+        }
+    }
+    @Override
+    public boolean assignDepartPermission(Object entity, Collection<MdcProduction> departments, boolean isAdd) {
+        if (isAdd) {
+            return assignAddDepart((ProcessSpecVersion) entity, departments);
+        } else {
+            return assignRemoveDepart((ProcessSpecVersion) entity, departments);
         }
     }
 }

--
Gitblit v1.9.3