opt:优化超威大屏接口。

This commit is contained in:
2024-10-24 15:41:13 +08:00
parent 517214a61a
commit 79858c4a37
2 changed files with 85 additions and 86 deletions

View File

@@ -47,23 +47,8 @@ public class SyncDeviceStatus {
private void device() {
long startTime = System.currentTimeMillis();
//long startTime = System.currentTimeMillis();
try {
//总数
Integer a1_count = 0;
//正常运行
Long a1_item1 = 0L;
//暂未生产
Long a1_item2 = 0L;
//空闲设备
Long a1_item3 = 0L;
//故障设备
Long a1_item4 = 0L;
Integer a2_count = 0;
Long a2_item1 = 0L;
Long a2_item2 = 0L;
Long a2_item3 = 0L;
Long a2_item4 = 0L;
JSONArray tbxList1 = new JSONArray();
JSONArray tbxList2 = new JSONArray();
JSONArray ghsList1 = new JSONArray();
@@ -209,9 +194,9 @@ public class SyncDeviceStatus {
//
// }
//redisUtils.set("agvList", agvList);
log.trace("自动上报驱动状态,完毕耗时{}", System.currentTimeMillis() - startTime);
//log.trace("自动上报驱动状态,完毕耗时{}", System.currentTimeMillis() - startTime);
} catch (Exception e) {
//log.error("自动线程开始查询AGV设备自动上报驱动状态失败{}{}", e, e.getMessage());
log.error("自动线程开始查询AGV设备自动上报驱动状态失败{}{}", e, e.getMessage());
}
}
@@ -221,59 +206,59 @@ public class SyncDeviceStatus {
Long a1_item1;
Long a1_item2;
Long a1_item4;
//0脱机1故障2待机3运行中
a1_count = deviceList.size();
JSONObject item1 = new JSONObject();
item1.put("count", a1_count);
result.add(item1);
a1_item1 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "3".equals(r.getString("mode")))
.count();
JSONObject item2 = new JSONObject();
item2.put("count", a1_item1.toString());
item2.put("name", "正常运行");
// 计算百分比
double a1Item1Percentage = (double) a1_item1 / a1_count * 100;
String a1Item1Percentages = new DecimalFormat("0.00").format(a1Item1Percentage) + "%";
item2.put("percent", a1Item1Percentages);
result.add(item2);
a1_item2 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "2".equals(r.getString("mode")))
.count();
JSONObject item3 = new JSONObject();
item3.put("count", a1_item2.toString());
item3.put("name", "暂未生产");
// 计算百分比
double a1Item2Percentage = (double) a1_item2 / a1_count * 100;
String a1Item2Percentages = new DecimalFormat("0.00").format(a1Item2Percentage) + "%";
item3.put("percent", a1Item2Percentages);
result.add(item3);
a1_item3 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "0".equals(r.getString("mode")))
.count();
JSONObject item4 = new JSONObject();
item4.put("count", a1_item3.toString());
item4.put("name", "空闲设备");
// 计算百分比
double a1Item3Percentage = (double) a1_item3 / a1_count * 100;
String a1Item3Percentages = new DecimalFormat("0.00").format(a1Item3Percentage) + "%";
item4.put("percent", a1Item3Percentages);
result.add(item4);
a1_item4 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "1".equals(r.getString("mode")))
.count();
JSONObject item5 = new JSONObject();
item5.put("count", a1_item4.toString());
item5.put("name", "故障设备");
// 计算百分比
double a1Item4Percentage = (double) a1_item4 / a1_count * 100;
String a1Item4Percentages = new DecimalFormat("0.00").format(a1Item4Percentage) + "%";
item5.put("percent", a1Item4Percentages);
result.add(item5);
try {
//0脱机1故障2待机3运行中
a1_count = deviceList.size();
item1.put("count", a1_count);
result.add(item1);
a1_item1 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "3".equals(r.getString("mode")))
.count();
JSONObject item2 = new JSONObject();
item2.put("count", a1_item1.toString());
item2.put("name", "正常运行");
double a1Item1Percentage = (double) a1_item1 / a1_count * 100;
String a1Item1Percentages = new DecimalFormat("0.00").format(a1Item1Percentage) + "%";
item2.put("percent", a1Item1Percentages);
result.add(item2);
a1_item2 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "2".equals(r.getString("mode")))
.count();
JSONObject item3 = new JSONObject();
item3.put("count", a1_item2.toString());
item3.put("name", "暂未生产");
double a1Item2Percentage = (double) a1_item2 / a1_count * 100;
String a1Item2Percentages = new DecimalFormat("0.00").format(a1Item2Percentage) + "%";
item3.put("percent", a1Item2Percentages);
result.add(item3);
a1_item3 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "0".equals(r.getString("mode")))
.count();
JSONObject item4 = new JSONObject();
item4.put("count", a1_item3.toString());
item4.put("name", "空闲设备");
double a1Item3Percentage = (double) a1_item3 / a1_count * 100;
String a1Item3Percentages = new DecimalFormat("0.00").format(a1Item3Percentage) + "%";
item4.put("percent", a1Item3Percentages);
result.add(item4);
a1_item4 = deviceList.stream()
.map(JSONObject.class::cast)
.filter(r -> "1".equals(r.getString("mode")))
.count();
JSONObject item5 = new JSONObject();
item5.put("count", a1_item4.toString());
item5.put("name", "故障设备");
double a1Item4Percentage = (double) a1_item4 / a1_count * 100;
String a1Item4Percentages = new DecimalFormat("0.00").format(a1Item4Percentage) + "%";
item5.put("percent", a1Item4Percentages);
result.add(item5);
} catch (Exception e) {
log.error("获取设备数量和百分比失败", e);
}
}
private static void getDeviceMode(Integer mode, JSONObject json) {