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

分组更新设备

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