From d073e531919d945344ae37b2df0737f245e345d3 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期五, 11 七月 2025 11:39:04 +0800 Subject: [PATCH] art: 工单信息转译 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamTechnicalStatusEvaluationOrderServiceImpl.java | 139 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 132 insertions(+), 7 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 a9246ce..7125c4e 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,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.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -9,15 +10,17 @@ 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.BusinessCodeConst; -import org.jeecg.modules.eam.constant.EamTechnicalStatusEvaluationOrderEnum; import org.jeecg.modules.eam.constant.HfTemplateCategoryEnum; import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; +import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationOrderStatusEnum; import org.jeecg.modules.eam.entity.EamBaseHFCode; import org.jeecg.modules.eam.entity.EamEquipment; import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrder; @@ -26,18 +29,24 @@ import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderQuery; import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderRequest; 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; /** @@ -46,8 +55,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; @@ -63,6 +72,21 @@ private IEamTechnicalStatusEvaluationStandardService standardService; @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) { @@ -148,7 +172,7 @@ request.setOrderNum(codeSeq); request.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); //鐘舵�佸垵濮嬪寲 - order.setEvaluationStatus(EamTechnicalStatusEvaluationOrderEnum.WAIT_EVALUATION.name()); + order.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.WAIT_EVALUATION.name()); order.setCreationMethod(request.getCreationMethod()); //鍒犻櫎鏍囪 order.setDelFlag(CommonConstant.DEL_FLAG_0); @@ -187,4 +211,105 @@ } 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()); + 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 + 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