From 1becd6d46123723bd2b898fd565b4331fb2cb2d8 Mon Sep 17 00:00:00 2001
From: lyh <liuyuanheng@xalxzn.com>
Date: 星期五, 28 二月 2025 15:51:50 +0800
Subject: [PATCH] 新增flow able 代办已办

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java |   89 ++++++++++++--------------------------------
 1 files changed, 25 insertions(+), 64 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java
index bd53894..8cee5f7 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/PartsInfoServiceImpl.java
@@ -2,6 +2,7 @@
 
 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;
@@ -21,6 +22,7 @@
 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.apache.commons.collections4.ListUtils;
 
@@ -53,6 +55,10 @@
     private IDocInfoService docInfoService;
     @Autowired
     private INcLogInfoService iNcLogInfoService;
+    @Autowired
+    private IDocRelativeService iDocRelativeService;
+    @Autowired
+    private IProductPermissionService productPermissionService;
     @Override
     @Transactional(rollbackFor = {Exception.class})
     public boolean addPartsInfo(PartsInfo partsInfo) {
@@ -80,15 +86,6 @@
         if(componentInfo == null)
             ExceptionCast.cast(PartsInfoCode.PARTS_COMPONENT_NONE);
         partsInfo.setPartsStatus(1);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("闆朵欢鍚嶇О锛�"+partsInfo.getPartsName()+"锛岄浂浠朵唬鍙凤細"+partsInfo.getPartsCode());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.save(partsInfo);
         List<PermissionStream> oldDepartPermList = permissionStreamService.getByComponentId(componentInfo.getProductId(), componentInfo.getComponentId());
         if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
@@ -119,36 +116,16 @@
         }
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        PartsPermission permission = new PartsPermission();
-        permission.setPartsId(partsInfo.getPartsId());
-        permission.setUserId(userId);
-        b = partsPermissionService.save(permission);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
-        //娣诲姞榛樿宸ュ簭
-        ProcessStream processStream = new ProcessStream();
-        processStream.setProductId(partsInfo.getProductId());
-        processStream.setComponentId(partsInfo.getComponentId());
-        processStream.setPartsId(partsInfo.getPartsId());
-        processStream.setProcessCode("1");
-        b = processStreamService.save(processStream);
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
+        b = productPermissionService.add(partsInfo.getPartsId(), userId,"3");
+        if (!b) {
+            ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
+        }
         //娣诲姞鐢ㄦ埛鏉冮檺
         PermissionStream stream = new PermissionStream();
         stream.setProductId(partsInfo.getProductId());
         stream.setComponentId(partsInfo.getComponentId());
         stream.setPartsId(partsInfo.getPartsId());
         stream.setUserId(userId);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfogx = new NcLogInfo();
-        //妯″潡
-        ncLogInfogx.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfogx.setOperateType(2);
-        //鏃ュ織鍐呭
-        ncLogInfogx.setLogContent("闆朵欢鍚嶇О锛�"+partsInfo.getPartsName()+"鐢熸垚榛樿宸ュ簭锛屽伐搴忓彿锛�"+processStream.getProcessCode());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfogx);
         return permissionStreamService.save(stream);
     }
 
@@ -168,17 +145,6 @@
         partsInfo.setPartsStatus(null);
         partsInfo.setProductId(null);
         partsInfo.setComponentId(null);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(3);
-        //淇敼淇濆瓨澶囨敞
-        ncLogInfo.setRemark(JSONObject.toJSONString(en));
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("淇敼閮ㄤ欢鍚嶇О锛�"+productInfoMapper.selectById(en.getProductId()).getProductName()+"瀛愰泦闆朵欢");
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         boolean b = super.updateById(partsInfo);
         if(!b)
             return false;
@@ -279,6 +245,11 @@
         if(processStreams != null && !processStreams.isEmpty())
             ExceptionCast.cast(PartsInfoCode.PARTS_PROCESS_EXIST);
         boolean b = partsPermissionService.deleteByPartsId(partsInfo.getPartsId());
+        //楠岃瘉鏄惁瀛樺湪鏂囨。
+        List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","3").eq("attribution_id",partsId));
+        if (!docRelativeList.isEmpty()){
+            ExceptionCast.cast(PartsInfoCode.PARTS_DOC_EXIST);
+        }
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
         b = partsDepartmentService.deleteByPartsId(partsInfo.getPartsId());
@@ -290,18 +261,6 @@
         b = permissionStreamService.deleteDepartPermsByPartsId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId());
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
-        b = docInfoService.deleteByPartsId(partsInfo.getPartsId());
-        if(!b)
-            ExceptionCast.cast(CommonCode.FAIL);
-        //娣诲姞鏃ュ織
-        NcLogInfo ncLogInfo = new NcLogInfo();
-        //妯″潡
-        ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�");
-        //绫诲瀷
-        ncLogInfo.setOperateType(4);
-        //鏃ュ織鍐呭
-        ncLogInfo.setLogContent("闆朵欢鍚嶇О锛�"+partsInfo.getPartsName());
-        iNcLogInfoService.saveLogNcInfos(ncLogInfo);
         return super.removeById(partsInfo.getPartsId());
     }
 
@@ -383,23 +342,24 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public boolean assignAddDepart(PartsInfo partsInfo, Collection<Department> departmentList) {
+    public boolean assignAddDepart(PartsInfo partsInfo, Collection<MdcProduction> departmentList) {
         if(partsInfo == null || departmentList == null || departmentList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<PartsDepartment> partsDepartments = new ArrayList<>();
         List<PermissionStream> permissionStreamList = new ArrayList<>();
         departmentList.forEach(item -> {
-            PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getDepartId());
+            PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId());
             if(en == null) {
                 en = new PartsDepartment();
-                en.setDepartId(item.getDepartId());
+                en.setDepartId(item.getId());
                 en.setPartsId(partsInfo.getPartsId());
                 partsDepartments.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getDepartId());
+            PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(),
+                    partsInfo.getPartsId(), item.getId());
             if(stream == null) {
                 stream = new PermissionStream();
-                stream.setDepartId(item.getDepartId());
+                stream.setDepartId(item.getId());
                 stream.setProductId(partsInfo.getProductId());
                 stream.setComponentId(partsInfo.getComponentId());
                 stream.setPartsId(partsInfo.getPartsId());
@@ -423,17 +383,18 @@
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
-    public boolean assignRemoveDepart(PartsInfo partsInfo, Collection<Department> departmentList) {
+    public boolean assignRemoveDepart(PartsInfo partsInfo, Collection<MdcProduction> departmentList) {
         if(partsInfo == null || departmentList == null || departmentList.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
         List<PartsDepartment> partsDepartments = new ArrayList<>();
         List<PermissionStream> permissionStreamList = new ArrayList<>();
         departmentList.forEach(item -> {
-            PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getDepartId());
+            PartsDepartment en = partsDepartmentService.getByPartsIdAndDepartId(partsInfo.getPartsId(), item.getId());
             if(en != null) {
                 partsDepartments.add(en);
             }
-            PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(), partsInfo.getPartsId(), item.getDepartId());
+            PermissionStream stream = permissionStreamService.getByPartsIdAndDepartId(partsInfo.getProductId(), partsInfo.getComponentId(),
+                    partsInfo.getPartsId(), item.getId());
             if(stream != null) {
                 permissionStreamList.add(stream);
             }

--
Gitblit v1.9.3