From 00719f879705dff841f25ed863864802ff1c94f8 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 3 Apr 2024 15:18:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?update:=20=E8=BD=A6=E8=BE=86/=E7=89=B9?= =?UTF-8?q?=E7=A7=8D=E8=AE=BE=E5=A4=87=E6=A8=A1=E5=9D=97=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/safeproduct/jobs/CarJob.java | 201 ++++++++++++--------- .../hzims/safeproduct/jobs/SpecialDeviceJob.java | 70 ++++--- .../hzims/safeproduct/service/ICarService.java | 18 +- .../safeproduct/service/impl/CarServiceImpl.java | 18 +- 4 files changed, 182 insertions(+), 125 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java index aaa9416..55af063 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/CarJob.java @@ -67,125 +67,164 @@ public class CarJob { String today = DateUtil.format(current, DateUtil.PATTERN_DATE); String yesterday = DateUtil.format(before, DateUtil.PATTERN_DATE); // 车保状态变更 - List uninsuredCarList = carService.getCarListByInsuranceTime(today, yesterday); + List uninsuredCarList = carService.getCarListByInsuranceTime(yesterday, today); if (!CollectionUtils.isEmpty(uninsuredCarList)) { uninsuredCarList.forEach(car -> car.setInsuranceStatus(CarInsuranceStatusEnum.UNINSURED.getValue())); boolean insuranceUpdate = carService.updateBatchById(uninsuredCarList); if (!insuranceUpdate) { return ReturnT.FAIL; } - // 变更成功则推送消息 - uninsuredCarList.forEach(this::sendUninsuredMessage); } // 维保状态变更 - List unmaintainedCarList = carService.getCarListByMaintenanceTime(today, yesterday); + List unmaintainedCarList = carService.getCarListByMaintenanceTime(yesterday, today); if (!CollectionUtils.isEmpty(unmaintainedCarList)) { unmaintainedCarList.forEach(car -> car.setMaintenanceStatus(CarMaintenanceStatusEnum.UNMAINTAINED.getValue())); boolean maintenanceUpdate = carService.updateBatchById(unmaintainedCarList); if (!maintenanceUpdate) { return ReturnT.FAIL; } - // 变更成功则推送消息 - unmaintainedCarList.forEach(this::sendUnmaintainedMessage); } // 年检状态变更 - List uninspectedCarList = carService.getCarListByAnnualInspectionTime(today, yesterday); + List uninspectedCarList = carService.getCarListByAnnualInspectionTime(yesterday, today); if (!CollectionUtils.isEmpty(uninspectedCarList)) { uninspectedCarList.forEach(car -> car.setAnnualInspectionStatus(CarAnnualInspectionStatusEnum.UNFINISHED.getValue())); boolean inspectionUpdate = carService.updateBatchById(uninspectedCarList); if (!inspectionUpdate) { return ReturnT.FAIL; } - // 变更成功则推送消息 - uninspectedCarList.forEach(this::sendUninspectedMessage); } return ReturnT.SUCCESS; } /** - * 推送车保过期消息 - * @param carEntity 车辆实体类 + * 推送车保即将过期消息 */ - private void sendUninsuredMessage(CarEntity carEntity) { - if (carEntity.getManagerId() == null) { - log.error("系统无该用户信息,推送车保过期消息失败"); - return; - } - // 查询用户 - R userRes = userClient.userInfoById(carEntity.getManagerId()); - User user = userRes.getData(); - BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); - if (StringUtils.isNotEmpty(user.getDeptId())) { - Long id = Long.valueOf(user.getDeptId()); - businessMessageDTO.setDeptId(id); - businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); - businessMessageDTO.setBusinessKey("车保到期"); - businessMessageDTO.setBusinessClassify("system"); - businessMessageDTO.setTaskId(carEntity.getId()); - businessMessageDTO.setSubject("车保到期通知"); - businessMessageDTO.setContent("您所管理的车辆" + carEntity.getPlateNumber() + "车保已过期,请及时续保。"); - businessMessageDTO.setUserIds(String.valueOf(carEntity.getManagerId())); - businessMessageDTO.setCreateUser(carEntity.getCreateUser()); - businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + @XxlJob("sendExpiredInsuranceMessage") + public ReturnT sendExpiredInsuranceMessage(String param) { + // 获取时间范围 + Date current = DateUtil.now(); + Date next = DateUtil.plusDays(current, 2); + String today = DateUtil.format(current, DateUtil.PATTERN_DATE); + String tomorrow = DateUtil.format(next, DateUtil.PATTERN_DATE); + // 获取车保状态即将过期的车辆 + List uninsuredCarList = carService.getCarListByInsuranceTime(today, tomorrow); + if (!CollectionUtils.isEmpty(uninsuredCarList)) { + for (CarEntity car : uninsuredCarList) { + if (car.getManagerId() == null) { + return new ReturnT<>("系统无该用户信息,无法推送车保过期提醒消息"); + } + // 查询用户 + R userRes = userClient.userInfoById(car.getManagerId()); + User user = userRes.getData(); + // 推送消息 + BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); + businessMessageDTO.setDeptId(id); + businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); + businessMessageDTO.setBusinessKey("车保到期"); + businessMessageDTO.setBusinessClassify("system"); + businessMessageDTO.setTaskId(car.getId()); + businessMessageDTO.setSubject("车保即将到期提醒"); + businessMessageDTO.setContent("您所管理的车辆" + car.getPlateNumber() + "的车保即将过期,请及时续保。"); + businessMessageDTO.setUserIds(String.valueOf(car.getManagerId())); + businessMessageDTO.setCreateUser(car.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + R res = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + if (!res.isSuccess()) { + return ReturnT.FAIL; + } + } } - messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + return ReturnT.SUCCESS; } /** - * 推送维保过期消息 - * @param carEntity 车辆实体类 + * 推送维保即将过期消息 */ - private void sendUnmaintainedMessage(CarEntity carEntity) { - if (carEntity.getManagerId() == null) { - log.error("系统无该用户信息,推送维保过期消息失败"); - return; - } - // 查询用户 - R userRes = userClient.userInfoById(carEntity.getManagerId()); - User user = userRes.getData(); - BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); - if (StringUtils.isNotEmpty(user.getDeptId())) { - Long id = Long.valueOf(user.getDeptId()); - businessMessageDTO.setDeptId(id); - businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); - businessMessageDTO.setBusinessKey("维保到期"); - businessMessageDTO.setBusinessClassify("system"); - businessMessageDTO.setTaskId(carEntity.getId()); - businessMessageDTO.setSubject("维保到期通知"); - businessMessageDTO.setContent("您所管理的车辆" + carEntity.getPlateNumber() + "维保已过期,请及时进行维保。"); - businessMessageDTO.setUserIds(String.valueOf(carEntity.getManagerId())); - businessMessageDTO.setCreateUser(carEntity.getCreateUser()); - businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + @XxlJob("sendExpiredMaintainedMessage") + public ReturnT sendExpiredMaintainedMessage(String param) { + // 获取时间范围 + Date current = DateUtil.now(); + Date next = DateUtil.plusDays(current, 2); + String today = DateUtil.format(current, DateUtil.PATTERN_DATE); + String tomorrow = DateUtil.format(next, DateUtil.PATTERN_DATE); + // 获取维保状态即将过期的车辆 + List unmaintainedCarList = carService.getCarListByMaintenanceTime(today, tomorrow); + if (!CollectionUtils.isEmpty(unmaintainedCarList)) { + for (CarEntity car : unmaintainedCarList) { + if (car.getManagerId() == null) { + return new ReturnT<>("系统无该用户信息,无法推送维保过期提醒消息"); + } + // 查询用户 + R userRes = userClient.userInfoById(car.getManagerId()); + User user = userRes.getData(); + // 推送消息 + BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); + businessMessageDTO.setDeptId(id); + businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); + businessMessageDTO.setBusinessKey("维保到期"); + businessMessageDTO.setBusinessClassify("system"); + businessMessageDTO.setTaskId(car.getId()); + businessMessageDTO.setSubject("维保即将到期提醒"); + businessMessageDTO.setContent("您所管理的车辆" + car.getPlateNumber() + "的维保即将过期,请及时进行维保。"); + businessMessageDTO.setUserIds(String.valueOf(car.getManagerId())); + businessMessageDTO.setCreateUser(car.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + R res = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + if (!res.isSuccess()) { + return ReturnT.FAIL; + } + } } - messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + return ReturnT.SUCCESS; } /** - * 推送年检过期消息 - * @param carEntity 车辆实体类 + * 推送年检即将过期消息 */ - private void sendUninspectedMessage(CarEntity carEntity) { - if (carEntity.getManagerId() == null) { - log.error("系统无该用户信息,推送年检过期消息失败"); - return; - } - // 查询用户 - R userRes = userClient.userInfoById(carEntity.getManagerId()); - User user = userRes.getData(); - BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); - if (StringUtils.isNotEmpty(user.getDeptId())) { - Long id = Long.valueOf(user.getDeptId()); - businessMessageDTO.setDeptId(id); - businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); - businessMessageDTO.setBusinessKey("年检到期"); - businessMessageDTO.setBusinessClassify("system"); - businessMessageDTO.setTaskId(carEntity.getId()); - businessMessageDTO.setSubject("年检到期通知"); - businessMessageDTO.setContent("您所管理的车辆" + carEntity.getPlateNumber() + "年检已过期,请及时进行年检。"); - businessMessageDTO.setUserIds(String.valueOf(carEntity.getManagerId())); - businessMessageDTO.setCreateUser(carEntity.getCreateUser()); - businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + @XxlJob("sendExpiredInspectedMessage") + public ReturnT sendExpiredInspectedMessage(String param) { + // 获取时间范围 + Date current = DateUtil.now(); + Date next = DateUtil.plusDays(current, 2); + String today = DateUtil.format(current, DateUtil.PATTERN_DATE); + String tomorrow = DateUtil.format(next, DateUtil.PATTERN_DATE); + // 获取维保状态即将过期的车辆 + List uninspectedCarList = carService.getCarListByAnnualInspectionTime(today, tomorrow); + if (!CollectionUtils.isEmpty(uninspectedCarList)) { + for (CarEntity car : uninspectedCarList) { + if (car.getManagerId() == null) { + return new ReturnT<>("系统无该用户信息,无法推送年检过期提醒消息"); + } + // 查询用户 + R userRes = userClient.userInfoById(car.getManagerId()); + User user = userRes.getData(); + // 推送消息 + BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); + businessMessageDTO.setDeptId(id); + businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); + businessMessageDTO.setBusinessKey("年检到期"); + businessMessageDTO.setBusinessClassify("system"); + businessMessageDTO.setTaskId(car.getId()); + businessMessageDTO.setSubject("年检即将到期提醒"); + businessMessageDTO.setContent("您所管理的车辆" + car.getPlateNumber() + "的年检即将过期,请及时进行年检。"); + businessMessageDTO.setUserIds(String.valueOf(car.getManagerId())); + businessMessageDTO.setCreateUser(car.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + R res = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + if (!res.isSuccess()) { + return ReturnT.FAIL; + } + } } - messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + return ReturnT.SUCCESS; } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java index e6ec1ab..f90cb6a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/SpecialDeviceJob.java @@ -11,6 +11,7 @@ import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; @@ -44,6 +45,9 @@ public class SpecialDeviceJob { @Autowired IMessageClient messageClient; + /** + * 特种设备状态自动变更 + */ @XxlJob("autoChangeDeviceStatus") public ReturnT autoChangeDeviceStatus(String param) { // 获取时间范围 @@ -54,11 +58,10 @@ public class SpecialDeviceJob { // 查询昨天的过期设备 List list = deviceService.getExpiredDeviceByTime(yesterday, today); if (CollectionUtils.isEmpty(list)) { - return ReturnT.SUCCESS; + return new ReturnT<>("无即将过期的特种设备"); } list.forEach(device -> { device.setDeviceStatus(DeviceStatusEnum.EXPIRED.getValue()); - sendExpiredMessage(device); }); // 更新状态 boolean update = deviceService.updateBatchById(list); @@ -66,31 +69,46 @@ public class SpecialDeviceJob { } /** - * 推送设备过期消息 - * @param specialDeviceEntity 特种设备实体类 + * 推送设备即将过期消息 */ - private void sendExpiredMessage(SpecialDeviceEntity specialDeviceEntity) { - if (specialDeviceEntity.getManagerId() == null) { - log.error("系统无该用户信息,推送设备过期消息失败"); - return; - } - // 查询用户 - R userRes = userClient.userInfoById(specialDeviceEntity.getManagerId()); - User user = userRes.getData(); - BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); - if (StringUtils.isNotEmpty(user.getDeptId())) { - Long id = Long.valueOf(user.getDeptId()); - businessMessageDTO.setDeptId(id); - businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); - businessMessageDTO.setBusinessKey("设备到期"); - businessMessageDTO.setBusinessClassify("system"); - businessMessageDTO.setTaskId(specialDeviceEntity.getId()); - businessMessageDTO.setSubject("设备到期通知"); - businessMessageDTO.setContent("您所管理的特种设备" + specialDeviceEntity.getName() + "已到期,请尽快进行检验。"); - businessMessageDTO.setUserIds(String.valueOf(specialDeviceEntity.getManagerId())); - businessMessageDTO.setCreateUser(specialDeviceEntity.getCreateUser()); - businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + @XxlJob("sendExpiredDeviceMessage") + public ReturnT sendExpiredDeviceMessage(String param) { + // 获取时间范围 + Date current = DateUtil.now(); + Date next = DateUtil.plusDays(current, 2); + String today = DateUtil.format(current, DateUtil.PATTERN_DATE); + String tomorrow = DateUtil.format(next, DateUtil.PATTERN_DATE); + // 查询即将的过期设备 + List list = deviceService.getExpiredDeviceByTime(today, tomorrow); + if (CollectionUtil.isNotEmpty(list)) { + for (SpecialDeviceEntity device : list) { + if (device.getManagerId() == null) { + return new ReturnT<>("系统无该用户信息,无法推送特种设备过期提醒消息"); + } + // 查询用户 + R userRes = userClient.userInfoById(device.getManagerId()); + User user = userRes.getData(); + BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO(); + if (StringUtils.isNotEmpty(user.getDeptId())) { + Long id = Long.valueOf(user.getDeptId()); + businessMessageDTO.setDeptId(id); + businessMessageDTO.setDeptName(sysClient.getDeptName(id).getData()); + businessMessageDTO.setBusinessKey("特种设备到期"); + businessMessageDTO.setBusinessClassify("system"); + businessMessageDTO.setTaskId(device.getId()); + businessMessageDTO.setSubject("特种设备到期通知"); + businessMessageDTO.setContent("您所管理的特种设备" + device.getName() + "即将过期,请尽快进行检验。"); + businessMessageDTO.setUserIds(String.valueOf(device.getManagerId())); + businessMessageDTO.setCreateUser(device.getCreateUser()); + businessMessageDTO.setTenantId(CommonConstant.TENANT_ID); + } + R res = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + if (!res.isSuccess()) { + return ReturnT.FAIL; + } + } } - messageClient.sendAppAndWsMsgByUsers(businessMessageDTO); + return ReturnT.SUCCESS; } + } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java index 1db48cd..0b5b71f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarService.java @@ -30,19 +30,19 @@ public interface ICarService extends IService { /** * 根据参保时间查询车辆列表 - * @param today 当天 - * @param yesterday 昨天 + * @param startTime 开始时间 + * @param endTime 结束时间 * @return 车辆列表数据 */ - List getCarListByInsuranceTime(String today, String yesterday); + List getCarListByInsuranceTime(String startTime, String endTime); /** * 根据维保时间查询车辆列表 - * @param today 当天 - * @param yesterday 昨天 + * @param startTime 开始时间 + * @param endTime 结束时间 * @return 车辆列表数据 */ - List getCarListByMaintenanceTime(String today, String yesterday); + List getCarListByMaintenanceTime(String startTime, String endTime); /** * 新增车辆 @@ -75,11 +75,11 @@ public interface ICarService extends IService { /** * 根据年检时间查询车辆列表 - * @param today 当天 - * @param yesterday 昨天 + * @param startTime 开始时间 + * @param endTime 结束时间 * @return 车辆列表数据 */ - List getCarListByAnnualInspectionTime(String today, String yesterday); + List getCarListByAnnualInspectionTime(String startTime, String endTime); /** * 根据车牌查询车辆 diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index 88a67ed..a46457a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -139,10 +139,10 @@ public class CarServiceImpl extends ServiceImpl implements * 根据参保时间查询车辆列表 */ @Override - public List getCarListByInsuranceTime(String today, String yesterday) { + public List getCarListByInsuranceTime(String startTime, String endTime) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().lt(CarEntity::getInsurancePayNextTime, today) - .ge(CarEntity::getInsurancePayNextTime, yesterday); + queryWrapper.lambda().lt(CarEntity::getInsurancePayNextTime, endTime) + .ge(CarEntity::getInsurancePayNextTime, startTime); return this.list(queryWrapper); } @@ -150,10 +150,10 @@ public class CarServiceImpl extends ServiceImpl implements * 根据维保时间查询车辆列表 */ @Override - public List getCarListByMaintenanceTime(String today, String yesterday) { + public List getCarListByMaintenanceTime(String startTime, String endTime) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().lt(CarEntity::getMaintenanceNextTime, today) - .ge(CarEntity::getMaintenanceNextTime, yesterday); + queryWrapper.lambda().lt(CarEntity::getMaintenanceNextTime, endTime) + .ge(CarEntity::getMaintenanceNextTime, startTime); return this.list(queryWrapper); } @@ -274,10 +274,10 @@ public class CarServiceImpl extends ServiceImpl implements * 根据年检时间查询车辆列表 */ @Override - public List getCarListByAnnualInspectionTime(String today, String yesterday) { + public List getCarListByAnnualInspectionTime(String startTime, String endTime) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().lt(CarEntity::getNextAnnualInspectionTime, today) - .ge(CarEntity::getNextAnnualInspectionTime, yesterday); + queryWrapper.lambda().lt(CarEntity::getNextAnnualInspectionTime, endTime) + .ge(CarEntity::getNextAnnualInspectionTime, startTime); return this.list(queryWrapper); } From 42332e9882eca77c11738c5374065cbd66e0f4d8 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 3 Apr 2024 18:05:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/alarm/monitor/listener/AlarmListener.java | 2 +- .../hzims/alarm/source/service/impl/MessageServiceImpl.java | 4 ++-- .../hzims/message/service/impl/WxMessageServiceImpl.java | 13 ++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index bb125ac..cff87ff 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -46,7 +46,7 @@ public class AlarmListener implements IQueueConsume { // 步骤4.微信公众号发送 if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ - //messageService.weChatMessage(alarm); + messageService.weChatMessage(alarm); } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 8ef2624..3415705 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -148,7 +148,7 @@ public class MessageServiceImpl implements MessageService { } WxMessageDTO message = new WxMessageDTO(); // 模板Id - message.setTemplateId("hIgINCsjpG-gyCKh8wzwBWjR-hkbjkNLFTXQEsnR_Z8"); + message.setTemplateId("Ce2YAZtX0UyoNrAag6CANtC8XQeLuil7domvJrUivhM"); // 微信消息跳转地址 message.setSkipUrl("http://baidu.com"); // 机构Id @@ -164,7 +164,7 @@ public class MessageServiceImpl implements MessageService { map.put("thing18",entity.getStationName()); map.put("thing5",Optional.ofNullable(entity.getDeviceCode()).orElse("未知设备")); map.put("thing11",entity.getAlarmContext()); - map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmType())); + map.put("thing14", DictCache.getValue("alarm_source", entity.getAlarmSource())); map.put("time2",entity.getAlarmTime()); message.setMap(map); // 消息内容 diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java index aea5845..cb04c86 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/WxMessageServiceImpl.java @@ -86,9 +86,20 @@ public class WxMessageServiceImpl implements IMessageService { PushTemplate template = new PushTemplate(); template.setTemplateId(message.getTemplateId()); template.setSkipUrl(message.getSkipUrl()); - template.setMap(message.getMap()); + Map map = message.getMap(); + map.replaceAll((key,value)->getTruncateString(value.toString(),27)); + template.setMap(map); template.setUserIds(Arrays.stream(message.getUserIds().split(",")).collect(Collectors.toList())); + template.setTenantId("200000"); R result = wxPushClient.sendPushTemplateByUserId(template); return result.isSuccess(); } + + private String getTruncateString(String ruleDefName, int maxSize) { + if (ruleDefName.length()<= maxSize){ + return ruleDefName; + }else { + return ruleDefName.substring(0, maxSize - 3) + "..."; + } + } }