Commit 155a9c6a authored by 彭松's avatar 彭松
parents 2fc8a6d2 777344ec
...@@ -147,6 +147,9 @@ ...@@ -147,6 +147,9 @@
<profiles.redis.username></profiles.redis.username> <profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password> <profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.database>6</profiles.redis.database> <profiles.redis.database>6</profiles.redis.database>
<profiles.redis.database>6</profiles.redis.database>
<profiles.rabbitmq.host>172.15.28.115</profiles.rabbitmq.host> <profiles.rabbitmq.host>172.15.28.115</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port> <profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username> <profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
......
...@@ -71,8 +71,17 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -71,8 +71,17 @@ public class CustomerKeyExpirationListener implements MessageListener {
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.在线.getValue()) { if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.在线.getValue()) {
deviceEntity.setOfflineTime(new Date()); deviceEntity.setOfflineTime(new Date());
deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue()); deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue());
deviceService.update(deviceEntity);
DeviceEntity entity = new DeviceEntity();
entity.setOnlineTime(new Date());
entity.setUpdateTime(new Date());
entity.setDeviceStatus(DeviceStatusEnum.离线.getValue());
DeviceEntity condition = new DeviceEntity();
condition.setId(deviceEntity.getId());
deviceService.getDeviceDao().update(entity, condition);
log.info("deviceCode:{},deviceName:{}==>离线", deviceEntity.getDeviceCode(), deviceEntity.getDeviceName());
// deviceService.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
ProductEntity productEntity = productService.get(deviceEntity.getProductId()); ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) { if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
......
...@@ -67,7 +67,7 @@ public class DirectDynamicListener implements MessageListener { ...@@ -67,7 +67,7 @@ public class DirectDynamicListener implements MessageListener {
String messageType = queueMsg.getHeaders().getData().get(MESSAGETYPE); String messageType = queueMsg.getHeaders().getData().get(MESSAGETYPE);
try { try {
if (ObjectUtils.isEmpty(deviceCode)) { if (ObjectUtils.isEmpty(deviceCode)) {
log.info("onMessage deviceCode is null,receive data:{},queue:{}", data,queue); log.info("onMessage deviceCode is null,receive data:{},queue:{}", data, queue);
return; return;
} }
...@@ -82,9 +82,7 @@ public class DirectDynamicListener implements MessageListener { ...@@ -82,9 +82,7 @@ public class DirectDynamicListener implements MessageListener {
entity.setDeviceStatus(DeviceStatusEnum.在线.getValue()); entity.setDeviceStatus(DeviceStatusEnum.在线.getValue());
DeviceEntity condition = new DeviceEntity(); DeviceEntity condition = new DeviceEntity();
condition.setId(deviceEntity.getId()); condition.setId(deviceEntity.getId());
int update = deviceService.getDeviceDao().update(entity, condition);
deviceService.getDeviceDao().update(entity, condition);
// deviceService.update(deviceEntity); // deviceService.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId()); PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
...@@ -93,6 +91,7 @@ public class DirectDynamicListener implements MessageListener { ...@@ -93,6 +91,7 @@ public class DirectDynamicListener implements MessageListener {
//新增设备通知第三方平台 //新增设备通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ONLINE);
} }
log.info("id:{},deviceCode:{} deviceStatus:{},updateRet:{}==>上线 ", entity.getId(), deviceEntity.getDeviceCode(), entity.getDeviceStatus(),update);
} }
if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType)) { if (!Constant.MESSAGETYPE_HEARTBEAT.equalsIgnoreCase(messageType)) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
......
package com.mortals.xhx.daemon.applicationservice; package com.mortals.xhx.daemon.applicationservice;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.springcloud.service.IApplicationStartedService; import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.xhx.base.framework.listener.DirectDynamicListener; import com.mortals.xhx.base.framework.listener.DirectDynamicListener;
import com.mortals.xhx.base.system.message.impl.MessageProducer; import com.mortals.xhx.base.system.message.impl.MessageProducer;
...@@ -12,14 +11,11 @@ import com.mortals.xhx.module.device.service.DeviceService; ...@@ -12,14 +11,11 @@ import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.service.PlatformService; import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer; import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.Collection;
/** /**
* 初始化设备消费者注册 * 初始化设备消费者注册
* *
...@@ -44,8 +40,6 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic ...@@ -44,8 +40,6 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic
private SendTaskThreadPool sendTaskThreadPool; private SendTaskThreadPool sendTaskThreadPool;
@Autowired @Autowired
private DirectDynamicListener directDynamicListener; private DirectDynamicListener directDynamicListener;
@Autowired
private RabbitTemplate rabbitTemplate;
@Override @Override
public void start() { public void start() {
...@@ -53,8 +47,6 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic ...@@ -53,8 +47,6 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic
sendTaskThreadPool.init(20); sendTaskThreadPool.init(20);
log.info("服务端消息队列初始化服务开始.."); log.info("服务端消息队列初始化服务开始..");
Collection<String> rabbitmqQueues = rabbitTemplate.expectedQueueNames();
log.info("queues:{}", JSON.toJSONString(rabbitmqQueues));
deviceService.find(new DeviceEntity()) deviceService.find(new DeviceEntity())
...@@ -71,6 +63,7 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic ...@@ -71,6 +63,7 @@ public class DeviceComsumersRegisterService implements IApplicationStartedServic
.stream() .stream()
.filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId()))) .filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId())))
.filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId()))) .filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId())))
.filter(f->!ObjectUtils.isEmpty(f.getDeviceCode()))
.map(item -> Constant.UPLOAD_TOPIC + item.getDeviceCode()) .map(item -> Constant.UPLOAD_TOPIC + item.getDeviceCode())
.toArray(String[]::new); .toArray(String[]::new);
......
...@@ -179,13 +179,13 @@ Content-Type: application/json ...@@ -179,13 +179,13 @@ Content-Type: application/json
[ [
{ {
"data": "{xxxx}", "data": "xxxx",
"deviceCode": "a102", "deviceCode": "a102",
"messageType": "aaaa", "messageType": "aaaa",
"timestamp": 1654656951795 "timestamp": 1654656951795
}, },
{ {
"data": "{bbbbbb}", "data": "bbbbbb",
"deviceCode": "a102", "deviceCode": "a102",
"messageType": "bbbb", "messageType": "bbbb",
"timestamp": 1654656951795 "timestamp": 1654656951795
......
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