Commit 9afe7521 authored by 赵啸非's avatar 赵啸非

修改消息组件

parent 1c150dec
...@@ -18,8 +18,10 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders; ...@@ -18,8 +18,10 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader; import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.module.firm.model.FirmQuery; import com.mortals.xhx.module.firm.model.FirmQuery;
import com.mortals.xhx.module.firm.service.FirmService; import com.mortals.xhx.module.firm.service.FirmService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.model.PlatformQuery; import com.mortals.xhx.module.platform.model.PlatformQuery;
import com.mortals.xhx.module.platform.service.PlatformService; import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductQuery; import com.mortals.xhx.module.product.model.ProductQuery;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.queue.TbQueueMsgHeaders; import com.mortals.xhx.queue.TbQueueMsgHeaders;
...@@ -123,19 +125,34 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic ...@@ -123,19 +125,34 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
DeviceEntity deviceEntity = this.service.get(deviceId, getContext()); DeviceEntity deviceEntity = this.service.get(deviceId, getContext());
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
//将上报信息转发到mq中 //将上报信息转发到mq中
TopicPartitionInfo info = TopicPartitionInfo.builder().topic(Constant.DOWN_TOPIC + deviceEntity.getDeviceMac()).build(); PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
if (ObjectUtils.isEmpty(platformEntity)) {
throw new AppException("当前设备未配置所属系统平台,请在后台配置后再激活!");
}
// authInfo.setHost(platformEntity.getPlatformSn());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (ObjectUtils.isEmpty(productEntity)) {
throw new AppException("当前设备未配置所属产品,请在后台配置后再激活!");
}
String exchangeName = platformEntity.getPlatformSn() + Constant.EXCHANGE_SPLIT + productEntity.getProductCode();
TopicPartitionInfo info = TopicPartitionInfo.builder().exchangeName(exchangeName).topic(Constant.DOWN_TOPIC + deviceEntity.getDeviceMac()).build();
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders(); TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, Constant.MESSAGETYPE_UPGREAD); header.put(MessageHeader.MESSAGETYPE, Constant.MESSAGETYPE_UPGREAD);
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
obj.put("content", content); obj.put("content", content);
ApiResp<String> sendDeviceMessageResp = this.service.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(obj), null);
ApiResp<String> sendDeviceMessageResp =this.service.sendDeviceMessage(deviceEntity, info, header, JSON.toJSONString(obj), null);
log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp))); log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
if (ApiRespCodeEnum.SUCCESS.getValue() != sendDeviceMessageResp.getCode()) { if (ApiRespCodeEnum.SUCCESS.getValue() != sendDeviceMessageResp.getCode()) {
throw new AppException("下发消息失败!"); throw new AppException("下发消息失败!");
} }
} else { // Thread.sleep(50);
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
}else {
throw new AppException("设备不存在!deviceId:" + deviceId); throw new AppException("设备不存在!deviceId:" + deviceId);
} }
this.init(request, response, null, model, getContext()); this.init(request, response, null, model, getContext());
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, model); jsonObject.put(KEY_RESULT_DATA, model);
......
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