diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java index d74ab34..02f42b4 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java @@ -74,7 +74,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + //log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); @@ -89,8 +89,8 @@ public class ItemProtocol { list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D10")); + list.add(new ItemDto(item_error, "报警信号", "DB600.B4")); + list.add(new ItemDto(item_task, "任务号", "DB600.D6")); return list; } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java index 2865d8d..e0f7997 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java @@ -51,18 +51,8 @@ public class StandardInspectSiteDefination implements OpcDeviceDriverDefination } @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D10")); - return list; + public List getReadableItemDtos(){ + return ItemProtocol.getReadableItemDtos(); } @Override diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index 46b3df4..399c7d0 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -90,7 +90,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp private Date instruction_require_time = new Date(); private Date instruction_finished_time = new Date(); - private int instruction_require_time_out; + private int instruction_require_time_out = 3000; boolean requireSucess = false; boolean inrequireSucess = false; boolean emptyrequireSucess = false; @@ -134,10 +134,11 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp @Override - public void execute() { + public void execute() throws Exception { String message = null; try { String device_code = this.getDeviceCode(); + devicecode = this.getDeviceCode(); mode = this.itemProtocol.getMode(); error = this.itemProtocol.getError(); move = this.itemProtocol.getMove(); @@ -145,12 +146,8 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp hasGoods = this.itemProtocol.getMove(); if (mode != last_mode) { - if (mode == 5){ - this.setEmptyrequireSucess(false); - } - if (mode == 6){ - this.setInrequireSucess(false); - } + this.setEmptyrequireSucess(false); + this.setInrequireSucess(false); this.execute_log.setResource(this.devicecode, this.device.getDevice_name()); this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode); } @@ -291,10 +288,25 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp if (material.length() > 0 && qty.length() > 0 && !requireSucess) { this.execute_log.log("设备:" + devicecode + ",material:" + material + ",qty:" + qty); - this.instruction_require(container); + } + break; + //申请 + case 3: + if (!inrequireSucess){ + if (move == 1){ + this.execute_log.log("设备:" + devicecode + ",move:" + move); + this.apply_in_require(container); + } } + break; + //取消 + case 4: + + this.cancle_require(); + + case 5: if (!emptyrequireSucess){ //mode = 5 并且工位上无货时申请空托盘 @@ -438,6 +450,32 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp return apply_in_require(container_code, WcsConfig.task_container_type_default_desc); } + /** + * 请求取消指令 + * + */ + public synchronized boolean cancle_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; + List taskList = taskserver.queryTaskByDeviceCode(this.devicecode); + if(taskList.size() != 0){ + for(int i=0;i iterator = tasks.iterator(); while (iterator.hasNext()) { TaskDto task = iterator.next(); - if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "0")) { + if (task.getStart_device_code().equals(device_code)) { list.add(task); } } diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java index a679fd5..cf0a8cf 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java @@ -186,3465 +186,642 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); try { - switch (type) { - case 0: - if (phase == 0x01) { - data = AgvService.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); - } - flag = true; - } - //分配 车id - else if (phase == 0x02) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - } - // 到达取货点请求取货 - else if (phase == 0x03) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 7); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //光电检测站点(优先入库)edit - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 7); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //检测站点 - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //输送机-控制点驱动 - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - - } - //标准版-货架 - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - // 取货完成请求离开 - else if (phase == 0x05) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 2); - standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 2); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 2); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 0); - deviceService.changeDeviceStatus(jo); - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - if(!inst.getTask_code().startsWith("-")) { - //反馈wms系统动作完成 - inst.setFinish_type("1"); - instructionService.update(inst); - JSONObject feedjo = new JSONObject(); - feedjo.put("status","1"); - feedjo.put("device_code",device_code); - feedjo.put("vehicle_code",inst.getVehicle_code()); - feedjo.put("task_code",inst.getTask_code()); - JSONArray feedja = JSONArray.fromObject(feedjo); - acsToWmsService.feedbackActionStatusToWms(feedja); - } - - - } - //请求放货 - else if (phase == 0x07) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 8); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 8); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - // 放货完成请求离开 - else if (phase == 0x09) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("6"); - instructionService.update(inst); - standardManipulatorStackingSiteDeviceDriver.writing(1, 3); - standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 3); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 3); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - - if(!inst.getTask_code().startsWith("-")){ - //反馈wms系统动作完成 - inst.setFinish_type("1"); - instructionService.update(inst); - JSONObject feedjo = new JSONObject(); - feedjo.put("status","2"); - feedjo.put("device_code",device_code); - feedjo.put("vehicle_code",inst.getVehicle_code()); - feedjo.put("task_code",inst.getTask_code()); - JSONArray feedja = JSONArray.fromObject(feedjo); - acsToWmsService.feedbackActionStatusToWms(feedja); - } - - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0A) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //请求删除任务 - else if (phase == 0x30) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); - } else { - log.info("未找到对应的指令无法删除"); - break; - } - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancel(inst.getInstruction_id()); - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //进入区域 - else if (phase == 0x50) { - //开门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("1"); - if (standardAutodoorDeviceDriver.getAction() == 1) { - standardAutodoorDeviceDriver.OpenOrClose("1"); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof OumulongPlcDeviceDriver) { - oumulongPlcDeviceDriver = (OumulongPlcDeviceDriver) device.getDeviceDriver(); - oumulongPlcDeviceDriver.OpenOrClose("1"); - if (oumulongPlcDeviceDriver.getAction() == 1) { - oumulongPlcDeviceDriver.OpenOrClose("1"); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - standardManipulatorStackingSiteDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - } - //离开区域 - else if (phase == 0x51) { - //关门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("2"); - if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof OumulongPlcDeviceDriver) { - oumulongPlcDeviceDriver = (OumulongPlcDeviceDriver) device.getDeviceDriver(); - oumulongPlcDeviceDriver.OpenOrClose("2"); - if (oumulongPlcDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - standardManipulatorStackingSiteDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - } else if (phase == 0x64) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //上报异常 - else if (phase == 0x67) { - 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"); - } - } - //X坐标 - else if (phase == 0x70) { - 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); - } - //Y坐标 - else if (phase == 0x71) { - 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); - } - //角度 - else if (phase == 0x72) { - 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); - } - //电量 - else if (phase == 0x73) { - 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); - } + if (phase == 0x01) { + data = AgvService.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); + } + flag = true; + } + //分配 车id + else if (phase == 0x02) { + if (!ObjectUtil.isEmpty(inst)) { + inst.setCarno(String.valueOf(carno)); + instructionService.update(inst); + } + } + // 到达取货点请求取货 + else if (phase == 0x03) { + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); break; - case 1: - //开始任务/上报订单号(无车id及状态) - if (phase == 0x01) { - data = AgvService.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); - } - flag = true; - } - //分配 车id - else if (phase == 0x02) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - } - // 到达取货点请求取货 - else if (phase == 0x03) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - if (weighingSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StorageConveyorDeviceDriver) { - storageConveyorDeviceDriver = (StorageConveyorDeviceDriver) device.getDeviceDriver(); - HttpResponse response = acsToXrlkService.isTakePermission(device.getDevice_code()); - if (response.getStatus() == 200) { - JSONObject jo = JSONObject.fromObject(response.body()); - if (StrUtil.equals(jo.get("signal").toString(), "1")) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("AGV请求取货设备{},立库WMS不允许取货", device_code); - } - } else { - log.info("AGV请求取货设备{},接口请求立库WMS失败", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - // 取货完成请求离开 - else if (phase == 0x05) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - if (device.getDeviceDriver() instanceof StorageConveyorDeviceDriver) { - storageConveyorDeviceDriver = (StorageConveyorDeviceDriver) device.getDeviceDriver(); - HttpResponse response = acsToXrlkService.AGVWorkStatus(device.getDevice_code(), "2"); - if (response.getStatus() == 200) { - JSONObject jo = JSONObject.fromObject(response.body()); - if (StrUtil.equals(jo.get("result").toString(), "1")) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("AGV取货完成反馈设备{},{}", device_code, jo.getString("message")); - } - } else { - log.info("AGV取货完成反馈设备{},接口请求立库WMS失败", device_code); - } - - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - if (weighingSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 2); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 0); - deviceService.changeDeviceStatus(jo); - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - // 球磨车间请求上料 - //( Itype=2,需要WCS反馈Phase) - else if (phase == 0x07) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - // 球磨车间上料完成请求离开 - else if (phase == 0x09) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - //请求放货库位 - else if (phase == 0x0A) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //调用接口 - String result = acsToWmsService.requestTaskAgain(String.valueOf(agvaddr), inst.getTask_id(), inst.getVehicle_code()); - JSONObject jo = JSONObject.fromObject(result); - String next_device = jo.getString("data"); - - String next_point = ""; - Device next_point_device = deviceAppService.findDeviceByCode(next_device); - if (next_point_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) next_point_device.getDeviceDriver(); - - int number = standardEmptyPalletSiteDeviceDriver.getNumber(); - int nowinstNum = instructionService.querySameDestinationInst(next_point); - if (number + nowinstNum >= Integer.parseInt(next_point_device.getExtraValue().get("max_emptypalletnum").toString())) { - log.info("当前叠盘位{},光电数量{},存在此设备指令数{},超过最大堆叠数量:{}无法反馈", next_point, number, nowinstNum, Integer.parseInt(device.getExtraValue().get("max_emptypalletnum").toString())); - break; - } - next_point = next_device + "." + (number + nowinstNum + 1); - } else { - next_point = next_device; - } - - int next_point_address = deviceService.queryAddressBydeviceCode(next_point); - data = AgvService.sendAgvOneModeInst(phase, index, next_point_address); - - TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); - task.setNext_device_code(next_device); - task.setNext_point_code(next_device); - taskService.update(task); - - inst.setNext_device_code(next_device); - inst.setNext_point_code(next_point); + } + //机械手码垛驱动-区分托盘类型 + if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { + standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); + if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 + && standardManipulatorStackingSiteDeviceDriver.getError() == 0 + && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { + inst.setExecute_status("1"); instructionService.update(inst); - flag = true; - } - //到达放货点 - else if (phase == 0x0B) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - if (device.getDeviceDriver() instanceof StorageConveyorDeviceDriver) { - storageConveyorDeviceDriver = (StorageConveyorDeviceDriver) device.getDeviceDriver(); - HttpResponse response = acsToXrlkService.isPutPermission(device.getDevice_code()); - if (response.getStatus() == 200) { - JSONObject jo = JSONObject.fromObject(response.body()); - if (StrUtil.equals(jo.get("signal").toString(), "1")) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("AGV请求放货设备{},立库WMS不允许放货", device_code); - } - } else { - log.info("AGV请求放货设备{},接口请求立库WMS失败", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - if (weighingSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getNumber() < Integer.parseInt(emptyNum)) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}数量异常,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - //放货完成请求离开 - else if (phase == 0x0D) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getNumber() == Integer.parseInt(emptyNum)) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成设备{}数量异常,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - if (weighingSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 3); - log.info("AGV放货完成请求离开设备{}下发输送to_commad{}", device_code, 3); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - if (device.getDeviceDriver() instanceof StorageConveyorDeviceDriver) { - storageConveyorDeviceDriver = (StorageConveyorDeviceDriver) device.getDeviceDriver(); - HttpResponse response = acsToXrlkService.AGVWorkStatus(device.getDevice_code(), "1"); - if (response.getStatus() == 200) { - JSONObject jo = JSONObject.fromObject(response.body()); - if (StrUtil.equals(jo.get("result").toString(), "1")) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("AGV放货完成反馈设备{},{}", device_code, jo.getString("message")); - } - } else { - log.info("AGV放货完成反馈设备{},接口请求立库WMS失败", device_code); - } - - } - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0F) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //请求删除任务 - else if (phase == 0x30) { + standardManipulatorStackingSiteDeviceDriver.writing(1, 7); flag = true; -// if (!ObjectUtil.isEmpty(inst)) { -// data = AgvService.sendAgvOneModeInst(0x8F, index, 0); -// } - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); - - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else if (phase == 0x50)//进入区域 - { - //开门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("1"); - if (standardAutodoorDeviceDriver.getAction() == 1) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getRelevance_device_code(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StorageConveyorDeviceDriver) { - storageConveyorDeviceDriver = (StorageConveyorDeviceDriver) device.getDeviceDriver(); - HttpResponse response = acsToXrlkService.invokeDoor(device.getDevice_code()); - if (response.getStatus() == 200) { - JSONObject jo = JSONObject.fromObject(response.body()); - if (StrUtil.equals(jo.get("result").toString(), "1")) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("AGV请求进入{},{}", device_code, jo.getString("message")); - } - } else { - log.info("AGV请求进入设备{},接口请求立库WMS失败", device_code); - } - } - } - - } else if (phase == 0x51)//离开区域 - { - //关门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("2"); - if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getRelevance_device_code(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - } else if (phase == 0x64) { + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); + } + } + //光电检测站点(优先入库)edit + if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { + standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 + && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { + inst.setExecute_status("1"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //上报异常 - else if (phase == 0x67) { - int errCar = arr[26] * 256 + arr[27]; - 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(errCar)); - if (arr[18] * 256 + arr[19] == 0) { - dto.setState("IDLE"); - } 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"); - } - } - //X坐标 - else if (phase == 0x70) { - 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)); - dto.setPositionX(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - //Y坐标 - else if (phase == 0x71) { - 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)); - dto.setPositionY(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - //角度 - else if (phase == 0x72) { - int errCar = arr[26] * 256 + arr[27]; - 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)); - dto.setPositionAngle(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - - } - //电量 - else if (phase == 0x73) { - 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)); - dto.setEnergyLevel(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - - break; - case 2: - //开始任务/上报订单号(无车id及状态) - if (phase == 0x01) { - data = AgvService.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); - } + standardPhotoelectricInspectSiteDeviceDriver.writing(1, 7); flag = true; - } - //分配 车id - else if (phase == 0x02) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - } - // 到达取货点请求取货 - else if (phase == 0x03) { - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - - } - //货架 - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - //检测站点-无PLC - if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "readyTake"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - //区域管制站点-无PLC - if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "readyTake"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - } - // 取货完成请求离开 - else if (phase == 0x05) { - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - } - //标准版-货架 - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - - } - //检测站点-无PLC - if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "getFinsh"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - //区域管制站点-无PLC - if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "getFinsh"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - } - // 到达放货点 - else if (phase == 0x07) { - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - - } - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - - } - //检测站点-无PLC - if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "readyPut"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - //区域管制站点-无PLC - if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "readyPut"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - } - // 放货完成离开 - else if (phase == 0x09) { - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - } - //检测站点-无PLC - if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "putFinish"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - //区域管制站点-无PLC - if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - HttpResponse result = acsToWmsService.requestSignalInteraction(device_code, inst.getVehicle_code(), "putFinish"); - if (result.getStatus() != 200) { - log.info("反馈状态异常"); - } else { - JSONObject jo = JSONObject.fromObject(result.body()); - if (jo.getInt("status") == 200) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0A) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x1A) { + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); + } + } + //检测站点 + if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + inst.setExecute_status("1"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //请求删除任务 - else if (phase == 0x30) { - flag = true; - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { flag = true; - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else if (phase == 0x50)//进入区域 - { - //开门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("1"); - if (standardAutodoorDeviceDriver.getAction() == 1) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - nonLineManipulatorInspectSiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = nonLineManipulatorInspectSiteDeviceDriver.getIoaction(); - if (io_action == 1 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - } else if (phase == 0x51)//离开区域 - { - //关门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("2"); - if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - nonLineManipulatorInspectSiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = nonLineManipulatorInspectSiteDeviceDriver.getIoaction(); - if (io_action == 2 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - } else if (phase == 0x64) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //上报异常 - else if (phase == 0x67) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - if (arr[18] * 256 + arr[19] == 0) { - dto.setState("IDLE"); - acsToWmsService.feedbackAgvStatus(String.valueOf(ikey), String.valueOf(arr[18] * 256 + arr[19]), ""); - } 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(ikey), String.valueOf(arr[18] * 256 + arr[19]), "error"); - } - } - //X坐标 - else if (phase == 0x70) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - //Y坐标 - else if (phase == 0x71) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - //角度 - else if (phase == 0x72) { - int errCar = arr[26] * 256 + arr[27]; - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - - } - //电量 - else if (phase == 0x73) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); } else { - - - } - break; - case 3: - - break; - case 5: - if (phase == 0x01) { - data = AgvService.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); - } - flag = true; - } - //分配 车id - else if (phase == 0x02) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - } - // 到达取货点请求取货 - else if (phase == 0x03) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - standardManipulatorStackingSiteDeviceDriver.writing(1, 7); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //光电检测站点(优先入库)edit - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 7); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //检测站点 - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof NdxySpecialDeviceDriver) { - ndxySpecialDeviceDriver = (NdxySpecialDeviceDriver) device.getDeviceDriver(); - if (ndxySpecialDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - ndxySpecialDeviceDriver.writing(1, 7); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //输送机-控制点驱动 - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - - } - //标准版-货架 - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - // 取货完成请求离开 - else if (phase == 0x05) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 2); - standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 2); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //检测站点 - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof NdxySpecialDeviceDriver) { - ndxySpecialDeviceDriver = (NdxySpecialDeviceDriver) device.getDeviceDriver(); - if (ndxySpecialDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - ndxySpecialDeviceDriver.writing(1, 2); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 2); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 0); - deviceService.changeDeviceStatus(jo); - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - //请求放货 - else if (phase == 0x07) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 8); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 8); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof NdxySpecialDeviceDriver) { - ndxySpecialDeviceDriver = (NdxySpecialDeviceDriver) device.getDeviceDriver(); - if (ndxySpecialDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - ndxySpecialDeviceDriver.writing(1, 8); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - // 放货完成请求离开 - else if (phase == 0x09) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - standardManipulatorStackingSiteDeviceDriver.writing(1, 3); - standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 3); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof NdxySpecialDeviceDriver) { - ndxySpecialDeviceDriver = (NdxySpecialDeviceDriver) device.getDeviceDriver(); - if (ndxySpecialDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - ndxySpecialDeviceDriver.writing(1, 3); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 3); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0A) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } + log.info("AGV请求取货设备{}无货,无法反馈", device_code); + } + } + //空盘堆叠站点 + if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { + standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); + if (standardEmptyPalletSiteDeviceDriver.getMove() != 0) { + inst.setExecute_status("1"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //请求删除任务 - else if (phase == 0x30) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); - } else { - log.info("未找到对应的指令无法删除"); - break; - } - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { flag = true; - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancel(inst.getInstruction_id()); - } - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //进入区域 - else if (phase == 0x50) { - //开门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("1"); - if (standardAutodoorDeviceDriver.getAction() == 1) { - standardAutodoorDeviceDriver.OpenOrClose("1"); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof NdxySpecialDeviceDriver) { - ndxySpecialDeviceDriver = (NdxySpecialDeviceDriver) device.getDeviceDriver(); - int io_action = ndxySpecialDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - ndxySpecialDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - standardManipulatorStackingSiteDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - } - //离开区域 - else if (phase == 0x51) { - //关门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("2"); - if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof NdxySpecialDeviceDriver) { - ndxySpecialDeviceDriver = (NdxySpecialDeviceDriver) device.getDeviceDriver(); - int io_action = ndxySpecialDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - ndxySpecialDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - standardManipulatorStackingSiteDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - } else if (phase == 0x64) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //上报异常 - else if (phase == 0x67) { - if (arr[18] * 256 + arr[19] == 0) { - - } else { - - } } else { - - - } - break; - case 7: - //开始任务/上报订单号(无车id及状态) - if (phase == 0x01) { - data = AgvService.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); - } + log.info("AGV请求取货设备{}无货,无法反馈", device_code); + } + } + //输送机-控制点驱动 + if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { + standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (standardCoveyorControlDeviceDriver.getMove() != 0) { + inst.setExecute_status("1"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); flag = true; - } - //分配 车id - else if (phase == 0x02) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - } - // 到达取货点请求取货 - else if (phase == 0x03) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - standardCoveyorControlDeviceDriver.writing(1, 1); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); + } + } + //普通站点 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { + inst.setExecute_status("1"); + instructionService.update(inst); + data = AgvService.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); flag = true; + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); } } - // 取货完成请求离开 - else if (phase == 0x05) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 2); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 0); - deviceService.changeDeviceStatus(jo); - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } + } + //标准版-货架 + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + inst.setExecute_status("1"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + } + } + // 取货完成请求离开 + else if (phase == 0x05) { + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); + break; + } + //机械手码垛驱动-区分托盘类型 + if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { + standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); + if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 + && standardManipulatorStackingSiteDeviceDriver.getError() == 0 + && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { + inst.setExecute_status("5"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardManipulatorStackingSiteDeviceDriver.writing(1, 2); + standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); + flag = true; + } else { + log.info("AGV请求取货设备{}有货,无法反馈", device_code); + } + } + //光电检测站点(优先入库) + if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { + standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 + && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { + inst.setExecute_status("5"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardPhotoelectricInspectSiteDeviceDriver.writing(1, 2); + standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); + flag = true; + } else { + log.info("AGV请求取货设备{}有货,无法反馈", device_code); } - // 球磨车间请求上料 - //( Itype=2,需要WCS反馈Phase) - else if (phase == 0x07) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } + } + if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0) { + inst.setExecute_status("5"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); flag = true; + } else { + log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); } - // 球磨车间上料完成请求离开 - else if (phase == 0x09) { + } + if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { + standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (standardCoveyorControlDeviceDriver.getMove() == 0) { + inst.setExecute_status("5"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardCoveyorControlDeviceDriver.writing(1, 2); flag = true; + } else { + log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); } - //请求放货库位 - else if (phase == 0x0A) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //调用接口 - String result = acsToWmsService.requestTaskAgain(String.valueOf(agvaddr), inst.getTask_id(), inst.getVehicle_code()); - JSONObject jo = JSONObject.fromObject(result); - String next_device = jo.getString("data"); - - String next_point = ""; - Device next_point_device = deviceAppService.findDeviceByCode(next_device); - if (next_point_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) next_point_device.getDeviceDriver(); - - int number = standardEmptyPalletSiteDeviceDriver.getNumber(); - int nowinstNum = instructionService.querySameDestinationInst(next_point); - if (number + nowinstNum >= Integer.parseInt(next_point_device.getExtraValue().get("max_emptypalletnum").toString())) { - log.info("当前叠盘位{},光电数量{},存在此设备指令数{},超过最大堆叠数量:{}无法反馈", next_point, number, nowinstNum, Integer.parseInt(device.getExtraValue().get("max_emptypalletnum").toString())); - break; - } - next_point = next_device + "." + (number + nowinstNum + 1); - } else { - next_point = next_device; - } - - int next_point_address = deviceService.queryAddressBydeviceCode(next_point); - data = AgvService.sendAgvOneModeInst(phase, index, next_point_address); - - TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); - TaskDto task = taskService.findByCodeFromCache(inst.getTask_code()); - task.setNext_device_code(next_device); - task.setNext_point_code(next_device); - taskService.update(task); - - inst.setNext_device_code(next_device); - inst.setNext_point_code(next_point); + } + if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { + standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); + if (standardEmptyPalletSiteDeviceDriver.getMove() == 0) { + inst.setExecute_status("5"); instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); flag = true; + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); } - //到达放货点 - else if (phase == 0x0B) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getNumber() < Integer.parseInt(emptyNum)) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}数量异常,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("3"); + } + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { + inst.setExecute_status("5"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + JSONObject jo = new JSONObject(); + jo.put("device_code", device.getDevice_code()); + jo.put("hasGoodStatus", 0); + deviceService.changeDeviceStatus(jo); + } else { + if (device.getHas_goods() == 0) { + inst.setExecute_status("5"); instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); flag = true; - } - } - //放货完成请求离开 - else if (phase == 0x0D) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getNumber() == Integer.parseInt(emptyNum)) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成设备{}数量异常,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 3); - log.info("AGV放货完成请求离开设备{}下发输送to_commad{}", device_code, 3); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } + JSONObject jo = new JSONObject(); + jo.put("device_code", device.getDevice_code()); + jo.put("hasGoodStatus", 1); + deviceService.changeDeviceStatus(jo); + } else { + log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); + } + } + + } + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); + inst.setExecute_status("5"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + } + if(!inst.getTask_code().startsWith("-")) { + //反馈wms系统动作完成 + inst.setFinish_type("1"); + instructionService.update(inst); + JSONObject feedjo = new JSONObject(); + feedjo.put("status","1"); + feedjo.put("device_code",device_code); + feedjo.put("vehicle_code",inst.getVehicle_code()); + feedjo.put("task_code",inst.getTask_code()); + JSONArray feedja = JSONArray.fromObject(feedjo); + acsToWmsService.feedbackActionStatusToWms(feedja); + } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0F) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } + + } + //请求放货 + else if (phase == 0x07) { + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); + break; + } + //机械手码垛驱动-区分托盘类型 + if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { + standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); + if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 + && standardManipulatorStackingSiteDeviceDriver.getError() == 0 + && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { + inst.setExecute_status("3"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardManipulatorStackingSiteDeviceDriver.writing(1, 8); + flag = true; + } else { + log.info("AGV请求取货设备{}有货,无法反馈", device_code); + } + } + //光电检测站点(优先入库) + if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { + standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 + && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { + inst.setExecute_status("3"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardPhotoelectricInspectSiteDeviceDriver.writing(1, 8); + flag = true; + } else { + log.info("AGV请求取货设备{}有货,无法反馈", device_code); } - //请求删除任务 - else if (phase == 0x30) { + } + if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() == 0) { + inst.setExecute_status("3"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); flag = true; - if (!ObjectUtil.isEmpty(inst)) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else { - log.info("未找到对应的指令无法删除"); - break; - } + } else { + log.info("AGV请求放货设备{}有货,无法反馈", device_code); } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { + } + if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { + standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (standardCoveyorControlDeviceDriver.getMove() == 0) { + inst.setExecute_status("3"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); flag = true; - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - } + } else { + log.info("AGV请求放货设备{}有货,无法反馈", device_code); + } + } + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { + inst.setExecute_status("3"); + instructionService.update(inst); data = AgvService.sendAgvOneModeInst(phase, index, 0); - } else if (phase == 0x50)//进入区域 - { - //开门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("1"); - if (standardAutodoorDeviceDriver.getAction() == 1) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getRelevance_device_code(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - - } else if (phase == 0x51)//离开区域 - { - //关门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("2"); - if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getRelevance_device_code(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } + flag = true; + JSONObject jo = new JSONObject(); + jo.put("device_code", device.getDevice_code()); + jo.put("hasGoodStatus", 1); + deviceService.changeDeviceStatus(jo); - } else if (phase == 0x64) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - //上报异常 - else if (phase == 0x67) { - int errCar = arr[26] * 256 + arr[27]; - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(errCar)) { - dto = map.get(errCar); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(errCar)); - if (arr[18] * 256 + arr[19] == 0) { - dto.setState("IDLE"); - } 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"); - } - } - //X坐标 - else if (phase == 0x70) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionX(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - //Y坐标 - else if (phase == 0x71) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } - //角度 - else if (phase == 0x72) { - int errCar = arr[26] * 256 + arr[27]; - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); + } else { + if (device.getHas_goods() == 0) { + inst.setExecute_status("3"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + JSONObject jo = new JSONObject(); + jo.put("device_code", device.getDevice_code()); + jo.put("hasGoodStatus", 1); + deviceService.changeDeviceStatus(jo); } else { - dto = new AgvDto(); + log.info("AGV请求放货设备{}有货,无法反馈", device_code); } - dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); } - //电量 - else if (phase == 0x73) { - AgvDto dto = null; - Map map = AgvService.findAllAgvFromCache(); - if (map.containsKey(carno)) { - dto = map.get(carno); - } else { - dto = new AgvDto(); - } - dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); - } + } + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + inst.setExecute_status("3"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + } + } + // 放货完成请求离开 + else if (phase == 0x09) { + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令号{}对应的指令", ikey); break; - case 9: - if (phase == 0x01) { - data = AgvService.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); - } + } + //机械手码垛驱动-区分托盘类型 + if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { + standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); + if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 + && standardManipulatorStackingSiteDeviceDriver.getError() == 0 + && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { + inst.setExecute_status("6"); + instructionService.update(inst); + standardManipulatorStackingSiteDeviceDriver.writing(1, 3); + standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); + } + } + //光电检测站点(优先入库) + if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { + standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 + && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { + inst.setExecute_status("6"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardPhotoelectricInspectSiteDeviceDriver.writing(1, 3); + standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); + flag = true; + } else { + log.info("AGV请求取货设备{}无货,无法反馈", device_code); } - //分配 车id - else if (phase == 0x02) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setCarno(String.valueOf(carno)); - instructionService.update(inst); - } - } - // 到达取货点请求取货 - else if (phase == 0x03) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 7); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //光电检测站点(优先入库)edit - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 7); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //检测站点 - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //空盘堆叠站点 - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //输送机-控制点驱动 - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //普通站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - - } - //标准版-货架 - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("1"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } + } + if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); + if (standardInspectSiteDeviceDriver.getMove() != 0) { + inst.setExecute_status("6"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + } else { + log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); } - // 取货完成请求离开 - else if (phase == 0x05) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 1 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 2); - standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 2); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 2); - flag = true; - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 0); - deviceService.changeDeviceStatus(jo); - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV取货完成请求离开设备{}有货,无法反馈", device_code); - } - } - - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver(); - inst.setExecute_status("5"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } - if(!inst.getTask_code().startsWith("-")) { - //反馈wms系统动作完成 - inst.setFinish_type("1"); - instructionService.update(inst); - JSONObject feedjo = new JSONObject(); - feedjo.put("status","1"); - feedjo.put("device_code",device_code); - feedjo.put("vehicle_code",inst.getVehicle_code()); - feedjo.put("task_code",inst.getTask_code()); - JSONArray feedja = JSONArray.fromObject(feedjo); - acsToWmsService.feedbackActionStatusToWms(feedja); - } - - + } + if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { + standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (standardCoveyorControlDeviceDriver.getMove() != 0) { + inst.setExecute_status("6"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + standardCoveyorControlDeviceDriver.writing(1, 3); + flag = true; + } else { + log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); } - //请求放货 - else if (phase == 0x07) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardManipulatorStackingSiteDeviceDriver.writing(1, 8); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 8); - flag = true; - } else { - log.info("AGV请求取货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - - } else { - if (device.getHas_goods() == 0) { - inst.setExecute_status("3"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", device.getDevice_code()); - jo.put("hasGoodStatus", 1); - deviceService.changeDeviceStatus(jo); - } else { - log.info("AGV请求放货设备{}有货,无法反馈", device_code); - } - - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("3"); + } + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { + inst.setExecute_status("6"); + instructionService.update(inst); + data = AgvService.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); flag = true; + } else { + log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); } } - // 放货完成请求离开 - else if (phase == 0x09) { - if (ObjectUtil.isEmpty(inst)) { - log.info("未找到指令号{}对应的指令", ikey); - break; - } - //机械手码垛驱动-区分托盘类型 - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && standardManipulatorStackingSiteDeviceDriver.getError() == 0 - && (standardManipulatorStackingSiteDeviceDriver.getAction() == 2 || standardManipulatorStackingSiteDeviceDriver.getAction() == 3)) { - inst.setExecute_status("6"); - instructionService.update(inst); - standardManipulatorStackingSiteDeviceDriver.writing(1, 3); - standardManipulatorStackingSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - //光电检测站点(优先入库) - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getError() == 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 3); - standardPhotoelectricInspectSiteDeviceDriver.writing(4, Integer.parseInt(inst.getVehicle_type())); - flag = true; - } else { - log.info("AGV请求取货设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMove() != 0) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - standardCoveyorControlDeviceDriver.writing(1, 3); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.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); - flag = true; - } else { - log.info("AGV放货完成请求离开设备{}无货,无法反馈", device_code); - } - } - } - if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - inst.setExecute_status("6"); - instructionService.update(inst); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - flag = true; - } + } + if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { + inst.setExecute_status("6"); + instructionService.update(inst); + data = AgvService.sendAgvOneModeInst(phase, index, 0); + flag = true; + } - if(!inst.getTask_code().startsWith("-")){ - //反馈wms系统动作完成 - inst.setFinish_type("1"); - instructionService.update(inst); - JSONObject feedjo = new JSONObject(); - feedjo.put("status","2"); - feedjo.put("device_code",device_code); - feedjo.put("vehicle_code",inst.getVehicle_code()); - feedjo.put("task_code",inst.getTask_code()); - JSONArray feedja = JSONArray.fromObject(feedjo); - acsToWmsService.feedbackActionStatusToWms(feedja); - } + if(!inst.getTask_code().startsWith("-")){ + //反馈wms系统动作完成 + inst.setFinish_type("1"); + instructionService.update(inst); + JSONObject feedjo = new JSONObject(); + feedjo.put("status","2"); + feedjo.put("device_code",device_code); + feedjo.put("vehicle_code",inst.getVehicle_code()); + feedjo.put("task_code",inst.getTask_code()); + JSONArray feedja = JSONArray.fromObject(feedjo); + acsToWmsService.feedbackActionStatusToWms(feedja); + } - } - //任务完毕 - //(无车id及状态) - else if (phase == 0x0A) { - if (!ObjectUtil.isEmpty(inst)) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } + } + //任务完毕 + //(无车id及状态) + else if (phase == 0x0A) { + if (!ObjectUtil.isEmpty(inst)) { + inst.setInstruction_status("2"); + instructionService.finish(inst); + } + data = AgvService.sendAgvOneModeInst(phase, index, 0); + } + //请求删除任务 + else if (phase == 0x30) { + flag = true; + if (!ObjectUtil.isEmpty(inst)) { + data = AgvService.sendAgvOneModeInst(0x8F, index, 0); + } else { + log.info("未找到对应的指令无法删除"); + break; + } + } + //任务删除确认 + //(需要WCS反馈) + else if (phase == 0xFF) { + flag = true; + if (!ObjectUtil.isEmpty(inst)) { + instructionService.cancel(inst.getInstruction_id()); + } + data = AgvService.sendAgvOneModeInst(phase, index, 0); + } + //进入区域 + else if (phase == 0x50) { + //开门 + if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { + standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); + standardAutodoorDeviceDriver.OpenOrClose("1"); + if (standardAutodoorDeviceDriver.getAction() == 1) { + standardAutodoorDeviceDriver.OpenOrClose("1"); data = AgvService.sendAgvOneModeInst(phase, index, 0); } - //请求删除任务 - else if (phase == 0x30) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - data = AgvService.sendAgvOneModeInst(0x8F, index, 0); - } else { - log.info("未找到对应的指令无法删除"); - break; - } - } - //任务删除确认 - //(需要WCS反馈) - else if (phase == 0xFF) { - flag = true; - if (!ObjectUtil.isEmpty(inst)) { - instructionService.cancelNOSendAgv(inst.getInstruction_id()); - } + } + if (device.getDeviceDriver() instanceof OumulongPlcDeviceDriver) { + oumulongPlcDeviceDriver = (OumulongPlcDeviceDriver) device.getDeviceDriver(); + oumulongPlcDeviceDriver.OpenOrClose("1"); + if (oumulongPlcDeviceDriver.getAction() == 1) { + oumulongPlcDeviceDriver.OpenOrClose("1"); data = AgvService.sendAgvOneModeInst(phase, index, 0); } - //进入区域 - else if (phase == 0x50) { - //开门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("1"); - if (standardAutodoorDeviceDriver.getAction() == 1) { - standardAutodoorDeviceDriver.OpenOrClose("1"); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof OumulongPlcDeviceDriver) { - oumulongPlcDeviceDriver = (OumulongPlcDeviceDriver) device.getDeviceDriver(); - oumulongPlcDeviceDriver.OpenOrClose("1"); - if (oumulongPlcDeviceDriver.getAction() == 1) { - oumulongPlcDeviceDriver.OpenOrClose("1"); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof TrafficLightDeviceDriver) { - trafficLightDeviceDriver = (TrafficLightDeviceDriver) device.getDeviceDriver(); - trafficLightDeviceDriver.writing(3); + } + if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { + manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); + String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device relevance_device = appService.findDeviceByCode(relevance_device_code); + if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); + int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); + if (io_action == 1 || io_action == 3) { data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - standardManipulatorStackingSiteDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); - if (io_action == 1 || io_action == 3) { - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 5); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - } - //离开区域 - else if (phase == 0x51) { - //关门 - if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - standardAutodoorDeviceDriver.OpenOrClose("2"); - if (standardAutodoorDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof OumulongPlcDeviceDriver) { - oumulongPlcDeviceDriver = (OumulongPlcDeviceDriver) device.getDeviceDriver(); - oumulongPlcDeviceDriver.OpenOrClose("2"); - if (oumulongPlcDeviceDriver.getAction() == 2) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (device.getDeviceDriver() instanceof TrafficLightDeviceDriver) { - trafficLightDeviceDriver = (TrafficLightDeviceDriver) device.getDeviceDriver(); - trafficLightDeviceDriver.writing(2); + if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { + standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); + int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); + if (io_action == 1 || io_action == 3) { + standardManipulatorStackingSiteDeviceDriver.writing(1, 5); data = AgvService.sendAgvOneModeInst(phase, index, 0); } - if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { - manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); - String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device relevance_device = appService.findDeviceByCode(relevance_device_code); - if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - standardManipulatorStackingSiteDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); - int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); - if (io_action == 2 || io_action == 3) { - standardPhotoelectricInspectSiteDeviceDriver.writing(1, 6); - data = AgvService.sendAgvOneModeInst(phase, index, 0); - } - } - } - } else if (phase == 0x64) { - data = AgvService.sendAgvOneModeInst(phase, index, 0); } - //上报异常 - else if (phase == 0x67) { - 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)); - if (ikey == 0) { - dto.setState("IDLE"); - acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "0", ""); - } else { - StringBuffer errbs = new StringBuffer(); - for (int i = 0; i < ERROR.length; i++) { - if (((ikey) & (1 << i)) > 0) - errbs.append("," + ERROR[i]); - //反馈故障 - } - dto.setState("ERROR"); - acsToWmsService.feedbackAgvStatus(String.valueOf(carno), String.valueOf(ikey), "error"); + if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { + standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); + int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); + if (io_action == 1 || io_action == 3) { + standardPhotoelectricInspectSiteDeviceDriver.writing(1, 5); + data = AgvService.sendAgvOneModeInst(phase, index, 0); } } - //X坐标 - else if (phase == 0x70) { - 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); + } + + } + //离开区域 + else if (phase == 0x51) { + //关门 + if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { + standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); + standardAutodoorDeviceDriver.OpenOrClose("2"); + if (standardAutodoorDeviceDriver.getAction() == 2) { + data = AgvService.sendAgvOneModeInst(phase, index, 0); } - //Y坐标 - else if (phase == 0x71) { - 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(); + } + if (device.getDeviceDriver() instanceof OumulongPlcDeviceDriver) { + oumulongPlcDeviceDriver = (OumulongPlcDeviceDriver) device.getDeviceDriver(); + oumulongPlcDeviceDriver.OpenOrClose("2"); + if (oumulongPlcDeviceDriver.getAction() == 2) { + data = AgvService.sendAgvOneModeInst(phase, index, 0); + } + } + if (device.getDeviceDriver() instanceof ManipulatorInspectSiteNDCDeviceDriver) { + manipulatorInspectSiteNDCDeviceDriver = (ManipulatorInspectSiteNDCDeviceDriver) device.getDeviceDriver(); + String relevance_device_code = manipulatorInspectSiteNDCDeviceDriver.getDevice().getExtraValue().get("relevance_device_code").toString(); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device relevance_device = appService.findDeviceByCode(relevance_device_code); + if (relevance_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); + int io_action = standardManipulatorInspectSiteDeviceDriver.getIo_action(); + if (io_action == 2 || io_action == 3) { + data = AgvService.sendAgvOneModeInst(phase, index, 0); } - dto.setName(String.valueOf(carno)); - dto.setPositionY(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); } - //角度 - else if (phase == 0x72) { - 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(); + if (relevance_device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { + standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) relevance_device.getDeviceDriver(); + int io_action = standardManipulatorStackingSiteDeviceDriver.getIo_action(); + if (io_action == 2 || io_action == 3) { + standardManipulatorStackingSiteDeviceDriver.writing(1, 6); + data = AgvService.sendAgvOneModeInst(phase, index, 0); } - dto.setName(String.valueOf(carno)); - dto.setPositionAngle(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); } - //电量 - else if (phase == 0x73) { - 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(); + if (relevance_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { + standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) relevance_device.getDeviceDriver(); + int io_action = standardPhotoelectricInspectSiteDeviceDriver.getIo_action(); + if (io_action == 2 || io_action == 3) { + standardPhotoelectricInspectSiteDeviceDriver.writing(1, 6); + data = AgvService.sendAgvOneModeInst(phase, index, 0); } - dto.setName(String.valueOf(carno)); - dto.setEnergyLevel(String.valueOf(ikey)); - AgvService.updateAgvFromCache(dto); } - break; - default: - log.info("字典表未找到满足条件的项目类型"); - break; + } + } else if (phase == 0x64) { + data = AgvService.sendAgvOneModeInst(phase, index, 0); + } + //上报异常 + else if (phase == 0x67) { + 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"); + } + } + //X坐标 + else if (phase == 0x70) { + 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); + } + //Y坐标 + else if (phase == 0x71) { + 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); + } + //角度 + else if (phase == 0x72) { + 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); + } + //电量 + else if (phase == 0x73) { + 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); } if (!ObjectUtil.isEmpty(data)) { write(data); diff --git a/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml b/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml index f9d3a4d..b76a1ef 100644 --- a/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/hd/nladmin-system/src/main/resources/config/application-dev.yml @@ -9,7 +9,7 @@ spring: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:zgln_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hs_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nywl_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} # password: ${DB_PWD:P@ssw0rd} # password: ${DB_PWD:Root.123456} diff --git a/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml b/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml index 9cc5214..8c19eae 100644 --- a/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml +++ b/acs/hd/nladmin-system/src/main/resources/config/application-prod.yml @@ -8,7 +8,7 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:tg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nywl_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true username: ${DB_USER:root} password: ${DB_PWD:123456} # 初始连接数 diff --git a/acs/hd/nladmin-system/src/main/resources/initsql.txt b/acs/hd/nladmin-system/src/main/resources/initsql.txt index dc704cb..98da62a 100644 --- a/acs/hd/nladmin-system/src/main/resources/initsql.txt +++ b/acs/hd/nladmin-system/src/main/resources/initsql.txt @@ -10,7 +10,7 @@ delete from acs_task; delete from sys_log; delete from acs_log; delete from acs_task_feedback; -delete from sys_quartz_log; +delete from sys_quartz_log;d delete from acs_storage_cell; update acs_stage_actor set device_code='',image_name ='1'; update sys_code_rule_detail set current_value=0; \ No newline at end of file