Browse Source

fix: 修复大屏数据

master
李永德 1 year ago
parent
commit
358b43e8e3
  1. 78
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java
  2. 60
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql

78
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java

@ -2,6 +2,7 @@ package org.nl.wms.cockpit.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.Data; import lombok.Data;
@ -191,8 +192,8 @@ public class BigScreenServiceImpl implements BigScreenService {
List<FailureDeviceInfoDto> res = new CopyOnWriteArrayList<>(); List<FailureDeviceInfoDto> res = new CopyOnWriteArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
FailureDeviceInfoDto dto = new FailureDeviceInfoDto(); FailureDeviceInfoDto dto = new FailureDeviceInfoDto();
dto.setDevice_code("hn01"); dto.setDevice_code("hl01");
dto.setDevice_name("混01"); dto.setDevice_name("混01");
dto.setFailure_time("05-30 09:50:12"); dto.setFailure_time("05-30 09:50:12");
dto.setFailure_info("机器故障"); dto.setFailure_info("机器故障");
dto.setDevice_status_name("待机"); dto.setDevice_status_name("待机");
@ -217,6 +218,25 @@ public class BigScreenServiceImpl implements BigScreenService {
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res); // JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty( // JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res; // devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject jsonObject = data.getJSONObject(i);
// if (jsonObject.getInteger("move") == 1
// && ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
// && jsonObject.getInteger("encoder_qty") > 0) {
// // 绿色
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// } else if (jsonObject.getInteger("move") == 1
// && ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
// && jsonObject.getInteger("encoder_qty") == 0) {
// // 黄色
// jsonObject.put("color_status", ColorEnum.YELLOW.getIndex());
// } else if (jsonObject.getInteger("move") == 0) {
// // 红色
// jsonObject.put("color_status", ColorEnum.RED.getIndex());
// } else { // 有托盘人工
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// }
// }
for (int i = 0; i < res.size(); i++) { for (int i = 0; i < res.size(); i++) {
JSONObject jsonObject = res.getJSONObject(i); JSONObject jsonObject = res.getJSONObject(i);
jsonObject.put("color_status", ColorEnum.RED.getIndex()); jsonObject.put("color_status", ColorEnum.RED.getIndex());
@ -263,12 +283,19 @@ public class BigScreenServiceImpl implements BigScreenService {
for (int i = 0; i < res.size(); i++) { for (int i = 0; i < res.size(); i++) {
JSONObject jsonObject = res.getJSONObject(i); JSONObject jsonObject = res.getJSONObject(i);
jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode()); jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode());
jsonObject.put("open_time", DateUtil.now()); String now = DateUtil.now();
jsonObject.put("open_time", now.substring(now.indexOf('-') + 1));
} }
// todo: 打开ACS系统对接数据 // todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res); // JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty( // JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res; // devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject jsonObject = data.getJSONObject(i);
// jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode());
// String openTime = jsonObject.getString("open_time");
// jsonObject.put("open_time", openTime.substring(openTime.indexOf('-') + 1));
// }
return res; return res;
}, pool); }, pool);
mixMachineTask.thenAccept(result -> { mixMachineTask.thenAccept(result -> {
@ -352,6 +379,25 @@ public class BigScreenServiceImpl implements BigScreenService {
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res); // JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty( // JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res; // devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject jsonObject = data.getJSONObject(i);
// if (jsonObject.getInteger("move") == 1
// && ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
// && jsonObject.getInteger("encoder_qty") > 0) {
// // 绿色
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// } else if (jsonObject.getInteger("move") == 1
// && ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
// && jsonObject.getInteger("encoder_qty") == 0) {
// // 黄色
// jsonObject.put("color_status", ColorEnum.YELLOW.getIndex());
// } else if (jsonObject.getInteger("move") == 0) {
// // 红色
// jsonObject.put("color_status", ColorEnum.RED.getIndex());
// } else { // 有托盘人工
// jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
// }
// }
return res; return res;
}, pool); }, pool);
sortAndPalletizingTask.thenAccept(result -> { sortAndPalletizingTask.thenAccept(result -> {
@ -361,6 +407,29 @@ public class BigScreenServiceImpl implements BigScreenService {
map.put("SortAndPalletizingList", null); map.put("SortAndPalletizingList", null);
return null; return null;
}); });
// 15、机械手状态
CompletableFuture<JSONArray> manipulatorInfoTask = CompletableFuture.supplyAsync(() -> {
JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION")
.addParamMap(MapOf.of("flag", "14"))
.process()
.getResultJSONArray(0);
for (int i = 0; i < res.size(); i++) {
JSONObject jsonObject = res.getJSONObject(i);
jsonObject.put("color_status", ColorEnum.RED.getIndex());
}
// TODO: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res;
}, pool);
manipulatorInfoTask.thenAccept(result -> {
map.put("ManipulatorInfoList", result);
}).exceptionally((e) -> {
log.error("机械手: {}", e.getMessage(), e);
map.put("ManipulatorInfoList", null);
return null;
});
CompletableFuture<Void> allQuery = CompletableFuture.allOf( CompletableFuture<Void> allQuery = CompletableFuture.allOf(
mixDayProductionTask, mixDayProductionTask,
pressDayProductionTask, pressDayProductionTask,
@ -373,7 +442,8 @@ public class BigScreenServiceImpl implements BigScreenService {
mixMachineTask, mixMachineTask,
trappedShelfTask, trappedShelfTask,
sortAndPalletizingTask, sortAndPalletizingTask,
semiFinishedProductShelfTask); semiFinishedProductShelfTask,
manipulatorInfoTask);
CompletableFuture<ConcurrentHashMap<String, Object>> future CompletableFuture<ConcurrentHashMap<String, Object>> future
= allQuery.thenApply((result) -> map).exceptionally((e) -> { = allQuery.thenApply((result) -> map).exceptionally((e) -> {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

60
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql

@ -237,6 +237,7 @@
PAGEQUERY PAGEQUERY
SELECT SELECT
d.device_code, d.device_code,
d.device_name,
LEFT(m.material_code, 11) AS material_code, LEFT(m.material_code, 11) AS material_code,
( (
SELECT IF(LENGTH(SUM(w.real_qty)) > 0,SUM(w.real_qty),0) SELECT IF(LENGTH(SUM(w.real_qty)) > 0,SUM(w.real_qty),0)
@ -276,23 +277,38 @@
IF 输入.flag = "12" IF 输入.flag = "12"
PAGEQUERY PAGEQUERY
SELECT SELECT
point.point_code, point.point_code,
point.point_name, point.point_name,
CASE point.point_status CASE point.point_status
WHEN '0' THEN '0' WHEN '0' THEN '0'
WHEN '1' THEN IF(vd.vd_id IS NULL,'1','2') WHEN '1' THEN IF(vd.vd_id IS NULL,'1','2')
ELSE '0' ELSE '0'
END AS point_status END AS point_status,
IF(LENGTH( vd.stand_status )> 0,vd.stand_status,'') AS stand_status,
CASE vd.stand_status
WHEN '2' THEN '困料中'
WHEN '3' THEN '困料完成'
WHEN '4' THEN '困料完成'
WHEN '5' THEN '困料超时'
ELSE ''
END AS stand_status_name,
CASE vd.stand_status
WHEN '2' THEN '1'
WHEN '3' THEN '2'
WHEN '4' THEN '2'
WHEN '5' THEN '3'
ELSE ''
END AS stand_status_color
FROM FROM
sch_base_point point sch_base_point point
LEFT JOIN st_ivt_vehicle_detail vd ON vd.vehicle_code = point.vehicle_code LEFT JOIN st_ivt_vehicle_detail vd ON vd.vehicle_code = point.vehicle_code
AND vd.vehicle_type = point.vehicle_type AND vd.vehicle_type = point.vehicle_type
AND vd.is_delete = '0' AND vd.is_delete = '0'
WHERE WHERE
point.region_code = 'KLHJ' point.region_code = 'KLHJ'
AND point.point_type IN ('2','3') AND point.point_type IN ('2','3')
ORDER BY ORDER BY
point.point_code ASC point.point_code ASC
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
@ -310,3 +326,19 @@
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
IF 输入.flag = "14"
PAGEQUERY
SELECT
d.device_code,
d.device_name,
d.region_code
FROM
`pdm_bi_device` d
WHERE ((d.region_code = 'YZ' AND d.device_model = '5')
OR (d.region_code = 'FJ' AND d.device_model = '9'))
AND d.device_code <> 'FJRGCD01'
ORDER BY d.device_model, d.region_code, d.device_code
ENDSELECT
ENDPAGEQUERY
ENDIF

Loading…
Cancel
Save