Commit 47a3ca2c authored by xixinzhao's avatar xixinzhao

增加物联数据连续发送间隔多久存库

parent fad9a2b4
......@@ -240,6 +240,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private String authKeyEnable;
private static final String QRCODE_REDIS_KEY = "qrCodeRedisKey";
@Value("${send.data.to.center.time}")
private long sendDataToCenterTime;
@Value("${send.data.to.center.key}")
private String sendDataToCenterKey;
public static List<EquipmentSpecificAlarmLog> upAlarmLogStatus(String iotCode, String equipmentSpecificIndexKey,
String traceId, IEquipmentSpecificAlarmLogService equipmentSpecificAlarmLogService,
boolean flag, boolean batchConfirm, String confirmType) {
......@@ -412,6 +418,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next();
String key = entry.getKey();
Object value = entry.getValue();
boolean saveData = isSaveData(topicEntity.getIotCode(), key, value);
if (saveData) {
return;
}
iotDataVO.setKey(key);
iotDataVO.setValue(value);
if ("traceId".equalsIgnoreCase(key)) {
......@@ -518,6 +528,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpeIndex.setUUID(UUIDUtils.getUUID());
equipmentSpeIndex.setUnit(Objects.nonNull(equipmentIndex.getUnit()) ? equipmentIndex.getUnit() : equipmentIndex.getUnitName());
boolean saveData = isSaveData(equipmentSpeIndex.getIotCode(), equipmentSpeIndex.getEquipmentIndexKey(), value);
if (saveData) {
return;
}
IotDataVO iotDataVO = new IotDataVO();
iotDataVO.setKey(equipmentSpeIndex.getNameKey());
iotDataVO.setValue(value);
......@@ -825,6 +840,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpeIndex.setTimeStamp(sShanStationMessage.getTimestamp());
equipmentSpeIndex.setUUID(UUIDUtils.getUUID());
boolean saveData = isSaveData(equipmentSpeIndex.getIotCode(), equipmentSpeIndex.getEquipmentIndexKey(), value);
if (saveData) {
return;
}
IotDataVO iotDataVO = new IotDataVO();
iotDataVO.setKey(equipmentSpeIndex.getNameKey());
iotDataVO.setValue(value);
......@@ -1464,7 +1484,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//预警业务 泡沫罐 或 者管网压力
JSONObject config = this.getRiskTriggerConfig("FIRE_EQUIP_LEVEL");
if (Objects.isNull(config)) {
throw new RuntimeException("获取配置失败!");
log.info("获取配置失败!");
return false;
}
HashMap<String, String> extra = new HashMap<>();
extra.put("useSource", config.getString("useSource"));
......@@ -1544,7 +1565,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String warningObjectCode = bizOrgCode + "@" + indexKey;
JSONObject config = this.getRiskTriggerConfig("FIRE_WATER_CAPACITY");
if (Objects.isNull(config)) {
throw new RuntimeException("获取配置失败!");
log.info("获取配置失败!");
return;
}
HashMap<String, String> extra = new HashMap<>();
extra.put("useSource", config.getString("useSource"));
......@@ -1590,7 +1612,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private void doPressurePumInfo(Integer totalNum, EquipmentSpecificIndex equipmentSpecificIndex) {
JSONObject config = this.getRiskTriggerConfig("FIRE_EQUIP_PRESSURE");
if (Objects.isNull(config)) {
throw new RuntimeException("获取配置失败!");
log.info("获取配置失败!");
return;
}
HashMap<String, String> extra = new HashMap<>();
extra.put("useSource", config.getString("useSource"));
......@@ -1693,7 +1716,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
if ("pool".equals(map.get("resourceType").toString()) || "waterTank".equals(map.get("resourceType").toString())) {
JSONObject config = this.getRiskTriggerConfig("FIRE_WATER_LEVEL");
if (Objects.isNull(config)) {
throw new RuntimeException("获取配置失败!");
log.info("获取配置失败!");
return false;
}
HashMap<String, String> extra = new HashMap<>();
extra.put("useSource", config.getString("useSource"));
......@@ -3155,9 +3179,29 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private JSONObject getRiskTriggerConfig(String tableName) {
Map<String, Object> configMap = JSON.parseObject(redisUtils.getString(QRCODE_REDIS_KEY), Map.class);
if (!ObjectUtils.isEmpty(configMap)) {
String config = configMap.get(tableName + "0").toString();
return JSONObject.parseObject(config).getJSONObject("content").getJSONObject("extra");
if (!ObjectUtils.isEmpty(configMap.get(tableName + "0"))) {
String config = String.valueOf(configMap.get(tableName + "0"));
return JSONObject.parseObject(config).getJSONObject("content").getJSONObject("extra");
}
}
return null;
}
private boolean isSaveData(String iotCode, String key, Object value) {
// 设置连续几秒内数据不入库
if (!ObjectUtils.isEmpty(sendDataToCenterKey)) {
String[] split = sendDataToCenterKey.split(",");
boolean contains = Arrays.asList(split).contains(key);
if (contains) {
String redisKey = iotCode + "-" + key + "-DATA-FREQUENCY";
Object existRedis = redisUtils.get(redisKey);
if (!ObjectUtils.isEmpty(existRedis)) {
return true;
} else {
redisUtils.set(redisKey, value, sendDataToCenterTime);
}
}
}
return false;
}
}
......@@ -187,4 +187,7 @@ message.alarm.char=\u51FA\u73B0
update.car.qrCode=-
power.station.url=-
equip.patrol.cron=0 21 17 * * ?
\ No newline at end of file
equip.patrol.cron=0 21 17 * * ?
send.data.to.center.time=30
send.data.to.center.key=FHS_FirePoolDevice_WaterLevel,FHS_PipePressureDetector_PipePressure
\ 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