From 22c554a156b7b0fdfbb63bff6f167f0bb8a60874 Mon Sep 17 00:00:00 2001 From: "ZHOUZ\\Noble'lift" <1014987728@qq.com> Date: Tue, 13 Sep 2022 09:40:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CargoLiftConveyorDefination.java | 2 +- .../CargoLiftConveyorDeviceDriver.java | 120 +++++++++++++++++- .../cargo_lift_conveyor/ItemProtocol.java | 4 + ...mptyVehicleStackingPositionDefination.java | 2 +- ...tyVehicleStackingPositionDeviceDriver.java | 2 +- .../HailiangSmartplcTestDefination.java | 2 +- .../HailiangSmartplcTestDeviceDriver.java | 2 +- .../HaoKaiAutoConveyorDefination.java | 2 +- .../HaoKaiAutoConveyorDeviceDriver.java | 2 +- .../PaintConveyorDefination.java | 2 +- .../PaintConveyorDeviceDriver.java | 2 +- .../ItemProtocol.java | 4 + ...CoveyorControlWithScannerDeviceDriver.java | 17 ++- .../service/impl/InstructionServiceImpl.java | 74 ++++++++++- 14 files changed, 210 insertions(+), 27 deletions(-) diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDefination.java index 44bdb8c..eb17957 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDefination.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDefination.java @@ -11,7 +11,7 @@ import java.util.LinkedList; import java.util.List; /** - * 海亮迅捷plc测试 + * 货梯对接线 */ @Service public class CargoLiftConveyorDefination implements OpcDeviceDriverDefination { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDeviceDriver.java index 88cad73..910d3a3 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/CargoLiftConveyorDeviceDriver.java @@ -1,9 +1,17 @@ package org.nl.acs.device_driver.basedriver.cargo_lift_conveyor; +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 com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; import org.nl.acs.agv.server.AgvService; +import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.DeviceService; @@ -19,18 +27,17 @@ import org.nl.acs.log.service.LogServer; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; import org.nl.utils.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** - * 海亮清洗机储料仓 + * 货梯对接线 */ @Slf4j @Data @@ -91,7 +98,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple Boolean requireSucess = false; @Override - public void execute() { + public void execute() throws Exception { String message = null; device_code = this.getDeviceCode(); @@ -136,6 +143,16 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple message = ""; Instruction instruction = null; List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 2: + //申请任务 + if (move > 0 && !requireSucess) { + instruction_require(); + } + } switch (flag) { //取货完成 case 1: @@ -167,6 +184,97 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple } } + public synchronized boolean instruction_require() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return false; + } else { + this.instruction_require_time = date; + //container_code + TaskDto task = taskserver.queryTaskByDeviceCode(device_code).get(0); + if (!ObjectUtil.isEmpty(task)) { + if (!ObjectUtils.isEmpty(instructionService.findByDeviceCodeFromCache(device_code))) { + return false; + } + String taskid = task.getTask_id(); + String taskcode = task.getTask_code(); + String vehiclecode = task.getVehicle_code(); + String priority = task.getPriority(); + String start_point_code = task.getStart_point_code(); + String start_device_code = task.getStart_device_code(); + String route_plan_code = task.getRoute_plan_code(); + String next_device_code = ""; + + /** + * 开始平均分配 + */ + String this_coevice_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); + if (StrUtil.isEmpty(this_coevice_code)) { + List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); + RouteLineDto routeLineDto = shortPathsList.get(0); + + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + if (!StrUtil.equals(type, "0")) { + return false; + } + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.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)) { + throw new RuntimeException("路由不通!"); + } + + Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + String next_point_code; + if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = task.getTo_x() + "-" + task.getTo_y() + "-" + task.getTo_z(); + } else { + next_point_code = next_device_code; + } + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(task.getRemark()); + instdto.setMaterial(task.getMaterial()); + instdto.setQuantity(task.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + instructionService.create(instdto); + //创建指令后修改任务状态 + task.setTask_status("1"); + taskserver.update(task); + requireSucess = true; + } + return true; + } + } + protected void thingToNothing() { } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/ItemProtocol.java index 1be3569..9af6915 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/ItemProtocol.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/cargo_lift_conveyor/ItemProtocol.java @@ -23,6 +23,8 @@ public class ItemProtocol { public static String item_to_command = "to_command"; public static String item_to_target = "to_target"; public static String item_to_task = "to_task"; + public static String item_to_door = "to_door"; + public static String item_to_floor = "to_floor"; private CargoLiftConveyorDeviceDriver driver; @@ -86,6 +88,8 @@ public class ItemProtocol { list.add(new ItemDto(item_to_command, "下发命令", "VW102")); list.add(new ItemDto(item_to_target, "下发目标站", "VW104")); list.add(new ItemDto(item_to_task, "任务号", "VD108")); + list.add(new ItemDto(item_to_door, "门", "VD112")); + list.add(new ItemDto(item_to_floor, "楼层", "VD114")); return list; } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDefination.java index 57b0b11..a5e78fc 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDefination.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDefination.java @@ -11,7 +11,7 @@ import java.util.LinkedList; import java.util.List; /** - * 海亮迅捷plc测试 + * 空托盘叠盘位 */ @Service public class EmptyVehicleStackingPositionDefination implements OpcDeviceDriverDefination { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDeviceDriver.java index d4ec4f5..d33abce 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/empty_vehicle_stacking_position/EmptyVehicleStackingPositionDeviceDriver.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; /** - * 海亮清洗机储料仓 + * 空托盘叠盘位 */ @Slf4j @Data diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java index 41ac944..f650942 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDefination.java @@ -11,7 +11,7 @@ import java.util.LinkedList; import java.util.List; /** - * 海亮迅捷plc测试 + * 三工位 */ @Service public class HailiangSmartplcTestDefination implements OpcDeviceDriverDefination { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java index 12724ce..a29cf2c 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hailiang_smart_plc_test/HailiangSmartplcTestDeviceDriver.java @@ -32,7 +32,7 @@ import java.util.List; import java.util.Map; /** - * 海亮清洗机储料仓 + * 三工位 */ @Slf4j @Data diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDefination.java index d8f37e4..b9e1141 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDefination.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDefination.java @@ -11,7 +11,7 @@ import java.util.LinkedList; import java.util.List; /** - * 海亮迅捷plc测试 + * 豪凯自动对接线 */ @Service public class HaoKaiAutoConveyorDefination implements OpcDeviceDriverDefination { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDeviceDriver.java index 7337bdf..6c00eaf 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/haokai_auto_conveyor/HaoKaiAutoConveyorDeviceDriver.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.Map; /** - * 海亮清洗机储料仓 + * 豪凯自动对接线 */ @Slf4j @Data diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDefination.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDefination.java index 02524ca..322e715 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDefination.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDefination.java @@ -11,7 +11,7 @@ import java.util.LinkedList; import java.util.List; /** - * 海亮迅捷plc测试 + * 油漆线 */ @Service public class PaintConveyorDefination implements OpcDeviceDriverDefination { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDeviceDriver.java index 3240558..2764c4b 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paint_conveyor/PaintConveyorDeviceDriver.java @@ -30,7 +30,7 @@ import java.util.HashMap; import java.util.Map; /** - * 海亮清洗机储料仓 + * 油漆线 */ @Slf4j @Data diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java index a1c8e77..7b2722c 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/ItemProtocol.java @@ -21,6 +21,8 @@ public class ItemProtocol { public static String item_to_command = "to_command"; public static String item_to_target = "to_target"; public static String item_to_task = "to_task"; + public static String item_to_door = "to_door"; + public static String item_to_floor = "to_floor"; private StandardCoveyorControlWithScannerDeviceDriver driver; @@ -84,6 +86,8 @@ public class ItemProtocol { list.add(new ItemDto(item_to_command, "下发命令", "VW102")); list.add(new ItemDto(item_to_target, "下发目标站", "VW104")); list.add(new ItemDto(item_to_task, "任务号", "VD108")); + list.add(new ItemDto(item_to_door, "门", "VD112")); + list.add(new ItemDto(item_to_floor, "楼层", "VD114")); return list; } diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 6b41695..294db09 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -259,7 +259,6 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } - public void set_last_container_type_desc(String type) { } @@ -306,6 +305,10 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe + "." + ItemProtocol.item_to_target; String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "." + ItemProtocol.item_to_task; + String to_door = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_door; + String to_floor = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_floor; String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); @@ -316,6 +319,10 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } else if (type == 3) { itemMap.put(to_task, command); + } else if (type == 4) { + itemMap.put(to_door, command); + } else if (type == 5) { + itemMap.put(to_floor, command); } ReadUtil.write(itemMap, server); @@ -436,7 +443,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe //container_code TaskDto task = taskserver.findByContainer(container_code); if (!ObjectUtil.isEmpty(task)) { - if(!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))){ + if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) { return false; } String taskid = task.getTask_id(); @@ -517,9 +524,9 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) { message = "申请任务中..."; JSONObject apply = new JSONObject(); - apply.put("type","6"); - apply.put("vehicle_code",container_code); - apply.put("point_code",device_code); + apply.put("type", "6"); + apply.put("vehicle_code", container_code); + apply.put("point_code", device_code); String str = acsToWmsService.applyTaskToWms(apply); JSONObject jo = JSON.parseObject(str); if (ObjectUtil.isEmpty(jo)) { diff --git a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 18ae983..1366d51 100644 --- a/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/wcs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -315,23 +315,83 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu if (startdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) { cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) startdevice.getDeviceDriver(); cargoLiftConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); + if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){ + standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver(); + standardCoveyorControlWithScannerDeviceDriver.writing(1,1); + String address = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("address").toString(); + if (StrUtil.isEmpty(address)){ + throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!"); + } + String door = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("door").toString(); + if (StrUtil.isEmpty(door)){ + throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!"); + } + String floor = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("floor").toString(); + if (StrUtil.isEmpty(floor)){ + throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!"); + } + standardCoveyorControlWithScannerDeviceDriver.writing(2, Integer.parseInt(address)); + standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.parseInt(task_code)); + standardCoveyorControlWithScannerDeviceDriver.writing(4, Integer.parseInt(door)); + standardCoveyorControlWithScannerDeviceDriver.writing(5, Integer.parseInt(floor)); + } } if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver(); standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); + if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver){ + cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) nextdevice.getDeviceDriver(); + cargoLiftConveyorDeviceDriver.writing(1,1); + String address = cargoLiftConveyorDeviceDriver.getExtraValue().get("address").toString(); + if (StrUtil.isEmpty(address)){ + throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!"); + } + String door = cargoLiftConveyorDeviceDriver.getExtraValue().get("door").toString(); + if (StrUtil.isEmpty(door)){ + throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!"); + } + String floor = cargoLiftConveyorDeviceDriver.getExtraValue().get("floor").toString(); + if (StrUtil.isEmpty(floor)){ + throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!"); + } + cargoLiftConveyorDeviceDriver.writing(2, Integer.parseInt(address)); + cargoLiftConveyorDeviceDriver.writing(3, Integer.parseInt(task_code)); + cargoLiftConveyorDeviceDriver.writing(4, Integer.parseInt(door)); + cargoLiftConveyorDeviceDriver.writing(5, Integer.parseInt(floor)); + } } - if (nextdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) { + if (startdevice.getDeviceDriver() instanceof HaoKaiAutoConveyorDeviceDriver) { haoKaiAutoConveyorDeviceDriver = (HaoKaiAutoConveyorDeviceDriver) startdevice.getDeviceDriver(); haoKaiAutoConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); } try { - HttpResponse result = agvService.sendAgvInstToZDAgv(dto); - if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) { - dto.setSend_status("2"); - } else { - dto.setSend_status("1"); + String start_device_code = task.getStart_device_code(); + String next_device_code = task.getNext_device_code(); + String route_plan_code = task.getRoute_plan_code(); + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + RouteLineDto route = null; + for (int i = 0; i < shortPathsList.size(); i++) { + RouteLineDto routeLineDto = shortPathsList.get(i); + String route_device = routeLineDto.getDevice_code(); + String route_next_device = routeLineDto.getNext_device_code(); + if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())){ + route = routeLineDto; + break; + } } + if (ObjectUtil.isEmpty(route)){ + throw new BadRequestException("未查询到相关路由!"); + } + if (StrUtil.equals(route.getType(), "1")) { + HttpResponse result = agvService.sendAgvInstToZDAgv(dto); + if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) { + dto.setSend_status("2"); + } else { + dto.setSend_status("1"); + } + } + } catch (Exception e) { dto.setSend_status("2"); e.printStackTrace(); @@ -1115,7 +1175,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu for (int i = 0; i < this.instructions.size(); i++) { Instruction inst = instructions.get(i); - if (StrUtil.equals(devicecode, inst.getExecute_code())) { + if (StrUtil.equals(devicecode, inst.getStart_device_code()) && inst.getInstruction_status().equals("0")) { return inst; } }