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 | 215 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 207 insertions(+), 8 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 3cd996f..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,5 +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; @@ -8,27 +10,43 @@ 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.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; +import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandard; import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationOrderMapper; import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderQuery; -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.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; /** @@ -37,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; @@ -50,6 +68,25 @@ private IEamEquipmentService equipmentService; @Autowired private ISysBusinessCodeRuleService businessCodeRuleService; + @Autowired + 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) { @@ -113,4 +150,166 @@ queryWrapper.orderByDesc("ems.create_time"); return this.getBaseMapper().queryPageList(page, queryWrapper); } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addTechnicalStatusEvaluationOrder(EamTechnicalStatusEvaluationOrderRequest request) { + EamEquipment equipment = equipmentService.getById(request.getEquipmentId()); + if (equipment == null) { + throw new JeecgBootException("璁惧涓嶅瓨鍦紝娣诲姞澶辫触锛�"); + } + EamTechnicalStatusEvaluationStandard standard = standardService.getById(request.getStandardId()); + if(standard == null) { + throw new JeecgBootException("鎶�鏈姸鎬侀壌瀹氳鑼冧笉瀛樺湪锛屾坊鍔犲け璐ワ紒"); + } + EamTechnicalStatusEvaluationOrder order = new EamTechnicalStatusEvaluationOrder(); + order.setOrderNum(request.getOrderNum()); + order.setEquipmentId(request.getEquipmentId()); + order.setStandardId(request.getStandardId()); + order.setEvaluationDate(request.getEvaluationDate()); + order.setRemark(request.getRemark()); + String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.TECHNICAL_STATUS_EVALUATION_ORDER_CODE_RULE); + request.setOrderNum(codeSeq); + request.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); + //鐘舵�佸垵濮嬪寲 + order.setEvaluationStatus(TechnicalStatusEvaluationOrderStatusEnum.WAIT_EVALUATION.name()); + order.setCreationMethod(request.getCreationMethod()); + //鍒犻櫎鏍囪 + 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()); + } + 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