Commit 56af34af authored by 赵啸非's avatar 赵啸非

分组更新设备

parent 72793dc8
......@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.BizLogPdu;
import com.mortals.framework.model.ErrorLogPdu;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IMessageProduceService;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.RedisKey;
......@@ -66,10 +67,16 @@ public class CustomerKeyExpirationListener implements MessageListener {
private ISmsSetFeign smsSetFeign;
@Autowired
private IMessageProduceService messageProducer;
@Autowired
private ICacheService cacheService;
@Override
public void onMessage(Message message, byte[] bytes) {
String key = message.toString();
//解决分布式系统 重复获取广播消息
boolean setnx = cacheService.setnx(key, 1, 10);
if (setnx) {
String subStr = StrUtil.removePrefix(key, RedisKey.KEY_DEVICE_ONLINE_CACHE);
if (!subStr.equals(key)) {
DeviceEntity deviceEntity = deviceService.getExtCache(subStr);
......@@ -112,7 +119,7 @@ public class CustomerKeyExpirationListener implements MessageListener {
errorLogPdu.initAttrValue();
errorLogPdu.setTraceID(IdUtil.objectId());
errorLogPdu.setAppName(productEntity.getProductCode());
errorLogPdu.setMessage(deviceEntity.getDeviceName()+deviceEntity.getDeviceCode()+"设备下线!");
errorLogPdu.setMessage(deviceEntity.getDeviceName() + deviceEntity.getDeviceCode() + "设备下线!");
errorLogPdu.setPlatform("webos");
errorLogPdu.setCulprit("");
errorLogPdu.setTags("");
......@@ -121,7 +128,7 @@ public class CustomerKeyExpirationListener implements MessageListener {
errorLogPdu.setReleaseVersion("");
errorLogPdu.setFingerprint(LogTypeEnum.上报事件.name());
errorLogPdu.setThreadNo(Thread.currentThread().toString());
errorLogPdu.setErrorStack(Thread.currentThread()+deviceEntity.getDeviceName()+deviceEntity.getDeviceCode()+"设备下线!");
errorLogPdu.setErrorStack(Thread.currentThread() + deviceEntity.getDeviceName() + deviceEntity.getDeviceCode() + "设备下线!");
errorLogPdu.setContext("");
errorLogPdu.setExtra("");
errorLogPdu.setLogTime(new Date());
......@@ -151,7 +158,7 @@ public class CustomerKeyExpirationListener implements MessageListener {
if (!ObjectUtils.isEmpty(alarmConfigEntity)) {
/* if (alarmConfigEntity.getAlarmPusW1ay() == AlarmPusW1ayEnum.站内信息.getValue()) {
}*/
if(EnabledEnum.启用.getValue()==alarmConfigEntity.getEnabled()){
if (EnabledEnum.启用.getValue() == alarmConfigEntity.getEnabled()) {
alarmInfoEntity.setProductId(productEntity.getId());
alarmInfoEntity.setProductCode(productEntity.getProductCode());
alarmInfoEntity.setProductName(productEntity.getProductName());
......@@ -188,20 +195,17 @@ public class CustomerKeyExpirationListener implements MessageListener {
//推送站类
}
}
}
}
}
// deviceAlarmInfoService.save(alarmInfoEntity);
}
}
}
}
log.info("监听到key:" + key + "过期");
}
}
\ 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