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

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

parent ea362255
package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
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.key.RedisKey;
import com.mortals.xhx.common.pdu.RespData;
......@@ -60,6 +63,8 @@ public class CustomerKeyExpirationListener implements MessageListener {
private AlarmSmsSendService alarmSmsSendService;
@Autowired
private ISmsSetFeign smsSetFeign;
@Autowired
private IMessageProduceService messageProducer;
@Override
public void onMessage(Message message, byte[] bytes) {
......@@ -87,6 +92,21 @@ public class CustomerKeyExpirationListener implements MessageListener {
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//通知第三方平台
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;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
......@@ -105,7 +106,7 @@ public class DirectDynamicListener implements MessageListener {
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("online");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg("设备上线");
bizLogPdu.setMsg(Base64.encode("设备上线"));
bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu);
......
package com.mortals.xhx.daemon.applicationservice;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
......@@ -190,7 +191,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("online");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg("设备上线");
bizLogPdu.setMsg(Base64.encode("设备上线"));
bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu);
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BizLogPdu;
......@@ -97,7 +98,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic("offline");
bizLogPdu.setEventTopicName(LogTypeEnum.上报事件.name());
bizLogPdu.setMsg("设备离线");
bizLogPdu.setMsg(Base64.encode("设备离线"));
bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu);
......
......@@ -52,7 +52,7 @@ public class DeviceLogController extends BaseCRUDJsonBodyMappingController<Devic
}
public static void main(String[] args) {
String en="eyJ3YWl0Y291bnQiOiIzIiwiZm9yd2FpdGNvdW50IjoiMCJ9";
String 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