From 0ed2995fbd51293095e78b6c55055d6f7794f992 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期三, 09 四月 2025 16:30:15 +0800
Subject: [PATCH] 修改指派程序至设备,点检工单流程与异常报修,修改flow已办查询

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java |   52 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
index 34d3494..49e51e3 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
@@ -1,6 +1,7 @@
 package org.jeecg.modules.dncFlow.service.impl;
 
 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.core.metadata.IPage;
@@ -8,7 +9,6 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.flowable.engine.TaskService;
@@ -36,6 +36,7 @@
 import org.jeecg.modules.dncFlow.service.IToEquipmentTaskService;
 import org.jeecg.modules.dncFlow.vo.AssignFlowTaskVo;
 import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
+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.FlowTaskVo;
@@ -105,6 +106,8 @@
     private IFlowTaskService flowTaskService;
     @Autowired
     private IDeviceTypeService deviceTypeService;
+    @Autowired
+    private IFlowMyBusinessService flowMyBusinessService;
 
     @Value("${securedoc.whether}")
     private String whether;
@@ -289,6 +292,30 @@
         //flowable澶勭悊
         FlowTaskVo flowTaskVo = new FlowTaskVo();
         BeanUtils.copyProperties(assignFlowTaskVo, flowTaskVo);
+
+        List<FlowMyBusiness> businessList = flowMyBusinessService.list(
+                new QueryWrapper<FlowMyBusiness>()
+                        .eq("process_instance_id", assignFlowTaskVo.getInstanceId())
+        );
+        if (businessList.isEmpty()) {
+            return false;
+        }
+        FlowMyBusiness flowMyBusiness = businessList.get(0);
+        List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class);
+        if (todoUsers == null || !todoUsers.contains(user.getUsername())) {
+            return false;
+        }
+
+        // 4. 璁ら浠诲姟锛堝鐞嗗凡琚棰嗙殑鎯呭喌锛�
+        String taskId = flowMyBusiness.getTaskId();
+        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
+        if (task == null) {
+            return false;
+        }
+        if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) {
+            return false;
+        }
+        taskService.claim(taskId, user.getUsername());
         Map<String, Object> values=new HashMap<>();
         values.put("dataId", assignFlowTaskVo.getDataId());
         flowTaskVo.setTaskId(assignFlowTaskVo.getTaskId());
@@ -407,14 +434,6 @@
         List<TaskRequest> list = approveBatchRequest.getTaskArr();
         if(list == null || list.isEmpty())
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
-//        list.forEach(item -> {
-//            AssignFileStream stream = new AssignFileStream();
-//            stream.setApproveContent(approveBatchRequest.getApproveContent());
-//            stream.setStatus(approveBatchRequest.getStatus());
-//            boolean b = approveAssignFile(item.getId(), item.getBusinessKey(), stream);
-//            if(!b)
-//                ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR);
-//        });
         return synchronizedFlagService.updateFlag(1);
     }
 
@@ -651,19 +670,6 @@
         }
     }
 
-    //寮�濮嬪伐浣滄祦
-//    private ProcessInstance startProcessInstance(AssignFileStream stream, List<String> userIdList) {
-//        String approveUsers = String.join(",", userIdList);
-//        Map<String, Object> avariableMap = new HashMap<>();
-//        avariableMap.put(APPLY_VARIABLE, stream.getApplyUserId());
-//        avariableMap.put(APPROVE_VARIABLE, approveUsers);
-//        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(PROCESS_KEY, stream.getStreamId(), avariableMap);
-//        if (processInstance == null) {
-//            ExceptionCast.cast(ActivitiCode.ACT_APPROVE_USERS_NONE);
-//        }
-//        return processInstance;
-//    }
-
     //鎷惧彇浠诲姟
     private void completeTask(ProcessInstance processInstance, String userId) {
         Task task = taskService.createTaskQuery().processDefinitionKey(PROCESS_KEY).taskAssignee(userId)
@@ -771,6 +777,6 @@
 
     @Override
     public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
-        return Lists.newArrayList("jeecg");
+        return null;
     }
 }

--
Gitblit v1.9.3