From bb957f15fa76b5eac4de84bbef2b5d95c900df38 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期二, 20 五月 2025 11:49:58 +0800
Subject: [PATCH] art: 设备管理-二保-启动流程实例

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java |  187 ++++++++++++++++++++++++++--------------------
 1 files changed, 107 insertions(+), 80 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java
index e292e6a..8c05550 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamSecondMaintenanceOrderServiceImpl.java
@@ -1,6 +1,7 @@
 package org.jeecg.modules.eam.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,12 +9,14 @@
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.flowable.engine.TaskService;
+import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.DataBaseConstant;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.eam.constant.BusinessCodeConst;
+import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
 import org.jeecg.modules.eam.constant.SecondMaintenanceStatusEnum;
 import org.jeecg.modules.eam.entity.EamEquipment;
 import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrder;
@@ -22,7 +25,9 @@
 import org.jeecg.modules.eam.request.EamSecondMaintenanceQuery;
 import org.jeecg.modules.eam.request.EamSecondMaintenanceRequest;
 import org.jeecg.modules.eam.service.*;
+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.service.IFlowDefinitionService;
 import org.jeecg.modules.flowable.service.IFlowTaskService;
@@ -32,10 +37,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -44,8 +46,8 @@
  * @Date:   2025-04-29
  * @Version: V1.0
  */
-@Service
-public class EamSecondMaintenanceOrderServiceImpl extends ServiceImpl<EamSecondMaintenanceOrderMapper, EamSecondMaintenanceOrder> implements IEamSecondMaintenanceOrderService {
+@Service("IEamSecondMaintenanceOrderService")
+public class EamSecondMaintenanceOrderServiceImpl extends ServiceImpl<EamSecondMaintenanceOrderMapper, EamSecondMaintenanceOrder> implements IEamSecondMaintenanceOrderService, FlowCallBackServiceI {
     @Resource
     private EamSecondMaintenanceOrderMapper eamSecondMaintenanceOrderMapper;
     @Autowired
@@ -152,32 +154,32 @@
         }
         //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋�
         if (StringUtils.isNotBlank(order.getOperator())) {
-            //鍚姩娴佺▼ TODO
-//            flowCommonService.initActBusiness("宸ュ崟鍙�:" + order.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧浜屼繚",
-//                    order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
-//            Map<String, Object> variables = new HashMap<>();
-//            variables.put("dataId", order.getId());
-//            if (StrUtil.isEmpty(order.getRemark())) {
-//                variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼");
-//                variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼");
-//            } else {
-//                variables.put("organization", order.getRemark());
-//                variables.put("comment", order.getRemark());
-//            }
-//            variables.put("proofreading", true);
-//            List<String> usernames = new ArrayList<>();
-//            usernames.add(order.getOperator());
-//            variables.put("NextAssignee", usernames);
-//            Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables);
-//            if (result != null) {
-//                //鏇存柊鍛ㄤ繚鐘舵��
-//                order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
-//                order.setActualStartTime(new Date());
-//                eamWeekMaintenanceOrderMapper.updateById(order);
-//                //鏇存柊璁惧淇濆吇鐘舵��
-//                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
-//                return result.isSuccess();
-//            }
+            //鍚姩娴佺▼
+            flowCommonService.initActBusiness("宸ュ崟鍙�:" + order.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧浜屼繚",
+                    order.getId(), "IEamSecondMaintenanceOrderService", "second_maintenance_process", null);
+            Map<String, Object> variables = new HashMap<>();
+            variables.put("dataId", order.getId());
+            if (StrUtil.isEmpty(order.getRemark())) {
+                variables.put("organization", "鏂板浜屼繚宸ュ崟榛樿鍚姩娴佺▼");
+                variables.put("comment", "鏂板浜屼繚宸ュ崟榛樿鍚姩娴佺▼");
+            } else {
+                variables.put("organization", order.getRemark());
+                variables.put("comment", order.getRemark());
+            }
+            variables.put("proofreading", true);
+            List<String> usernames = new ArrayList<>();
+            usernames.add(order.getOperator());
+            variables.put("NextAssignee", usernames);
+            Result result = flowDefinitionService.startProcessInstanceByKey("second_maintenance_process", variables);
+            if (result != null) {
+                //鏇存柊鍛ㄤ繚鐘舵��
+                order.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
+                order.setActualStartTime(new Date());
+                eamSecondMaintenanceOrderMapper.updateById(order);
+                //鏇存柊璁惧淇濆吇鐘舵��
+                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
+                return result.isSuccess();
+            }
         }
 
         return true;
@@ -227,32 +229,32 @@
         }
         //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋�
         if (StringUtils.isNotBlank(entity.getOperator())) {
-            //鍚姩娴佺▼ TODO
-//            flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧鍛ㄤ繚",
-//                    entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
-//            Map<String, Object> variables = new HashMap<>();
-//            variables.put("dataId", entity.getId());
-//            if (StrUtil.isEmpty(entity.getRemark())) {
-//                variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼");
-//                variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼");
-//            } else {
-//                variables.put("organization", entity.getRemark());
-//                variables.put("comment", entity.getRemark());
-//            }
-//            variables.put("proofreading", true);
-//            List<String> usernames = new ArrayList<>();
-//            usernames.add(entity.getOperator());
-//            variables.put("NextAssignee", usernames);
-//            Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables);
-//            if (result != null) {
-//                //鏇存柊鍛ㄤ繚鐘舵��
-//                entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
-//                entity.setActualStartTime(new Date());
-//                eamWeekMaintenanceOrderMapper.updateById(entity);
-//                //鏇存柊璁惧淇濆吇鐘舵��
-//                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
-//                return result.isSuccess();
-//            }
+            //鍚姩娴佺▼
+            flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧浜屼繚",
+                    entity.getId(), "IEamSecondMaintenanceOrderService", "second_maintenance_process", null);
+            Map<String, Object> variables = new HashMap<>();
+            variables.put("dataId", entity.getId());
+            if (StrUtil.isEmpty(entity.getRemark())) {
+                variables.put("organization", "鏂板浜屼繚宸ュ崟榛樿鍚姩娴佺▼");
+                variables.put("comment", "鏂板浜屼繚宸ュ崟榛樿鍚姩娴佺▼");
+            } else {
+                variables.put("organization", entity.getRemark());
+                variables.put("comment", entity.getRemark());
+            }
+            variables.put("proofreading", true);
+            List<String> usernames = new ArrayList<>();
+            usernames.add(entity.getOperator());
+            variables.put("NextAssignee", usernames);
+            Result result = flowDefinitionService.startProcessInstanceByKey("second_maintenance_process", variables);
+            if (result != null) {
+                //鏇存柊鍛ㄤ繚鐘舵��
+                entity.setMaintenanceStatus(SecondMaintenanceStatusEnum.UNDER_MAINTENANCE.name());
+                entity.setActualStartTime(new Date());
+                eamSecondMaintenanceOrderMapper.updateById(entity);
+                //鏇存柊璁惧淇濆吇鐘舵��
+                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
+                return result.isSuccess();
+            }
 
         }
         return true;
@@ -281,28 +283,53 @@
         entity.setActualStartTime(new Date());
         eamSecondMaintenanceOrderMapper.updateById(entity);
 
-//        //鍚姩娴佺▼
-//        flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧鍛ㄤ繚",
-//                entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null);
-//        Map<String, Object> variables = new HashMap<>();
-//        variables.put("dataId", entity.getId());
-//        if (StrUtil.isEmpty(entity.getRemark())) {
-//            variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼");
-//            variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼");
-//        } else {
-//            variables.put("organization", entity.getRemark());
-//            variables.put("comment", entity.getRemark());
-//        }
-//        variables.put("proofreading", true);
-//        List<String> usernames = new ArrayList<>();
-//        usernames.add(entity.getOperator());
-//        variables.put("NextAssignee", usernames);
-//        Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables);
-//        if (result != null) {
-//            //鏇存柊璁惧淇濆吇鐘舵��
-//            eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name());
-//            return result.isSuccess();
-//        }
+        //鍚姩娴佺▼
+        flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";杩涜璁惧浜屼繚",
+                entity.getId(), "IEamSecondMaintenanceOrderService", "second_maintenance_process", null);
+        Map<String, Object> variables = new HashMap<>();
+        variables.put("dataId", entity.getId());
+        if (StrUtil.isEmpty(entity.getRemark())) {
+            variables.put("organization", "鏂板浜屼繚宸ュ崟榛樿鍚姩娴佺▼");
+            variables.put("comment", "鏂板浜屼繚宸ュ崟榛樿鍚姩娴佺▼");
+        } else {
+            variables.put("organization", entity.getRemark());
+            variables.put("comment", entity.getRemark());
+        }
+        variables.put("proofreading", true);
+        List<String> usernames = new ArrayList<>();
+        usernames.add(entity.getOperator());
+        variables.put("NextAssignee", usernames);
+        Result result = flowDefinitionService.startProcessInstanceByKey("second_maintenance_process", variables);
+        if (result != null) {
+            //鏇存柊璁惧淇濆吇鐘舵��
+            eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name());
+            return result.isSuccess();
+        }
         return true;
     }
+
+    @Override
+    public void afterFlowHandle(FlowMyBusiness business) {
+        business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣
+        business.getValues();//鍓嶇浼犺繘鏉ョ殑鍙傛暟
+        business.getActStatus();
+    }
+
+    @Override
+    public Object getBusinessDataById(String dataId) {
+        return this.getById(dataId);
+    }
+
+    @Override
+    public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) {
+        return null;
+    }
+
+    @Override
+    public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) {
+        //涓氬姟鏄惁骞查娴佺▼锛屼笟鍔″共棰勶紝娴佺▼骞查锛屾寚瀹氫汉鍛樿繘琛屽鐞�
+        //鑾峰彇涓嬩竴姝ュ鐞嗕汉
+        Object object = values.get("NextAssignee");
+        return (List<String>) object;
+    }
 }

--
Gitblit v1.9.3