From 1930b4e59d60c015ffa7bfee92e4bc227b90dcb3 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期三, 28 五月 2025 15:41:41 +0800
Subject: [PATCH] 1.Dnc产品结构树检索nc文件 2.新增批次功能 3.新增审签查询流程 4.修改刀具系统查询

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepServiceImpl.java |  134 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 122 insertions(+), 12 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepServiceImpl.java
index 90a1463..af81a36 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/WorkStepServiceImpl.java
@@ -1,5 +1,7 @@
 package org.jeecg.modules.dnc.service.impl;
 
+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;
@@ -7,9 +9,12 @@
 import org.apache.commons.collections4.ListUtils;
 import org.apache.shiro.SecurityUtils;
 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.WorkStepMapper;
+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.ProcessInfoCode;
 import org.jeecg.modules.dnc.response.ProductInfoCode;
@@ -19,10 +24,12 @@
 import org.jeecg.modules.system.entity.MdcProduction;
 import org.jeecg.modules.system.entity.SysUser;
 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.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: TODO
@@ -50,6 +57,12 @@
 
     @Autowired
     private IProductMixService productMixService;
+
+    @Autowired
+    @Lazy
+    private IDocInfoService docInfoService;
+    @Autowired
+    private IDeviceTypeService deviceTypeService;
 
     @Override
     public List<WorkStep> getByUserPerms(String userId) {
@@ -109,7 +122,7 @@
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
         //娣诲姞閮ㄩ棬鏉冮檺
-        List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(workStep.getProcessId(),"5","1");
+        List<PermissionStreamNew> oldDepartPermList = permissionStreamNewService.loadPermissionStreamNewByBusinessId(workStep.getProcessId(), DocAttributionTypeEnum.PROCESS.getCode().toString(),"1");
         if(oldDepartPermList != null && !oldDepartPermList.isEmpty()) {
             List<WorkStepDepartment> workStepDepartmentList = new ArrayList<>();
             List<PermissionStreamNew> permissionStreamList = new ArrayList<>();
@@ -121,7 +134,7 @@
                 PermissionStreamNew perm = new PermissionStreamNew();
                 perm.setDepartId(item.getDepartId());
                 perm.setBusinessId(workStep.getId());
-                perm.setBusinessType("6");
+                perm.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
                 permissionStreamList.add(perm);
             });
             if(!workStepDepartmentList.isEmpty()) {
@@ -136,19 +149,19 @@
             }
         }
         //娣诲姞鐢ㄦ埛鏉冮檺
-        b = productPermissionService.add(workStep.getId(), userId,"6");
+        b = productPermissionService.add(workStep.getId(), userId,DocAttributionTypeEnum.WORKSITE.getCode().toString());
         if (!b) {
             ExceptionCast.cast(ProductInfoCode.PRODUCT_SAVE_ERROR);
         }
         //娣诲姞缁撴瀯鏍�
         ProductMix productMix = new ProductMix(Long.parseLong(workStep.getId()),Long.parseLong(workStep.getProcessId())
-                ,workStep.getStepName(),workStep.getStepCode(),6,new Date());
+                ,workStep.getStepName(),workStep.getStepCode(),DocAttributionTypeEnum.WORKSITE.getCode(),new Date());
         productMixService.save(productMix);
         //娣诲姞鏉冮檺楠岃瘉
         PermissionStreamNew permissionStream = new PermissionStreamNew();
         permissionStream.setUserId(userId);
         permissionStream.setBusinessId(workStep.getId());
-        permissionStream.setBusinessType("6");
+        permissionStream.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
         return permissionStreamNewService.addPermissionStreamNew(permissionStream);
     }
 
@@ -202,12 +215,12 @@
                 en.setStepId(workStep.getId());
                 workStepDepartmentList.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),"6");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
             if(stream == null) {
                 stream = new PermissionStreamNew();
                 stream.setDepartId(item.getId());
                 stream.setBusinessId(workStep.getId());
-                stream.setBusinessType("6");
+                stream.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
                 permissionStreamList.add(stream);
             }
         });
@@ -264,7 +277,7 @@
             if(en != null) {
                 workStepDepartmentList.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),"6");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndDepartId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
             if(stream != null) {
                 permissionStreamList.add(stream);
             }
@@ -296,7 +309,7 @@
         if(en == null)
             ExceptionCast.cast(ProcessInfoCode.PROCESS_NOT_EXIST);
         //楠岃瘉鏄惁瀛樺湪鏂囨。
-        List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type","6").eq("attribution_id",id));
+        List<DocRelative> docRelativeList=iDocRelativeService.list(new QueryWrapper<DocRelative>().eq("attribution_type",DocAttributionTypeEnum.WORKSITE.getCode().toString()).eq("attribution_id",id));
         if (!docRelativeList.isEmpty()){
             ExceptionCast.cast(ProcessInfoCode.WORKSTEP_HAS_DOC);
         }
@@ -322,12 +335,12 @@
                 en.setStepId(workStep.getId());
                 permissionList.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),"6");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
             if(stream == null) {
                 stream = new PermissionStreamNew();
                 stream.setUserId(item.getId());
                 stream.setBusinessId(workStep.getId());
-                stream.setBusinessType("6");
+                stream.setBusinessType(DocAttributionTypeEnum.WORKSITE.getCode().toString());
                 permissionStreamList.add(stream);
             }
         });
@@ -358,7 +371,7 @@
             if(en != null) {
                 permissionList.add(en);
             }
-            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),"6");
+            PermissionStreamNew stream = permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(),item.getId(),DocAttributionTypeEnum.WORKSITE.getCode().toString());
             if(stream != null) {
                 permissionStreamList.add(stream);
             }
@@ -379,4 +392,101 @@
         return true;
     }
 
+    /**
+     * 閫氳繃宸ユ鍙枫�佸伐姝ュ悕绉扮瓑鏌ヨ瀵瑰簲NC鏂囦欢
+     * NC鏂囦欢瀛樺湪璁惧绫讳笅闈�
+     * @param treeInfoRequest
+     * @return
+     */
+    @Override
+    public List<DocInfo> getByWorkStepOtherFile(TreeInfoRequest treeInfoRequest){
+        LambdaQueryWrapper<WorkStep> queryWrapper = new LambdaQueryWrapper<>();
+        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getProductId, treeInfoRequest.getProductIds());
+        }
+        if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getComponentId, treeInfoRequest.getComponentIds());
+        }
+        if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getPartsId, treeInfoRequest.getPartsIds());
+        }
+        if (treeInfoRequest.getPsvIds() != null && !treeInfoRequest.getPsvIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getPsvId, treeInfoRequest.getPsvIds());
+        }
+        if (treeInfoRequest.getProcessIds() != null && !treeInfoRequest.getProcessIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getProcessId, treeInfoRequest.getProcessIds());
+        }
+        if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())){
+            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),WorkStep::getId,treeInfoRequest.getAttributionId());
+        }
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),WorkStep::getStepName, treeInfoRequest.getTreeName());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),WorkStep::getStepCode, treeInfoRequest.getTreeName());
+        queryWrapper.orderByDesc(WorkStep::getCreateTime);
+        List<WorkStep> list = super.list(queryWrapper);
+        List<DocInfo> docInfos;
+        if (list == null || list.isEmpty() || StrUtil.isNotBlank(treeInfoRequest.getStructureType())){
+            return new ArrayList<>();
+        }else {
+            String ids=list.stream().map(WorkStep::getId).collect(Collectors.joining(","));
+            DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
+            BeanUtil.copyProperties(treeInfoRequest,docQuery);
+            docQuery.setAttributionIds(ids);
+            docQuery.setDocClassCode("OTHER");
+            docQuery.setAttributionType(DocAttributionTypeEnum.WORKSITE.getCode());
+            docInfos=docInfoService.findListByDocQuery(docQuery);
+        }
+        return docInfos;
+    }
+
+    /**
+     * 閫氳繃宸ユ鍙枫�佸伐姝ュ悕绉扮瓑鏌ヨ瀵瑰簲NC鏂囦欢
+     * NC鏂囦欢瀛樺湪璁惧绫讳笅闈�
+     * @param treeInfoRequest
+     * @return
+     */
+    @Override
+    public List<DocInfo> getByWorkStepNCFile(TreeInfoRequest treeInfoRequest){
+        LambdaQueryWrapper<WorkStep> queryWrapper = new LambdaQueryWrapper<>();
+        if (treeInfoRequest.getProductIds() != null && !treeInfoRequest.getProductIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getProductId, treeInfoRequest.getProductIds());
+        }
+        if (treeInfoRequest.getComponentIds() != null && !treeInfoRequest.getComponentIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getComponentId, treeInfoRequest.getComponentIds());
+        }
+        if (treeInfoRequest.getPartsIds() != null && !treeInfoRequest.getPartsIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getPartsId, treeInfoRequest.getPartsIds());
+        }
+        if (treeInfoRequest.getPsvIds() != null && !treeInfoRequest.getPsvIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getPsvId, treeInfoRequest.getPsvIds());
+        }
+        if (treeInfoRequest.getProcessIds() != null && !treeInfoRequest.getProcessIds().isEmpty()) {
+            queryWrapper.in(WorkStep::getProcessId, treeInfoRequest.getProcessIds());
+        }
+        if (Objects.equals(treeInfoRequest.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())){
+            queryWrapper.eq(StrUtil.isNotEmpty(treeInfoRequest.getAttributionId()),WorkStep::getProcessId,treeInfoRequest.getAttributionId());
+        }
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeName()),WorkStep::getStepName, treeInfoRequest.getTreeName());
+        queryWrapper.like(StrUtil.isNotEmpty(treeInfoRequest.getTreeCode()),WorkStep::getStepCode, treeInfoRequest.getTreeName());
+        queryWrapper.orderByDesc(WorkStep::getCreateTime);
+        List<WorkStep> list = super.list(queryWrapper);
+        List<DocInfo> docInfos = new ArrayList<>();
+        //NC鏂囦欢瀛樺湪瀵瑰簲鐨勮澶囩被涓嬶紝鎵�浠ラ渶瑕佽繃婊�
+        if (!list.isEmpty()) {
+            List<String> workStepIds = list.stream().map(WorkStep::getId).collect(Collectors.toList());
+            List<DeviceType> deviceTypeList = deviceTypeService.getDeviceTypeByAttribution(workStepIds,
+                    DocAttributionTypeEnum.WORKSITE.getCode(),treeInfoRequest.getDeviceManagementName(),treeInfoRequest.getDeviceManagementCode());
+            if (deviceTypeList != null && !deviceTypeList.isEmpty()) {
+                List<String> deviceManagementIds=deviceTypeList.stream().map(DeviceType::getDeviceManagementId).collect(Collectors.toList());
+                DocInfoQueryRequest docQuery = new DocInfoQueryRequest();
+                BeanUtil.copyProperties(treeInfoRequest,docQuery);
+                docQuery.setAttributionIds(String.join(",",deviceManagementIds));
+                docQuery.setDocClassCode("NC");
+                docQuery.setAttributionType(DocAttributionTypeEnum.WORKSITE.getCode());
+                docInfos=docInfoService.findListByDocQuery(docQuery);
+            }
+            return docInfos;
+        }
+        return new ArrayList<>();
+    }
+
 }

--
Gitblit v1.9.3