add: 添加故障信息表,修复大屏数据
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package org.nl.wms.cockpit.service.enums;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 故障信息枚举
|
||||
* @Date: 2023/6/26
|
||||
*/
|
||||
public enum ErrorInfoEnum {
|
||||
scram("1", "急停中"),
|
||||
LIGHT_CURTAIN_ALARM("2", "光幕报警"),
|
||||
BODY_ALARM("3", "本体报警"),
|
||||
NO_SCHEDULED_PRODUCTION_ALARM("4", "未排产报警"),
|
||||
SCANNING_FAULT("5", "扫码故障");
|
||||
|
||||
/**
|
||||
* 1.急停中
|
||||
* 2.光幕报警
|
||||
* 3.本体报警
|
||||
* 4.未排产报警
|
||||
* 5.扫码故障
|
||||
*/
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
ErrorInfoEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static ErrorInfoEnum getErrorInfoEnumByCode(String code) {
|
||||
ErrorInfoEnum[] enums = ErrorInfoEnum.values();
|
||||
for (ErrorInfoEnum errorInfoEnum : enums) {
|
||||
if (errorInfoEnum.getCode().equals(code)) {
|
||||
return errorInfoEnum;
|
||||
}
|
||||
}
|
||||
return null; // 如果没有找到对应的枚举常量,可以根据需要返回null或者抛出异常
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -127,8 +127,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(result);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : result;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getJSONArray("data") : result;
|
||||
// 初始化数据 数组下标:0关机 1待机 2生产中 3故障
|
||||
JSONObject total = new JSONObject();
|
||||
DeviceEnum[] values = DeviceEnum.values();
|
||||
@@ -138,8 +138,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
// 遍历判断
|
||||
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")
|
||||
Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("status"))
|
||||
? device.getInteger("status")
|
||||
: 0;
|
||||
String regionCode = device.getString("region_code");
|
||||
DeviceEnum deviceEnumByCode = DeviceEnum.getDeviceEnumByCode(regionCode); // 获取属于哪种设备
|
||||
@@ -168,16 +168,13 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
return null;
|
||||
});
|
||||
// TODO: 5、近一个月故障次数前5台设备
|
||||
CompletableFuture<List<OperationConditionDto>> lastMonthFailureTask = CompletableFuture.supplyAsync(() -> {
|
||||
List<OperationConditionDto> res = new ArrayList<>();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
OperationConditionDto dto = new OperationConditionDto();
|
||||
dto.setDevice_name("机器" + (i + 1));
|
||||
dto.setFailure(random.nextInt(30 - 10 + 1) + 10);
|
||||
res.add(dto);
|
||||
}
|
||||
return res;
|
||||
CompletableFuture<JSONArray> lastMonthFailureTask = CompletableFuture.supplyAsync(() -> {
|
||||
// 获取所有设备
|
||||
JSONArray result = WQL.getWO("COCKPIT_DEVICE")
|
||||
.addParam("flag", "6")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
return result;
|
||||
}, pool);
|
||||
lastMonthFailureTask.thenAccept(result -> {
|
||||
map.put("LastMonthFailureList", result);
|
||||
@@ -187,18 +184,12 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
return null;
|
||||
});
|
||||
// TODO: 6、最近10次设备故障
|
||||
CompletableFuture<List<FailureDeviceInfoDto>> lastTenFailureTask = CompletableFuture.supplyAsync(() -> {
|
||||
List<FailureDeviceInfoDto> res = new CopyOnWriteArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
FailureDeviceInfoDto dto = new FailureDeviceInfoDto();
|
||||
dto.setDevice_code("hl01");
|
||||
dto.setDevice_name("混料01");
|
||||
dto.setFailure_time("05-30 09:50:12");
|
||||
dto.setFailure_info("机器故障");
|
||||
dto.setDevice_status_name("待机");
|
||||
res.add(dto);
|
||||
}
|
||||
return res;
|
||||
CompletableFuture<JSONArray> lastTenFailureTask = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray result = WQL.getWO("COCKPIT_DEVICE")
|
||||
.addParam("flag", "5")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
return result;
|
||||
}, pool);
|
||||
lastTenFailureTask.thenAccept(result -> {
|
||||
map.put("LastTenFailureList", result);
|
||||
@@ -214,6 +205,7 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
@@ -251,8 +243,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getJSONArray("data") : res;
|
||||
return data;
|
||||
}, pool);
|
||||
pressMachineTask.thenAccept(result -> {
|
||||
@@ -269,8 +261,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getJSONArray("data") : res;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject jsonObject = data.getJSONObject(i);
|
||||
jsonObject.put("device_status", DeviceStatusEnum.STANDBY.getCode());
|
||||
@@ -353,8 +345,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getJSONArray("data") : res;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject jsonObject = data.getJSONObject(i);
|
||||
if (jsonObject.getInteger("move") == 1
|
||||
@@ -390,8 +382,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getJSONArray("data") : res;
|
||||
return data;
|
||||
}, pool);
|
||||
manipulatorInfoTask.thenAccept(result -> {
|
||||
@@ -824,8 +816,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
JSONArray res = WQL.getWO("COCKPIT_MIX_AND_TRAP").addParamMap(MapOf.of("flag", "2"))
|
||||
.process().getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? 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"))
|
||||
@@ -950,8 +942,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "4"))
|
||||
.process().getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? 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"))
|
||||
@@ -974,8 +966,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "5"))
|
||||
.process().getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getJSONArray("data") : res;
|
||||
return data;
|
||||
}, pool);
|
||||
trayStationPopoverTask.thenAccept(result -> {
|
||||
@@ -990,8 +982,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
JSONArray res = WQL.getWO("COCKPIT_MOLDING_INFO").addParamMap(MapOf.of("flag", "6"))
|
||||
.process().getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? 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"))
|
||||
@@ -1061,7 +1053,7 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
moldingIOStoringTask.thenAccept(result -> {
|
||||
map.put("MoldingIOStoringList", result);
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取半成品货架信息: {}", e.getMessage(), e);
|
||||
log.error("获取成型出入库信息: {}", e.getMessage(), e);
|
||||
map.put("MoldingIOStoringList", null);
|
||||
return null;
|
||||
});
|
||||
@@ -1108,16 +1100,10 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
map.put("SemiFinishedIOList", null);
|
||||
return null;
|
||||
});
|
||||
// todo: 3、烧制窑内物料
|
||||
// 3、烧制窑内物料
|
||||
CompletableFuture<JSONArray> fireInTheKilnTask = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray res = new JSONArray();
|
||||
Random random = new Random();
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
JSONObject r = new JSONObject();
|
||||
r.put("qty", random.nextInt(2000 - 100 + 1) + 100);
|
||||
r.put("material_code", "物料" + i);
|
||||
res.add(r);
|
||||
}
|
||||
JSONArray res = WQL.getWO("COCKPIT_FIR_AND_DRY").addParamMap(MapOf.of("flag", "4"))
|
||||
.process().getResultJSONArray(0);
|
||||
return res;
|
||||
}, pool);
|
||||
fireInTheKilnTask.thenAccept(result -> {
|
||||
@@ -1127,16 +1113,10 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
map.put("FireInTheKilnList", null);
|
||||
return null;
|
||||
});
|
||||
// todo: 4、冷却窑内物料
|
||||
// 4、冷却窑内物料
|
||||
CompletableFuture<JSONArray> coolingInTheKilnTask = CompletableFuture.supplyAsync(() -> {
|
||||
JSONArray res = new JSONArray();
|
||||
Random random = new Random();
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
JSONObject r = new JSONObject();
|
||||
r.put("qty", random.nextInt(2000 - 100 + 1) + 100);
|
||||
r.put("material_code", "物料" + i);
|
||||
res.add(r);
|
||||
}
|
||||
JSONArray res = WQL.getWO("COCKPIT_FIR_AND_DRY").addParamMap(MapOf.of("flag", "5"))
|
||||
.process().getResultJSONArray(0);
|
||||
return res;
|
||||
}, pool);
|
||||
coolingInTheKilnTask.thenAccept(result -> {
|
||||
@@ -1292,8 +1272,8 @@ public class BigScreenServiceImpl implements BigScreenService {
|
||||
JSONArray res = WQL.getWO("COCKPIT_SORTE_AND_PACKAGE").addParamMap(MapOf.of("flag", "5"))
|
||||
.process().getResultJSONArray(0);
|
||||
JSONObject devicesStatus = PointUpdateUtil.getDevicesStatus(res);
|
||||
JSONArray data = ObjectUtil.isNotEmpty(
|
||||
devicesStatus.getJSONArray("data")) ? devicesStatus.getJSONArray("data") : res;
|
||||
// JSONObject devicesStatus = null;
|
||||
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? 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"))
|
||||
|
||||
@@ -102,3 +102,33 @@
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
das.*,
|
||||
d.device_name
|
||||
FROM
|
||||
`das_device_number` das
|
||||
LEFT JOIN pdm_bi_device d ON d.device_code = das.device_code
|
||||
ORDER BY das.failure_time DESC
|
||||
LIMIT 10
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "6"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
COUNT(*) AS failure,
|
||||
d.device_name
|
||||
FROM
|
||||
`das_device_number` das
|
||||
LEFT JOIN pdm_bi_device d ON d.device_code = das.device_code
|
||||
WHERE das.failure_time >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
|
||||
GROUP BY d.device_name
|
||||
ORDER BY failure DESC
|
||||
LIMIT 5
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
p.point_name,
|
||||
IF(LENGTH(p.vehicle_code)>0,p.vehicle_code,'-') AS vehicle_code,
|
||||
IF(LENGTH(LEFT(m.material_code, 11))>0,LEFT(m.material_code, 11),'-') AS material_code,
|
||||
IF(LENGTH(vd.qty)>0,vd.qty,0) AS qty,
|
||||
IF(LENGTH(vd.qty)>0,vd.qty,'-') AS qty,
|
||||
IF(LENGTH(mix_num)>0,CONCAT(DATE_FORMAT(CURRENT_DATE(), '%Y%m%d'),LPAD(mix_num, 3, '0')),'-') AS mix_num,
|
||||
IF(LENGTH(vd.create_time),vd.create_time,'-') AS create_time
|
||||
FROM
|
||||
@@ -122,3 +122,36 @@
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
SUM(vd.qty) AS qty,
|
||||
LEFT(m.material_code, 11) AS material_code
|
||||
FROM
|
||||
`sch_base_task` t
|
||||
LEFT JOIN st_ivt_vehicle_detail vd ON vd.vd_id = t.group_id
|
||||
LEFT JOIN md_me_materialbase m ON m.material_id = vd.material_id
|
||||
WHERE t.handle_class = 'org.nl.wms.sch.task.call.material.SZCallMaterialTask'
|
||||
AND vd.vd_id IS NOT NULL AND vd.is_fire = 0 AND vd.vehicle_type = '2'
|
||||
GROUP BY m.material_code
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "5"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
SUM(vd.qty) AS qty,
|
||||
LEFT(m.material_code, 11) AS material_code
|
||||
FROM
|
||||
`st_ivt_vehicle_detail` vd
|
||||
LEFT JOIN md_me_materialbase m ON m.material_id = vd.material_id
|
||||
WHERE vd.is_fire = 1 AND vd.vehicle_type = '2'
|
||||
AND vd_id NOT IN (
|
||||
SELECT t.group_id FROM sch_base_task t WHERE t.handle_class = 'org.nl.wms.sch.task.send.material.SZSendMaterialTask'
|
||||
)
|
||||
GROUP BY m.material_code
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -209,4 +209,12 @@ public class AcsToWmsController {
|
||||
public ResponseEntity<Object> mark(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.mark(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/errorDeviceRecord")
|
||||
@Log("设备异常记录")
|
||||
@ApiOperation("设备异常记录")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> errorDeviceRecord(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.errorDeviceRecord(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,4 +118,6 @@ public interface AcsToWmsService {
|
||||
|
||||
|
||||
JSONObject mark(JSONObject whereJson);
|
||||
|
||||
JSONObject errorDeviceRecord(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.nl.wms.basedata.eum.StandStatus;
|
||||
import org.nl.wms.basedata.eum.TrueOrFalse;
|
||||
import org.nl.wms.basedata.eum.VehicleType;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.nl.wms.cockpit.service.enums.ErrorInfoEnum;
|
||||
import org.nl.wms.common.PickType;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
@@ -1024,4 +1025,29 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
throw new BadRequestException("[" + VehicleType.get(String.valueOf(vehicle_type)).label() + "] [" + vehicle_code + "] 无信息!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public JSONObject errorDeviceRecord(JSONObject device) {
|
||||
/**
|
||||
* 1.急停中
|
||||
* 2.光幕报警
|
||||
* 3.本体报警
|
||||
* 4.未排产报警
|
||||
* 5.扫码故障
|
||||
*/
|
||||
WQLObject dasDeviceNumber = WQLObject.getWQLObject("DAS_device_number");
|
||||
String deviceCode = device.getString("device_code");
|
||||
String errorInfo = device.getString("error");
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("data_id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
res.put("device_code", deviceCode);
|
||||
res.put("failure_info", ErrorInfoEnum.getErrorInfoEnumByCode(errorInfo).getName());
|
||||
res.put("failure_time", DateUtil.now());
|
||||
dasDeviceNumber.insert(res);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "故障上报完成!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user