|
@ -457,8 +457,10 @@ public class DcDeviceController extends BaseController { |
|
|
|
|
|
|
|
|
//转换为 double 类型,去除单位
|
|
|
//转换为 double 类型,去除单位
|
|
|
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); |
|
|
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); |
|
|
double formatValue = Double.parseDouble(decimalFormat.format(valueWithoutUnit)); |
|
|
// double formatValue = Double.parseDouble(valueWithoutUnit);
|
|
|
|
|
|
double parsedValue = Double.parseDouble(valueWithoutUnit); |
|
|
|
|
|
// 保留两位小数
|
|
|
|
|
|
double formatValue = Double.parseDouble(decimalFormat.format(parsedValue)); |
|
|
// 汇总每个小时的数据
|
|
|
// 汇总每个小时的数据
|
|
|
deviceHourlyAggregates.merge(key, formatValue, Double::sum); |
|
|
deviceHourlyAggregates.merge(key, formatValue, Double::sum); |
|
|
} |
|
|
} |
|
@ -505,7 +507,10 @@ public class DcDeviceController extends BaseController { |
|
|
String property = data.get("property").getAsString(); |
|
|
String property = data.get("property").getAsString(); |
|
|
String formatValueStr = data.get("formatValue").getAsString(); |
|
|
String formatValueStr = data.get("formatValue").getAsString(); |
|
|
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); |
|
|
String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", ""); |
|
|
double value = Double.parseDouble(decimalFormat.format(valueWithoutUnit)); |
|
|
|
|
|
|
|
|
double value2 = Double.parseDouble(valueWithoutUnit); |
|
|
|
|
|
double value = Double.parseDouble(decimalFormat.format(value2)); |
|
|
|
|
|
|
|
|
attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal); |
|
|
attributeMap.merge(property, value, (oldVal, newVal) -> oldVal + newVal); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -897,8 +902,26 @@ public class DcDeviceController extends BaseController { |
|
|
|
|
|
|
|
|
//获取要回滚的数据
|
|
|
//获取要回滚的数据
|
|
|
JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); |
|
|
JSONObject mdJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.MD.getValue()).get("data")); |
|
|
|
|
|
if (mdJSONObject==null) { |
|
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
|
|
result.put("device", device.getString("id")); |
|
|
|
|
|
result.put("deviceType", device.getInteger("deviceType")); |
|
|
|
|
|
result.put("functionId", UniversalEnum.MD.getValue()); |
|
|
|
|
|
result.put("result", AjaxResult.error()); |
|
|
|
|
|
resultArray.add(result); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
String mdValue = mdJSONObject.getString("value"); |
|
|
String mdValue = mdJSONObject.getString("value"); |
|
|
JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data")); |
|
|
JSONObject tmJSONObject = (JSONObject) JSON.toJSON(getDeviceLatestProperty(iotDeviceId, UniversalEnum.TM.getValue()).get("data")); |
|
|
|
|
|
if (tmJSONObject==null) { |
|
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
|
|
result.put("device", device.getString("id")); |
|
|
|
|
|
result.put("deviceType", device.getInteger("deviceType")); |
|
|
|
|
|
result.put("functionId", UniversalEnum.TM.getValue()); |
|
|
|
|
|
result.put("result", AjaxResult.error()); |
|
|
|
|
|
resultArray.add(result); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
String tmValue = tmJSONObject.getString("value"); |
|
|
String tmValue = tmJSONObject.getString("value"); |
|
|
//循环执行功能
|
|
|
//循环执行功能
|
|
|
for (Object function : functions) { |
|
|
for (Object function : functions) { |
|
|