Browse Source

设备类型改category判定

jwy_category
review512jwy@163.com 4 weeks ago
parent
commit
b27f44ceb4
  1. 2
      src/main/java/com/techsor/datacenter/sender/dao/DeviceDao.java
  2. 2
      src/main/java/com/techsor/datacenter/sender/dto/DeviceInfoVO.java
  3. 2
      src/main/java/com/techsor/datacenter/sender/entitiy/DynamodbEntity.java
  4. 62
      src/main/java/com/techsor/datacenter/sender/service/impl/DataProcessServiceImpl.java
  5. 11
      src/main/resources/application-dev.properties
  6. 11
      src/main/resources/application-prd.properties

2
src/main/java/com/techsor/datacenter/sender/dao/DeviceDao.java

@ -248,6 +248,7 @@ public class DeviceDao {
+ " bbuilding.retain_alert retainAlert,\r\n" + " bbuilding.retain_alert retainAlert,\r\n"
+ " basset.equipment_id assetId,\r\n" + " basset.equipment_id assetId,\r\n"
+ " basset.name assetName,\r\n" + " basset.name assetName,\r\n"
+ " ty.device_category_id categoryId,\r\n"
+ " dct.category_name_en category\r\n" + " dct.category_name_en category\r\n"
+ "FROM\r\n" + "FROM\r\n"
+ " device_info dinfo\r\n" + " device_info dinfo\r\n"
@ -273,6 +274,7 @@ public class DeviceDao {
item.setCategory(rs.getString("category")); item.setCategory(rs.getString("category"));
item.setMonitoringPointName(rs.getString("monitoringPointName")); item.setMonitoringPointName(rs.getString("monitoringPointName"));
item.setRetainAlert(rs.getInt("retainAlert")); item.setRetainAlert(rs.getInt("retainAlert"));
item.setCategoryId(rs.getLong("categoryId"));
return item; return item;
}); });
return dataList; return dataList;

2
src/main/java/com/techsor/datacenter/sender/dto/DeviceInfoVO.java

@ -51,4 +51,6 @@ public class DeviceInfoVO implements Serializable {
private Integer retainAlert; private Integer retainAlert;
private Long categoryId;
} }

2
src/main/java/com/techsor/datacenter/sender/entitiy/DynamodbEntity.java

@ -137,4 +137,6 @@ public class DynamodbEntity implements Serializable {
private Integer typeId; private Integer typeId;
private Long categoryId;
} }

62
src/main/java/com/techsor/datacenter/sender/service/impl/DataProcessServiceImpl.java

@ -94,30 +94,49 @@ public class DataProcessServiceImpl implements IDataProcessService {
// @Qualifier("sysMqttClient") // @Qualifier("sysMqttClient")
// private MqttClient sysMqttClient; // private MqttClient sysMqttClient;
@Value("${category.alarm.deviceTypeIds}") // @Value("${category.alarm.deviceTypeIds}")
private List<Integer> alarmTypeIds; // private List<Integer> alarmTypeIds;
//
// @Value("${category.measure.deviceTypeIds}")
// private List<Integer> measureTypeIds;
//
// @Value("${category.accumulate.deviceTypeIds}")
// private List<Integer> accumulateTypeIds;
//
// @Value("${category.status.deviceTypeIds}")
// private List<Integer> statusTypeIds;
//
@Value("${category.temperature-humidity.deviceTypeIds}")
private List<Integer> temperatureHumidityTypeIds;
//
// // 所有设备类型ID集合
// public static final List<Integer> ALL_DEVICE_TYPE_IDS = new ArrayList<>();
@Value("${category.measure.deviceTypeIds}") @Value("${category.id.alarm}")
private List<Integer> measureTypeIds; private List<Long> categoryIdAlarm;
@Value("${category.accumulate.deviceTypeIds}") @Value("${category.id.measure}")
private List<Integer> accumulateTypeIds; private List<Long> categoryIdMeasure;
@Value("${category.status.deviceTypeIds}") @Value("${category.id.accumulate}")
private List<Integer> statusTypeIds; private List<Long> categoryIdAccumulate;
@Value("${category.temperature-humidity.deviceTypeIds}") @Value("${category.id.status}")
private List<Integer> temperatureHumidityTypeIds; private List<Long> categoryIdStatus;
// 所有设备类型ID集合 // 所有设备类型ID集合
public static final List<Integer> ALL_DEVICE_TYPE_IDS = new ArrayList<>(); public static final List<Long> ALL_CATEGORY_ID = new ArrayList<>();
@PostConstruct @PostConstruct
public void init() { public void init() {
ALL_DEVICE_TYPE_IDS.addAll(alarmTypeIds); // ALL_DEVICE_TYPE_IDS.addAll(alarmTypeIds);
ALL_DEVICE_TYPE_IDS.addAll(measureTypeIds); // ALL_DEVICE_TYPE_IDS.addAll(measureTypeIds);
ALL_DEVICE_TYPE_IDS.addAll(accumulateTypeIds); // ALL_DEVICE_TYPE_IDS.addAll(accumulateTypeIds);
ALL_DEVICE_TYPE_IDS.addAll(statusTypeIds); // ALL_DEVICE_TYPE_IDS.addAll(statusTypeIds);
ALL_CATEGORY_ID.addAll(categoryIdAlarm);
ALL_CATEGORY_ID.addAll(categoryIdMeasure);
ALL_CATEGORY_ID.addAll(categoryIdAccumulate);
ALL_CATEGORY_ID.addAll(categoryIdStatus);
} }
private static final String REDIS_DASHBOARD_DEVICE_STATUS_KEY = "dashboard_device_status"; private static final String REDIS_DASHBOARD_DEVICE_STATUS_KEY = "dashboard_device_status";
@ -619,6 +638,9 @@ public class DataProcessServiceImpl implements IDataProcessService {
if (deviceInfoVO.getRetainAlert()!=null){ if (deviceInfoVO.getRetainAlert()!=null){
baseTransDataEntity.setRetainAlert(deviceInfoVO.getRetainAlert()); baseTransDataEntity.setRetainAlert(deviceInfoVO.getRetainAlert());
} }
if (deviceInfoVO.getCategoryId()!=null){
baseTransDataEntity.setCategoryId(deviceInfoVO.getCategoryId());
}
} }
baseTransDataEntity.setHashId(UUID.randomUUID()); baseTransDataEntity.setHashId(UUID.randomUUID());
@ -690,14 +712,16 @@ public class DataProcessServiceImpl implements IDataProcessService {
} }
} else { } else {
String uploadValue = uploadValueList.get(0);//这里只取第一个元素 String uploadValue = uploadValueList.get(0);//这里只取第一个元素
if (accumulateTypeIds.contains(baseTransDataEntity.getTypeId())) { if (baseTransDataEntity.getDeviceId().endsWith("_85")){
if (categoryIdAccumulate.contains(baseTransDataEntity.getCategoryId())) {
storageAccumulate(DeviceAttrCode.COMMON, uploadValue, baseTransDataEntity); storageAccumulate(DeviceAttrCode.COMMON, uploadValue, baseTransDataEntity);
} }
if (measureTypeIds.contains(baseTransDataEntity.getTypeId())) { if (categoryIdMeasure.contains(baseTransDataEntity.getCategoryId())) {
storageMeasure(DeviceAttrCode.COMMON, uploadValue, baseTransDataEntity); storageMeasure(DeviceAttrCode.COMMON, uploadValue, baseTransDataEntity);
} }
} }
} }
}
private void storageMeasure(String attrCode, String uploadValue, DynamodbEntity baseTransDataEntity) throws Exception { private void storageMeasure(String attrCode, String uploadValue, DynamodbEntity baseTransDataEntity) throws Exception {
BigDecimal currentValue = new BigDecimal(uploadValue); BigDecimal currentValue = new BigDecimal(uploadValue);
@ -854,7 +878,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
private void handleDashboardAlert(DynamodbEntity baseTransDataEntity) { private void handleDashboardAlert(DynamodbEntity baseTransDataEntity) {
if (!ALL_DEVICE_TYPE_IDS.contains(baseTransDataEntity.getTypeId())) { if (!ALL_CATEGORY_ID.contains(baseTransDataEntity.getCategoryId())) {
return; return;
} }
@ -873,7 +897,7 @@ public class DataProcessServiceImpl implements IDataProcessService {
} }
//告警历史处理 //告警历史处理
if (alarmTypeIds.contains(baseTransDataEntity.getTypeId())) { if (categoryIdAlarm.contains(baseTransDataEntity.getCategoryId())) {
String status = baseTransDataEntity.getStatus(); String status = baseTransDataEntity.getStatus();
if (null == redisOldStatusObj) { if (null == redisOldStatusObj) {
if ("alert".equals(status)) { if ("alert".equals(status)) {

11
src/main/resources/application-dev.properties

@ -99,6 +99,17 @@ category.status.deviceTypeIds=86,113,123
# 温湿度设备类型ID # 温湿度设备类型ID
category.temperature-humidity.deviceTypeIds=888888 category.temperature-humidity.deviceTypeIds=888888
# 报警类设备类型ID
category.id.alarm=1001
# 计测类设备类型ID
category.id.measure=1003
# 累积类设备类型ID
category.id.accumulate=1002
# 状态类设备类型ID
category.id.status=1004
data.operation.batch-size=${dataOperationBatchSize:100} data.operation.batch-size=${dataOperationBatchSize:100}
sys.mqtt.endpoint=${sysMqttEndpoint:mqtt-stg.kr-sensor.net} sys.mqtt.endpoint=${sysMqttEndpoint:mqtt-stg.kr-sensor.net}

11
src/main/resources/application-prd.properties

@ -93,6 +93,17 @@ category.status.deviceTypeIds=86,113,123
# 温湿度设备类型ID # 温湿度设备类型ID
category.temperature-humidity.deviceTypeIds=888888 category.temperature-humidity.deviceTypeIds=888888
# 报警类设备类型ID
category.id.alarm=1001
# 计测类设备类型ID
category.id.measure=1003
# 累积类设备类型ID
category.id.accumulate=1002
# 状态类设备类型ID
category.id.status=1004
data.operation.batch-size=${dataOperationBatchSize:100} data.operation.batch-size=${dataOperationBatchSize:100}
sys.mqtt.endpoint=${sysMqttEndpoint:mqtt-stg.kr-sensor.net} sys.mqtt.endpoint=${sysMqttEndpoint:mqtt-stg.kr-sensor.net}

Loading…
Cancel
Save