Commit 6cd87910 authored by 赵啸非's avatar 赵啸非

添加巴中经开区windows shell

parent 31e54e96
......@@ -4,6 +4,7 @@ import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.busiz.req.DeviceMsgReq;
import com.mortals.xhx.common.code.LogTypeEnum;
......@@ -50,6 +51,10 @@ public class DeviceDownMsgService implements IApplicationStartedService {
public void start() {
log.info("DeviceDownMsgService start");
ThreadPool.getInstance().init(10);
Thread sendThread = new Thread(new Runnable() {
@Override
public void run() {
......@@ -111,7 +116,9 @@ public class DeviceDownMsgService implements IApplicationStartedService {
}
});
sendThread.start();
ThreadPool.getInstance().execute(sendThread);
// sendThread.start();
}
@Override
......
......@@ -245,7 +245,7 @@ public class DeviceEntity extends DeviceVo {
this.deviceName = "";
this.deviceCode = "";
this.deviceMac = "";
this.siteId = null;
this.siteId = -1L;
this.siteCode = "";
this.siteName = "";
this.platformId = null;
......
......@@ -7,14 +7,14 @@ import com.mortals.framework.model.BizLogPdu;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.IMessageProduceService;
import com.mortals.xhx.common.code.LogTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.LogTypeEnum;
import com.mortals.xhx.module.device.dao.DeviceLogDao;
import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.service.DeviceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
......@@ -49,6 +49,7 @@ public class DeviceLogServiceImpl extends AbstractCRUDServiceImpl<DeviceLogDao,
@Override
protected void saveAfter(DeviceLogEntity entity, Context context) throws AppException {
log.debug("业务日志保存成功!");
BizLogPdu bizLogPdu = new BizLogPdu();
......
......@@ -222,8 +222,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + deviceCode, Constant.UPLOAD_TOPIC + deviceCode);
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceCode, Constant.DOWN_TOPIC + deviceCode);
//订阅上行队列
// container.addQueueNames(Constant.UPLOAD_TOPIC + deviceCode);
restartMessageListener(Constant.UPLOAD_TOPIC + deviceCode);
// container.addQueueNames(Constant.UPLOAD_TOPIC + deviceCode);
restartMessageListener(Constant.UPLOAD_TOPIC + deviceCode);
//新增设备通知第三方平台,先新增后激活
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ADD);
......@@ -370,8 +372,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//注册rabbmit相关队列与绑定
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.UPLOAD_TOPIC + entity.getDeviceCode(), Constant.UPLOAD_TOPIC + entity.getDeviceCode());
messageProducer.queueAddAndBinds(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + entity.getDeviceCode(), Constant.DOWN_TOPIC + entity.getDeviceCode());
restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
//监听上行队列
restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
//监听上行队列
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.UPDATE);
}
}
......@@ -609,7 +613,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setPlatformName(platformEntity.getPlatformName());
}
}
}else if (!ObjectUtils.isEmpty(entity.getProductName())) {
} else if (!ObjectUtils.isEmpty(entity.getProductName())) {
ProductEntity productEntity = productService.selectOne(new ProductQuery().productName(entity.getProductName()));
if (!ObjectUtils.isEmpty(productEntity)) {
entity.setProductId(productEntity.getId());
......@@ -638,7 +642,9 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if (!ObjectUtils.isEmpty(entity.getDeviceStatus()) && entity.getDeviceStatus() > DeviceStatusEnum.未激活.getValue()) {
//激活设备,添加队列订阅
//container.addQueueNames(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
restartMessageListener(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
PlatformEntity platformEntity = platformService.getCache(entity.getPlatformId().toString());
ProductEntity productEntity = productService.getCache(entity.getProductId().toString());
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ADD);
......@@ -740,18 +746,24 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
/**
* 重启对消息队列的监听
*
* @param queueName
* @return
*/
public boolean restartMessageListener(String queueName) {
String key = StringUtils.trim(queueName);
container.addQueueNames(key);
try {
String key = StringUtils.trim(queueName);
container.addQueueNames(key);
if(container.isRunning()){
container.stop();
if (container.isRunning()) {
container.stop();
container.start();
}
container.start();
} catch (AppException e) {
log.error("重启消息监听失败", e);
return false;
}
container.start();
return true;
}
......
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