diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 619a16d..7b82db9 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -81,192 +81,60 @@ public class NDCAgvServiceImpl implements NDCAgvService { ",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() + ",nextAddress:" + inst.getNext_point_code()); if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { - if (!StrUtil.equals(agv_system_type, "1")) { - String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getAgv_inst_type()); - int priority = Integer.parseInt(inst.getPriority()) + 128; - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); - int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); - int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2()); - int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2()); - byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); - byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); - byte typehigh = (byte) IntToHexHigh(type); - byte typelow = (byte) IntToHexLow(type); - byte qhdhigh = (byte) IntToHexHigh(startAddress); - byte qhdlow = (byte) IntToHexLow(startAddress); - byte qhdhigh2 = (byte) IntToHexHigh(startAddress2); - byte qhdlow2 = (byte) IntToHexLow(startAddress2); - byte fhdhigh = (byte) IntToHexHigh(nextAddress); - byte fhdlow = (byte) IntToHexLow(nextAddress); - byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2); - byte fhdlow2 = (byte) IntToHexLow(nextAddress2); - byte prioritylow = (byte) IntToHexLow(priority); - - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "任务号 ikey:" + (Integer.parseInt(instcode)); - str1 += "任务号 ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); - - str += "指令类型 /type:" + (type); - str1 += "指令类型 /type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); - - str += "取货点 /qhd:" + (startAddress); - str1 += "取货点 /qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); - str += "放货点 /fhd:" + (nextAddress); - str1 += "放货点 /fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - - str += "取货点2 /qhd2:" + (startAddress2); - str1 += "取货点2 /qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF); - str += "放货点2 /fhd2:" + (nextAddress2); - str1 += "放货点2 /fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF); - - str += "优先级 /priority:" + (priority); - str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF); - - byte[] b = new byte[]{}; - if (type == 1) { - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) qhdhigh2, (byte) qhdlow2, - (byte) fhdhigh, (byte) fhdlow, - (byte) fhdhigh2, (byte) fhdlow2 - }; - } else if (type == 2) { - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) 0X00, (byte) 0X00, - (byte) fhdhigh, (byte) fhdlow, - (byte) 0X00, (byte) 0X00 - }; - } else if (type == 3) { - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) qhdhigh2, (byte) qhdlow2, - (byte) fhdhigh, (byte) fhdlow, - (byte) fhdhigh2, (byte) fhdlow2 - }; - } - log.info("下发AGV作业指令 --{}", str1); - log.info("下发AGV作业指令--{}", str); - log.info("下发agv指令数据--{}", Bytes2HexString(b)); - - if (StrUtil.equals(agv_system_type, "2")) { - TwoNDCSocketConnectionAutoRun.write(b); - } - } else { - - String instcode = inst.getInstruction_code(); - int startHeight = Integer.parseInt(StrUtil.isEmpty(inst.getStart_height()) ? "0" : inst.getStart_height()); - int nextHeight = Integer.parseInt(StrUtil.isEmpty(inst.getNext_height()) ? "0" : inst.getNext_height()); - //默认取货放货高度都为0 - //int type = Integer.parseInt(inst.getInstruction_type()); - int type = 4; - if (startHeight != 0 && nextHeight != 0) { - //取货放货高度都不为0 - type = 1; - } else if (startHeight != 0 && nextHeight == 0) { - //取货高度不为0 放货高度为0 - type = 2; - } else if (startHeight == 0 && nextHeight != 0) { - //取货高度为0 放货高度不为0 - type = 3; - } - int priority = Integer.parseInt(inst.getPriority()) + 128; - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); - int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); - - byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); - byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); - byte typehigh = (byte) IntToHexHigh(type); - byte typelow = (byte) IntToHexLow(type); - byte qhdhigh = (byte) IntToHexHigh(startAddress); - byte qhdlow = (byte) IntToHexLow(startAddress); - byte fhdhigh = (byte) IntToHexHigh(nextAddress); - byte fhdlow = (byte) IntToHexLow(nextAddress); - byte prioritylow = (byte) IntToHexLow(priority); - - byte shhigh = (byte) IntToHexHigh(startHeight); - byte shlow = (byte) IntToHexLow(startHeight); - - byte nhhigh = (byte) IntToHexHigh(nextHeight); - byte nhlow = (byte) IntToHexLow(nextHeight); - - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "ikey:" + (Integer.parseInt(instcode)); - str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); - - str += "/type:" + (type); - str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); - - str += "/qhd:" + (startAddress); - str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); - str += "/fhd:" + (nextAddress); - str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - - str += "/priority:" + (priority); - str1 += "/priority:" + hexToString(prioritylow & 0xFF); - - System.out.println(str); - System.out.println(str1); - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X16, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X12, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) fhdhigh, (byte) fhdlow, - (byte) shhigh, (byte) shlow, - (byte) nhhigh, (byte) nhlow - }; - log.info("下发AGV作业指令 --{}", str1); - log.info("下发AGV作业指令--{}", str); - log.info("下发agv指令数据--{}", Bytes2HexString(b)); - OneNDCSocketConnectionAutoRun.write(b); + String instcode = inst.getInstruction_code(); + int type = Integer.parseInt(inst.getInstruction_type()); + int priority = Integer.parseInt(inst.getPriority()) + 128; + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); + int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); + + byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); + byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); + byte typehigh = (byte) IntToHexHigh(type); + byte typelow = (byte) IntToHexLow(type); + byte qhdhigh = (byte) IntToHexHigh(startAddress); + byte qhdlow = (byte) IntToHexLow(startAddress); + byte fhdhigh = (byte) IntToHexHigh(nextAddress); + byte fhdlow = (byte) IntToHexLow(nextAddress); + byte prioritylow = (byte) IntToHexLow(priority); + + String str = "十进制下发:"; + String str1 = "十六进制下发:"; + str += "ikey:" + (Integer.parseInt(instcode)); + str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); + + str += "/type:" + (type); + str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); + + str += "/qhd:" + (startAddress); + str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); + str += "/fhd:" + (nextAddress); + str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); + + str += "/priority:" + (priority); + str1 += "/priority:" + hexToString(prioritylow & 0xFF); + + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X12, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X0E, + (byte) 0X01, prioritylow, + (byte) 0X00, (byte) 0X01, + (byte) ikeyhigh, (byte) ikeylow, + (byte) ikeyhigh, (byte) ikeylow, + (byte) typehigh, (byte) typelow, + (byte) qhdhigh, (byte) qhdlow, + (byte) fhdhigh, (byte) fhdlow + }; + log.info("下发AGV作业指令--{}", str); + log.info("下发AGV作业指令--{}", str1); + TwoNDCSocketConnectionAutoRun.write(b); } } - } + @Override public byte[] sendAgvOneModeInst(int phase, int index, int result, int startPoint, int nextPoint, int startHigh, int nextHigh) { diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index 19f5de0..6e09c5d 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -260,7 +260,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { // TODO Auto-generated catch block try { Thread.sleep(5000L); - log.info("再次下发agv数据:" + Bytes2HexString(b)); + log.info("再次下发agv数据:" + Bytes2HexString(b)); System.out.println("再次下发agv数据:" + Bytes2HexString(b)); dos.write(b); dos.flush(); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java index 14a13a3..c90e290 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java @@ -248,45 +248,16 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { log.info(agvaddr + "对应设备号为空!"); return; } - if (ObjectUtil.isNotEmpty(device)) { + if (ObjectUtil.isNotEmpty(device)) { if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - String link_three_lamp = (String) device.getExtraValue().get("link_three_lamp"); - if (StrUtil.isNotEmpty(link_three_lamp)) { - Device code = deviceAppService.findDeviceByCode(link_three_lamp); - if (code.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) code.getDeviceDriver(); - lampThreecolorDeviceDriver.writing("to_command", "1"); - } - //5秒后发送关门信号 - Thread.sleep(5000); - try { - standardAutodoorDeviceDriver.writing("to_open", "0"); - standardAutodoorDeviceDriver.writing("to_close", "1"); - } catch (Exception e) { - log.info("下发电气信号失败:" + e.getMessage()); - e.printStackTrace(); - } - if (standardAutodoorDeviceDriver.getClose() == 1) { - log.info("读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose()); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - log.info("未下发NDC信号原因: 读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose()); - } + if (standardAutodoorDeviceDriver.getDoor() == 1) { + standardAutodoorDeviceDriver.writing("item_to_command",1); + } + if (standardAutodoorDeviceDriver.getTo_command() == 1) { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); } else { - try { - standardAutodoorDeviceDriver.writing("to_open", "1"); - standardAutodoorDeviceDriver.writing("to_close", "0"); - } catch (Exception e) { - log.info("下发电气信号失败:" + e.getMessage()); - e.printStackTrace(); - } - if (standardAutodoorDeviceDriver.getOpen() == 1 && standardAutodoorDeviceDriver.getToOpen() == 1) { - log.info("下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getOpen()); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", standardAutodoorDeviceDriver.getToOpen(), standardAutodoorDeviceDriver.getToClose()); - } + log.info("未下发NDC信号原因: 读取下发信号值为:{}", standardAutodoorDeviceDriver.getTo_command()); } } } else { @@ -300,41 +271,12 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } if (ObjectUtil.isNotEmpty(device)) { if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - String link_three_lamp = (String) device.getExtraValue().get("link_three_lamp"); - if (StrUtil.isNotEmpty(link_three_lamp)) { - Device code = deviceAppService.findDeviceByCode(link_three_lamp); - if (code.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) code.getDeviceDriver(); - lampThreecolorDeviceDriver.writing("to_command", "0"); - } - try { - standardAutodoorDeviceDriver.writing("to_open", "0"); - standardAutodoorDeviceDriver.writing("to_close", "0"); - } catch (Exception e) { - log.info("下发电气信号失败:" + e.getMessage()); - e.printStackTrace(); - } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - try { - standardAutodoorDeviceDriver.writing("to_close", "1"); - standardAutodoorDeviceDriver.writing("to_open", "0"); - } catch (Exception e) { - log.info("下发电气信号失败:" + e.getMessage()); - e.printStackTrace(); - } - if (standardAutodoorDeviceDriver.getClose() == 1) { - log.info("读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose()); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - } else { - log.info("未下发NDC信号原因: 读取关门信号值为:{}", standardAutodoorDeviceDriver.getClose()); - } } } - } else { - log.info(device_code + "对应设备号为空!"); - } + else { + log.info(device_code + "对应设备号为空!"); + } } else { //上报异常信息 //(不需要WCS反馈) diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java index ba8e720..ca3a7f3 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java @@ -9,10 +9,9 @@ import java.util.List; @Slf4j public class ItemProtocol { - public static String item_open = "open"; - public static String item_close = "close"; - public static String item_to_open = "to_open"; - public static String item_to_close = "to_close"; + public static String item_mode = "mode"; + public static String item_door = "door"; + public static String item_to_command = "to_command"; private StandardAutodoorDeviceDriver driver; @@ -21,21 +20,17 @@ public class ItemProtocol { this.driver = driver; } - public int getOpen() { - return this.getOpcIntegerValue(item_open); + public int getMode() { + return this.getOpcIntegerValue(item_mode); } - public int getClose() { - return this.getOpcIntegerValue(item_close); + public int getDoor() { + return this.getOpcIntegerValue(item_door); } - public int getToOpen() { - return this.getOpcIntegerValue(item_to_open); - } - - public int getToClose() { - return this.getOpcIntegerValue(item_to_close); + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); } public int getOpcIntegerValue(String protocol) { @@ -61,15 +56,14 @@ public class ItemProtocol { public static List getReadableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_open, "开到位", "10001")); - list.add(new ItemDto(item_close, "关到位", "10002")); + list.add(new ItemDto(item_mode, "模式", "DB600,B1",Boolean.valueOf(true))); + list.add(new ItemDto(item_door, "门到位", "DB600,B2")); return list; } public static List getWriteableItemDtos() { ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_open, "下发开门", "00001" )); - list.add(new ItemDto(item_to_close, "下发关门", "00002")); + list.add(new ItemDto(item_to_command, "作业命令", "DB601,W2", Boolean.valueOf(true))); return list; } diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java index a8d8478..86ba2a2 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java @@ -35,46 +35,24 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem @Autowired LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); - int open = 0; - int close = 0; - int last_open = 0; - int last_close = 0; - - int toOpen = 0; - int last_toOpen = 0; - int toClose = 0; - int last_toClose = 0; String device_code = null; @Override public Device getDevice() { return this.device; } - - + int mode=0; + int door=0; + int to_command=0; @Override public void execute() { String message = null; device_code = this.getDevice().getDevice_code(); - open = this.itemProtocol.getOpen(); - close = this.itemProtocol.getClose(); - toOpen = this.itemProtocol.getToOpen(); - toClose = this.itemProtocol.getToClose(); - if (open != last_open) { - logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open + "->" + open); - } - if (close != last_close) { - if(close ==1 ){ - this.writing("to_close","0"); - } - } - - last_open = open; - last_close = close; - last_toClose = toClose; - last_toOpen = toOpen; + mode = this.itemProtocol.getMode(); + door = this.itemProtocol.getDoor(); + to_command=this.itemProtocol.getToCommand(); } @@ -110,25 +88,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem @Override public JSONObject getDeviceStatusName() { - JSONObject jo = new JSONObject(); - String open = ""; - String close = ""; - if (this.getOpen() == 0) { - open = "未知"; - } else if (this.getOpen() == 1) { - open = "开到位"; - } - if (this.getClose() == 0) { - open = "未知"; - } else if (this.getClose() == 1) { - open = "关到位"; - } - jo.put("device_name", this.getDevice().getDevice_name()); - jo.put("open", open); - jo.put("close", close); - jo.put("isOnline", true); - - return jo; + JSONObject jo=new JSONObject(); + return jo; } @Override diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 55f95e0..0a686ee 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -587,8 +587,8 @@ public class TaskServiceImpl extends CommonServiceImpl impleme task_code = CodeUtil.getNewCode("TASK_NO"); task_code = CommonFinalParam.HYPHEN_ + task_code; } - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); + String start_device_code = dto.getStart_point_code(); + String next_device_code = dto.getNext_point_code(); String route_plan_code = dto.getRoute_plan_code(); dto.setCreate_by(StrUtil.isNotEmpty(currentUsername) ? currentUsername : "LMS"); dto.setUpdate_by(currentUsername); @@ -599,15 +599,15 @@ public class TaskServiceImpl extends CommonServiceImpl impleme dto.setTask_status(TaskStatusEnum.READY.getIndex()); dto.setStart_point_code(start_device_code); dto.setNext_point_code(next_device_code); - - + dto.setStart_device_code(start_device_code); + dto.setNext_device_code(next_device_code); if (StrUtil.isEmpty(dto.getPriority())) { dto.setPriority(CommonFinalParam.ONE); } String plan_code = dto.getRoute_plan_code(); // 路由校验 if (routeLineService - .getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code) + .getShortPathLines(dto.getStart_point_code(), dto.getNext_point_code(), plan_code) .size() == 0) { throw new BadRequestException(dto.getStart_point_code() + "->" + dto.getNext_point_code() + " " + LangProcess.msg("route_isNull")); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java deleted file mode 100644 index 430d466..0000000 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java +++ /dev/null @@ -1,431 +0,0 @@ -package org.nl.system.service.quartz.task; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.common.base.CommonFinalParam; -import org.nl.acs.device.domain.Device; -import org.nl.acs.device.enums.DeviceType; -import org.nl.acs.device.service.DeviceExtraService; -import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; -import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; -import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver; -import org.nl.acs.instruction.domain.Instruction; -import org.nl.acs.instruction.enums.InstructionStatusEnum; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.enums.TaskStatusEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.common.exception.BadRequestException; -import org.nl.common.utils.SecurityUtils; -import org.nl.config.SpringContextHolder; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -@Slf4j -@Component -public class CreateDDJInst { - - - /** - * 定时查询堆垛机任务 - */ - public void run() { - log.info("定时查询堆垛机任务"+DateUtil.now()); - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - List taskDtos = taskserver.findByTaskStatus("0"); - List taskDtoList = new ArrayList<>(); - if (CollUtil.isEmpty(taskDtos) || taskDtos.size() < 1) { - } else { - for (TaskDto taskDto : taskDtos) { - String start_device_code = taskDto.getStart_device_code(); - Device startDevice = appService.findDeviceByCode(start_device_code); - String next_device_code = taskDto.getNext_device_code(); - Device nextDevice = appService.findDeviceByCode(next_device_code); - //判断有无出入库任务是相同路线 -// TaskDto dto = taskserver.findByCodeAndExcute(next_device_code, start_device_code); -// if (ObjectUtil.isNotEmpty(dto)) { -// continue; -// } - if (startDevice.getDevice_type().equals(DeviceType.storage.name()) && - (nextDevice.getDevice_type().equals(DeviceType.conveyor.name()) || nextDevice.getDevice_type().equals(DeviceType.storage.name()))) { - taskDtoList.add(taskDto); - } - } - if (CollUtil.isNotEmpty(taskDtoList)) { - taskDtoList = sortInst(taskDtoList); - for (TaskDto taskDto : taskDtoList) { - Device nextDevice = null; - List pathlist; - Device deviceByCode = null; - String taskid = taskDto.getTask_id(); - String taskcode = taskDto.getTask_code(); - String task_type = taskDto.getTask_type(); - String vehiclecode = taskDto.getVehicle_code(); - String vehiclecode2 = taskDto.getVehicle_code2(); - String priority = taskDto.getPriority(); - - String start_device_code = taskDto.getStart_device_code(); - Device startDevice = appService.findDeviceByCode(start_device_code); - String start_point_code = taskDto.getStart_point_code(); - - String put_device_code = taskDto.getPut_device_code(); - String put_point_code = taskDto.getPut_point_code(); - String next_device_code = taskDto.getNext_device_code(); - nextDevice = appService.findDeviceByCode(next_device_code); - String next_point_code = taskDto.getNext_point_code(); - - String start_point_code2 = taskDto.getStart_point_code2(); - String start_device_code2 = taskDto.getStart_device_code2(); - - String next_point_code2 = taskDto.getNext_point_code2(); - String next_device_code2 = taskDto.getNext_device_code2(); - - String route_plan_code = taskDto.getRoute_plan_code(); - String vehicleType = taskDto.getVehicle_type(); - String agv_system_type = taskDto.getAgv_system_type(); - - String start_height = taskDto.getStart_height(); - String next_height = taskDto.getNext_height(); - //同排的货位移库任务 - if (StrUtil.equals(taskDto.getStart_device_code(), taskDto.getNext_device_code())) { - //通过起点找路由 - List list = - routeLineService.getShortPathLinesByCode( - taskDto.getStart_device_code(), taskDto.getRoute_plan_code()); - if (ObjectUtils.isEmpty(list)) { - throw new BadRequestException("路由不通"); - } - RouteLineDto routeLineDto = list.get(0); - String[] path = routeLineDto.getPath().split("->"); - pathlist = Arrays.asList(path); - deviceByCode = appService.findDeviceByCode(pathlist.get(1)); - if (ObjectUtils.isEmpty(deviceByCode)) { - log.error("没有找到DDJ设备"); - continue; - } - StandardStackerDeviceDriver standardStackerDeviceDriver; - if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) { - standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver(); - if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0) { - log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code()); - ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中"); - continue; - } - } - next_device_code = start_device_code; - nextDevice = appService.findDeviceByCode(next_device_code); - } else { - List list = - routeLineService.getShortPathLines( - taskDto.getStart_device_code(), taskDto.getNext_device_code(), taskDto.getRoute_plan_code()); - if (ObjectUtils.isEmpty(list)) { - throw new BadRequestException("路由不通"); - } - RouteLineDto routeLineDto = list.get(0); - String[] path = routeLineDto.getPath().split("->"); - pathlist = Arrays.asList(path); - deviceByCode = appService.findDeviceByCode(pathlist.get(1)); - - if (ObjectUtils.isEmpty(deviceByCode)) { - log.error("没有找到DDJ设备"); - continue; - } - StandardStackerDeviceDriver standardStackerDeviceDriver; - if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) { - standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver(); - if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getForkCargo() == 1 || standardStackerDeviceDriver.getCommand() != 0 || standardStackerDeviceDriver.getError() != 0) { - log.error("堆垛机,{}未联机或者在执行中或者有异常", deviceByCode.getDevice_code()); - ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("堆垛机,{}未联机或者在执行中"); - continue; - } - } - - next_device_code = taskDto.getNext_device_code(); - - - /** - * 开始平均分配 - */ - String this_coevice_code = taskserver.queryAssignedByDeviceCode(start_device_code, next_device_code); - if (StrUtil.isEmpty(this_coevice_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - RouteLineDto routeLineDto1 = shortPathsList.get(0); - - String path1 = routeLineDto1.getPath(); - String[] str = path1.split("->"); - - List pathlist1 = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist1.size(); m++) { - String deviceType1 = appService.findDeviceByCode(pathlist1.get(m)).getDevice_type(); - if (deviceType1.equals(DeviceType.stacker.name())) { - index = m + 1; - break; - } - /*if (pathlist1.get(m).equals(start_device_code)) { - - }*/ - } - next_device_code = pathlist1.get(index); - } else { - next_device_code = this_coevice_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList) || shortPathsList.size() < 1) { - throw new RuntimeException("路由不通!"); - - } - } - - if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = next_device_code + "-" + taskDto.getTo_y() + "-" + taskDto.getTo_z(); - } else { - next_point_code = next_device_code; - } - - nextDevice = appService.findDeviceByCode(next_device_code); - BeltConveyorDeviceDriver beltConveyorDeviceDriver; - if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); - if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) { - log.error("输送机,{}未联机或执行中", next_device_code); - ((BeltConveyorDeviceDriver) nextDevice.getDeviceDriver()).setNotCreateInstMessage("one_message7"); - continue; - } - } - - //单台堆垛机最多只能创建固定数量指令 - Instruction instruction = new Instruction(); - instruction.setInstruction_status(CommonFinalParam.ONE); - List byDeviceCodes = instructionService.findByDeviceCodes(instruction, true); - Instruction instdto = new Instruction(); - if (CollUtil.isEmpty(byDeviceCodes)) { - //判断有没有DDJ对接位出入库的指令,只判断终点 - List byCodeAndExcute = instructionService.findByNextCode(next_device_code); - if (CollUtil.isNotEmpty(byCodeAndExcute)){ - ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位为终点的指令"); - continue; - } - instdto.setInstruction_type(task_type); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskDto.getRemark()); - instdto.setMaterial(taskDto.getMaterial()); - instdto.setQuantity(taskDto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - instdto.setVehicle_code2(vehiclecode2); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - - instdto.setStart_device_code(start_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setPut_device_code(put_device_code); - instdto.setPut_point_code(put_point_code); - instdto.setNext_device_code(next_device_code); - instdto.setNext_point_code(next_point_code); - - instdto.setStart_point_code2(start_point_code2); - instdto.setStart_device_code2(start_device_code2); - instdto.setNext_point_code2(next_point_code2); - instdto.setNext_device_code2(next_device_code2); - - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(vehicleType); - instdto.setAgv_system_type(agv_system_type); - instdto.setStart_height(start_height); - instdto.setNext_height(next_height); - if (ObjectUtil.isNotNull(startDevice) && startDevice.getDevice_type().equals(DeviceType.storage.name())) { - instdto.setFrom_x(taskDto.getFrom_x()); - instdto.setFrom_z(taskDto.getFrom_z()); - instdto.setFrom_y(taskDto.getFrom_y()); - } - if (ObjectUtil.isNotNull(nextDevice) && nextDevice.getDevice_type().equals(DeviceType.storage.name())) { - instdto.setTo_x(taskDto.getTo_x()); - instdto.setTo_z(taskDto.getTo_z()); - instdto.setTo_y(taskDto.getTo_y()); - } - try { - instructionService.create(instdto); - } catch (Exception e) { - taskDto.setRemark(e.getMessage()); - taskserver.update(taskDto); - return; - } - //创建指令后修改任务状态 - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskDto); - } else { - List insts = new ArrayList<>(); - for (Instruction byDeviceCode : byDeviceCodes) { - String nextDeviceCode = byDeviceCode.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(nextDeviceCode); - String startDeviceCode = byDeviceCode.getStart_device_code(); - Device startDevice1 = appService.findDeviceByCode(startDeviceCode); - if (startDevice1.getDevice_type().equals(DeviceType.storage.name()) && - (nextdevice.getDevice_type().equals(DeviceType.conveyor.name()) || nextdevice.getDevice_type().equals(DeviceType.storage.name()))) { - insts.add(byDeviceCode); - } - } - int max = 0; - //非同排的路径 - for (Instruction inst : insts) { - List shortPathLines =new ArrayList<>(); - if (!(inst.getStart_device_code().equals(inst.getNext_device_code()))) { - shortPathLines = routeLineService.getShortPathLines(inst.getStart_device_code(), inst.getNext_device_code(), - inst.getRoute_plan_code()); - if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) { - log.error("没有此路由"); - throw new BadRequestException("路由不通"); - } - }else { - //同排路径 - shortPathLines = routeLineService.getShortPathLinesByCode(inst.getStart_device_code(), inst.getRoute_plan_code()); - if (CollUtil.isEmpty(shortPathLines) || shortPathLines.size() < 1) { - log.error("没有此路由"); - throw new BadRequestException("路由不通"); - } - } - RouteLineDto routeLineDto1 = (RouteLineDto) shortPathLines.get(0); - String[] path1 = routeLineDto1.getPath().split("->"); - List pathlist1 = Arrays.asList(path1); - if (pathlist1.get(1).equals(pathlist.get(1))) { - max++; - } - } - /*List deviceExtras = deviceExtra.list(Wrappers.lambdaQuery(DeviceExtra.class). - eq(DeviceExtra::getDevice_code, pathlist.get(1)).orderByDesc(DeviceExtra::getCreate_time));*/ - String count = deviceByCode.getExtraValue().get("count").toString(); - if (StrUtil.isNotEmpty(count)) { - if (max <= Integer.parseInt(count)) { - //判断有没有DDJ对接位出入库的指令,只判断终点 - List byCodeAndExcute = instructionService.findByNextCode(next_device_code); - if (CollUtil.isNotEmpty(byCodeAndExcute)){ - ((StandardStackerDeviceDriver) deviceByCode.getDeviceDriver()).setNotCreateInstMessage("有DDJ对接位为终点的指令"); - continue; - } - instdto.setInstruction_type(task_type); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(taskDto.getRemark()); - instdto.setMaterial(taskDto.getMaterial()); - instdto.setQuantity(taskDto.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - instdto.setVehicle_code2(vehiclecode2); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - - instdto.setStart_device_code(start_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setPut_device_code(put_device_code); - instdto.setPut_point_code(put_point_code); - instdto.setNext_device_code(next_device_code); - instdto.setNext_point_code(next_point_code); - - instdto.setStart_point_code2(start_point_code2); - instdto.setStart_device_code2(start_device_code2); - instdto.setNext_point_code2(next_point_code2); - instdto.setNext_device_code2(next_device_code2); - - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(vehicleType); - instdto.setAgv_system_type(agv_system_type); - instdto.setStart_height(start_height); - instdto.setNext_height(next_height); - if (ObjectUtil.isNotNull(startDevice) && startDevice.getDevice_type().equals(DeviceType.storage.name())) { - instdto.setFrom_x(taskDto.getFrom_x()); - instdto.setFrom_z(taskDto.getFrom_z()); - instdto.setFrom_y(taskDto.getFrom_y()); - } - if (ObjectUtil.isNotNull(nextDevice) && nextDevice.getDevice_type().equals(DeviceType.storage.name())) { - instdto.setTo_x(taskDto.getTo_x()); - instdto.setTo_z(taskDto.getTo_z()); - instdto.setTo_y(taskDto.getTo_y()); - } - //判断agv系统 - //1、1楼叉车系统 - //2、2楼1区域AGV系统 - //3、2楼2区域AGV系统 -已废弃 - if (!StrUtil.equals(agv_system_type, CommonFinalParam.ONE)) { - // task_type - //1、生箔; Itype=1:取空,取满,放空,放满; - //2、分切 Itype=3取满、取空、放满、放空; - //3、普通任务 Itype=2:取货、放货; - //4、叉车任务 - //5、输送任务 - //6、行架 - //7、立库 - if (StrUtil.equals(task_type, CommonFinalParam.ONE)) { - instdto.setAgv_inst_type(CommonFinalParam.ONE); - } else if (StrUtil.equals(task_type, "3")) { - instdto.setAgv_inst_type("2"); - } else if (StrUtil.equals(task_type, "2")) { - instdto.setAgv_inst_type("3"); - } else if (StrUtil.equals(task_type, "8")) { - instdto.setAgv_inst_type("2"); - } else { - log.info("未找到对应的AGV指令类型,任务号:" + taskDto.getTask_code() + ",task_type:" + taskDto.getTask_type()); - } - } else { - instdto.setAgv_inst_type("4"); - } - try { - instructionService.create(instdto); - } catch (Exception e) { - taskDto.setRemark(e.getMessage()); - taskserver.updateByCodeFromCache(taskDto); - } - //创建指令后修改任务状态 - taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); - taskserver.update(taskDto); - continue; - } - } - } - } - } - //单台堆垛机只能出四五 - } - } - - private List sortInst(List taskDtos) { - Collections.sort(taskDtos, (t1, t2) -> { - //优先级从大到小 - int i = t1.getPriority().compareTo(t2.getPriority()); - //如果优先级相等 - if (i == 0) { - //时间从早到晚 - i = t1.getCreate_time().compareTo(t2.getCreate_time()); - } - return i; - }); - return taskDtos; - } - -} diff --git a/acs/nladmin-ui/.env.production b/acs/nladmin-ui/.env.production index 25a073f..14155f9 100644 --- a/acs/nladmin-ui/.env.production +++ b/acs/nladmin-ui/.env.production @@ -2,6 +2,6 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http -VUE_APP_BASE_API = 'http://47.97.157.227:8011' +VUE_APP_BASE_API = 'http://192.168.0.8:8011' # 如果接口是 http 形式, wss 需要改为 ws -VUE_APP_WS_API = 'ws://47.97.157.227:8011' +VUE_APP_WS_API = 'ws://192.168.0.8:8011' diff --git a/acs/nladmin-ui/public/config.js b/acs/nladmin-ui/public/config.js index 4f59769..ca5cd6f 100644 --- a/acs/nladmin-ui/public/config.js +++ b/acs/nladmin-ui/public/config.js @@ -3,7 +3,7 @@ window.g = { VUE_APP_BASE_API: 'http://127.0.0.1:8011' }, prod: { - VUE_APP_BASE_API: 'http://10.1.3.96:8011' + VUE_APP_BASE_API: 'http://192.168.0.8:8011' } } diff --git a/acs/nladmin-ui/src/views/acs/task/index.vue b/acs/nladmin-ui/src/views/acs/task/index.vue index b155be6..fae4a91 100644 --- a/acs/nladmin-ui/src/views/acs/task/index.vue +++ b/acs/nladmin-ui/src/views/acs/task/index.vue @@ -4,276 +4,308 @@
- + + - - - - - - - - - - - - - - - - - - + + + + + +
- {{ $t('auto.common.Create') }} + 新增 - - {{ $t('auto.common.synchronous') }} - + 同步 + --> - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + - + + + + + + + + + + - - - - - - - - - + + + + + + + @@ -286,39 +318,35 @@