Commit f7eb0391 authored by 赵啸非's avatar 赵啸非

添加设备上线和下线的业务日志记录

parent ea362255
package com.mortals.xhx.base.framework.listener; package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.BizLogPdu;
import com.mortals.framework.service.IMessageProduceService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
...@@ -60,6 +63,8 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -60,6 +63,8 @@ public class CustomerKeyExpirationListener implements MessageListener {
private AlarmSmsSendService alarmSmsSendService; private AlarmSmsSendService alarmSmsSendService;
@Autowired @Autowired
private ISmsSetFeign smsSetFeign; private ISmsSetFeign smsSetFeign;
@Autowired
private IMessageProduceService messageProducer;
@Override @Override
public void onMessage(Message message, byte[] bytes) { public void onMessage(Message message, byte[] bytes) {
...@@ -87,6 +92,21 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -87,6 +92,21 @@ public class CustomerKeyExpirationListener implements MessageListener {
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//通知第三方平台 //通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE);
//保存业务消息为离线
BizLogPdu bizLogPdu = new BizLogPdu();
bizLogPdu.initAttrValue();
//保存为产品名称
bizLogPdu.setAppName(productEntity.getProductCode());
bizLogPdu.setTraceID(IdUtil.objectId());
bizLogPdu.setUserCode("system");
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("online");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg(Base64.encode("设备下线"));
bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu);
} }
//保存离线告警消息 //保存离线告警消息
......
package com.mortals.xhx.base.framework.listener; package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
...@@ -105,7 +106,7 @@ public class DirectDynamicListener implements MessageListener { ...@@ -105,7 +106,7 @@ public class DirectDynamicListener implements MessageListener {
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode()); bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("online"); bizLogPdu.setEventTopic("online");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name()); bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg("设备上线"); bizLogPdu.setMsg(Base64.encode("设备上线"));
bizLogPdu.setLogLevel("INFO"); bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date()); bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu); messageProducer.syncBizSend(bizLogPdu);
......
package com.mortals.xhx.daemon.applicationservice; package com.mortals.xhx.daemon.applicationservice;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
...@@ -190,7 +191,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -190,7 +191,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode()); bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("online"); bizLogPdu.setEventTopic("online");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name()); bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg("设备上线"); bizLogPdu.setMsg(Base64.encode("设备上线"));
bizLogPdu.setLogLevel("INFO"); bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date()); bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu); messageProducer.syncBizSend(bizLogPdu);
......
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BizLogPdu; import com.mortals.framework.model.BizLogPdu;
...@@ -97,7 +98,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService { ...@@ -97,7 +98,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode()); bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("offline"); bizLogPdu.setEventTopic("offline");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name()); bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg("设备离线"); bizLogPdu.setMsg(Base64.encode("设备离线"));
bizLogPdu.setLogLevel("INFO"); bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date()); bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu); messageProducer.syncBizSend(bizLogPdu);
......
...@@ -52,7 +52,7 @@ public class DeviceLogController extends BaseCRUDJsonBodyMappingController<Devic ...@@ -52,7 +52,7 @@ public class DeviceLogController extends BaseCRUDJsonBodyMappingController<Devic
} }
public static void main(String[] args) { public static void main(String[] args) {
String en="eyJ3YWl0Y291bnQiOiIzIiwiZm9yd2FpdGNvdW50IjoiMCJ9"; String en="好的";
System.out.println(Base64.decodeStr(en)); System.out.println(Base64.decodeStr(en));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment