Browse Source

fix: 对接acs系统获取数据

master
李永德 1 year ago
parent
commit
2576d9132f
  1. 2
      lms/nladmin-system/src/main/java/org/nl/modules/common/utils/PointUpdateUtil.java
  2. 19
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/enums/DeviceEnum.java
  3. 16
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/enums/DeviceStatusEnum.java
  4. 135
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/impl/BigScreenServiceImpl.java
  5. 15
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_DEVICE.wql
  6. 2
      lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_PROCESS_PRODUCTION.wql

2
lms/nladmin-system/src/main/java/org/nl/modules/common/utils/PointUpdateUtil.java

@ -64,6 +64,7 @@ public class PointUpdateUtil {
/** /**
* 访问acs获取点位数据更新点位信息 * 访问acs获取点位数据更新点位信息
* 分拣呼叫空托盘空钢托盘叠盘架 * 分拣呼叫空托盘空钢托盘叠盘架
*
* @param pointCodes * @param pointCodes
* @deprecated 只更新点位状态和载具类型 * @deprecated 只更新点位状态和载具类型
*/ */
@ -136,6 +137,7 @@ public class PointUpdateUtil {
/** /**
* 查找设备状态 * 查找设备状态
*
* @return * @return
*/ */
public static JSONObject getDevicesStatus(JSONArray deviceCode) { public static JSONObject getDevicesStatus(JSONArray deviceCode) {

19
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/enums/DeviceEnum.java

@ -11,11 +11,12 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum DeviceEnum { public enum DeviceEnum {
HL(0, "混料"), HL(0, "HL", "混料"),
YZ(1, "压制"), YZ(1, "YZ", "压制"),
GZ(2, "干燥"), GZ(2, "SZ", "干燥"),
BZ(3, "包装"); BZ(3, "FJ", "包装");
private final int index; private final int index;
private final String code;
private final String device_name; private final String device_name;
public static DeviceEnum getDeviceEnumByIndex(int index) { public static DeviceEnum getDeviceEnumByIndex(int index) {
@ -27,4 +28,14 @@ public enum DeviceEnum {
} }
return null; // 如果没有找到对应的枚举常量,可以根据需要返回null或者抛出异常 return null; // 如果没有找到对应的枚举常量,可以根据需要返回null或者抛出异常
} }
public static DeviceEnum getDeviceEnumByCode(String code) {
DeviceEnum[] enums = DeviceEnum.values();
for (DeviceEnum deviceEnum : enums) {
if (deviceEnum.getCode().equals(code)) {
return deviceEnum;
}
}
return null; // 如果没有找到对应的枚举常量,可以根据需要返回null或者抛出异常
}
} }

16
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/service/enums/DeviceStatusEnum.java

@ -6,11 +6,12 @@ package org.nl.wms.cockpit.service.enums;
* @Date: 2023/3/10 * @Date: 2023/3/10
*/ */
public enum DeviceStatusEnum { public enum DeviceStatusEnum {
STANDBY(1, "待机"), STANDBY(1, "standby", "待机"),
RUNNING(2, "运行中"), RUNNING(2, "running", "运行中"),
FAILURE(3, "故障"), FAILURE(3, "failure", "故障"),
SHUTDOWN(0, "关机"); SHUTDOWN(0, "shutdown", "关机");
private final Integer code; private final Integer code;
private final String name;
private final String description; private final String description;
public static DeviceStatusEnum getDeviceStatusEnumByCode(int index) { public static DeviceStatusEnum getDeviceStatusEnumByCode(int index) {
@ -23,8 +24,9 @@ public enum DeviceStatusEnum {
return null; // 如果没有找到对应的枚举常量,可以根据需要返回null或者抛出异常 return null; // 如果没有找到对应的枚举常量,可以根据需要返回null或者抛出异常
} }
DeviceStatusEnum(Integer code, String description) { DeviceStatusEnum(Integer code, String name, String description) {
this.code = code; this.code = code;
this.name = name;
this.description = description; this.description = description;
} }
@ -32,6 +34,10 @@ public enum DeviceStatusEnum {
return code; return code;
} }
public String getName() {
return name;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }

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

@ -4,9 +4,11 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
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.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.config.thread.ThreadPoolExecutorUtil; import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.nl.modules.common.utils.PointUpdateUtil;
import org.nl.modules.wql.WQL; import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.cockpit.service.BigScreenService; import org.nl.wms.cockpit.service.BigScreenService;
@ -114,17 +116,46 @@ public class BigScreenServiceImpl implements BigScreenService {
map.put("CPDayList", null); map.put("CPDayList", null);
return null; return null;
}); });
// TODO: 4、设备运行情况 // 4、设备运行情况
CompletableFuture<List<OperationConditionDto>> deviceConditionTask = CompletableFuture.supplyAsync(() -> { CompletableFuture<List<OperationConditionDto>> deviceConditionTask = CompletableFuture.supplyAsync(() -> {
List<OperationConditionDto> res = new ArrayList<>(); List<OperationConditionDto> res = new ArrayList<>();
for (int i = 0; i < 4; i++) { // 获取所有设备
DeviceEnum deviceEnumByIndex = DeviceEnum.getDeviceEnumByIndex(i); JSONArray result = WQL.getWO("COCKPIT_DEVICE")
.addParam("flag", "4")
.process()
.getResultJSONArray(0);
// TODO: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(result);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : result;
JSONArray data = result;
// 初始化数据 数组下标:0关机 1待机 2生产中 3故障
JSONObject total = new JSONObject();
DeviceEnum[] values = DeviceEnum.values();
for (int i = 0; i < values.length; i++) {
total.put(values[i].getCode(), new int[4]);
}
// 遍历判断
for (int i = 0; i < data.size(); i++) {
JSONObject device = data.getJSONObject(i);
Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("devices_status"))
? device.getInteger("devices_status")
: 0;
String regionCode = device.getString("region_code");
DeviceEnum deviceEnumByCode = DeviceEnum.getDeviceEnumByCode(regionCode); // 获取属于哪种设备
int[] ints = (int[]) total.get(deviceEnumByCode.getCode());
ints[devicesStatus1] = ints[devicesStatus1] + 1;
total.put(deviceEnumByCode.getCode(), ints);
}
// 返回输出值
for (int i = 0; i < values.length; i++) { // 4个
int[] ints = (int[]) total.get(values[i].getCode());
OperationConditionDto dto = new OperationConditionDto(); OperationConditionDto dto = new OperationConditionDto();
dto.setDevice_name(deviceEnumByIndex.getDevice_name()); dto.setDevice_name(values[i].getDevice_name()); // 列名
dto.setRunning(3); dto.setRunning(ints[2]);
dto.setFailure(5); dto.setFailure(ints[3]);
dto.setShutdown(2); dto.setShutdown(ints[0]);
dto.setStandby(6); dto.setStandby(ints[1]);
res.add(dto); res.add(dto);
} }
return res; return res;
@ -182,21 +213,24 @@ public class BigScreenServiceImpl implements BigScreenService {
.addParamMap(MapOf.of("flag", "5", "region_code", "YZ")) .addParamMap(MapOf.of("flag", "5", "region_code", "YZ"))
.process() .process()
.getResultJSONArray(0); .getResultJSONArray(0);
return res;
}, pool);
stackingPositionTask.thenAccept(result -> {
// TODO: 颜色、实时数量请求acs系统 // TODO: 颜色、实时数量请求acs系统
for (int i = 0; i < result.size(); i++) { // JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
JSONObject jsonObject = result.getJSONObject(i); // JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
for (int i = 0; i < res.size(); i++) {
JSONObject jsonObject = res.getJSONObject(i);
jsonObject.put("color_status", ColorEnum.RED.getIndex()); jsonObject.put("color_status", ColorEnum.RED.getIndex());
} }
return res;
}, pool);
stackingPositionTask.thenAccept(result -> {
map.put("StackingPositionList", result); map.put("StackingPositionList", result);
}).exceptionally((e) -> { }).exceptionally((e) -> {
log.error("码垛位情况显示: {}", e.getMessage(), e); log.error("码垛位情况显示: {}", e.getMessage(), e);
map.put("StackingPositionList", null); map.put("StackingPositionList", null);
return null; return null;
}); });
// 8、压机信息显示 todo: 压机的状态,请求acs // 8、压机信息显示
CompletableFuture<JSONArray> pressMachineTask = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONArray> pressMachineTask = CompletableFuture.supplyAsync(() -> {
JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION") JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION")
.addParamMap(MapOf.of("flag", "10")) .addParamMap(MapOf.of("flag", "10"))
@ -207,6 +241,10 @@ public class BigScreenServiceImpl implements BigScreenService {
jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode()); jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode());
jsonObject.put("open_time", DateUtil.now()); jsonObject.put("open_time", DateUtil.now());
} }
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res; return res;
}, pool); }, pool);
pressMachineTask.thenAccept(result -> { pressMachineTask.thenAccept(result -> {
@ -216,7 +254,7 @@ public class BigScreenServiceImpl implements BigScreenService {
map.put("PressMachineList", null); map.put("PressMachineList", null);
return null; return null;
}); });
// 9、混料机信息显示 todo: 设备状态,请求acs // 9、混料机信息显示
CompletableFuture<JSONArray> mixMachineTask = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONArray> mixMachineTask = CompletableFuture.supplyAsync(() -> {
JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION") JSONArray res = WQL.getWO("COCKPIT_PROCESS_PRODUCTION")
.addParamMap(MapOf.of("flag", "11")) .addParamMap(MapOf.of("flag", "11"))
@ -227,6 +265,10 @@ public class BigScreenServiceImpl implements BigScreenService {
jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode()); jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode());
jsonObject.put("open_time", DateUtil.now()); jsonObject.put("open_time", DateUtil.now());
} }
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res; return res;
}, pool); }, pool);
mixMachineTask.thenAccept(result -> { mixMachineTask.thenAccept(result -> {
@ -302,11 +344,14 @@ public class BigScreenServiceImpl implements BigScreenService {
.addParamMap(MapOf.of("flag", "13")) .addParamMap(MapOf.of("flag", "13"))
.process() .process()
.getResultJSONArray(0); .getResultJSONArray(0);
// TODO: 颜色、实时数量请求acs系统
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());
} }
// TODO: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res; return res;
}, pool); }, pool);
sortAndPalletizingTask.thenAccept(result -> { sortAndPalletizingTask.thenAccept(result -> {
@ -340,6 +385,7 @@ public class BigScreenServiceImpl implements BigScreenService {
/** /**
* 工序生产 * 工序生产
*
* @return * @return
*/ */
@Override @Override
@ -736,10 +782,22 @@ public class BigScreenServiceImpl implements BigScreenService {
CompletableFuture<JSONArray> mixDevicePopoverInformationTask = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONArray> mixDevicePopoverInformationTask = CompletableFuture.supplyAsync(() -> {
JSONArray res = WQL.getWO("COCKPIT_MIX_AND_TRAP").addParamMap(MapOf.of("flag", "2")) JSONArray res = WQL.getWO("COCKPIT_MIX_AND_TRAP").addParamMap(MapOf.of("flag", "2"))
.process().getResultJSONArray(0); .process().getResultJSONArray(0);
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("devices_status"))
// ? device.getInteger("devices_status")
// : 0;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1);
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
// }
return res; return res;
}, pool); }, pool);
mixDevicePopoverInformationTask.thenAccept(result -> { mixDevicePopoverInformationTask.thenAccept(result -> {
//todo: 请求acs设置开机状态等等信息 //todo: 以下代码去掉
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
JSONObject device = result.getJSONObject(i); JSONObject device = result.getJSONObject(i);
if (!device.getString("material_code").equals("-")) { if (!device.getString("material_code").equals("-")) {
@ -869,10 +927,21 @@ public class BigScreenServiceImpl implements BigScreenService {
CompletableFuture<JSONArray> pressPopoverTask = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONArray> pressPopoverTask = CompletableFuture.supplyAsync(() -> {
JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "4")) JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "4"))
.process().getResultJSONArray(0); .process().getResultJSONArray(0);
// todo: 打开ACS系统对接数据
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("devices_status"))
// ? device.getInteger("devices_status")
// : 0;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1);
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
return res; return res;
}, pool); }, pool);
pressPopoverTask.thenAccept(result -> { pressPopoverTask.thenAccept(result -> {
//todo: 请求acs获取开机状态等等信息 //todo: 以下代码去掉
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
JSONObject device = result.getJSONObject(i); JSONObject device = result.getJSONObject(i);
if (!device.getString("material_code").equals("-")) { if (!device.getString("material_code").equals("-")) {
@ -901,6 +970,9 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "5")) JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "5"))
.process().getResultJSONArray(0); .process().getResultJSONArray(0);
// todo: request acs to find device status and other information // todo: request acs to find device status and other information
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
return res; return res;
}, pool); }, pool);
trayStationPopoverTask.thenAccept(result -> { trayStationPopoverTask.thenAccept(result -> {
@ -910,10 +982,22 @@ public class BigScreenServiceImpl implements BigScreenService {
map.put("TrayStationPopoverList", null); map.put("TrayStationPopoverList", null);
return null; return null;
}); });
// 3、机械手状态 todo // 3、机械手状态
CompletableFuture<JSONArray> manipulatorConditionTask = CompletableFuture.supplyAsync(() -> { CompletableFuture<JSONArray> manipulatorConditionTask = CompletableFuture.supplyAsync(() -> {
JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "6")) JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "6"))
.process().getResultJSONArray(0); .process().getResultJSONArray(0);
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("devices_status"))
// ? device.getInteger("devices_status")
// : 0;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1);
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
// }
// todo 去掉以下代码
for (int i = 0; i < res.size(); i++) { for (int i = 0; i < res.size(); i++) {
JSONObject device = res.getJSONObject(i); JSONObject device = res.getJSONObject(i);
device.put("device_status", DeviceStatusEnum.RUNNING.getCode()); device.put("device_status", DeviceStatusEnum.RUNNING.getCode());
@ -1215,6 +1299,19 @@ public class BigScreenServiceImpl implements BigScreenService {
JSONArray res = WQL.getWO("COCKPIT_SORTE_AND_PACKAGE").addParamMap(MapOf.of("flag", "5")) JSONArray res = WQL.getWO("COCKPIT_SORTE_AND_PACKAGE").addParamMap(MapOf.of("flag", "5"))
.process().getResultJSONArray(0); .process().getResultJSONArray(0);
// todo: 向acs申请获取 // todo: 向acs申请获取
// JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
// JSONArray data = ObjectUtil.isNotEmpty(
// devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
// for (int i = 0; i < data.size(); i++) {
// JSONObject device = data.getJSONObject(i);
// Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("devices_status"))
// ? device.getInteger("devices_status")
// : 0;
// DeviceStatusEnum deviceStatusEnumByCode = DeviceStatusEnum.getDeviceStatusEnumByCode(devicesStatus1);
// device.put("device_status_name", deviceStatusEnumByCode.getDescription());
// resObj.put(device.getString("device_code"), device);
// }
// todo 去掉以下代码
for (int i = 0; i < res.size(); i++) { for (int i = 0; i < res.size(); i++) {
JSONObject device = res.getJSONObject(i); JSONObject device = res.getJSONObject(i);
device.put("device_status", DeviceStatusEnum.RUNNING.getCode()); device.put("device_status", DeviceStatusEnum.RUNNING.getCode());

15
lms/nladmin-system/src/main/java/org/nl/wms/cockpit/wql/COCKPIT_DEVICE.wql

@ -87,3 +87,18 @@
ENDSELECT ENDSELECT
ENDPAGEQUERY ENDPAGEQUERY
ENDIF ENDIF
IF 输入.flag = "4"
PAGEQUERY
SELECT
d.device_code,
d.device_name,
d.region_code,
0 AS devices_status
FROM
`pdm_bi_device` d
WHERE d.region_code IN ('YZ','HL','SZ','FJ')
ORDER BY d.region_code, d.device_code
ENDSELECT
ENDPAGEQUERY
ENDIF

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

@ -126,7 +126,7 @@
IF 输入.flag = "5" IF 输入.flag = "5"
PAGEQUERY PAGEQUERY
SELECT SELECT
point_code, point_code AS device_code,
point_name, point_name,
region_code region_code
FROM FROM

Loading…
Cancel
Save