From 7fbb8dedb1112e1d87b8ccfb8d9df9bb763ec024 Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期二, 22 七月 2025 17:48:17 +0800 Subject: [PATCH] 点检、周保执行中设备异常报修消息推送 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 54 insertions(+), 2 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java index 2014997..210b5d3 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamReportRepairServiceImpl.java @@ -20,13 +20,20 @@ import org.jeecg.modules.eam.request.EamReportRepairQuery; import org.jeecg.modules.eam.service.IEamEquipmentExtendService; import org.jeecg.modules.eam.service.IEamEquipmentFaultReasonService; +import org.jeecg.modules.eam.service.IEamEquipmentService; import org.jeecg.modules.eam.service.IEamReportRepairService; import org.jeecg.modules.eam.vo.EquipmentRepairListVO; import org.jeecg.modules.eam.vo.EquipmentRepairStatistics; import org.jeecg.modules.eam.vo.EquipmentRepairStatusStatistics; import org.jeecg.modules.eam.vo.FaultTypeStatisticsVO; +import org.jeecg.modules.qywx.message.vo.TemplateCard; +import org.jeecg.modules.qywx.message.vo.TemplateCardEntity; import org.jeecg.modules.system.service.IMdcProductionService; +import org.jeecg.modules.system.service.ISysUserService; +import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl; +import org.jeecg.modules.system.vo.UserSelector; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; @@ -34,6 +41,7 @@ import javax.annotation.Resource; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; /** * @Description: 鏁呴殰鎶ヤ慨 @@ -49,6 +57,15 @@ private IMdcProductionService mdcProductionService; @Autowired private IEamEquipmentFaultReasonService eamEquipmentFaultReasonService; + @Autowired + private ISysUserService sysUserService; + @Autowired + private IEamEquipmentService eamEquipmentService; + @Autowired + private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService; + + @Value("${wechatEnterprise.cardActionUrl}") + private String cardActionUrl; /** * 鍒嗛〉鍒楄〃 @@ -127,7 +144,7 @@ sb.append(detail.getItemCode()).append("銆�"); sb.append(detail.getExceptionDescription()).append(";"); }); - EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250009); + EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250010); EamReportRepair entity = new EamReportRepair(); entity.setEquipmentId(equipmentId); entity.setCreateBy(reportUser); @@ -145,6 +162,8 @@ this.baseMapper.insert(entity); //鏇存柊璁惧缁翠慨鐘舵�� eamEquipmentExtendService.updateEquipmentRepairStatus(entity.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name()); + //鎺ㄩ�佷紒涓氬井淇℃秷鎭� + sendQywxTemplateCardMessage(entity); return entity; } @@ -157,7 +176,7 @@ sb.append(detail.getItemCode()).append("銆�"); sb.append(detail.getExceptionDescription()).append(";"); }); - EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250010); + EamEquipmentFaultReason reason = eamEquipmentFaultReasonService.selectByFaultCode(BusinessCodeConst.EFR20250009); EamReportRepair entity = new EamReportRepair(); entity.setEquipmentId(equipmentId); entity.setCreateBy(reportUser); @@ -175,6 +194,8 @@ this.baseMapper.insert(entity); //鏇存柊璁惧缁翠慨鐘舵�� eamEquipmentExtendService.updateEquipmentRepairStatus(entity.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name()); + //鎺ㄩ�佷紒涓氬井淇℃秷鎭� + sendQywxTemplateCardMessage(entity); return entity; } @@ -198,9 +219,40 @@ this.baseMapper.insert(eamReportRepair); //鏇存柊璁惧缁翠慨鐘舵�� eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.WAIT_REPAIR.name()); + //鎺ㄩ�佷紒涓氬井淇℃秷鎭� + sendQywxTemplateCardMessage(eamReportRepair); return eamReportRepair; } + private void sendQywxTemplateCardMessage(EamReportRepair eamReportRepair) { + TemplateCard templateCard = new TemplateCard(); + String equipmentId = eamReportRepair.getEquipmentId(); + EamEquipment equipment = eamEquipmentService.getById(equipmentId); + if (equipment != null) { + //鏌ヨ鏈夎璁惧鏉冮檺鐨勬墍鏈夌淮淇伐 + String productionId = equipment.getOrgId(); + List<UserSelector> userSelectorList = sysUserService.selectOperatorList(equipment.getEquipmentCode(), productionId, BusinessCodeConst.PCR0002); + String toUsers = userSelectorList.stream().map(UserSelector::getUsername).collect(Collectors.joining(",")); + String touser = wechatEnterpriseService.getTouser(toUsers, false); + templateCard.setTouser(touser); + + TemplateCardEntity templateCardEntity = new TemplateCardEntity(); + templateCard.setTemplate_card(templateCardEntity); + templateCardEntity.setTask_id(eamReportRepair.getId()); + TemplateCardEntity.MainTitle mainTitle = new TemplateCardEntity.MainTitle(); + mainTitle.setTitle("璁惧缁翠慨"); + templateCardEntity.setMain_title(mainTitle); + templateCardEntity.setSub_title_text("鎮ㄦ湁寰呴鍙栫淮淇伐鍗曪紝璇疯繘鍏ョ郴缁熼鍙�"); + TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction(); + cardAction.setType(1); + cardAction.setUrl(cardActionUrl); + templateCardEntity.setCard_action(cardAction); + wechatEnterpriseService.sendTemplateCardMsg(templateCard, true); + } else { + log.error("鎶ヤ慨宸ュ崟: " + eamReportRepair.getId() + " 璁惧涓嶅瓨鍦紝鏃犳硶鎺ㄩ�佸伐鍗曞緟棰嗗彇鎻愰啋娑堟伅锛�"); + } + } + @Override @Transactional(rollbackFor = Exception.class) public boolean edit(EamReportRepair eamReportRepair) { -- Gitblit v1.9.3