Commit 96922b59 authored by 赵啸非's avatar 赵啸非

添加巴中经开区windows shell

parent 8c5caeb8
......@@ -46,7 +46,7 @@ public class RabbitMsgComsumerStartedService implements IApplicationStartedServi
.toArray(String[]::new);
simpleContainer.addQueueNames(queues);
simpleContainer.start();
simpleContainer.addQueueNames("123");
// simpleContainer.addQueueNames("123");
simpleContainer.setMessageListener(simpleDynamicListener);
}
......
......@@ -45,6 +45,7 @@ import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.queue.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.beans.BeanUtils;
......@@ -107,7 +108,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Autowired
private SiteService siteService;
public void refresh() {
log.info("开始初始化系统参数...");
try {
......@@ -222,7 +222,8 @@ 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);
// container.addQueueNames(Constant.UPLOAD_TOPIC + deviceCode);
restartMessageListener(Constant.UPLOAD_TOPIC + deviceCode);
//新增设备通知第三方平台,先新增后激活
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.ADD);
......@@ -369,7 +370,8 @@ 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());
//监听上行队列
sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.UPDATE);
}
}
......@@ -386,10 +388,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceReq.setDeviceInFloor(entity.getDeviceInFloor() == null ? 0 : entity.getDeviceInFloor());
//http://192.168.0.98:8090/inter/device/deviceIn
//判断是否是php,如果不是 则是java 则内部调用
try {
if ("smartOffice".equals(platformEntity.getPlatformSn())) {
deviceReq.setReceiveMethod(update.getValue());
//todo 调用智慧办公系统
......@@ -417,16 +416,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
log.info("fill resp ==>{}", JSON.toJSONString(fillRest));
} else {
cacheService.lpush(RedisKey.KEY_DEVICE_THIRDPARTY_QUEUE, deviceReq);
// log.info("lpush:{}",lpush);
// String phpInUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_IN_HTTP_URL, "http://172.15.28.116:8090");
// ApiResp<String> resp = messageService.sendThirdParty(UrlBuilder.of(phpInUrl).addPath(thirdPartyPath).build(), deviceReq);
// log.info("sendThirty resp ==>{}", JSON.toJSONString(resp));
//
// if (!ObjectUtils.isEmpty(resp) && resp.getCode() == YesNoEnum.YES.getValue()) {
// return Rest.ok("成功!");
// } else {
// return Rest.fail("发送失败");
// }
}
} catch (Exception e) {
log.error("feign调用异常!");
......@@ -648,7 +637,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if (!ObjectUtils.isEmpty(entity.getDeviceStatus()) && entity.getDeviceStatus() > DeviceStatusEnum.未激活.getValue()) {
//激活设备,添加队列订阅
container.addQueueNames(Constant.UPLOAD_TOPIC + entity.getDeviceCode());
//container.addQueueNames(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);
......@@ -737,40 +727,35 @@ 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());
deviceLogList.add(deviceLogEntity);*/
// deviceLogService.save(deviceLogEntity, null);
} else {
log.info("未找到设备,deviceCode:{}", item.getDeviceCode());
}
}
/* if (!ObjectUtils.isEmpty(deviceLogList)) {
List<List<DeviceLogEntity>> partitionlogs = ListUtil.partition(deviceLogList, 100);
for (List<DeviceLogEntity> deviceLogEntities : partitionlogs) {
deviceLogService.save(deviceLogEntities);
}
}*/
} catch (Exception e) {
log.error("异常:", e);
}
}
/**
* 重启对消息队列的监听
* @param queueName
* @return
*/
public boolean restartMessageListener(String queueName) {
String key = StringUtils.trim(queueName);
container.addQueueNames(key);
if(container.isRunning()){
container.stop();
container.start();
}
container.start();
return true;
}
public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal("104.22241");
BigDecimal add = bigDecimal.add(new BigDecimal("0.01"));
......
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