From 8d63dd77b9b3cd9b6d9768f216670fc499a8cab3 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期四, 23 一月 2025 14:32:16 +0800
Subject: [PATCH] 整合DNC 权限分配 修改为设备车间管理权限

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java
index e22d52e..6462d98 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ProcessStreamServiceImpl.java
@@ -14,16 +14,20 @@
 import org.jeecg.modules.dnc.response.*;
 
 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.request.ProcessStreamRequest;
 import org.jeecg.modules.dnc.entity.*;
+import org.jeecg.modules.system.entity.MdcProduction;
 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;
 
@@ -45,6 +49,8 @@
     private INcLogInfoService iNcLogInfoService;
     @Autowired
     private IPermissionStreamService permissionStreamService;
+    @Autowired
+    private IProcessionDepartmentService processionDepartmentService;
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
@@ -264,4 +270,90 @@
         queryWrapper.orderByAsc(ProcessStream::getCreateTime);
         return super.list(queryWrapper);
     }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean assignAddDepart(ProcessStream processStream, Collection<MdcProduction> departmentList) {
+        if(processStream == null || departmentList == null || departmentList.isEmpty())
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        List<ProcessionDepartment> processionDepartmentList = new ArrayList<>();
+        List<PermissionStream> permissionStreamList = new ArrayList<>();
+        departmentList.forEach(item -> {
+            ProcessionDepartment en = processionDepartmentService.getByProcessIdAndDepartId(processStream.getProcessId(), item.getId());
+            if(en == null) {
+                en = new ProcessionDepartment();
+                en.setDepartId(item.getId());
+                en.setProcessId(processStream.getProcessId());
+                processionDepartmentList.add(en);
+            }
+            PermissionStream stream = permissionStreamService.getByProcessIdAndDepartId(processStream.getProductId(), processStream.getComponentId(), processStream.getPartsId(),processStream.getProcessId(),item.getId());
+            if(stream == null) {
+                stream = new PermissionStream();
+                stream.setDepartId(item.getId());
+                stream.setProductId(processStream.getProductId());
+                stream.setComponentId(processStream.getComponentId());
+                stream.setPartsId(processStream.getPartsId());
+                stream.setProcessId(processStream.getProcessId());
+                permissionStreamList.add(stream);
+            }
+        });
+        if(!processionDepartmentList.isEmpty()) {
+            boolean b = processionDepartmentService.saveBatch(processionDepartmentList);
+            if(!b) {
+                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
+            }
+        }
+        if(!permissionStreamList.isEmpty()) {
+            boolean b = permissionStreamService.saveBatch(permissionStreamList);
+            if(!b) {
+                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public List<ProcessStream> getByComponentIdList(String productId, List<String> componentIds, List<String> partsIds) {
+        return super.baseMapper.findByPartsAndComponents(productId,componentIds,partsIds);
+    }
+
+
+    /**
+     * 鍒嗛厤閮ㄩ棬鏉冮檺
+     * @param processStream
+     * @param departmentList
+     * @return
+     */
+    @Override
+    public boolean assignRemoveDepart(ProcessStream processStream, Collection<MdcProduction> departmentList){
+        if(processStream == null || departmentList == null || departmentList.isEmpty())
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        List<ProcessionDepartment> processionDepartmentList = new ArrayList<>();
+        List<PermissionStream> permissionStreamList = new ArrayList<>();
+        departmentList.forEach(item -> {
+            ProcessionDepartment en = processionDepartmentService.getByProcessIdAndDepartId(processStream.getProcessId(), item.getId());
+            if(en != null) {
+                processionDepartmentList.add(en);
+            }
+            PermissionStream stream = permissionStreamService.getByProcessIdAndDepartId(processStream.getProductId(), processStream.getComponentId(), processStream.getPartsId()
+                    ,processStream.getProcessId(), item.getId());
+            if(stream != null) {
+                permissionStreamList.add(stream);
+            }
+        });
+        if(!processionDepartmentList.isEmpty()) {
+            boolean b = processionDepartmentService.removeByCollection(processionDepartmentList);
+            if(!b) {
+                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
+            }
+        }
+        if(!permissionStreamList.isEmpty()) {
+            boolean b = permissionStreamService.removeByCollection(permissionStreamList);
+            if(!b) {
+                ExceptionCast.cast(ProductInfoCode.PRODUCT_USER_PERM_ERROR);
+            }
+        }
+        return true;
+    }
+
 }

--
Gitblit v1.9.3