opt:优化秒级接口查询;
This commit is contained in:
@@ -116,8 +116,8 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
return null;
|
||||
});
|
||||
//生产汇总
|
||||
CompletableFuture<JSONObject> task6 = CompletableFuture.supplyAsync(() -> cockpitMapper.getProductionsummary(), pool);
|
||||
task6.thenAccept((result) -> {
|
||||
CompletableFuture<JSONObject> task6 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONObject result =cockpitMapper.getProductionsummary();
|
||||
List<Map<String, Object>> productionSummaryList = new ArrayList<>();
|
||||
for (String itemName : Arrays.asList("1", "2", "3")) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
@@ -134,15 +134,16 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
});
|
||||
}
|
||||
getHomeInfo.put("production_summary", productionSummaryList);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
},pool);
|
||||
task6.exceptionally((e) -> {
|
||||
log.error("生产汇总: {}", e.getMessage(), e);
|
||||
getHomeInfo.put("production_summary", null);
|
||||
return null;
|
||||
});
|
||||
|
||||
//今日生产任务
|
||||
CompletableFuture<List<Map<String, Object>>> task7 = CompletableFuture.supplyAsync(() -> cockpitMapper.getTdWorkmsg(), pool);
|
||||
task7.thenAccept((result) -> {
|
||||
CompletableFuture<List<Map<String, Object>>> task7 = CompletableFuture.supplyAsync(() -> {
|
||||
List<Map<String, Object>> result =cockpitMapper.getTdWorkmsg();
|
||||
List<Map<String, Object>> today_work = new ArrayList<>();
|
||||
if (ObjectUtil.isEmpty(result)) {
|
||||
//测试数据,上线后删除
|
||||
@@ -157,52 +158,61 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
today_work.add(item1);
|
||||
}
|
||||
getHomeInfo.put("today_work", today_work);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task7.exceptionally((e) -> {
|
||||
log.error("今日生产任务: {}", e.getMessage(), e);
|
||||
getHomeInfo.put("today_work", null);
|
||||
return null;
|
||||
});
|
||||
//固化一周生产
|
||||
CompletableFuture<List<Map<String, Object>>> task8 = CompletableFuture.supplyAsync(() -> cockpitMapper.getGhsQty("7"), pool);
|
||||
task8.thenAccept((result) -> {
|
||||
CompletableFuture<List<Map<String, Object>>> task8 = CompletableFuture.supplyAsync(() -> {
|
||||
List<Map<String, Object>> result =cockpitMapper.getGhsQty("7");
|
||||
List<Map<String, Object>> gh_real_qty_default = new ArrayList<>();
|
||||
getWeekWorkStatistics(result, gh_real_qty_default, "GHS", 7);
|
||||
getHomeInfo.put("ghs_produce", gh_real_qty_default);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task8.exceptionally((e) -> {
|
||||
log.error("固化一周生产: {}", e.getMessage(), e);
|
||||
getHomeInfo.put("ghs_produce", null);
|
||||
return null;
|
||||
});
|
||||
|
||||
//涂板一周生产
|
||||
CompletableFuture<List<Map<String, Object>>> task9 = CompletableFuture.supplyAsync(() -> cockpitMapper.getTxQty("7", "TBX"), pool);
|
||||
task9.thenAccept((result) -> {
|
||||
CompletableFuture<List<Map<String, Object>>> task9 = CompletableFuture.supplyAsync(() ->{
|
||||
List<Map<String, Object>> result =cockpitMapper.getTxQty("7", "TBX");
|
||||
List<Map<String, Object>> tb_real_qty_default = new ArrayList<>();
|
||||
getWeekWorkStatistics(result, tb_real_qty_default, "TBX", 7);
|
||||
getHomeInfo.put("tbx_produce", tb_real_qty_default);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task9.exceptionally((e) -> {
|
||||
log.error("涂板一周生产: {}", e.getMessage(), e);
|
||||
getHomeInfo.put("tbx_produce", null);
|
||||
return null;
|
||||
});
|
||||
|
||||
//实时故障告警
|
||||
CompletableFuture<List<Map<String, Object>>> task10 = CompletableFuture.supplyAsync(() -> cockpitMapper.faultAlarm(), pool);
|
||||
task10.thenAccept((result) -> {
|
||||
CompletableFuture<List<Map<String, Object>>> task10 = CompletableFuture.supplyAsync(() -> {
|
||||
List<Map<String, Object>> result =cockpitMapper.faultAlarm();
|
||||
//测试数据,上线后删除
|
||||
faultAlarmDefault(result, "GHS01");
|
||||
getHomeInfo.put("fault_alarm", result);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task10.exceptionally((e) -> {
|
||||
log.error("实时故障告警: {}", e.getMessage(), e);
|
||||
getHomeInfo.put("fault_alarm", null);
|
||||
return null;
|
||||
});
|
||||
//近30日故障统计
|
||||
CompletableFuture<JSONArray> task11 = CompletableFuture.supplyAsync(() -> cockpitMapper.monthlyFaultStatistics(), pool);
|
||||
task11.thenAccept((result) -> {
|
||||
CompletableFuture<JSONArray> task11 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray result=cockpitMapper.monthlyFaultStatistics();
|
||||
//测试数据,上线后删除
|
||||
monthlyFaultStatisticsDefault(result, "GHS01");
|
||||
getHomeInfo.put("monthly_fault_statistics", result);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task11.exceptionally((e) -> {
|
||||
log.error("近30日故障统计: {}", e.getMessage(), e);
|
||||
getHomeInfo.put("monthly_fault_statistics", null);
|
||||
return null;
|
||||
@@ -563,6 +573,8 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
res.put("device_code", deviceCode);
|
||||
//todo 运行状态,信号缺失
|
||||
res.put("mode", 2);
|
||||
//1-待机;2-生产中;3-故障
|
||||
res.put("device_status", "1");
|
||||
//todo 当前生产时间,信号缺失
|
||||
res.put("production_time", 0);
|
||||
res.put("device_name", point.getPoint_name());
|
||||
@@ -588,7 +600,10 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (pointObj.getPoint_code().equals(jsonObject.getString("device_code"))) {
|
||||
one.put("move", jsonObject.getString("move") == null ? "0" : jsonObject.getString("move"));
|
||||
one.put("mode", StringUtils.isBlank(jsonObject.getString("mode"))? "运行" : jsonObject.getString("mode"));
|
||||
// 1正常运行,0故障
|
||||
one.put("mode", StringUtils.isBlank(jsonObject.getString("mode")) ? "运行" : jsonObject.getString("mode"));
|
||||
// 1正常运行,0故障
|
||||
//one.put("device_status", jsonObject.getString("mode") == null ? "1" : jsonObject.getString("mode"));
|
||||
//todo 错误码(中文),信号缺失
|
||||
one.put("error", jsonObject.getString("error") == null ? "0" : jsonObject.getString("error"));
|
||||
}
|
||||
@@ -808,8 +823,8 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
vehicleInfo.put("end_time", end_time);
|
||||
String production_time = StringUtils.isNotBlank(vehicleInfo.getString("production_time")) ? String.valueOf((long) Double.parseDouble(vehicleInfo.getString("production_time")) / 3600) : "";
|
||||
vehicleInfo.put("production_time", production_time);
|
||||
//运行状态
|
||||
String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : "";
|
||||
//todo 正式环境可以去除,在ACS端处理运行状态
|
||||
String device_status = StringUtils.isNotBlank(vehicleInfo.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(vehicleInfo.getString("status")) : "4";
|
||||
vehicleInfo.put("device_status", device_status);
|
||||
String vehicle_status = StringUtils.isNotBlank(vehicleInfo.getString("Error")) ? "故障" : "正常";
|
||||
vehicleInfo.put("vehicle_status", vehicle_status);
|
||||
@@ -864,44 +879,127 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
@Override
|
||||
public JSONArray allDeviceStatus() {
|
||||
JSONArray array = new JSONArray();
|
||||
//读取设备缓存信息
|
||||
CompletableFuture<List<Map<String, Object>>> task1 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray baoshijian = (JSONArray) redisUtils.get("baoshijian1");
|
||||
JSONArray guhuashi = (JSONArray) redisUtils.get("guhuashi1");
|
||||
JSONArray AGV = (JSONArray) redisUtils.get("AGV1");
|
||||
JSONArray RGV = (JSONArray) redisUtils.get("RGV1");
|
||||
JSONArray site = (JSONArray) redisUtils.get("site1");
|
||||
array.add(baoshijian);
|
||||
array.add(guhuashi);
|
||||
array.add(AGV);
|
||||
array.add(RGV);
|
||||
array.add(site);
|
||||
return null;
|
||||
// 固化室详情
|
||||
CompletableFuture<JSONArray> task1 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray result = cockpitMapper.getGHSInteriorList();
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
JSONObject ghsDetailInfo = new JSONObject();
|
||||
JSONArray ghsDetails = new JSONArray();
|
||||
JSONArray guHuaShi = (JSONArray) redisUtils.get("guhuashi1");
|
||||
array.add(guHuaShi);
|
||||
// for (Object object : result) {
|
||||
// //设备状态 按照lms点位管理来 1-无货;2-有货;3-进料;4固化;5出料,6故障
|
||||
// JSONObject d = (JSONObject) object;
|
||||
// guHuaShi.forEach(r -> {
|
||||
// JSONObject g = (JSONObject) r;
|
||||
// if (g.getString("device_code").equals(d.getString("device"))) {
|
||||
// d.put("device_status", g.getString("device_status"));
|
||||
// ghsDetails.add(d);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
ghsDetailInfo.put("ghs_detail", result);
|
||||
array.add(ghsDetailInfo);
|
||||
}
|
||||
return array;
|
||||
}, pool);
|
||||
task1.exceptionally((e) -> {
|
||||
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
// 固化室详情
|
||||
CompletableFuture<JSONArray> task2 = CompletableFuture.supplyAsync(() -> cockpitMapper.getGHSInteriorList(), pool);
|
||||
task2.thenAccept((result) -> {
|
||||
JSONObject ghsDetail = new JSONObject();
|
||||
ghsDetail.put("ghs_detail", result);
|
||||
array.add(ghsDetail);
|
||||
}).exceptionally((e) -> {
|
||||
log.error("固化室详情{}", e.getMessage(), e);
|
||||
JSONObject ghsDetail = new JSONObject();
|
||||
ghsDetail.put("ghs_detail", null);
|
||||
array.add(ghsDetail);
|
||||
//查询保湿间信息
|
||||
CompletableFuture<List<Map<String, Object>>> task2 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray baoShiJian = (JSONArray) redisUtils.get("baoshijian1");
|
||||
//todo 待补充信号逻辑
|
||||
for (Object object : baoShiJian) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (StringUtils.isBlank(jsonObject.getString("device_status"))) {
|
||||
jsonObject.put("device_status", "1");
|
||||
}
|
||||
}
|
||||
array.add(baoShiJian);
|
||||
return null;
|
||||
}, pool);
|
||||
task2.exceptionally((e) -> {
|
||||
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
// 输送线详情
|
||||
CompletableFuture<JSONArray> task3 = CompletableFuture.supplyAsync(() -> cockpitMapper.getSSXInteriorList(), pool);
|
||||
task3.thenAccept((result) -> {
|
||||
//查询检测站点数据
|
||||
CompletableFuture<List<Map<String, Object>>> task3 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray site = (JSONArray) redisUtils.get("site1");
|
||||
//todo 待补充信号逻辑
|
||||
for (Object object : site) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (StringUtils.isBlank(jsonObject.getString("device_status"))) {
|
||||
//0故障1正常
|
||||
jsonObject.put("device_status", "1");
|
||||
}
|
||||
}
|
||||
array.add(site);
|
||||
return null;
|
||||
}, pool);
|
||||
task3.exceptionally((e) -> {
|
||||
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
//查询AGV数据
|
||||
CompletableFuture<List<Map<String, Object>>> task4 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray agv = (JSONArray) redisUtils.get("AGV1");
|
||||
//todo 待补充信号逻辑
|
||||
for (Object object : agv) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
if (StringUtils.isBlank(jsonObject.getString("move"))) {
|
||||
jsonObject.put("move", "0");
|
||||
}
|
||||
if (StringUtils.isBlank(jsonObject.getString("full"))) {
|
||||
jsonObject.put("full", "0");
|
||||
}
|
||||
if (StringUtils.isBlank(jsonObject.getString("vehicle_type"))) {
|
||||
jsonObject.put("vehicle_type", "0");
|
||||
}
|
||||
}
|
||||
array.add(agv);
|
||||
return null;
|
||||
}, pool);
|
||||
task4.exceptionally((e) -> {
|
||||
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
//查询RGV设备信息
|
||||
CompletableFuture<List<Map<String, Object>>> task5 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray rgv = (JSONArray) redisUtils.get("RGV1");
|
||||
//todo 待补充信号逻辑
|
||||
for (Object object : rgv) {
|
||||
JSONObject jsonObject = (JSONObject) object;
|
||||
//todo 正式环境可以去除,在ACS端处理运行状态
|
||||
String device_status = StringUtils.isNotBlank(jsonObject.getString("status")) ? AcsDefineEnum.RGV_STATUS.check1(jsonObject.getString("status")) : "4";
|
||||
jsonObject.put("device_status", device_status);
|
||||
if (StringUtils.isBlank(jsonObject.getString("move"))) {
|
||||
jsonObject.put("move", "0");
|
||||
}
|
||||
if (StringUtils.isBlank(jsonObject.getString("full"))) {
|
||||
jsonObject.put("full", "0");
|
||||
}
|
||||
if (StringUtils.isBlank(jsonObject.getString("vehicle_type"))) {
|
||||
jsonObject.put("vehicle_type", "0");
|
||||
}
|
||||
}
|
||||
array.add(rgv);
|
||||
return null;
|
||||
}, pool);
|
||||
task5.exceptionally((e) -> {
|
||||
log.error("读取设备缓存信息: {}", e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
// todo 输送线详情,对接Redis
|
||||
CompletableFuture<JSONArray> task6 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray result = cockpitMapper.getSSXInteriorList();
|
||||
JSONObject ssxDetail = new JSONObject();
|
||||
ssxDetail.put("ssx_detail", result);
|
||||
array.add(ssxDetail);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task6.exceptionally((e) -> {
|
||||
log.error("输送线详情{}", e.getMessage(), e);
|
||||
JSONObject ssxDetail = new JSONObject();
|
||||
ssxDetail.put("ssx_detail", ssxDetail);
|
||||
@@ -909,19 +1007,21 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
return null;
|
||||
});
|
||||
// 库位详情
|
||||
CompletableFuture<JSONArray> task4 = CompletableFuture.supplyAsync(() -> cockpitMapper.getZCList(), pool);
|
||||
task4.thenAccept((result) -> {
|
||||
CompletableFuture<JSONArray> task7 = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray result = cockpitMapper.getZCList();
|
||||
JSONObject storage = new JSONObject();
|
||||
storage.put("storage", result);
|
||||
array.add(storage);
|
||||
}).exceptionally((e) -> {
|
||||
return null;
|
||||
}, pool);
|
||||
task7.exceptionally((e) -> {
|
||||
log.error("库位详情{}", e.getMessage(), e);
|
||||
JSONObject storage = new JSONObject();
|
||||
storage.put("storage", null);
|
||||
array.add(storage);
|
||||
return null;
|
||||
});
|
||||
CompletableFuture<Void> allQuery = CompletableFuture.allOf(task1, task2, task3, task4);
|
||||
CompletableFuture<Void> allQuery = CompletableFuture.allOf(task1, task2, task3, task4, task5, task6, task7);
|
||||
CompletableFuture<JSONArray> future = allQuery.thenApply((result) -> array).exceptionally((e) -> {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
|
||||
@@ -263,20 +263,39 @@
|
||||
AND point_type = '2'
|
||||
</select>
|
||||
<select id="getSSXInteriorList" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT CAST(point_status - 1 AS SIGNED) AS move,
|
||||
point_code AS device_code,
|
||||
point_name AS device_name,
|
||||
"1" AS mode,
|
||||
"0" AS error,
|
||||
parent_point_code AS device
|
||||
FROM `sch_base_point`
|
||||
WHERE region_code = 'KJZC'
|
||||
SELECT
|
||||
CAST( point_status - 1 AS SIGNED ) AS move,
|
||||
point_code AS device_code,
|
||||
point_name AS device_name,
|
||||
"1" AS mode,
|
||||
"0" AS error,
|
||||
"1" AS device_status,
|
||||
parent_point_code AS device,
|
||||
CASE
|
||||
vehicle_type
|
||||
WHEN 1 THEN
|
||||
"1"
|
||||
WHEN 2 THEN
|
||||
"2" ELSE "0"
|
||||
END AS vehicle_type
|
||||
FROM
|
||||
`sch_base_point`
|
||||
WHERE
|
||||
region_code = 'KJZC'
|
||||
AND point_type IN ('1', '3', '4')
|
||||
</select>
|
||||
<select id="getZCList" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT CAST(point_status - 1 AS SIGNED) AS move,
|
||||
point_code AS device_code,
|
||||
point_name AS device_name
|
||||
point_name AS device_name,
|
||||
CASE
|
||||
vehicle_type
|
||||
WHEN 1 THEN
|
||||
"1"
|
||||
WHEN 2 THEN
|
||||
"2"
|
||||
ELSE "0"
|
||||
END AS vehicle_type
|
||||
FROM `sch_base_point`
|
||||
WHERE region_code = 'ZC'
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user