|
|
@ -108,6 +108,9 @@ public class DataProcessServiceImpl implements IDataProcessService { |
|
|
//
|
|
|
//
|
|
|
@Value("${category.temperature-humidity.deviceTypeIds}") |
|
|
@Value("${category.temperature-humidity.deviceTypeIds}") |
|
|
private List<Integer> temperatureHumidityTypeIds; |
|
|
private List<Integer> temperatureHumidityTypeIds; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${category.co2-temperature-humidity.deviceTypeIds}") |
|
|
|
|
|
private List<Integer> co2TemperatureHumidityTypeIds; |
|
|
//
|
|
|
//
|
|
|
// // 所有设备类型ID集合
|
|
|
// // 所有设备类型ID集合
|
|
|
// public static final List<Integer> ALL_DEVICE_TYPE_IDS = new ArrayList<>();
|
|
|
// public static final List<Integer> ALL_DEVICE_TYPE_IDS = new ArrayList<>();
|
|
|
@ -700,16 +703,17 @@ public class DataProcessServiceImpl implements IDataProcessService { |
|
|
if (CollectionUtil.isEmpty(uploadValueList)) { |
|
|
if (CollectionUtil.isEmpty(uploadValueList)) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (temperatureHumidityTypeIds.contains(baseTransDataEntity.getTypeId())) { |
|
|
if (co2TemperatureHumidityTypeIds.contains(baseTransDataEntity.getTypeId())) { |
|
|
for (int i = 0; i < uploadValueList.size(); i++) { |
|
|
// CO2、温度、湿度(顺序固定)
|
|
|
String uploadValue = uploadValueList.get(i); |
|
|
handleMultiMeasure(uploadValueList, baseTransDataEntity, |
|
|
//温湿度的rawdata,一定是温度在前,湿度在后
|
|
|
DeviceAttrCode.MEASURE_CO2, |
|
|
if (0 == i) { |
|
|
DeviceAttrCode.MEASURE_TEMPERATURE, |
|
|
storageMeasure(DeviceAttrCode.MEASURE_TEMPERATURE, uploadValue, baseTransDataEntity); |
|
|
DeviceAttrCode.MEASURE_HUMIDITY); |
|
|
} else if (1 == i) { |
|
|
} else if (temperatureHumidityTypeIds.contains(baseTransDataEntity.getTypeId())) { |
|
|
storageMeasure(DeviceAttrCode.MEASURE_HUMIDITY, uploadValue, baseTransDataEntity); |
|
|
// 温度、湿度
|
|
|
} |
|
|
handleMultiMeasure(uploadValueList, baseTransDataEntity, |
|
|
} |
|
|
DeviceAttrCode.MEASURE_TEMPERATURE, |
|
|
|
|
|
DeviceAttrCode.MEASURE_HUMIDITY); |
|
|
} else { |
|
|
} else { |
|
|
String uploadValue = uploadValueList.get(0);//这里只取第一个元素
|
|
|
String uploadValue = uploadValueList.get(0);//这里只取第一个元素
|
|
|
if (baseTransDataEntity.getDeviceId().endsWith("_85")){ |
|
|
if (baseTransDataEntity.getDeviceId().endsWith("_85")){ |
|
|
@ -723,6 +727,16 @@ public class DataProcessServiceImpl implements IDataProcessService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void handleMultiMeasure(List<String> uploadValueList, DynamodbEntity entity, String... attrCodes) throws Exception { |
|
|
|
|
|
if (uploadValueList == null || uploadValueList.isEmpty()) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
int size = Math.min(uploadValueList.size(), attrCodes.length); |
|
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
|
storageMeasure(attrCodes[i], uploadValueList.get(i), entity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
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); |
|
|
BigDecimal minValue = currentValue; |
|
|
BigDecimal minValue = currentValue; |
|
|
@ -733,8 +747,8 @@ public class DataProcessServiceImpl implements IDataProcessService { |
|
|
|
|
|
|
|
|
// 获取 Redis 数据
|
|
|
// 获取 Redis 数据
|
|
|
String currentDayKey = Constants.STATISTICS_MEASURE_LATEST_PREFIX + complexTime.getDateKey(); |
|
|
String currentDayKey = Constants.STATISTICS_MEASURE_LATEST_PREFIX + complexTime.getDateKey(); |
|
|
if (!DeviceAttrCode.COMMON.equalsIgnoreCase(attrCode)) { |
|
|
if (!DeviceAttrCode.COMMON.equalsIgnoreCase(attrCode)) {//兼容新数据
|
|
|
|
|
|
currentDayKey = Constants.STATISTICS_MEASURE_LATEST_PREFIX + attrCode + ":" + complexTime.getDateKey(); |
|
|
} |
|
|
} |
|
|
Object currentDayInfoObj = this.redisTemplate.opsForHash().get(currentDayKey, baseTransDataEntity.getDeviceId()); |
|
|
Object currentDayInfoObj = this.redisTemplate.opsForHash().get(currentDayKey, baseTransDataEntity.getDeviceId()); |
|
|
|
|
|
|
|
|
@ -781,6 +795,10 @@ public class DataProcessServiceImpl implements IDataProcessService { |
|
|
// 获取 Redis 数据
|
|
|
// 获取 Redis 数据
|
|
|
String currentDayKey = Constants.STATISTICS_ACCUMULATE_LATEST_PREFIX + complexTime.getDateKey(); |
|
|
String currentDayKey = Constants.STATISTICS_ACCUMULATE_LATEST_PREFIX + complexTime.getDateKey(); |
|
|
String lastDayKey = Constants.STATISTICS_ACCUMULATE_LATEST_PREFIX + complexTime.getPreviousDateKey(); |
|
|
String lastDayKey = Constants.STATISTICS_ACCUMULATE_LATEST_PREFIX + complexTime.getPreviousDateKey(); |
|
|
|
|
|
if (!DeviceAttrCode.COMMON.equalsIgnoreCase(attrCode)) {//兼容新数据
|
|
|
|
|
|
currentDayKey = Constants.STATISTICS_ACCUMULATE_LATEST_PREFIX + attrCode + ":" + complexTime.getDateKey(); |
|
|
|
|
|
lastDayKey = Constants.STATISTICS_ACCUMULATE_LATEST_PREFIX + attrCode + ":" + complexTime.getPreviousDateKey(); |
|
|
|
|
|
} |
|
|
Object currentDayInfoObj = this.redisTemplate.opsForHash().get(currentDayKey, baseTransDataEntity.getDeviceId()); |
|
|
Object currentDayInfoObj = this.redisTemplate.opsForHash().get(currentDayKey, baseTransDataEntity.getDeviceId()); |
|
|
Object lastDayInfoObj = this.redisTemplate.opsForHash().get(lastDayKey, baseTransDataEntity.getDeviceId()); |
|
|
Object lastDayInfoObj = this.redisTemplate.opsForHash().get(lastDayKey, baseTransDataEntity.getDeviceId()); |
|
|
|
|
|
|
|
|
@ -812,7 +830,7 @@ public class DataProcessServiceImpl implements IDataProcessService { |
|
|
lastMinuteValue = new BigDecimal(String.valueOf(currentDayInfo.getValue())); |
|
|
lastMinuteValue = new BigDecimal(String.valueOf(currentDayInfo.getValue())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (lastMinuteValue != null && currentValue.compareTo(lastMinuteValue) >= 0) { |
|
|
if (lastMinuteValue != null) { |
|
|
incrementMinute = currentValue.subtract(lastMinuteValue).doubleValue(); |
|
|
incrementMinute = currentValue.subtract(lastMinuteValue).doubleValue(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|