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/dncFlow/service/impl/DispatchFileServiceImpl.java |  137 +++++++++++++++++++++++----------------------
 1 files changed, 69 insertions(+), 68 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java
index 6ffcbf9..0314c77 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/DispatchFileServiceImpl.java
@@ -2,8 +2,10 @@
 
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.shiro.SecurityUtils;
 import org.flowable.common.engine.api.FlowableException;
 import org.flowable.engine.TaskService;
@@ -11,14 +13,15 @@
 import org.flowable.task.api.Task;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.modules.dnc.entity.*;
+import org.jeecg.modules.dnc.entity.DocInfo;
+import org.jeecg.modules.dnc.entity.PermissionStreamNew;
 import org.jeecg.modules.dnc.exception.ExceptionCast;
 import org.jeecg.modules.dnc.mapper.DocInfoMapper;
 import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
 import org.jeecg.modules.dnc.response.ActivitiCode;
 import org.jeecg.modules.dnc.response.CommonCode;
 import org.jeecg.modules.dnc.response.UcenterCode;
-import org.jeecg.modules.dnc.service.*;
+import org.jeecg.modules.dnc.service.IDocInfoService;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
 import org.jeecg.modules.dncFlow.entity.DispatchFile;
 import org.jeecg.modules.dncFlow.mapper.DispatchFileMapper;
@@ -28,8 +31,10 @@
 import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
 import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI;
 import org.jeecg.modules.flowable.apithird.service.FlowCommonService;
+import org.jeecg.modules.flowable.domain.vo.FlowHistoricalVo;
 import org.jeecg.modules.flowable.service.IFlowDefinitionService;
 import org.jeecg.modules.flowable.service.IFlowTaskService;
+import org.jeecg.modules.flowable.service.IHisWorkTaskService;
 import org.jeecg.modules.system.service.ISysUserRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -37,6 +42,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.lang.reflect.InvocationTargetException;
 import java.util.*;
 
 /**
@@ -51,20 +57,12 @@
     @Autowired
     @Lazy
     private IDocInfoService docInfoService;
-    @Autowired
-    private IProcessStreamService processStreamService;
-    @Autowired
-    private IWorkStepService workStepService;
-    @Autowired
-    private IPermissionStreamNewService permissionStreamNewService;
     @Resource
     private FlowCommonService flowCommonService;
     @Resource
     private IFlowDefinitionService flowDefinitionService;
     @Autowired
     private IFlowTaskService flowTaskService;
-    @Autowired
-    private IDeviceTypeService deviceTypeService;
     @Autowired
     private TaskService taskService;
     @Autowired
@@ -73,6 +71,10 @@
     private DocInfoMapper docInfoMapper;
     @Autowired
     private ISysUserRoleService sysUserRoleService;
+    @Autowired
+    private PermissionService permissionService;
+    @Autowired
+    private IHisWorkTaskService hisWorkTaskService;
     /**
      * 娴佺▼鍚姩,淇濆瓨瀵瑰簲鐨勬暟鎹�
      * @param dispatchFile
@@ -109,6 +111,29 @@
             docInfoService.updateById(docInfo);
         }
         return result;
+    }
+
+    /**
+     * 鏂囦欢鏌ヨ瀹$娴佺▼
+     * @param attributionId,attributionType,docId
+     * @return
+     */
+    @Override
+    public Result<?> queryDispatchDocFile(String attributionId, String attributionType, String docId){
+        DispatchFile dispatchFile=super.getOne(new LambdaQueryWrapper<DispatchFile>()
+                .eq(DispatchFile::getAttributionId, attributionId).eq(DispatchFile::getAttributionType, attributionType)
+                .eq(DispatchFile::getDocId, docId));
+        if (dispatchFile==null){
+            return Result.error("鏈壘鍒板搴斿绛炬枃浠�");
+        }else {
+            FlowMyBusiness flowMyBusiness=flowMyBusinessService.selectByDataId(dispatchFile.getId());
+            if (flowMyBusiness==null){
+                return Result.error("鏈壘鍒板搴斿绛炬祦绋�");
+            }else {
+                List<FlowHistoricalVo> queryHisTaskByProcInstId=hisWorkTaskService.queryHisTaskByProcInstId(flowMyBusiness.getProcessInstanceId());
+                return Result.ok(queryHisTaskByProcInstId);
+            }
+        }
     }
 
     /**
@@ -230,6 +255,7 @@
      * @return
      */
     @Override
+    @Transactional
     public Result<?> auditDispatchFile(DispatchFileFlowTaskVo dispatchFileFlowTaskVo) {
         try {
             // 鍙傛暟鏍¢獙
@@ -299,6 +325,36 @@
         } catch (Exception e) {
             return Result.error("鎿嶄綔澶辫触锛�" + e.getMessage());
         }
+    }
+
+    /**
+     * 鎵归噺瀹℃壒鎿嶄綔
+     * @param dispatchFileFlowTaskVo
+     * @return
+     */
+    @Override
+    @Transactional
+    public Result<?> auditBatchDispatchFile(DispatchFileFlowTaskVo dispatchFileFlowTaskVo) throws InvocationTargetException, IllegalAccessException {
+        if (dispatchFileFlowTaskVo.getTaskIds()==null || dispatchFileFlowTaskVo.getTaskIds().isEmpty()) {
+            return Result.error(CommonCode.INVALID_PARAM.toString());
+        }
+        if (dispatchFileFlowTaskVo.getTaskIds().contains(",")){
+            String[] taskIds = dispatchFileFlowTaskVo.getTaskIds().split(",");
+            for (String taskId : taskIds) {
+                FlowMyBusiness flowMyBusiness=flowMyBusinessService.getOne(new QueryWrapper<FlowMyBusiness>().eq("task_id",taskId));
+                DispatchFileFlowTaskVo dispatchFileFlowTaskVoNew=new DispatchFileFlowTaskVo();
+                BeanUtils.copyProperties(dispatchFileFlowTaskVoNew, dispatchFileFlowTaskVo);
+                dispatchFileFlowTaskVoNew.setTaskId(taskId);
+                dispatchFileFlowTaskVoNew.setDataId(flowMyBusiness.getDataId());
+                dispatchFileFlowTaskVoNew.setInstanceId(flowMyBusiness.getProcessInstanceId());
+                if (dispatchFileFlowTaskVo.getTargetKey().equals("task_prepare")){
+                    reStartDispatchFile(dispatchFileFlowTaskVoNew);
+                }else {
+                    auditDispatchFile(dispatchFileFlowTaskVoNew);
+                }
+            }
+        }
+        return Result.OK("鎿嶄綔鎴愬姛");
     }
 
     /**
@@ -391,67 +447,12 @@
         return true;
     }
 
-    //鑾峰彇鏂囦欢淇℃伅
-    private DocInfo getDocInfo(DispatchFile dispatchFile) {
-        DocInfo docInfo = docInfoService.getByDocAttrAndDocId(dispatchFile.getDocId(),
-                Integer.parseInt(dispatchFile.getAttributionType()), dispatchFile.getAttributionId());
-        if (docInfo == null || docInfo.getDocStatus() == 3) {
-            ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR);
-        }
-        return docInfo;
-    }
-
-
     private PermissionStreamNew getPermissionStreams(DispatchFile dispatchFile) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        DeviceType deviceType = deviceTypeService.getById(dispatchFile.getAttributionId());
-        String attributionId = deviceType != null ? deviceType.getAttributionId() : dispatchFile.getAttributionId();
-
-        PermissionStreamNew permissionStreams;
-        if (dispatchFile.getAttributionType().equals("5")) {
-            // 宸ュ簭
-            permissionStreams = handleProcess(dispatchFile, attributionId, user);
-        } else {
-            // 宸ユ
-            permissionStreams = handleWorkStep(dispatchFile, attributionId, user);
-        }
-        if (permissionStreams == null) {
+        PermissionStreamNew permissionStreamNew = permissionService.getPermissionStreams(dispatchFile);
+        if (permissionStreamNew == null) {
             ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE);
         }
-        return permissionStreams;
-    }
-
-    private PermissionStreamNew handleProcess(DispatchFile dispatchFile, String attributionId, LoginUser user) {
-        ProcessStream processStream = processStreamService.getById(attributionId);
-        if (processStream == null) {
-            ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        }
-        dispatchFile.setProductId(processStream.getProductId());
-        dispatchFile.setComponentId(processStream.getComponentId());
-        dispatchFile.setPartsId(processStream.getPartsId());
-        dispatchFile.setPsvId(processStream.getPsvId());
-        dispatchFile.setProcessId(processStream.getProcessId());
-        if (deviceTypeService.getById(dispatchFile.getAttributionId()) != null) {
-            dispatchFile.setDeviceTypeId(deviceTypeService.getById(dispatchFile.getAttributionId()).getId());
-        }
-        return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(), user.getId(), "5");
-    }
-
-    private PermissionStreamNew handleWorkStep(DispatchFile dispatchFile, String attributionId, LoginUser user) {
-        WorkStep workStep = workStepService.getById(attributionId);
-        if (workStep == null) {
-            ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        }
-        dispatchFile.setProductId(workStep.getProductId());
-        dispatchFile.setComponentId(workStep.getComponentId());
-        dispatchFile.setPartsId(workStep.getPartsId());
-        dispatchFile.setPsvId(workStep.getPsvId());
-        dispatchFile.setProcessId(workStep.getProcessId());
-        dispatchFile.setStepId(workStep.getId());
-        if (deviceTypeService.getById(dispatchFile.getAttributionId()) != null) {
-            dispatchFile.setDeviceTypeId(deviceTypeService.getById(dispatchFile.getAttributionId()).getId());
-        }
-        return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(), user.getId(), "6");
+        return permissionStreamNew;
     }
 
     @Override

--
Gitblit v1.9.3