From 798a127ff50b19552b51c4732762102bcefb1fd7 Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期二, 08 七月 2025 11:31:54 +0800 Subject: [PATCH] 设备维修业务流程增加企业微信消息推送 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java | 152 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 148 insertions(+), 4 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java index 9f28cc2..9faa0c0 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamRepairOrderServiceImpl.java @@ -25,10 +25,7 @@ import org.jeecg.modules.eam.entity.EamRepairOrder; import org.jeecg.modules.eam.entity.EamReportRepair; import org.jeecg.modules.eam.mapper.EamRepairOrderMapper; -import org.jeecg.modules.eam.request.EamRepairOrderQuery; -import org.jeecg.modules.eam.request.EamRepairOrderRequest; -import org.jeecg.modules.eam.request.EamRepairOrderResponse; -import org.jeecg.modules.eam.request.EamReportRepairQuery; +import org.jeecg.modules.eam.request.*; import org.jeecg.modules.eam.service.IEamEquipmentExtendService; import org.jeecg.modules.eam.service.IEamEquipmentService; import org.jeecg.modules.eam.service.IEamRepairOrderService; @@ -38,11 +35,18 @@ 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.domain.vo.WorkTaskDataVo; import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; import org.jeecg.modules.mdc.util.DateUtils; +import org.jeecg.modules.qywx.message.vo.TemplateCard; +import org.jeecg.modules.qywx.message.vo.TemplateCardEntity; +import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; +import org.jeecg.modules.system.service.ISysUserService; +import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -50,6 +54,7 @@ import javax.annotation.Resource; import java.util.*; +import java.util.stream.Collectors; /** * @Description: 缁翠慨宸ュ崟 @@ -85,6 +90,12 @@ @Resource private IEamEquipmentExtendService eamEquipmentExtendService; + + @Resource + private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService; + + @Resource + private ISysUserService sysUserService; /** * 鍒嗛〉鍒楄〃 @@ -205,6 +216,8 @@ eamReportRepairService.updateById(eamReportRepair); //鏇存柊璁惧缁翠慨鐘舵�� eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name()); + //鎺ㄩ�佷紒涓氬井淇℃秷鎭� + sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, null); } } @@ -249,7 +262,134 @@ eamReportRepairService.updateById(eamReportRepair); //鏇存柊璁惧缁翠慨鐘舵�� eamEquipmentExtendService.updateEquipmentRepairStatus(eamReportRepair.getEquipmentId(), EquipmentRepairStatus.UNDER_REPAIR.name()); + //鎺ㄩ�佷紒涓氬井淇℃秷鎭� + sendQywxTemplateCardMessage(eamRepairOrder, null, null); } + } + + private void sendQywxTemplateCardMessage(EamRepairOrder eamRepairOrder, EamReportRepair reportRepair, EamRepairOrderRequest request) { + TemplateCard templateCard = new TemplateCard(); + String repairStatus = eamRepairOrder.getRepairStatus(); + EamEquipment equipment = eamEquipmentService.getById(eamRepairOrder.getEquipmentId()); + eamRepairOrder.setEquipmentCode(equipment.getEquipmentCode()); + if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { + //宸ュ崟宸叉寚娲撅紝鎺ㄩ�佹秷鎭粰缁翠慨宸� + String repairer = eamRepairOrder.getRepairer(); + String touser = wechatEnterpriseService.getTouser(repairer, false); + templateCard.setTouser(touser); + } + if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus)) { + //宸ュ崟杩涘叆绛夊緟澶囦欢鐘舵�侊紝鎺ㄩ�佹秷鎭粰璁惧绠$悊鍛� + List<String> nextAssignee = (List<String>) request.getValues().get("NextAssignee"); + String nextAssigneeStr = nextAssignee.stream() + .filter(Objects::nonNull) // 鍙�夛細杩囨护 null 鍊� + .collect(Collectors.joining(",")); + String touser = wechatEnterpriseService.getTouser(nextAssigneeStr, false); + templateCard.setTouser(touser); + } + if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { + //宸ュ崟杩涘叆寰呯‘璁ょ姸鎬侊紝鎺ㄩ�佹秷鎭粰鎶ヤ慨鍛� + String touser = wechatEnterpriseService.getTouser(reportRepair.getCreateBy(), false); + templateCard.setTouser(touser); + } + + TemplateCardEntity templateCardEntity = new TemplateCardEntity(); + templateCard.setTemplate_card(templateCardEntity); + templateCardEntity.setTask_id(eamRepairOrder.getId()); + TemplateCardEntity.MainTitle mainTitle = new TemplateCardEntity.MainTitle(); + mainTitle.setTitle("璁惧缁翠慨"); + templateCardEntity.setMain_title(mainTitle); + + if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { + if (Objects.isNull(reportRepair) && Objects.isNull(request)) { + templateCardEntity.setSub_title_text("鏀跺埌鎸囨淳缁翠慨宸ュ崟: " + eamRepairOrder.getRepairCode() + " 璇峰紑濮嬭繘琛岀淮淇�"); + } else if (Objects.isNull(request)) { + templateCardEntity.setSub_title_text("宸查鍙栫淮淇伐鍗�: " + eamRepairOrder.getRepairCode() + " 寮�濮嬭繘琛岀淮淇�"); + } + else { + templateCardEntity.setSub_title_text("缁翠慨宸ュ崟: " + eamRepairOrder.getRepairCode() + " 澶囦欢宸插埌浣嶏紝璇风户缁繘琛岀淮淇�"); + } + } + if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus)) { + templateCardEntity.setSub_title_text("缁翠慨宸ュ崟: " + eamRepairOrder.getRepairCode() + " 闇�瑕侀鐢ㄥ浠�"); + } + if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { + templateCardEntity.setSub_title_text("宸ュ崟: " + eamRepairOrder.getRepairCode() + " 宸插畬鎴愯澶囩淮淇紝璇疯繘鍏ョ郴缁熺‘璁�"); + } + + List<TemplateCardEntity.HorizontalContent> horizontalContentList = CollectionUtil.newArrayList(); + TemplateCardEntity.HorizontalContent content1 = new TemplateCardEntity.HorizontalContent(); + content1.setKeyname("宸ュ崟鍙�"); + content1.setValue(eamRepairOrder.getRepairCode()); + horizontalContentList.add(content1); + TemplateCardEntity.HorizontalContent content2 = new TemplateCardEntity.HorizontalContent(); + content2.setKeyname("璁惧缂栧彿"); + content2.setValue(eamRepairOrder.getEquipmentCode()); + horizontalContentList.add(content2); + + //濡傛灉宸ュ崟鐘舵�佷负寰呯淮淇紙娌℃寚娲剧淮淇汉锛夛紝娴佺▼鏄病鏈夊惎鍔ㄧ殑锛屾棤娉曡幏鍙栬妭鐐逛俊鎭� + if (!ReportRepairEnum.WAIT_REPAIR.name().equals(repairStatus)) { + WorkTaskDataVo previousFlowInfo = flowTaskService.getPreviousFlowInfo(eamRepairOrder.getId()); + TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent(); + content3.setKeyname("鍓嶉┍鑺傜偣"); + content3.setValue(previousFlowInfo.getPreNode()); + horizontalContentList.add(content3); + TemplateCardEntity.HorizontalContent content4 = new TemplateCardEntity.HorizontalContent(); + content4.setKeyname("褰撳墠鑺傜偣"); + if (InspectionStatus.COMPLETE.name().equals(repairStatus)) { + content4.setValue("宸插畬鎴�"); + } else { + content4.setValue(previousFlowInfo.getName()); + } + horizontalContentList.add(content4); + } + + TemplateCardEntity.HorizontalContent content5 = new TemplateCardEntity.HorizontalContent(); + TemplateCardEntity.HorizontalContent content6 = new TemplateCardEntity.HorizontalContent(); + + if (ReportRepairEnum.UNDER_REPAIR.name().equals(repairStatus)) { + SysUser sysUser = sysUserService.getUserByName(eamRepairOrder.getRepairer()); + if (Objects.isNull(reportRepair) && Objects.isNull(request)) { + content5.setKeyname("鎸囨淳浜�"); + SysUser assignUser = sysUserService.getUserByName(eamRepairOrder.getCreateBy()); + content5.setValue(assignUser.getRealname()); + horizontalContentList.add(content5); + } else if (Objects.isNull(request)) { + TemplateCardEntity.HorizontalContent content = new TemplateCardEntity.HorizontalContent(); + content.setKeyname("棰嗗彇浜�"); + content.setValue(sysUser.getRealname()); + horizontalContentList.add(content); + } else { + content5.setKeyname("澶囦欢棰嗗彇浜�"); + SysUser assignUser = sysUserService.getUserByName(request.getAssignee()); + content5.setValue(assignUser.getRealname()); + horizontalContentList.add(content5); + } + content6.setKeyname("缁翠慨浜�"); + content6.setValue(sysUser.getRealname()); + horizontalContentList.add(content6); + } + if (ReportRepairEnum.WAIT_SPARES.name().equals(repairStatus) || ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { + content5.setKeyname("缁翠慨浜�"); + SysUser repairUser = sysUserService.getUserByName(eamRepairOrder.getRepairer()); + content5.setValue(repairUser.getRealname()); + horizontalContentList.add(content5); + } + if (ReportRepairEnum.WAIT_CONFIRM.name().equals(repairStatus)) { + content6.setKeyname("纭浜�"); + SysUser sysUser = sysUserService.getUserByName(reportRepair.getCreateBy()); + content6.setValue(sysUser.getRealname()); + horizontalContentList.add(content6); + } + + templateCardEntity.setHorizontal_content_list(horizontalContentList); + + TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction(); + cardAction.setType(1); + cardAction.setUrl("http://houjie.xalxzn.com:8866/h5"); + templateCardEntity.setCard_action(cardAction); + + wechatEnterpriseService.sendTemplateCardMsg(templateCard, true); } @Override @@ -410,6 +550,10 @@ this.baseMapper.updateById(eamRepairOrder); // 鍚屾鏇存柊鎶ヤ慨琛ㄧ姸鎬� eamReportRepairService.updateById(eamReportRepair); + if (!ReportRepairEnum.COMPLETE.name().equals(eamRepairOrder.getRepairStatus())) { + //鎺ㄩ�佷紒涓氬井淇℃秷鎭紙娴佺▼瀹岀粨涓嶅彂閫佹秷鎭級 + sendQywxTemplateCardMessage(eamRepairOrder, eamReportRepair, request); + } return eamRepairOrder; } -- Gitblit v1.9.3