包头bug修复

This commit is contained in:
guoshengxiong 2025-05-15 09:17:04 +08:00
parent 8505fd410a
commit 913d812c9b

View File

@ -140,19 +140,22 @@ public class ElectricalTask {
log.info("电箱实时数据" + execute.body()); log.info("电箱实时数据" + execute.body());
JSONObject result = JSONObject.parseObject(execute.body()).getJSONObject("result"); JSONObject result = JSONObject.parseObject(execute.body()).getJSONObject("result");
JSONObject metric = result.getJSONObject("metric"); JSONObject metric = result.getJSONObject("metric");
String temperatures = String.format("%.1f", Double.parseDouble(result.getJSONArray("temperatures").getJSONObject(0).getString("temperature"))); JSONArray jsonArray = result.getJSONArray("temperatures");
ElectricalData electricalData = new ElectricalData(devId, if (CollUtil.isNotEmpty(jsonArray)) {
metric.getString("modified"), String temperatures = String.format("%.1f", Double.parseDouble(jsonArray.getJSONObject(0).getString("temperature")));
String.format("%.1f", Double.parseDouble(metric.getString("voltage_a"))), ElectricalData electricalData = new ElectricalData(devId,
String.format("%.1f", Double.parseDouble(metric.getString("voltage_b"))), metric.getString("modified"),
String.format("%.1f", Double.parseDouble(metric.getString("voltage_c"))), String.format("%.1f", Double.parseDouble(metric.getString("voltage_a"))),
String.format("%.1f", Double.parseDouble(metric.getString("current_a"))), String.format("%.1f", Double.parseDouble(metric.getString("voltage_b"))),
String.format("%.1f", Double.parseDouble(metric.getString("current_b"))), String.format("%.1f", Double.parseDouble(metric.getString("voltage_c"))),
String.format("%.1f", Double.parseDouble(metric.getString("current_c"))), String.format("%.1f", Double.parseDouble(metric.getString("current_a"))),
String.format("%.1f", Double.parseDouble(result.getJSONArray("leakages").getJSONObject(0).getString("leakage"))), String.format("%.1f", Double.parseDouble(metric.getString("current_b"))),
temperatures, temperatures, temperatures, String.format("%.1f", Double.parseDouble(metric.getString("current_c"))),
temperatures); String.format("%.1f", Double.parseDouble(result.getJSONArray("leakages").getJSONObject(0).getString("leakage"))),
electricalDataService.saveElectricalData(electricalData); temperatures, temperatures, temperatures,
temperatures);
electricalDataService.saveElectricalData(electricalData);
}
return true; return true;
} }
return false; return false;