From bcd90314646203b32f73c89c1c2f89eaa96e2c9f Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期五, 18 七月 2025 18:05:35 +0800
Subject: [PATCH] art: 设备台账-查询需要做技术状态鉴定的设备列表

---
 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderServiceImpl.java |  523 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 501 insertions(+), 22 deletions(-)

diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderServiceImpl.java
index 6398882..9648448 100644
--- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderServiceImpl.java
+++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderServiceImpl.java
@@ -1,40 +1,47 @@
 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.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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.EamTechnicalStatusEvaluationOrderEnum;
-import org.jeecg.modules.eam.entity.EamEquipment;
-import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrder;
+import org.jeecg.modules.eam.constant.*;
+import org.jeecg.modules.eam.entity.*;
 import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationOrderMapper;
 import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderQuery;
 import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderRequest;
-import org.jeecg.modules.eam.service.IEamEquipmentService;
-import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationOrderDetailService;
-import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationOrderService;
+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;
 import org.jeecg.modules.system.entity.BaseFactory;
 import org.jeecg.modules.system.entity.BaseFactoryUser;
 import org.jeecg.modules.system.service.IBaseFactoryService;
 import org.jeecg.modules.system.service.IBaseFactoryUserService;
 import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
+import org.jeecg.modules.system.service.ISysUserService;
+import org.jeecg.modules.system.vo.UserSelector;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -43,8 +50,8 @@
  * @Date: 2025-07-09
  * @Version: V1.0
  */
-@Service
-public class EamTechnicalStatusEvaluationOrderServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationOrderMapper, EamTechnicalStatusEvaluationOrder> implements IEamTechnicalStatusEvaluationOrderService {
+@Service("IEamTechnicalStatusEvaluationOrderService")
+public class EamTechnicalStatusEvaluationOrderServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationOrderMapper, EamTechnicalStatusEvaluationOrder> implements IEamTechnicalStatusEvaluationOrderService, FlowCallBackServiceI {
 
     @Autowired
     private IBaseFactoryUserService baseFactoryUserService;
@@ -56,6 +63,27 @@
     private IEamEquipmentService equipmentService;
     @Autowired
     private ISysBusinessCodeRuleService businessCodeRuleService;
+    @Autowired
+    private IEamTechnicalStatusEvaluationStandardService standardService;
+    @Autowired
+    private IEamTechnicalStatusEvaluationStandardDetailService standardDetailService;
+    @Autowired
+    private IEamBaseHFCodeService hfCodeService;
+    @Autowired
+    private FlowCommonService flowCommonService;
+    @Autowired
+    private IFlowDefinitionService flowDefinitionService;
+    @Autowired
+    private IFlowMyBusinessService flowMyBusinessService;
+    @Autowired
+    private TaskService taskService;
+    @Autowired
+    private IFlowTaskService flowTaskService;
+
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private IEamEquipmentExtendService equipmentExtendService;
 
     @Override
     public IPage<EamTechnicalStatusEvaluationOrder> queryPageList(Page<EamTechnicalStatusEvaluationOrder> page, EamTechnicalStatusEvaluationOrderQuery query) {
@@ -116,7 +144,6 @@
         } else {
             queryWrapper.orderByDesc("ems.create_time");
         }
-        queryWrapper.orderByDesc("ems.create_time");
         return this.getBaseMapper().queryPageList(page, queryWrapper);
     }
 
@@ -127,27 +154,479 @@
         if (equipment == null) {
             throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�");
         }
+        EamTechnicalStatusEvaluationStandard standard = standardService.getById(request.getStandardId());
+        if (standard == null) {
+            throw new JeecgBootException("鎶�鏈姸鎬侀壌瀹氳鑼冧笉瀛樺湪锛屾坊鍔犲け璐ワ紒");
+        }
+        if (!TechnicalStatusEvaluationStandardStatusEnum.ENABLE.name().equals(standard.getStandardStatus())) {
+            throw new JeecgBootException("鎶�鏈姸鎬侀壌瀹氳鑼冩湭鍚敤锛屾坊鍔犲け璐ワ紒");
+        }
+        List<EamTechnicalStatusEvaluationStandardDetail> standardDetailList = standardDetailService.queryList(standard.getId());
+        if (CollectionUtil.isEmpty(standardDetailList)) {
+            throw new JeecgBootException("鎶�鏈姸鎬侀壌瀹氳鑼冩鏌ラ」涓虹┖锛屾坊鍔犲け璐ワ紒");
+        }
         EamTechnicalStatusEvaluationOrder order = new EamTechnicalStatusEvaluationOrder();
-        order.setOrderNum(request.getOrderNum());
         order.setEquipmentId(request.getEquipmentId());
         order.setStandardId(request.getStandardId());
         order.setEvaluationDate(request.getEvaluationDate());
-        order.setEvaluator(request.getEvaluator());
         order.setRemark(request.getRemark());
+        String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.TECHNICAL_STATUS_EVALUATION_ORDER_CODE_RULE);
+        order.setOrderNum(codeSeq);
+        order.setCreationMethod(OrderCreationMethodEnum.MANUAL.name());
         //鐘舵�佸垵濮嬪寲
-        order.setEvaluationStatus(EamTechnicalStatusEvaluationOrderEnum.WAIT_EVALUATION.name());
-        order.setCreationMethod(request.getCreationMethod());
+        order.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.WAIT_EVALUATION.name());
         //鍒犻櫎鏍囪
         order.setDelFlag(CommonConstant.DEL_FLAG_0);
+        //鎶�鏈姸鎬侀壌瀹氳〃
+        EamBaseHFCode eamBaseHFCode = hfCodeService.selectByCategory(HfTemplateCategoryEnum.TECHNICAL_STATUS_EVALUATION.name());
+        if (eamBaseHFCode == null) {
+            throw new JeecgBootException("鏈厤缃妧鏈姸鎬侀壌瀹氳〃鐨凥F缂栫爜锛屾坊鍔犲け璐ワ紒");
+        }
+        order.setHfCodeA(eamBaseHFCode.getHfCode());
+        //鎶�鏈姸鎬侀壌瀹氬畨鍏ㄨ缃鏌ヨ〃
+        eamBaseHFCode = hfCodeService.selectByCategory(HfTemplateCategoryEnum.TECHNICAL_STATUS_EVALUATION_SAFETY_CHECK.name());
+        if (eamBaseHFCode == null) {
+            throw new JeecgBootException("鏈厤缃畨鍏ㄨ缃鏌ヨ〃鐨凥F缂栫爜锛屾坊鍔犲け璐ワ紒");
+        }
+        order.setHfCodeB(eamBaseHFCode.getHfCode());
+        //鎶�鏈姸鎬侀壌瀹氬叾浠栨鏌ヨ〃
+        eamBaseHFCode = hfCodeService.selectByCategory(HfTemplateCategoryEnum.TECHNICAL_STATUS_EVALUATION_OTHER_CHECK.name());
+        if (eamBaseHFCode == null) {
+            throw new JeecgBootException("鏈厤缃叾浠栨鏌ヨ〃鐨凥F缂栫爜锛屾坊鍔犲け璐ワ紒");
+        }
+        order.setHfCodeD(eamBaseHFCode.getHfCode());
+        //鎶�鏈姸鎬侀壌瀹氳澶囩簿搴︽鏌ヨ〃
+        eamBaseHFCode = hfCodeService.selectByCategory(HfTemplateCategoryEnum.TECHNICAL_STATUS_EVALUATION_PRECISION_CHECK.name());
+        if (eamBaseHFCode == null) {
+            throw new JeecgBootException("鏈厤缃澶囩簿搴︽鏌ヨ〃鐨凥F缂栫爜锛屾坊鍔犲け璐ワ紒");
+        }
+        order.setHfCodeC(eamBaseHFCode.getHfCode());
         this.getBaseMapper().insert(order);
         //澶勭悊鏄庣粏鏁版嵁
-        if (CollectionUtil.isNotEmpty(request.getTableDetailList())) {
-            request.getTableDetailList().forEach(tableDetail -> {
-                tableDetail.setId(null);
-                tableDetail.setOrderId(order.getId());
-            });
-            orderDetailService.saveBatch(request.getTableDetailList());
+        List<EamTechnicalStatusEvaluationOrderDetail> orderDetailList = standardDetailList.stream().map(item -> new EamTechnicalStatusEvaluationOrderDetail(item, order.getId())).collect(Collectors.toList());
+        orderDetailService.saveBatch(orderDetailList);
+        return true;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean collect(String id) {
+        EamTechnicalStatusEvaluationOrder entity = super.getBaseMapper().selectById(id);
+        if (entity == null) {
+            throw new JeecgBootException("瑕侀鍙栫殑宸ュ崟涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒");
+        }
+        if (!TechnicalStatusEvaluationOrderStatusEnum.WAIT_EVALUATION.name().equals(entity.getEvaluationStatus())) {
+            throw new JeecgBootException("璇ュ伐鍗曞凡杩涜杩囬鍙栵紒");
+        }
+        EamTechnicalStatusEvaluationStandard standard = standardService.getById(entity.getStandardId());
+        if (standard == null) {
+            throw new JeecgBootException("璁惧淇濆吇鏍囧噯涓嶅瓨鍦紝璇锋鏌ワ紒");
+        }
+        EamEquipment equipment = equipmentService.getById(entity.getEquipmentId());
+        if (equipment == null) {
+            throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�");
+        }
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (sysUser == null) {
+            throw new JeecgBootException("涓嶆槸缁翠慨宸ワ紝鏃犳硶棰嗗彇姝ゅ伐鍗曪紒");
+        }
+        List<UserSelector> userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002);
+        if (CollectionUtil.isEmpty(userSelectors)) {
+            throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨宸ワ紝鏃犳硶棰嗗彇锛�");
+        }
+        List<String> userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+        if (!userApprovalList.contains(sysUser.getUsername())) {
+            throw new JeecgBootException("鎮ㄦ病鏈夐鍙栨宸ュ崟鐨勬潈闄愶紒");
+        }
+        entity.setEvaluator(sysUser.getUsername());
+        entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.UNDER_EVALUATION.name());
+        entity.setActualStartTime(new Date());
+        this.getBaseMapper().updateById(entity);
+
+        //鍚姩娴佺▼
+        flowCommonService.initActBusiness("宸ュ崟鍙�: " + entity.getOrderNum() + ";璁惧缂栧彿: " + equipment.getEquipmentCode() + ";瀹夎浣嶇疆" + equipment.getInstallationPosition(),
+                entity.getId(), "IEamTechnicalStatusEvaluationOrderService", "technical_status_evaluation_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);
+        if (CommonConstant.STATUS_1.equals(standard.getHasSafetyEquipmentCheck())) {
+            variables.put("hasSafetyEquipmentCheck", CommonConstant.STATUS_1);
+            variables.put("safety_equipment_check", userApprovalList);
+            entity.setSafetyCheckCompleted(CommonConstant.STATUS_0);
+        } else {
+            variables.put("hasSafetyEquipmentCheck", CommonConstant.STATUS_0);
+            variables.put("safety_equipment_check", userApprovalList);
+        }
+        if (CommonConstant.STATUS_1.equals(standard.getHasPrecisionCheck())) {
+            variables.put("hasPrecisionCheck", CommonConstant.STATUS_1);
+            variables.put("equipment_precision_check", userApprovalList);
+            entity.setPrecisionCheckCompleted(CommonConstant.STATUS_0);
+        } else {
+            variables.put("hasPrecisionCheck", CommonConstant.STATUS_0);
+            variables.put("equipment_precision_check", userApprovalList);
+        }
+        if (CommonConstant.STATUS_1.equals(standard.getHasOtherCheck())) {
+            variables.put("hasOtherCheck", CommonConstant.STATUS_1);
+            variables.put("other_check", userApprovalList);
+            entity.setOtherCheckCompleted(CommonConstant.STATUS_0);
+        } else {
+            variables.put("hasOtherCheck", CommonConstant.STATUS_0);
+            variables.put("other_check", userApprovalList);
+        }
+        Result<?> result = flowDefinitionService.startProcessInstanceByKey("technical_status_evaluation_process", variables);
+        if (result == null || !result.isSuccess()) {
+            throw new JeecgBootException("鍚姩娴佺▼澶辫触锛岄鍙栧け璐�");
         }
         return true;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public EamTechnicalStatusEvaluationOrder approval(EamTechnicalStatusEvaluationOrderRequest request) {
+        EamTechnicalStatusEvaluationOrder entity = this.getBaseMapper().selectById(request.getId());
+        if (entity == null) {
+            throw new JeecgBootException("瀹℃壒鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�");
+        }
+        // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (user == null || StrUtil.isBlank(user.getId())) {
+            throw new JeecgBootException("鏈幏鍙栧埌鐧诲綍鐢ㄦ埛锛岃閲嶆柊鐧诲綍鍚庡啀璇曪紒");
+        }
+        request.setAssignee(user.getUsername());
+        // 鑾峰彇娴佺▼涓氬姟璁板綍
+        FlowMyBusiness flowMyBusiness = flowMyBusinessService.getFlowMyBusiness(request.getInstanceId(), request.getTaskId());
+        if (flowMyBusiness == null) {
+            throw new JeecgBootException("娴佺▼瀹炰緥涓嶅瓨鍦紝璇峰埛鏂板悗閲嶈瘯锛�");
+        }
+
+        boolean userAuthorized = flowMyBusinessService.isUserAuthorized(flowMyBusiness, user);
+        if (!userAuthorized) {
+            throw new JeecgBootException("鐢ㄦ埛鏃犳潈鎿嶄綔姝や换鍔★紝璇峰埛鏂板悗閲嶈瘯锛�");
+        }
+        // 璁ら浠诲姟
+        if (!flowMyBusinessService.claimTask(flowMyBusiness.getTaskId(), user)) {
+            throw new JeecgBootException("浠诲姟涓嶅瓨鍦ㄣ�佸凡瀹屾垚鎴栧凡琚粬浜鸿棰嗭紒");
+        }
+
+        EamEquipment equipment = equipmentService.getById(entity.getEquipmentId());
+        if (equipment == null) {
+            throw new JeecgBootException("璁惧涓嶅瓨鍦紝璇锋鏌ワ紒");
+        }
+
+        TechnicalStatusEvaluationOrderStatusEnum status = TechnicalStatusEvaluationOrderStatusEnum.getInstance(entity.getEvaluationStatus());
+        if (status == null) {
+            return null;
+        }
+        //娴佺▼鍙橀噺
+        Map<String, Object> values = new HashMap<>();
+        List<String> userApprovalList;
+        List<UserSelector> userSelectors;
+        switch (status) {
+            case UNDER_EVALUATION:
+                if(CollectionUtil.isEmpty(request.getTableDetailList())) {
+                    throw new JeecgBootException("妫�鏌ユ槑缁嗕俊鎭负绌猴紒");
+                }
+                boolean parallelCompletion = flowTaskService.checkParallelCompletion(flowMyBusiness.getTaskId());
+                //鎵ц瀹屾垚
+                userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0008);
+                if (CollectionUtil.isEmpty(userSelectors)) {
+                    throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨瀹や富浠伙紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�");
+                }
+                userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+                values.put("dataId", entity.getId());
+                values.put("organization", "鎶�鏈姸鎬侀壌瀹氭墽琛岀粨鏉�");
+                values.put("comment", "鎶�鏈姸鎬侀壌瀹氭墽琛岀粨鏉�");
+                request.setComment("鎶�鏈姸鎬侀壌瀹氭墽琛岀粨鏉�");
+                //璁剧疆entity
+                if (CommonConstant.STATUS_1.equals(entity.getSafetyCheckCompleted())
+                        && CommonConstant.STATUS_1.equals(entity.getPrecisionCheckCompleted())
+                        && CommonConstant.STATUS_1.equals(entity.getOtherCheckCompleted())
+                        && parallelCompletion) {
+                    //澶氫釜浠诲姟閮藉凡瀹屾垚涓旂淮淇涓讳换閮藉凡瀹℃壒閫氳繃,浼氱瀹屾垚锛岃繘琛岀淮淇伐绛惧瓧
+                    userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0002);
+                    userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.REPAIRER_SIGNING.name());
+                    entity.setActualEndTime(new Date());
+                }
+                if ("safety_equipment_check".equals(flowMyBusiness.getTaskNameId())) {
+                    //鎵ц瀹夊叏妫�鏌�
+                    //瀹夊叏瑁呯疆妫�鏌ョ粨鏋滃~鎶�
+                    List<EamTechnicalStatusEvaluationOrderDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
+                    if (CollectionUtil.isEmpty(collect)) {
+                        throw new JeecgBootException("瀹夊叏瑁呯疆妫�鏌ラ」鏄庣粏涓虹┖锛�");
+                    }
+                    //缁撴灉椤规鏌�
+                    checkDetailResult(request.getTableDetailList(), TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK);
+                    //娣诲姞鎿嶄綔浜轰俊鎭�
+                    for (EamTechnicalStatusEvaluationOrderDetail detail : collect) {
+                        detail.setRepairmanSignature(user.getUsername());
+                        detail.setRepairmanSignatureTime(new Date());
+                    }
+                    orderDetailService.updateBatchById(collect);
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setSafetyCheckCompleted(CommonConstant.STATUS_1);
+                } else if ("safety_equipment_check_confirm".equals(flowMyBusiness.getTaskNameId()) && CommonConstant.STATUS_1.equals(entity.getSafetyCheckCompleted())) {
+                    values.put("safetyEquipmentCheckFlag", request.getSafetyCheckConfirmResult());
+                    entity.setSafetyCheckConfirmResult(request.getSafetyCheckConfirmResult());
+                    entity.setSafetyCheckConfirm(user.getUsername());
+                    entity.setSafetyCheckConfirmTime(new Date());
+                    entity.setSafetyCheckConfirmComment(request.getSafetyCheckConfirmComment());
+                    //缁翠慨瀹や富浠诲鎵�
+                    if (!CommonConstant.STATUS_1.equals(request.getSafetyCheckConfirmResult())) {
+                        //椹冲洖 缁欑洃瀵熶汉
+                        userApprovalList = Collections.singletonList(request.getTableDetailList().get(0).getRepairmanSignature());
+                        values.put("NextAssignee", userApprovalList);
+                        entity.setSafetyCheckCompleted(CommonConstant.STATUS_0);
+                    }
+                } else if ("equipment_precision_check".equals(flowMyBusiness.getTaskNameId())) {
+                    //澶勭悊绮惧害妫�楠�
+                    //璁惧绮惧害妫�鏌ョ粨鏋滃~鎶�
+                    List<EamTechnicalStatusEvaluationOrderDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
+                    if (CollectionUtil.isEmpty(collect)) {
+                        throw new JeecgBootException("璁惧绮惧害妫�鏌ラ」鏄庣粏涓虹┖锛�");
+                    }
+                    //缁撴灉椤规鏌�
+                    checkDetailResult(request.getTableDetailList(), TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK);
+                    //娣诲姞鎿嶄綔浜轰俊鎭�
+                    for (EamTechnicalStatusEvaluationOrderDetail detail : collect) {
+                        detail.setRepairmanSignature(user.getUsername());
+                        detail.setRepairmanSignatureTime(new Date());
+                    }
+                    orderDetailService.updateBatchById(collect);
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setPrecisionCheckCompleted(CommonConstant.STATUS_1);
+                } else if ("equipment_precision_check_confirm".equals(flowMyBusiness.getTaskNameId()) && CommonConstant.STATUS_1.equals(entity.getPrecisionCheckCompleted())) {
+                    values.put("precisionCheckFlag", request.getPrecisionCheckConfirmResult());
+                    entity.setPrecisionCheckConfirmResult(request.getPrecisionCheckConfirmResult());
+                    entity.setPrecisionCheckConfirm(user.getUsername());
+                    entity.setPrecisionCheckConfirmTime(new Date());
+                    entity.setPrecisionCheckConfirmComment(request.getPrecisionCheckConfirmComment());
+                    //缁翠慨瀹や富浠诲鎵�
+                    if (!CommonConstant.STATUS_1.equals(request.getPrecisionCheckConfirmResult())) {
+                        //椹冲洖 缁欑洃瀵熶汉
+                        userApprovalList = Collections.singletonList(request.getTableDetailList().get(0).getRepairmanSignature());
+                        values.put("NextAssignee", userApprovalList);
+                        entity.setPrecisionCheckCompleted(CommonConstant.STATUS_0);
+                    }
+                } else if ("other_check".equals(flowMyBusiness.getTaskNameId())) {
+                    //澶勭悊鍏朵粬妫�鏌�
+                    //鍏朵粬妫�鏌ョ粨鏋滃~鎶�
+                    List<EamTechnicalStatusEvaluationOrderDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList());
+                    if (CollectionUtil.isEmpty(collect)) {
+                        throw new JeecgBootException("鍏朵粬妫�鏌ラ」鏄庣粏涓虹┖锛�");
+                    }
+                    //缁撴灉椤规鏌�
+                    checkDetailResult(request.getTableDetailList(), TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK);
+                    //娣诲姞鎿嶄綔浜轰俊鎭�
+                    for (EamTechnicalStatusEvaluationOrderDetail detail : collect) {
+                        detail.setRepairmanSignature(user.getUsername());
+                        detail.setRepairmanSignatureTime(new Date());
+                    }
+                    orderDetailService.updateBatchById(collect);
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setOtherCheckCompleted(CommonConstant.STATUS_1);
+                } else if ("other_check_confirm".equals(flowMyBusiness.getTaskNameId()) && CommonConstant.STATUS_1.equals(entity.getOtherCheckCompleted())) {
+                    values.put("otherCheckFlag", request.getOtherCheckConfirmResult());
+                    entity.setOtherCheckConfirmResult(request.getOtherCheckConfirmResult());
+                    entity.setOtherCheckConfirm(user.getUsername());
+                    entity.setOtherCheckConfirmTime(new Date());
+                    entity.setOtherCheckConfirmComment(request.getOtherCheckConfirmComment());
+                    //缁翠慨瀹や富浠诲鎵�
+                    if (!CommonConstant.STATUS_1.equals(request.getOtherCheckConfirmResult())) {
+                        //椹冲洖 缁欑洃瀵熶汉
+                        userApprovalList = Collections.singletonList(request.getTableDetailList().get(0).getRepairmanSignature());
+                        values.put("NextAssignee", userApprovalList);
+                        entity.setOtherCheckCompleted(CommonConstant.STATUS_0);
+                    }
+                }
+                break;
+            case REPAIRER_SIGNING:
+                //缁翠慨宸ョ瀛�
+                userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0008);
+                if (CollectionUtil.isEmpty(userSelectors)) {
+                    throw new JeecgBootException("璁惧鏈垎閰嶇粰缁翠慨瀹や富浠伙紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�");
+                }
+                userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+                values.put("dataId", entity.getId());
+                values.put("organization", "缁翠慨宸ョ瀛楀畬鎴�");
+                values.put("comment", "缁翠慨宸ョ瀛楀畬鎴�");
+                values.put("NextAssignee", userApprovalList);
+                request.setComment("缁翠慨宸ョ瀛楀畬鎴�");
+                //璁剧疆entity
+                entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.REPAIR_MANAGER_SIGNING.name());
+                entity.setRepairerSignature(user.getUsername());
+                entity.setRepairerSignatureTime(new Date());
+                entity.setSafetyEquipmentCheckResult(request.getSafetyEquipmentCheckResult());
+                entity.setPrecisionCheckResult(request.getPrecisionCheckResult());
+                entity.setFunctionalCheckResult(request.getFunctionalCheckResult());
+                entity.setOtherCheckResult(request.getOtherCheckResult());
+                break;
+            case REPAIR_MANAGER_SIGNING:
+                //缁翠慨瀹や富浠荤瀛�
+                userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0007);
+                if (CollectionUtil.isEmpty(userSelectors)) {
+                    throw new JeecgBootException("璁惧鏈垎閰嶇粰宸ヨ壓鍛橈紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�");
+                }
+                userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+                values.put("dataId", entity.getId());
+                values.put("organization", request.getRepairManagerComment());
+                values.put("comment", request.getRepairManagerComment());
+                request.setComment(request.getRepairManagerComment());
+                values.put("repairManagerApprovalFlag", request.getRepairManagerSignatureResult());
+                entity.setRepairManagerSignature(user.getUsername());
+                entity.setRepairManagerSignatureTime(new Date());
+                entity.setRepairManagerComment(request.getRepairManagerComment());
+                entity.setRepairManagerSignatureResult(request.getRepairManagerSignatureResult());
+                //璁剧疆entity
+                if (BusinessCodeConst.APPROVED.equals(request.getRepairManagerSignatureResult())) {
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.PROCESS_TECHNICIAN_SIGNING.name());
+                } else {
+                    userApprovalList = Collections.singletonList(entity.getRepairerSignature());
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.REPAIRER_SIGNING.name());
+                }
+//                //鏇存柊璁惧淇濆吇鐘舵��
+//                eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.NORMAL.name());
+                break;
+            case PROCESS_TECHNICIAN_SIGNING:
+                //宸ヨ壓鍛樼瀛�
+                userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0010);
+                if (CollectionUtil.isEmpty(userSelectors)) {
+                    throw new JeecgBootException("璁惧鏈垎閰嶇粰浣跨敤鍗曚綅鎶�鏈富绠★紝鏃犳硶杩涘叆涓嬬骇瀹℃壒锛�");
+                }
+                userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+                values.put("dataId", entity.getId());
+                values.put("organization", request.getProcessTechnicianComment());
+                values.put("comment", request.getProcessTechnicianComment());
+                values.put("NextAssignee", userApprovalList);
+                request.setComment(request.getProcessTechnicianComment());
+                //璁剧疆entity
+                entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.DEPART_TECHNICAL_LEADER_SIGNING.name());
+                entity.setProcessTechnicianSignature(user.getUsername());
+                entity.setProcessTechnicianSignatureTime(new Date());
+                entity.setSampleCheckResult(request.getSampleCheckResult());
+                entity.setProcessTechnicianComment(request.getProcessTechnicianComment());
+                break;
+            case DEPART_TECHNICAL_LEADER_SIGNING:
+                //浣跨敤鍗曚綅鎶�鏈富绠$瀛�
+                userSelectors = sysUserService.selectOperatorList(equipment.getEquipmentCode(), equipment.getFactoryOrgCode(), BusinessCodeConst.PCR0003);
+                if (CollectionUtil.isEmpty(userSelectors)) {
+                    throw new JeecgBootException("璁惧鏈垎閰嶇粰璁惧妫�楠屽憳锛屾棤娉曡繘鍏ヤ笅绾у鎵癸紒");
+                }
+                userApprovalList = userSelectors.stream().map(UserSelector::getUsername).collect(Collectors.toList());
+                values.put("dataId", entity.getId());
+                values.put("organization", request.getDepartTechnicalLeaderComment());
+                values.put("comment", request.getDepartTechnicalLeaderComment());
+                request.setComment(request.getDepartTechnicalLeaderComment());
+                values.put("technicalLeaderApprovalFlag", request.getDepartTechnicalLeaderSignatureResult());
+                entity.setDepartTechnicalLeaderSignature(user.getUsername());
+                entity.setDepartTechnicalLeaderSignatureTime(new Date());
+                entity.setDepartTechnicalLeaderComment(request.getDepartTechnicalLeaderComment());
+                entity.setDepartTechnicalLeaderSignatureResult(request.getDepartTechnicalLeaderSignatureResult());
+                //璁剧疆entity
+                if (BusinessCodeConst.APPROVED.equals(request.getDepartTechnicalLeaderSignatureResult())) {
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.INSPECTOR_SIGNING.name());
+                } else {
+                    userApprovalList = Collections.singletonList(entity.getProcessTechnicianSignature());
+                    values.put("NextAssignee", userApprovalList);
+                    entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.PROCESS_TECHNICIAN_SIGNING.name());
+                }
+                break;
+            case INSPECTOR_SIGNING:
+                //璁惧妫�瀵熷憳绛惧瓧
+                values.put("dataId", entity.getId());
+                values.put("organization", request.getInspectorComment());
+                values.put("comment", request.getInspectorComment());
+                request.setComment(request.getInspectorComment());
+                //璁剧疆entity
+                entity.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.COMPLETED.name());
+                entity.setInspectorSignature(user.getUsername());
+                entity.setInspectorSignatureTime(new Date());
+                entity.setInspectorComment(request.getInspectorComment());
+                entity.setEvaluationResult(request.getEvaluationResult());
+                entity.setEvaluationReason(request.getEvaluationReason());
+                break;
+        }
+        request.setValues(values);
+
+        // 瀹屾垚娴佺▼浠诲姟
+        Result<?> result = flowTaskService.complete(request);
+        if (!result.isSuccess()) {
+            throw new JeecgBootException("瀹℃壒澶辫触锛岃鍒锋柊鏌ョ湅锛�");
+        }
+        //淇濆瓨宸ュ崟
+        this.getBaseMapper().updateById(entity);
+        return entity;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean updateEvaluationStatus(String orderId, String evaluationStatus) {
+        UpdateWrapper<EamTechnicalStatusEvaluationOrder> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.eq("id", orderId);
+        updateWrapper.set("evaluation_status", evaluationStatus);
+        updateWrapper.eq("del_flag", CommonConstant.DEL_FLAG_0);
+        updateWrapper.in("evaluation_status", Arrays.asList(TechnicalStatusEvaluationOrderStatusEnum.WAIT_EVALUATION.name(), TechnicalStatusEvaluationOrderStatusEnum.LOCKED.name()));
+        int update = this.getBaseMapper().update(null, updateWrapper);
+        return update > 0;
+    }
+
+    private void checkDetailResult(List<EamTechnicalStatusEvaluationOrderDetail> detailList, TechnicalStatusEvaluationCheckCategoryEnum checkCategory) {
+        boolean b;
+        switch (checkCategory) {
+            case SAFETY_EQUIPMENT_CHECK:
+                b = detailList.stream().allMatch(item -> StringUtils.isNotBlank(item.getSafetyEquipmentCheckResult()));
+                if (!b) {
+                    throw new JeecgBootException("鏈夊畨鍏ㄨ缃鏌ョ粨鏋滄湭濉啓锛�");
+                }
+                break;
+            case PRECISION_CHECK:
+                b = detailList.stream().allMatch(item -> item.getPrecisionCheckResult() != null);
+                if (!b) {
+                    throw new JeecgBootException("鏈夎澶囩簿搴︽鏌ョ粨鏋滄湭濉啓锛�");
+                }
+                break;
+            case OTHER_CHECK:
+                b = detailList.stream().allMatch(item -> StringUtils.isNotBlank(item.getOtherCheckResult()));
+                if (!b) {
+                    throw new JeecgBootException("鏈夊叾浠栨鏌ョ粨鏋滄湭濉啓锛�");
+                }
+                break;
+        }
+    }
+
+    @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