|
@@ -68,6 +68,9 @@ public class MqttSubHandle {
|
|
|
@Autowired
|
|
|
private DevShareService devShareService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AlarmPlanService alarmPlanService;
|
|
|
+
|
|
|
/**
|
|
|
* MQTT消息统一入口处理方法
|
|
|
*
|
|
@@ -701,8 +704,16 @@ public class MqttSubHandle {
|
|
|
// 1.1 判断 消息类型是否符合 起夜异常 or 异常滞留
|
|
|
if (AlarmEventType.isTargetEvent(eventType)) {
|
|
|
String clientId = obj.getString("dev_id");
|
|
|
+ String uuid = obj.getString("plan_uuid");
|
|
|
+
|
|
|
+ // 1.2 判断告警计划是否开启服务号推送
|
|
|
+ AlarmPlan alarmPlan = alarmPlanService.findByUuid(uuid);
|
|
|
+ if (alarmPlan.getLinkagePushWechatService() == 0) {
|
|
|
+ log.info("服务号通知发送失败,当前设备告警计划未开启服务号推送: clientId={}, uuid={}", clientId, uuid);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- // 1.2 查找设备信息,获取主绑人的userId
|
|
|
+ // 1.3 查找设备信息,获取主绑人的userId
|
|
|
DevInfo dev = devInfoService.queryByClientId(clientId);
|
|
|
|
|
|
if (dev == null) {
|
|
@@ -715,27 +726,28 @@ public class MqttSubHandle {
|
|
|
String devId = dev.getClientId();
|
|
|
|
|
|
|
|
|
- // 1.3 如果userId为空,则没有绑定人
|
|
|
+ // 1.4 如果userId为空,则没有绑定人
|
|
|
if (userId == null) {
|
|
|
log.info("服务号通知发送失败,设备未绑定用户: clientId={}", clientId);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 1.4 查询主绑人信息
|
|
|
+ // 1.5 查询主绑人信息
|
|
|
UserInfo user = userService.queryById(userId);
|
|
|
|
|
|
- // 1.5 获取用户微信服务号OpenId
|
|
|
+ // 1.6 获取用户微信服务号OpenId
|
|
|
WxRelation wxRelations = wxRelationService.queryOneByUnionId(user.getUnionId());
|
|
|
|
|
|
if (wxRelations == null) {
|
|
|
log.info("服务号通知发送失败,用户未绑定微信服务号: userId={}", userId);
|
|
|
+ return;
|
|
|
}
|
|
|
String fwhOpenId = wxRelations.getFwhOpenId();
|
|
|
|
|
|
log.info("mqttutil--当前useropenid=" + user.getOpenid() + ", fwhopenId=" + fwhOpenId);
|
|
|
log.info("发送微信公众号信息:devName=" + devName.toString() + ", phoneNo=" + user.getPhone() + "fwhOpenId=" + fwhOpenId);
|
|
|
|
|
|
- // 1.6 发送微信公告号消息
|
|
|
+ // 1.7 发送微信公告号消息
|
|
|
wxOfficeAccountClient.sendMsg(devId, devName.toString(), user.getPhone(), fwhOpenId, "设备检测到异常滞留,请前往小程序查看详细信息");
|
|
|
log.info("发送微信公众号消息发完了");
|
|
|
return;
|