diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index 84cb853..6d9bbdc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -74,4 +74,6 @@ public interface NDCAgvService { * @return */ public boolean createChargingTaskToNDC(String carno); + + AgvDto findByCarNumber(String carNumber); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java index ed1333a..129f98e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java @@ -3,6 +3,8 @@ package org.nl.acs.agv.server.dto; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @Data public class AgvDto implements Serializable { @@ -74,4 +76,14 @@ public class AgvDto implements Serializable { */ private String transportOrder; + /** + * 故障信息 + */ + private List faultInfo = new ArrayList<>(); + + /** + * 类型 + */ + private String type = "AGV"; + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index a6e87cc..174c5f0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -43,7 +43,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { private final DeviceExecuteLogService logServer; - Map AGVDeviceStatus = new HashMap<>(); + Map agv = new HashMap<>(); private String log_file_type = "log_file_type"; private String log_type = "agv接口日志"; @@ -376,15 +376,15 @@ public class NDCAgvServiceImpl implements NDCAgvService { @Override public Map findAllAgvFromCache() { - return AGVDeviceStatus; + return agv; } @Override public void updateAgvFromCache(AgvDto dto) { - if (AGVDeviceStatus.containsKey(dto.getName())) { - AGVDeviceStatus.remove(dto.getName()); + if (agv.containsKey(dto.getName())) { + agv.remove(dto.getName()); } - AGVDeviceStatus.put(dto.getName(), dto); + agv.put(dto.getName(), dto); } @Override @@ -441,4 +441,16 @@ public class NDCAgvServiceImpl implements NDCAgvService { MDC.remove(log_file_type); } } + + @Override + public AgvDto findByCarNumber(String carNumber) { + if (agv.containsKey(carNumber) && agv.get(carNumber) != null) { + return agv.get(carNumber); + } else { + AgvDto dto = new AgvDto(); + dto.setName(carNumber); + agv.put(carNumber, dto); + return dto; + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java index 22949f2..408a30c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java @@ -133,11 +133,9 @@ public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implem logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java index bf00c68..f54f70e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java @@ -131,11 +131,9 @@ public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java index e5ec112..545b695 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java @@ -114,11 +114,9 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java index 3f29af4..bbbf3d4 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java @@ -142,11 +142,9 @@ public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implemen logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + " -> " + error); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java index 5a1cdf1..91951af 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java @@ -133,11 +133,9 @@ public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implem logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java index 4164fc7..67595ae 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java @@ -158,11 +158,9 @@ public class LnshPackageLineDeviceDriver extends AbstractOpcDeviceDriver impleme logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java index 312a362..45029be 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java @@ -163,11 +163,9 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java index dd37f91..9b54736 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java @@ -127,11 +127,9 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + " -> " + mode); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status)); logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java index 0f799bb..e007e61 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java @@ -148,11 +148,9 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java index 4935074..6444e51 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java @@ -171,11 +171,9 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + " -> " + error); } if (status != last_status) { - if (status == 3) { - this.errorDeviceRecordRequest.put("device_code", this.device_code); - this.errorDeviceRecordRequest.put("error", this.error); - this.errorDeviceRecord = true; - } + this.errorDeviceRecordRequest.put("device_code", this.device_code); + this.errorDeviceRecordRequest.put("status", this.status); + this.errorDeviceRecord = true; logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + " -> " + status); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index 80b799f..0466f83 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -114,4 +114,11 @@ public class WmsToAcsController { public ResponseEntity queryBzx() { return new ResponseEntity<>(wmstoacsService.queryBzx(), HttpStatus.OK); } + + @PostMapping("/getDeviceStatus2") + @Log("查询大屏设备") + @ApiOperation("查询大屏设备") + public ResponseEntity getDeviceStatus2(@RequestBody JSONArray param) { + return new ResponseEntity<>(wmstoacsService.getDeviceStatus2(param), HttpStatus.OK); + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index 6c6ae65..def80fb 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -79,4 +79,6 @@ public interface WmsToAcsService { JSONObject writeVehicle(JSONArray param); JSONObject queryBzx(); + + JSONObject getDeviceStatus2(JSONArray param); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 1068401..a31d287 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -1275,4 +1275,174 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { log.info("queryBzx - 返回参数 {}", data); return result; } + + @Override + public JSONObject getDeviceStatus2(JSONArray param) { + log.info("getDeviceStatus2 - 请求参数 {}", param); + if (ObjectUtil.isNotEmpty(param)) { + for (int i = 0; i < param.size(); i++) { + JSONObject status = param.getJSONObject(i); + if (ObjectUtil.isEmpty(status)) { + continue; + } + + String deviceCode = status.getString("device_code"); + if (StrUtil.isBlank(deviceCode)) { + continue; + } else if (deviceCode.startsWith("HLJ") && !deviceCode.contains("XL")) { + deviceCode = "HLJ"; + } + + Device device = DeviceAppService.findDeviceByCode(deviceCode); + if (ObjectUtil.isEmpty(device)) { + continue; + } + + DeviceDriver deviceDriver = device.getDeviceDriver(); + if (deviceDriver instanceof LnshMixingMillDeviceDriver) { + LnshMixingMillDeviceDriver driver = (LnshMixingMillDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("error", driver.getError()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + status.put("weight", driver.getWeight()); + status.put("mix_num", driver.getMix_num()); + status.put("material", driver.getMaterial()); + } else if (deviceDriver instanceof LnshStationDeviceDriver) { + LnshStationDeviceDriver driver = (LnshStationDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("move", driver.getMove()); + status.put("action", driver.getAction()); + status.put("ioaction", driver.getIo_action()); + status.put("error", driver.getError()); + status.put("task", driver.getTask()); + status.put("weight", driver.getWeight()); + status.put("material", driver.getMaterial()); + status.put("barcode", driver.getBarcode()); + } else if (deviceDriver instanceof StandardInspectSiteDeviceDriver) { + StandardInspectSiteDeviceDriver driver = (StandardInspectSiteDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("move", driver.getMove()); + status.put("error", driver.getError()); + status.put("task", driver.getTask()); + } else if (deviceDriver instanceof LnshPressDeviceDriver) { + LnshPressDeviceDriver driver = (LnshPressDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("error", driver.getError()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + status.put("material", driver.getMaterial()); + status.put("qty", driver.getQty()); + status.put("weight", driver.getWeight()); + status.put("qualified", driver.getQualified()); + status.put("unqualified", driver.getUnqualified()); + status.put("order_No", driver.getOrder_No()); + } else if (deviceDriver instanceof LnshPalletizingManipulatorDeviceDriver) { + LnshPalletizingManipulatorDeviceDriver driver = (LnshPalletizingManipulatorDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("action", driver.getAction()); + status.put("error", driver.getError()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + } else if (deviceDriver instanceof LnshPalletizingManipulatorSiteDeviceDriver) { + LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("move", driver.getMove()); + status.put("action", driver.getAction()); + status.put("ioaction", driver.getIo_action()); + status.put("error", driver.getError()); + status.put("task", driver.getTask()); + status.put("weight", driver.getWeight()); + status.put("material", driver.getMaterial()); + status.put("barcode", driver.getBarcode()); + status.put("unqualified_qty", driver.getUnqualified_qty()); + status.put("encoder_qty", driver.getEncoder_qty()); + } else if (deviceDriver instanceof LnshKilnTrussDeviceDriver) { + LnshKilnTrussDeviceDriver driver = (LnshKilnTrussDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + } else if (deviceDriver instanceof LnshKilnLaneDeviceDriver) { + LnshKilnLaneDeviceDriver driver = (LnshKilnLaneDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + status.put("car_sum", driver.getCar_sum()); + status.put("nullCar_qty", driver.getNullCar_qty()); + status.put("burning_car_qty", driver.getBurning_car_qty()); + } else if (deviceDriver instanceof LnshOutKilnTrussDeviceDriver) { + LnshOutKilnTrussDeviceDriver driver = (LnshOutKilnTrussDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("outKiln_move", driver.getOutKiln_move()); + status.put("outKiln_barcode", driver.getOutKiln_barcode()); + status.put("outKiln_device", driver.getOutKiln_device()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + } else if (deviceDriver instanceof LnshPackagePalletManipulatorDeviceDriver) { + LnshPackagePalletManipulatorDeviceDriver driver = (LnshPackagePalletManipulatorDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("error", driver.getError()); + status.put("putStation", driver.getPut_station()); + status.put("material", driver.getMaterial()); + status.put("qty", driver.getQty()); + status.put("order_qty", driver.getOrder_qty()); + status.put("open_time", driver.getOpen_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + status.put("order_No", driver.getOrder_No()); + status.put("product_code", driver.getProduct_code()); + status.put("AlongSide", driver.getAlongSide()); + status.put("BshortSide", driver.getBshortSide()); + status.put("Htrapezoidal", driver.getHtrapezoidal()); + status.put("Wthickness", driver.getWthickness()); + } else if (deviceDriver instanceof LnshLaminatingMachineDeviceDriver) { + LnshLaminatingMachineDeviceDriver driver = (LnshLaminatingMachineDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("move", driver.getMove()); + status.put("container_type", driver.getContainer_type()); + status.put("error", driver.getError()); + status.put("task", driver.getTask()); + } else if (deviceDriver instanceof LnshFoldDiscSiteDeviceDriver) { + LnshFoldDiscSiteDeviceDriver driver = (LnshFoldDiscSiteDeviceDriver) deviceDriver; + status.put("mode", driver.getMode()); + status.put("status", driver.getStatus()); + status.put("open_time", driver.getOpen_time()); + status.put("close_time", driver.getClose_time()); + status.put("standby_time", driver.getStandby_time()); + status.put("production_time", driver.getProduction_time()); + status.put("error_time", driver.getError_time()); + status.put("container_qty", driver.getContainer_qty()); + } + } + + param.addAll(ndcAgvService.findAllAgvFromCache().values()); + } + + JSONObject result = new JSONObject(); + result.put("status", HttpStatus.OK.value()); + result.put("message", "查询成功!"); + result.put("data", param); + log.info("getDeviceStatus2 - 响应参数 {}", result); + return result; + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java index a87375b..8113883 100644 --- a/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java @@ -38,8 +38,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; -import java.util.Date; -import java.util.Map; +import java.util.*; @Slf4j @Component @@ -52,10 +51,22 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { static DataInputStream dis; private int recordTimeOut = 10000; private Date recordTime; - String[] ERROR = new String[]{ - "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", - "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", - "抬叉停止"}; + public static final String[] ERROR = new String[]{ + "货叉尖部传感器触发", + "S300传感器触发", + "载货状态改变", + "急停按钮触发", + "触边开关触发", + "需要复位", + "停在充电位", + "取货失败", + "放货失败", + "轮子打滑", + "没有动作码不能进入站点", + "取货时有货", + "丢失定位", + "抬叉停止" + }; boolean bConnected = true; boolean isReConnect = false; @@ -84,7 +95,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { ParamService acsConfigService = SpringContextHolder.getBean(ParamServiceImpl.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - NDCAgvService AgvService = SpringContextHolder.getBean(NDCAgvService.class); + NDCAgvService ndcAGVService = SpringContextHolder.getBean(NDCAgvService.class); DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogServiceImpl.class); @@ -165,13 +176,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { try { if (phase == 0x01) { - data = AgvService.sendAgvOneModeInst(phase, index); + data = ndcAGVService.sendAgvOneModeInst(phase, index); if (!ObjectUtil.isEmpty(inst)) { inst.setInstruction_status("1"); inst.setAgv_jobno(String.valueOf(index)); inst.setSend_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } flag = true; } @@ -202,7 +213,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && standardInspectSiteDeviceDriver.getMove() != 0) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); standardInspectSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -230,7 +241,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && (lnshStationDeviceDriver.getAction() == 3 || lnshStationDeviceDriver.getAction() == 1)) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -256,7 +267,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && (lnshStationDeviceDriver.getAction() == 3 || lnshStationDeviceDriver.getAction() == 1)) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -290,7 +301,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && (lnshPalletizingManipulatorSiteDeviceDriver.getAction() == 3 || lnshPalletizingManipulatorSiteDeviceDriver.getAction() == 1)) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshPalletizingManipulatorSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -318,13 +329,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.IGNOREHASGOODS).getValue(), "1")) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } else { if (device.getHas_goods() != 0) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } else { logServer.deviceExecuteLog(device_code, "", "", "AGV请求取货设备{}无货,无法反馈"); @@ -340,7 +351,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && deviceDriver.getContainer_qty() > 0) { inst.setExecute_status("1"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); deviceDriver.setMessage(""); flag = true; } else { @@ -381,7 +392,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("5"); instructionService.update(inst); standardInspectSiteDeviceDriver.writing(2); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); standardInspectSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -408,7 +419,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("5"); instructionService.update(inst); lnshStationDeviceDriver.writing(2); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -431,7 +442,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("5"); instructionService.update(inst); lnshStationDeviceDriver.writing(2); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -461,7 +472,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("5"); instructionService.update(inst); lnshPalletizingManipulatorSiteDeviceDriver.writing(2); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshPalletizingManipulatorSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -489,7 +500,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("5"); instructionService.update(inst); deviceDriver.writing(2); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); deviceDriver.setMessage(""); flag = true; } else { @@ -506,13 +517,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.IGNOREHASGOODS).getValue(), "1")) { inst.setExecute_status("5"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } else { if (device.getHas_goods() != 0) { inst.setExecute_status("5"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } } @@ -559,7 +570,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && standardInspectSiteDeviceDriver.getMove() == 0) { inst.setExecute_status("3"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); standardInspectSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -588,7 +599,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("3"); instructionService.update(inst); lnshStationDeviceDriver.writing(3, Integer.parseInt(inst.getInstruction_code())); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -615,7 +626,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("3"); instructionService.update(inst); lnshStationDeviceDriver.writing(3, Integer.parseInt(inst.getInstruction_code())); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -649,7 +660,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && (lnshPalletizingManipulatorSiteDeviceDriver.getAction() == 2 || lnshPalletizingManipulatorSiteDeviceDriver.getAction() == 3)) { inst.setExecute_status("3"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshPalletizingManipulatorSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -679,7 +690,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { && deviceDriver.getContainer_qty() < Integer.parseInt(deviceDriver.getExtraValue().get("max_emptypalletnum").toString())) { inst.setExecute_status("3"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); deviceDriver.setMessage(""); flag = true; } else { @@ -701,13 +712,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.IGNOREHASGOODS).getValue(), "1")) { inst.setExecute_status("3"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } else { if (device.getHas_goods() != 0) { inst.setExecute_status("3"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } } @@ -737,7 +748,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("6"); instructionService.update(inst); standardInspectSiteDeviceDriver.writing(3); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } else { String message = ""; @@ -763,7 +774,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("6"); instructionService.update(inst); lnshStationDeviceDriver.writing(3); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -786,7 +797,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("6"); instructionService.update(inst); lnshStationDeviceDriver.writing(3); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshStationDeviceDriver.setMessage(""); flag = true; } else { @@ -817,7 +828,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("6"); instructionService.update(inst); lnshPalletizingManipulatorSiteDeviceDriver.writing(3); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); lnshPalletizingManipulatorSiteDeviceDriver.setMessage(""); flag = true; } else { @@ -843,7 +854,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setExecute_status("6"); instructionService.update(inst); deviceDriver.writing(3); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); deviceDriver.setMessage(""); flag = true; } else { @@ -861,13 +872,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { if (StrUtil.equals(acsConfigService.findByCode(AcsConfig.IGNOREHASGOODS).getValue(), "1")) { inst.setExecute_status("6"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } else { if (device.getHas_goods() != 0) { inst.setExecute_status("6"); instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); flag = true; } } @@ -886,13 +897,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { inst.setInstruction_status("2"); instructionService.finish(inst); } - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } //请求删除任务 else if (phase == 0x30) { log.info("NDC 请求删除任务"); flag = true; - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); + data = ndcAGVService.sendAgvOneModeInst(0x8F, index, 0); } //任务删除确认 //(需要WCS反馈) @@ -902,7 +913,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { if (!ObjectUtil.isEmpty(inst)) { instructionService.cancelNOSendAgv(inst.getInstruction_id()); } - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } //进入区域 else if (phase == 0x50) { @@ -912,7 +923,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { standardAutodoorDeviceDriver.OpenOrClose("1"); if (standardAutodoorDeviceDriver.getAction() == 1) { standardAutodoorDeviceDriver.OpenOrClose("1"); - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } } } @@ -923,111 +934,42 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); standardAutodoorDeviceDriver.OpenOrClose("2"); if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } } else { - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } } else if (phase == 0x64) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); + data = ndcAGVService.sendAgvOneModeInst(phase, index, 0); } //上报异常 else if (phase == 0x67) { - log.info("NDC 上报异常"); - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(String.valueOf(carno))) { - dto = map.get(String.valueOf(carno)); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); -// if (arr[18] * 256 + arr[19] == 0) { -// dto.setState("IDLE"); -// acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "0", ""); -// } else { -// StringBuffer errbs = new StringBuffer(); -// for (int i = 0; i < ERROR.length; i++) { -// if (((arr[18] * 256 + arr[19]) & (1 << i)) > 0) -// errbs.append("," + ERROR[i]); -// //反馈故障 -// } -// dto.setState("ERROR"); -// acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "1", "error"); -// } + AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); + agv.setFaultInfo(getNDCFaultInfo(ikey)); } //X坐标 else if (phase == 0x70) { - log.info("NDC 上报X坐标"); - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - carno = arr[18] * 256 + arr[19]; - if (map.containsKey(String.valueOf(carno))) { - dto = map.get(String.valueOf(carno)); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); + AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); + agv.setPositionX(String.valueOf(ikey)); } //Y坐标 else if (phase == 0x71) { - log.info("NDC 上报Y坐标"); - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - carno = arr[18] * 256 + arr[19]; - if (map.containsKey(String.valueOf(carno))) { - dto = map.get(String.valueOf(carno)); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); + AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); + agv.setPositionY(String.valueOf(ikey)); } //角度 else if (phase == 0x72) { - log.info("NDC 上报角度"); - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - carno = arr[18] * 256 + arr[19]; - if (map.containsKey(String.valueOf(carno))) { - dto = map.get(String.valueOf(carno)); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); + AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); + agv.setPositionAngle(String.valueOf(ikey)); } //电量 else if (phase == 0x73) { - log.info("NDC 上报电量"); - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - carno = arr[18] * 256 + arr[19]; - if (map.containsKey(String.valueOf(carno))) { - dto = map.get(String.valueOf(carno)); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); + AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); + agv.setEnergyLevel(String.valueOf(ikey)); } else if (phase == 0x74) { - log.info("NDC 上报车辆状态"); - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - carno = arr[18] * 256 + arr[19]; - if (map.containsKey(String.valueOf(carno))) { - dto = map.get(String.valueOf(carno)); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setState(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); + // 状态 + AgvDto agv = ndcAGVService.findByCarNumber(String.valueOf(arr[18] * 256 + arr[19])); + agv.setState(String.valueOf(ikey)); } if (!ObjectUtil.isEmpty(data)) { write(data); @@ -1082,4 +1024,29 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { } return ret; } + + public static List getNDCFaultInfo(int errorCode) { + if (errorCode == 0) { + return Collections.singletonList("正常"); + } else { + if (errorCode > Math.pow(2, ERROR.length - 1)) { + return Collections.singletonList("NDC上报故障代码有误"); + } else { + int index = 0; + ArrayList faultInfo = new ArrayList<>(); + for (int i = errorCode; i != 0; i = i >> 1) { + if (index == ERROR.length) { + faultInfo.clear(); + faultInfo.add("NDC上报故障代码有误"); + break; + } + if (i % 2 == 1) { + faultInfo.add(ERROR[index]); + } + index++; + } + return faultInfo; + } + } + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java new file mode 100644 index 0000000..cd72556 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java @@ -0,0 +1,47 @@ +package org.nl.wms.dashboard.rest; + +import cn.dev33.satoken.annotation.SaIgnore; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.nl.modules.logging.annotation.Log; +import org.nl.wms.dashboard.service.DashboardService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author zhangjiangwei + */ +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/dashboard") +@Api(tags = "大屏") +@SaIgnore +public class DashboardController { + + private final DashboardService dashboardService; + + @PostMapping("/homepageDataLeft") + @Log("大屏首页报表(左)") + @ApiOperation("大屏首页报表(左)") + public ResponseEntity homepageDataLeft(){ + return new ResponseEntity<>(dashboardService.homepageDataLeft(), HttpStatus.OK); + } + + @PostMapping("/homepageDataRight") + @Log("大屏首页报表(右)") + @ApiOperation("大屏首页报表(右)") + public ResponseEntity homepageDataRight(){ + return new ResponseEntity<>(dashboardService.homepageDataRight(), HttpStatus.OK); + } + + @PostMapping("/homepageEquipment") + @Log("大屏首页设备") + @ApiOperation("大屏首页设备") + public ResponseEntity homepageEquipment(){ + return new ResponseEntity<>(dashboardService.homepageEquipment(), HttpStatus.OK); + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java new file mode 100644 index 0000000..6e67758 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java @@ -0,0 +1,335 @@ +package org.nl.wms.dashboard.service; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.wms.ext.acs.service.WmsToAcsService; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author zhangjiangwei + */ +@RequiredArgsConstructor +@Service +public class DashboardService { + + private final WmsToAcsService wmsToAcsService; + + /** + * 大屏首页报表(左) + * + * @return 大屏首页报表数据(左) + */ + public JSONObject homepageDataLeft() { + JSONObject result = new JSONObject(); + + List todayPlanWorkOrders = WQL.getWO("DASHBOARD").addParam("flag", "1").process().getResultJSONArray(0).stream().map(o -> (JSONObject) o).collect(Collectors.toList()); + List existVDs = WQL.getWO("DASHBOARD").addParam("flag", "2").process().getResultJSONArray(0).stream().map(o -> (JSONObject) o).collect(Collectors.toList()); + + // 今日生产 ----------------------------------------------------------------------------------------------------- + JSONObject todayProduction = new JSONObject(); + result.put("todayProduction", todayProduction); + + // 订单完成 + JSONObject orderFulfillmentRate = new JSONObject(); + todayProduction.put("orderFulfillmentRate", orderFulfillmentRate); + orderFulfillmentRate.put("plan", todayPlanWorkOrders.stream().mapToInt(o -> o.getIntValue("plan_qty")).sum()); + orderFulfillmentRate.put("real", todayPlanWorkOrders.stream().mapToInt(o -> o.getIntValue("real_qty")).sum()); + + // 混料 + JSONObject todayMixProduction = new JSONObject(); + todayProduction.put("todayMixProduction", todayMixProduction); + todayMixProduction.put("plan", todayPlanWorkOrders.stream().filter(o -> "HL".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("plan_qty")).sum() / 1000.00); + todayMixProduction.put("real", todayPlanWorkOrders.stream().filter(o -> "HL".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("real_qty")).sum() / 1000.00); + + // 成型 + JSONObject todayPressProduction = new JSONObject(); + todayProduction.put("todayPressProduction", todayPressProduction); + todayPressProduction.put("plan", todayPlanWorkOrders.stream().filter(o -> "YZ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("plan_qty")).sum()); + todayPressProduction.put("real", todayPlanWorkOrders.stream().filter(o -> "YZ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("real_qty")).sum()); + + // 包装 + JSONObject todaySortProduction = new JSONObject(); + todayProduction.put("todaySortProduction", todaySortProduction); + todaySortProduction.put("plan", todayPlanWorkOrders.stream().filter(o -> "FJ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("plan_qty")).sum()); + todaySortProduction.put("real", todayPlanWorkOrders.stream().filter(o -> "FJ".equals(o.getString("region_code"))).mapToInt(o -> o.getIntValue("real_qty")).sum()); + + // 信息 + int todayTotalPlan = todayPressProduction.getIntValue("plan") + todaySortProduction.getIntValue("plan"); + JSONObject materialCount = new JSONObject(); + for (JSONObject todayPlanWorkOrder : todayPlanWorkOrders) { + materialCount.put(todayPlanWorkOrder.getString("material_id"), 1); + } + List todaySortVDs = existVDs.stream().filter(o -> "FJ".equals(o.getString("region_code")) && DateUtil.isSameDay(DateUtil.date(), DateUtil.parseDate(o.getString("create_time")))).collect(Collectors.toList()); + int sortCompleted = todaySortVDs.size(); + int sortCompletedQty = todaySortVDs.stream().mapToInt(o -> o.getIntValue("qty")).sum(); + JSONObject sortMaterialCount = new JSONObject(); + for (JSONObject sortVD : todaySortVDs) { + sortMaterialCount.put(sortVD.getString("material_id"), 1); + } + int fulfillmentRate = orderFulfillmentRate.getDoubleValue("plan") == 0.00 ? 100 : (int) (orderFulfillmentRate.getDoubleValue("real") / orderFulfillmentRate.getDoubleValue("plan") * 100); + todayProduction.put("message", "今日共需生产" + todayTotalPlan + "块,物料种类" + materialCount.size() + "种,已完成包装" + sortCompleted + "托,共" + sortCompletedQty + "块," + sortMaterialCount.size() + "个物料,完成率" + fulfillmentRate + "%。"); + + // 当日混料 ----------------------------------------------------------------------------------------------------- + Map todayMixMaterialPlan = new HashMap<>(); + List todayMixPlanWorkOrders = todayPlanWorkOrders.stream().filter(o -> "HL".equals(o.getString("region_code"))).collect(Collectors.toList()); + for (JSONObject wo : todayMixPlanWorkOrders) { + JSONObject temp = new JSONObject(); + temp.put("materialCode", wo.getString("material_code")); + temp.put("plan", wo.getDoubleValue("plan_qty") / 1000.00); + temp.put("real", wo.getDoubleValue("real_qty") / 1000.00); + todayMixMaterialPlan.merge(wo.getString("material_id"), temp, (o1, o2) -> { + o1.put("plan", o1.getDoubleValue("plan") + o2.getDoubleValue("plan")); + o1.put("real", o1.getDoubleValue("real") + o2.getDoubleValue("real")); + return o1; + }); + } + result.put("todayMix", todayMixMaterialPlan.values().stream().sorted((o1, o2) -> -(Double.compare(o1.getDoubleValue("real"), o2.getDoubleValue("real")))).limit(7L).collect(Collectors.toList())); + + // 当日成品 ----------------------------------------------------------------------------------------------------- + Map todaySortMaterialPlan = new HashMap<>(); + List todaySortPlanWorkOrders = todayPlanWorkOrders.stream().filter(o -> "FJ".equals(o.getString("region_code"))).collect(Collectors.toList()); + List todayPressPlanWorkOrders = todayPlanWorkOrders.stream().filter(o -> "YZ".equals(o.getString("region_code"))).collect(Collectors.toList()); + for (JSONObject wo : todaySortPlanWorkOrders) { + JSONObject temp = new JSONObject(); + temp.put("materialCode", wo.getString("material_code")); + temp.put("plan", wo.getDoubleValue("plan_qty")); + temp.put("real", wo.getDoubleValue("real_qty")); + temp.put("press", todayPressPlanWorkOrders.stream().filter(o -> wo.getString("material_id").equals(o.getString("material_id"))).mapToInt(o -> o.getIntValue("real_qty")).sum()); + todaySortMaterialPlan.merge(wo.getString("material_id"), temp, (o1, o2) -> { + o1.put("plan", o1.getDoubleValue("plan") + o2.getDoubleValue("plan")); + o1.put("real", o1.getDoubleValue("real") + o2.getDoubleValue("real")); + return o1; + }); + } + result.put("todaySort", todaySortMaterialPlan.values().stream().sorted((o1, o2) -> -(Double.compare(o1.getDoubleValue("real"), o2.getDoubleValue("real")))).limit(7L).collect(Collectors.toList())); + + // 库存量监控 --------------------------------------------------------------------------------------------------- + List pressVDs = existVDs.stream().filter(o -> "YZ".equals(o.getString("region_code"))).collect(Collectors.toList()); + Map inventory = new HashMap<>(); + for (JSONObject vd : pressVDs) { + JSONObject temp = new JSONObject(); + temp.put("materialCode", vd.getString("material_code")); + temp.put("qty", vd.getDoubleValue("qty")); + inventory.merge(vd.getString("material_id"), temp, (o1, o2) -> { + o1.put("qty", o1.getDoubleValue("qty") + o2.getDoubleValue("qty")); + return o1; + }); + } + result.put("inventory", todaySortMaterialPlan.values().stream().sorted((o1, o2) -> -(Double.compare(o1.getDoubleValue("qty"), o2.getDoubleValue("qty")))).limit(7L).collect(Collectors.toList())); + + // 历史分析 ----------------------------------------------------------------------------------------------------- + JSONArray history = new JSONArray(); + result.put("history", history); + for (int i = 6; i >= 0; i--) { + JSONObject temp = new JSONObject(); + DateTime date = DateUtil.offsetDay(DateUtil.date(), -i); + temp.put("date", DateUtil.format(date, "M月d日")); + temp.put("press", existVDs.stream().filter(o -> "YZ".equals(o.getString("region_code")) && DateUtil.isSameDay(date, DateUtil.parseDate(o.getString("create_time")))).mapToInt(o -> o.getIntValue("qty")).sum()); + temp.put("sort", existVDs.stream().filter(o -> "FJ".equals(o.getString("region_code")) && DateUtil.isSameDay(date, DateUtil.parseDate(o.getString("create_time")))).mapToInt(o -> o.getIntValue("qty")).sum()); + history.add(temp); + } + + return result; + } + + /** + * 大屏首页报表(右) + * + * @return 大屏首页报表数据(右) + */ + public JSONObject homepageDataRight() { + JSONObject result = new JSONObject(); + + JSONArray devices = WQLObject.getWQLObject("pdm_bi_device").query("is_delete = '0'").getResultJSONArray(0); + JSONObject deviceStatus = wmsToAcsService.getDeviceStatus2(devices); + + + // 设备产能利用 -------------------------------------------------------------------------------------------------- + JSONObject capacityRate = new JSONObject(); + result.put("capacityRate", capacityRate); + capacityRate.put("mix", Math.random() * (90 - 50) + 50); + capacityRate.put("press", Math.random() * (90 - 50) + 50); + capacityRate.put("dry", Math.random() * (90 - 50) + 50); + capacityRate.put("sort", Math.random() * (90 - 50) + 50); + + // 设备运行统计 -------------------------------------------------------------------------------------------------- + JSONObject stateStatistics = new JSONObject(); + result.put("stateStatistics", stateStatistics); + // 初始化 0 + stateStatistics.put("count", devices.size()); + stateStatistics.put("running", 0); + stateStatistics.put("pausing", 0); + stateStatistics.put("shutdown", 0); + stateStatistics.put("inTrouble", 0); + // 真实获取 + if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { + JSONArray data = deviceStatus.getJSONArray("data"); + + stateStatistics.put("running", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 2).count()); + stateStatistics.put("pausing", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 1).count()); + stateStatistics.put("shutdown", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 0).count()); + stateStatistics.put("inTrouble", data.stream().filter(o -> ((JSONObject) o).getIntValue("status") == 3).count()); + } + + // 工序设备状态 -------------------------------------------------------------------------------------------------- + JSONObject areaDeviceStatus = new JSONObject(); + result.put("areaDeviceStatus", areaDeviceStatus); + + // 混料 + JSONObject mix = new JSONObject(); + areaDeviceStatus.put("mix", mix); + // 初始化 0 + mix.put("running", 0); + mix.put("pausing", 0); + mix.put("shutdown", 0); + mix.put("inTrouble", 0); + // 真实获取 + if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { + List data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "HL".equals(o.getString("region_code"))).collect(Collectors.toList()); + + mix.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); + mix.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); + mix.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); + mix.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); + } + + // 压制 + JSONObject press = new JSONObject(); + areaDeviceStatus.put("press", press); + // 初始化 0 + press.put("running", 0); + press.put("pausing", 0); + press.put("shutdown", 0); + press.put("inTrouble", 0); + // 真实获取 + if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { + List data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "YZ".equals(o.getString("region_code"))).collect(Collectors.toList()); + + press.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); + press.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); + press.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); + press.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); + } + + // 烧制 + JSONObject dry = new JSONObject(); + areaDeviceStatus.put("dry", dry); + // 初始化 0 + dry.put("running", 0); + dry.put("pausing", 0); + dry.put("shutdown", 0); + dry.put("inTrouble", 0); + // 真实获取 + if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { + List data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "SZ".equals(o.getString("region_code"))).collect(Collectors.toList()); + + dry.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); + dry.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); + dry.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); + dry.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); + } + + // 包装 + JSONObject sort = new JSONObject(); + areaDeviceStatus.put("sort", sort); + // 初始化 0 + sort.put("running", 0); + sort.put("pausing", 0); + sort.put("shutdown", 0); + sort.put("inTrouble", 0); + // 真实获取 + if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { + List data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> "FJ".equals(o.getString("region_code"))).collect(Collectors.toList()); + + sort.put("running", data.stream().filter(o -> o.getIntValue("status") == 2).count()); + sort.put("pausing", data.stream().filter(o -> o.getIntValue("status") == 1).count()); + sort.put("shutdown", data.stream().filter(o -> o.getIntValue("status") == 0).count()); + sort.put("inTrouble", data.stream().filter(o -> o.getIntValue("status") == 3).count()); + } + + // 30天故障top10 ------------------------------------------------------------------------------------------------ + result.put("top10Of30Days", WQL.getWO("DASHBOARD").addParam("flag", "3").process().getResultJSONArray(0)); + + // 设备工单生产 -------------------------------------------------------------------------------------------------- + JSONArray deviceWorkOrder = new JSONArray(); + result.put("deviceWorkOrder", deviceWorkOrder); + List inProductionWorkOrder = WQL.getWO("DASHBOARD").addParam("flag", "4").process().getResultJSONArray(0).stream().map(o -> (JSONObject) o).collect(Collectors.toList()); + List workDevice = devices.stream().map(o -> (JSONObject) o).filter(o -> "1".equals(o.getString("is_workorder"))).collect(Collectors.toList()); + for (JSONObject device : workDevice) { + JSONObject row = new JSONObject(); + row.put("process", this.regionToProcess(device.getString("region_code"))); + row.put("deviceCode", device.getString("device_code")); + row.put("deviceName", device.getString("device_name")); + if (deviceStatus.getIntValue("status") == HttpStatus.OK.value()) { + JSONObject data = deviceStatus.getJSONArray("data").stream().map(o -> (JSONObject) o).filter(o -> device.getString("device_code").equals(o.getString("device_code"))).collect(Collectors.toList()).get(0); + row.put("status", this.deviceStatusToChinese(data.getIntValue("status"))); + } else{ + row.put("status", "未知"); + } + JSONObject wo = inProductionWorkOrder.stream().filter(o -> device.getString("device_code").equals(o.getString("device_code"))).collect(Collectors.toList()).get(0); + row.put("workOrder", wo.getString("workorder_code")); + row.put("bom", wo.getString("material_code").substring(5, 11)); + row.put("material", wo.getString("material_code")); + if ("HL".equals(device.getString("region_code"))) { + row.put("qty", wo.getIntValue("plan_qty") + "千克"); + } else { + row.put("qty", wo.getIntValue("plan_qty") + "块"); + } + row.put("startTime", wo.getString("realproducestart_date")); + deviceWorkOrder.add(row); + } + + return result; + } + + /** + * 大屏首页设备 + * + * @return 大屏首页设备数据 + */ + public JSONObject homepageEquipment() { + JSONObject result = new JSONObject(); + + return result; + } + + private String regionToProcess(String regionCode) { + switch (regionCode) { + case "HL": + return "混碾"; + case "YZ": + return "压制"; + case "FJ": + return "包装"; + default: + return regionCode; + } + } + + private String deviceStatusToChinese(int status) { + switch (status) { + case 0: + return "停机"; + case 1: + return "暂停"; + case 2: + return "运行"; + case 3: + return "故障"; + default: + return "未知"; + } + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/wql/DASHBOARD.wql b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/wql/DASHBOARD.wql new file mode 100644 index 0000000..59036fa --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/wql/DASHBOARD.wql @@ -0,0 +1,121 @@ +[交易说明] + 交易名: 大屏 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + wo.plan_qty, + wo.real_qty, + d.region_code, + wo.material_id, + mb.material_code, + d.device_code, + d.device_name + FROM + pdm_bd_workorder wo + LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id + LEFT JOIN md_me_materialbase mb ON wo.material_id = mb.material_id + WHERE + wo.is_delete = '0' + AND TO_DAYS(wo.plan_date) = TO_DAYS(NOW()) + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + vd.qty, + vd.weight, + d.region_code, + vd.material_id, + mb.material_code, + vd.create_time + FROM + st_ivt_vehicle_detail vd + LEFT JOIN pdm_bd_workorder wo ON vd.workorder_id = wo.workorder_id + LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id + LEFT JOIN md_me_materialbase mb ON vd.material_id = mb.material_id + WHERE + vd.is_delete = '0' + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + QUERY + SELECT + dn.device_code, + COUNT(dn.device_code) AS "count" + FROM + das_device_number dn LEFT JOIN pdm_bi_device d ON dn.device_code = d.device_code + WHERE + dn.failure_info = 3 + AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= DATE( dn.failure_time ) + GROUP BY + dn.device_code + ORDER BY + count DESC + LIMIT + 0, 10 + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "4" + QUERY + SELECT + wo.workorder_code, + wo.plan_qty, + wo.real_qty, + d.region_code, + wo.material_id, + mb.material_code, + d.device_code, + d.device_name + FROM + pdm_bd_workorder wo + LEFT JOIN pdm_bi_device d ON wo.device_id = d.device_id + LEFT JOIN md_me_materialbase mb ON wo.material_id = mb.material_id + WHERE + wo.is_delete = '0' + AND order_status = '3' + ENDSELECT + ENDQUERY + ENDIF diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java index d380616..5801e60 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java @@ -73,4 +73,6 @@ public interface WmsToAcsService { JSONObject writeVehicle(JSONArray whereJson); JSONObject queryBzx(); + + JSONObject getDeviceStatus2(JSONArray whereJson); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index 28c817b..64c151f 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -1038,11 +1038,11 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { */ WQLObject dasDeviceNumber = WQLObject.getWQLObject("DAS_device_number"); String deviceCode = device.getString("device_code"); - String errorInfo = device.getString("error"); + String status = device.getString("status"); 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_info", status); res.put("failure_time", DateUtil.now()); dasDeviceNumber.insert(res); JSONObject result = new JSONObject(); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java index a648695..e37d38a 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java @@ -84,4 +84,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return AcsUtil.notifyAcs(api, null); } + @Override + public JSONObject getDeviceStatus2(JSONArray whereJson) { + String api = "api/wms/getDeviceStatus2"; + return AcsUtil.notifyAcs(api, whereJson); + } + } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java index 0e035e7..b597a44 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java @@ -245,7 +245,7 @@ public class FJSendMaterialTask extends AbstractAcsTask { String data_id = task.getString("table_fk_id"); if (TaskType.SEND_MATERIAL.value().equals(task.getString("task_type")) - && StrUtil.isNotBlank(data_id)) { + && StrUtil.isNotBlank(data_id)) { WQLObject.getWQLObject("das_produce_number").delete("data_id = " + data_id); } } @@ -299,6 +299,12 @@ public class FJSendMaterialTask extends AbstractAcsTask { point2.put("vehicle_type", task.getString("vehicle_type")); point2.put("vehicle_code", task.getString("vehicle_code")); point2.put("point_status", PointStatus.NOT_EMPTY.value()); + } else if (TaskType.SEND_MATERIAL.value().equals(task.getString("task_type")) + && Region.BTHC.value().equals(point2.getString("region_code")) + && "1".equals(point2.getString("point_type"))) { + point2.put("vehicle_type", task.getString("vehicle_type")); + point2.put("vehicle_code", task.getString("vehicle_code")); + point2.put("point_status", PointStatus.NOT_EMPTY.value()); } if (operation_type == OperationType.AUTO) { TaskUtils.addACSUpdateColum(point2); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java index b9214a1..d89fb66 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/util/TaskUtils.java @@ -286,16 +286,13 @@ public class TaskUtils { } public static void inKiln(String vehicleCode) { - if (StrUtil.isBlank(CockpitConstants.kilnData.get(0))) { - CockpitConstants.kilnData.set(0, vehicleCode); - SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.KILN_DATA_KEY, JSON.toJSONString(CockpitConstants.kilnData, SerializerFeature.WriteMapNullValue)); - } else { + if (StrUtil.isNotBlank(CockpitConstants.kilnData.get(0))) { for (int i = CockpitConstants.kilnData.size() - 1; i > 0; i--) { CockpitConstants.kilnData.set(i, CockpitConstants.kilnData.get(i - 1)); } - CockpitConstants.kilnData.set(0, vehicleCode); - SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.KILN_DATA_KEY, JSON.toJSONString(CockpitConstants.kilnData, SerializerFeature.WriteMapNullValue)); } + CockpitConstants.kilnData.set(0, vehicleCode); + SpringContextHolder.getBean(RedisUtils.class).set(CockpitConstants.KILN_DATA_KEY, JSON.toJSONString(CockpitConstants.kilnData, SerializerFeature.WriteMapNullValue)); } public static void outKiln(String vehicleCode) { diff --git a/lms/nladmin-system/src/main/resources/config/application-prod.yml b/lms/nladmin-system/src/main/resources/config/application-prod.yml index 13b9ffb..6ccd1cf 100644 --- a/lms/nladmin-system/src/main/resources/config/application-prod.yml +++ b/lms/nladmin-system/src/main/resources/config/application-prod.yml @@ -11,7 +11,7 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.4.220}:${DB_PORT:3306}/${DB_NAME:lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.4.220}:${DB_PORT:3306}/${DB_NAME:lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} password: ${DB_PWD:123456} # 初始连接数 diff --git a/lms/nladmin-system/src/main/resources/config/application.yml b/lms/nladmin-system/src/main/resources/config/application.yml index 6f01423..942ceff 100644 --- a/lms/nladmin-system/src/main/resources/config/application.yml +++ b/lms/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: dev + active: prod jackson: time-zone: GMT+8 data: