Commit d8e3734b authored by 赵啸非's avatar 赵啸非

修改设备通知刷新消息

parent 75d0c78b
......@@ -881,7 +881,7 @@ public class DeviceApiController {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
//String temp = domain + "/" + download;
productVersionInfo.setDownloadUrl(UrlBuilder.of(domain).addPath(download).toString());
productVersionInfo.setDownloadUrl(UrlBuilder.of(domain).addPath(download).build());
//productVersionInfo.setDownloadUrl(temp);
log.info("downurl:" + productVersionInfo.getDownloadUrl());
}
......
......@@ -111,7 +111,7 @@ public final class Constant {
/**
* 消息类型(通知更新)
*/
public static final String MESSAGETYPE_NOTIFY_REFRESH = "NOTIFY_REFRESH";
public static final String MESSAGETYPE_NOTIFY_REFRESH = "sitechange";
/**
* 消息类型(upgread)
......
package com.mortals.xhx.module.product.service.impl;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductVersionQuery;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.system.message.impl.MessageProducer;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.product.dao.ProductVersionDao;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.module.product.service.ProductVersionService;
import com.mortals.xhx.queue.DefaultTbQueueMsg;
import com.mortals.xhx.queue.TbQueueMsg;
import com.mortals.xhx.queue.TbQueueMsgHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import static com.mortals.xhx.common.key.Constant.MESSAGETYPE_UPGREAD;
/**
* ProductVersionService
......@@ -27,6 +42,10 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
@Autowired
private ProductService productService;
@Autowired
private DeviceService deviceService;
@Autowired
private MessageProducer messageProducer;
@Override
......@@ -39,4 +58,31 @@ public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVe
}
}
}
@Override
protected void saveAfter(ProductVersionEntity entity, Context context) throws AppException {
//推送消息
if (!ObjectUtils.isEmpty(entity.getProductId())) {
ProductEntity productEntity = productService.get(entity.getProductId(), context);
if (!ObjectUtils.isEmpty(productEntity)) {
List<DeviceEntity> deviceEntities = deviceService.find(new DeviceQuery().productId(entity.getProductId()));
for (DeviceEntity deviceEntity : deviceEntities) {
TbQueueMsgHeaders header = new DefaultTbQueueMsgHeaders();
header.put(MessageHeader.MESSAGETYPE, MESSAGETYPE_UPGREAD);
header.put(MessageHeader.DEVICECODE, deviceEntity.getDeviceCode());
header.put(MessageHeader.TIMESTAMP, DateUtils.getCurrStrDateTime());
TbQueueMsg queueMsg = new DefaultTbQueueMsg(IdUtil.fastUUID(), "==", header);
messageProducer.sendMsg(QueueKey.DEFAULT_EXCHANGE, Constant.DOWN_TOPIC + deviceEntity.getDeviceCode(), JSON.toJSONString(queueMsg));
}
}
}
super.saveAfter(entity, context);
}
}
\ No newline at end of file
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