Commit 8d99ed85 authored by 赵啸非's avatar 赵啸非

添加下发日志

parent a5cd203a
......@@ -11,7 +11,6 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.thread.DeviceDownMsgThread;
import com.mortals.xhx.thread.DeviceUpdateComsumerThread;
import com.mortals.xhx.thread.SendThirdPartyThread;
import lombok.extern.slf4j.Slf4j;
......@@ -51,8 +50,6 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic
private DeviceUpdateComsumerThread deviceUpdateComsumerThread;
@Autowired
private SendThirdPartyThread sendThirdPartyThread;
@Autowired
private DeviceDownMsgThread deviceDownMsgThread;
@Value("${deviceUpdateComsumerIp:}")
public String deviceUpdateComsumerIp;
......
......@@ -81,6 +81,9 @@ public class DeviceDownMsgService implements IApplicationStartedService {
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), deviceMsgReq.getData(), header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(), JSON.toJSONString(queueMsg));
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
......@@ -118,7 +121,6 @@ public class DeviceDownMsgService implements IApplicationStartedService {
ThreadPool.getInstance().execute(sendThread);
// sendThread.start();
}
@Override
......
......@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BizLogPdu;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.ErrorLogPdu;
import com.mortals.framework.model.OrderCol;
......@@ -742,6 +743,36 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
correlationData.setId(deviceEntity.getDeviceCode());
log.info("send rabbitmq msg:{}", item.getDeviceCode());
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(), JSON.toJSONString(queueMsg), correlationData);
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType());
deviceLogEntity.setContent(item.getData());
deviceLogEntity.setLogType(LogTypeEnum.下发服务.getValue());
deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date());
deviceLogService.save(deviceLogEntity, null);
//保存业务消息为离线
BizLogPdu bizLogPdu = new BizLogPdu();
bizLogPdu.initAttrValue();
//保存为产品名称
bizLogPdu.setAppName(deviceEntity.getProductCode());
bizLogPdu.setTraceID(IdUtil.objectId());
bizLogPdu.setUserCode("system");
bizLogPdu.setDeviceCode(deviceEntity.getDeviceCode());
bizLogPdu.setEventTopic(item.getMessageType());
bizLogPdu.setEventTopicName(LogTypeEnum.下发服务.name());
bizLogPdu.setMsg(item.getData());
bizLogPdu.setLogLevel("INFO");
bizLogPdu.setLogTime(new Date());
messageProducer.syncBizSend(bizLogPdu);
} else {
log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
}
......
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