From 699295ce3e0e1116d1fc20f0fae89b66613bbacf Mon Sep 17 00:00:00 2001 From: cuilei <ray_tsu1@163.com> Date: 星期四, 28 八月 2025 17:40:51 +0800 Subject: [PATCH] 企业微信消息推送增加try catch 只记录错误日志,不抛出异常 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java | 56 +++++++++++++++++++++++++++++++------------------------- 1 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java index bb05add..4c885b6 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java @@ -47,6 +47,7 @@ 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 org.springframework.transaction.annotation.Transactional; @@ -93,6 +94,9 @@ private IMdcProductionService mdcProductionService; @Autowired private ThirdAppWechatEnterpriseServiceImpl wechatEnterpriseService; + + @Value("${wechatEnterprise.cardActionUrl}") + private String cardActionUrl; @Override @Transactional(rollbackFor = Exception.class) @@ -149,7 +153,11 @@ //鏇存柊璁惧淇濆吇鐘舵�� eamEquipmentExtendService.updateEquipmentMaintenanceStatus(order.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); //鎺ㄩ�佷紒涓氬井淇℃秷鎭� - sendQywxTemplateCardMessage(order, null); + try { + sendQywxTemplateCardMessage(order, null); + } catch (Exception e) { + log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e); + } return result.isSuccess(); } } @@ -341,7 +349,11 @@ //鏇存柊璁惧淇濆吇鐘舵�� eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_MAINTENANCE.name()); //鎺ㄩ�佷紒涓氬井淇℃秷鎭� - sendQywxTemplateCardMessage(entity, null); + try { + sendQywxTemplateCardMessage(entity, null); + } catch (Exception e) { + log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e); + } return result.isSuccess(); } return true; @@ -428,8 +440,12 @@ //鏂板鐨勫伐鍗曪紙鎸囧畾浜嗕繚鍏讳汉锛夈�佹柊棰嗗彇鐨勫伐鍗� TemplateCardEntity.HorizontalContent content = new TemplateCardEntity.HorizontalContent(); content.setKeyname("鍙戣捣浜�"); - SysUser sysUser = sysUserService.getUserByName(order.getCreateBy()); - content.setValue(sysUser.getRealname()); + if (order.getCreateBy() == null) { + content.setValue("瀹氭椂浠诲姟鐢熸垚"); + } else { + SysUser sysUser = sysUserService.getUserByName(order.getCreateBy()); + content.setValue(sysUser.getRealname()); + } horizontalContentList.add(content); } else { //琚┏鍥炵殑宸ュ崟 @@ -451,47 +467,28 @@ SysUser sysUser = sysUserService.getUserByName(order.getOperator()); content.setValue(sysUser.getRealname()); horizontalContentList.add(content); - //TemplateCardEntity.HorizontalContent content = new TemplateCardEntity.HorizontalContent(); - //List<String> nextAssignee = (List<String>) request.getValues().get("NextAssignee"); - //String realNameStr = sysUserService.getRealNameStrByUserNameList(nextAssignee); - //content.setKeyname("纭浜�"); - //content.setValue(realNameStr); - //horizontalContentList.add(content); } if (WeekMaintenanceStatusEnum.WAIT_INITIAL_ACCEPTANCE.name().equals(maintenanceStatus)) { TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent(); - //TemplateCardEntity.HorizontalContent content4 = new TemplateCardEntity.HorizontalContent(); String confirmAssignee = request.getAssignee(); SysUser confirmUser = sysUserService.getUserByName(confirmAssignee); content3.setKeyname("纭浜�"); content3.setValue(confirmUser.getRealname()); horizontalContentList.add(content3); - //List<String> nextAssignee = (List<String>) request.getValues().get("NextAssignee"); - //String realNameStr = sysUserService.getRealNameStrByUserNameList(nextAssignee); - //content4.setKeyname("鍒濋獙浜�"); - //content4.setValue(realNameStr); - //horizontalContentList.add(content4); } if (WeekMaintenanceStatusEnum.WAIT_FINAL_ACCEPTANCE.name().equals(maintenanceStatus)) { TemplateCardEntity.HorizontalContent content3 = new TemplateCardEntity.HorizontalContent(); - //TemplateCardEntity.HorizontalContent content4 = new TemplateCardEntity.HorizontalContent(); String initialAssignee = request.getAssignee(); SysUser initialUser = sysUserService.getUserByName(initialAssignee); content3.setKeyname("鍒濋獙浜�"); content3.setValue(initialUser.getRealname()); horizontalContentList.add(content3); - //List<String> nextAssignee = (List<String>) request.getValues().get("NextAssignee"); - //String realNameStr = sysUserService.getRealNameStrByUserNameList(nextAssignee); - //content4.setKeyname("缁堥獙浜�"); - //content4.setValue(realNameStr); - //horizontalContentList.add(content4); } - templateCardEntity.setHorizontal_content_list(horizontalContentList); TemplateCardEntity.CardAction cardAction = new TemplateCardEntity.CardAction(); cardAction.setType(1); - cardAction.setUrl("http://houjie.xalxzn.com:8866/h5"); + cardAction.setUrl(cardActionUrl); templateCardEntity.setCard_action(cardAction); wechatEnterpriseService.sendTemplateCardMsg(templateCard, true); @@ -669,7 +666,11 @@ eamWeekMaintenanceOrderMapper.updateById(entity); //鎺ㄩ�佷紒涓氬井淇℃秷鎭紝宸ュ崟瀹岀粨涓嶅彂閫� if (!WeekMaintenanceStatusEnum.COMPLETE.name().equals(entity.getMaintenanceStatus())) { - sendQywxTemplateCardMessage(entity, request); + try { + sendQywxTemplateCardMessage(entity, request); + } catch (Exception e) { + log.error("鎺ㄩ�佷紒涓氬井淇℃秷鎭け璐ワ細" + e.getMessage(), e); + } } return entity; } @@ -707,6 +708,11 @@ return list; } + @Override + public List<EamWeekMaintenanceOrder> selectUnReceivedMaintenanceOrder() { + return this.baseMapper.selectUnReceivedMaintenanceOrder(); + } + private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); return todoUsers != null && todoUsers.contains(user.getUsername()); -- Gitblit v1.9.3