From 256409b9fa70a6716cc9d0cd7d16800da65ce5c0 Mon Sep 17 00:00:00 2001 From: zhangjiangwei Date: Wed, 22 Mar 2023 16:43:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/nl/acs/AcsConfig.java | 2 + .../agv/server/impl/NDCAgvServiceImpl.java | 29 ++- .../acs/ext/wms/data/CreateTaskRequest.java | 10 + .../acs/ext/wms/rest/WmsToAcsController.java | 27 ++- .../acs/ext/wms/service/WmsToAcsService.java | 7 + .../wms/service/impl/WmsToAcsServiceImpl.java | 80 +++++++ .../service/dto/InstructionDto.java | 10 + .../service/impl/InstructionServiceImpl.java | 2 - .../org/nl/acs/task/service/dto/TaskDto.java | 10 + .../modules/quartz/task/AutoCreateInst.java | 224 ++++++++++-------- 10 files changed, 282 insertions(+), 119 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java b/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java index 77cbff7..bfd8215 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java @@ -56,4 +56,6 @@ public interface AcsConfig { String MAXSENDTASKTIME = "maxSendTaskTime"; //指令下发立库 String INSTSENDLK = "instSendLk"; + + String SEND_INST = "sendInst"; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 09eb276..8f5d556 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -75,7 +75,22 @@ public class NDCAgvServiceImpl implements NDCAgvService { public void sendAgvInstToNDC(String agv_system_type, Instruction inst) { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getAgv_inst_type()); + + String start_height_str = inst.getStart_height(); + String next_height_str = inst.getNext_height(); + int type; + if (StrUtil.isNotBlank(start_height_str) && StrUtil.isNotBlank(next_height_str)) { + type = 1; + } else if (StrUtil.isNotBlank(start_height_str)) { + type = 2; + } else if (StrUtil.isNotBlank(next_height_str)) { + type = 3; + } else { + type = 4; + } + int start_height = Integer.parseInt(start_height_str); + int next_height = Integer.parseInt(next_height_str); + int priority = Integer.parseInt(inst.getPriority()) + 128; DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); @@ -90,6 +105,10 @@ public class NDCAgvServiceImpl implements NDCAgvService { byte fhdhigh = (byte) IntToHexHigh(nextAddress); byte fhdlow = (byte) IntToHexLow(nextAddress); byte prioritylow = (byte) IntToHexLow(priority); + byte qhghigh = (byte) IntToHexHigh(start_height); + byte qhglow = (byte) IntToHexLow(start_height); + byte fhghigh = (byte) IntToHexHigh(next_height); + byte fhglow = (byte) IntToHexLow(next_height); String str = "十进制下发:"; String str1 = "十六进制下发:"; str += "ikey:" + (Integer.parseInt(instcode)); @@ -102,6 +121,10 @@ public class NDCAgvServiceImpl implements NDCAgvService { str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); str += "/priority:" + (priority); str1 += "/priority:" + hexToString(prioritylow & 0xFF); + str += "/qhg:" + (start_height); + str1 += "/qhg:" + hexToString(qhghigh & 0XFF) + hexToString(qhglow & 0XFF); + str += "/fhg:" + (next_height); + str1 += "/fhg:" + hexToString(fhghigh & 0XFF) + hexToString(fhglow & 0XFF); System.out.println(str); System.out.println(str1); byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, @@ -116,7 +139,9 @@ public class NDCAgvServiceImpl implements NDCAgvService { (byte) ikeyhigh, (byte) ikeylow, (byte) typehigh, (byte) typelow, (byte) qhdhigh, (byte) qhdlow, - (byte) fhdhigh, (byte) fhdlow + (byte) fhdhigh, (byte) fhdlow, + (byte) qhghigh, (byte) qhglow, + (byte) fhghigh, (byte) fhglow }; log.info("下发AGV作业指令--{}", str1); OneNDCSocketConnectionAutoRun.write(b); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java index 687b419..039678d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java @@ -53,6 +53,16 @@ public class CreateTaskRequest extends BaseRequest { */ String remark; + /** + * 起点高度 + */ + String start_height; + + /** + * 终点高度 + */ + String next_height; + /** * 扩展属性 */ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index d44ee5d..934c8cb 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -36,7 +36,7 @@ public class WmsToAcsController { private final WmsToAcsService wmstoacsService; @PostMapping("/task") - @Log(value = "ACS接收WMS任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "ACS接收WMS任务", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("接收WMS任务") @SaIgnore public ResponseEntity createFromWms(@RequestBody List reqs) { @@ -44,7 +44,7 @@ public class WmsToAcsController { } @PostMapping("/cancelTask") - @Log(value = "WMS取消任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "WMS取消任务", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS取消任务") @SaIgnore public ResponseEntity cancelFromWms(@RequestBody List reqs) throws Exception { @@ -52,21 +52,21 @@ public class WmsToAcsController { } @PostMapping("/updateDeviceGoodsFromWms") - @Log(value = "WMS修改点位状态",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "WMS修改点位状态", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS修改点位状态") public ResponseEntity updateDeviceGoodsFromWms(@RequestBody String whereJson) { return new ResponseEntity<>(wmstoacsService.updateDeviceGoodsFromWms(whereJson), HttpStatus.OK); } @PostMapping("/areaControl") - @Log(value = "区域控制",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "区域控制", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("区域控制") public ResponseEntity areaControl(@RequestBody JSONObject whereJson) { return new ResponseEntity<>(wmstoacsService.areaControl(whereJson), HttpStatus.OK); } @PostMapping("/action") - @Log(value = "WMS下发点位信号",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "WMS下发点位信号", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS下发点位信号") @SaIgnore public ResponseEntity putAction(@RequestBody String whereJson) throws Exception { @@ -74,7 +74,7 @@ public class WmsToAcsController { } @PostMapping("/querydevice") - @Log(value = "WMS查询设备状态",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "WMS查询设备状态", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS查询设备状态") @SaIgnore public ResponseEntity queryDevice(@RequestBody String whereJson) throws Exception { @@ -82,20 +82,27 @@ public class WmsToAcsController { } @PostMapping("/queryDeviceDBValue") - @Log(value = "WMS查询设备DB值",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "WMS查询设备DB值", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS查询设备DB值") @SaIgnore - public ResponseEntity queryDeviceDBValue(@RequestBody String whereJson){ + public ResponseEntity queryDeviceDBValue(@RequestBody String whereJson) { return new ResponseEntity<>(wmstoacsService.queryDeviceDBValue(whereJson), HttpStatus.OK); } @PostMapping("/putPlusPullAction") - @Log(value = "WMS下发插拔轴动作",isInterfaceLog = true,interfaceLogType= InterfaceLogType.LMS_TO_ACS) + @Log(value = "WMS下发插拔轴动作", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) @ApiOperation("WMS下发插拔轴动作") @SaIgnore - public ResponseEntity putPlusPullAction(@RequestBody String whereJson){ + public ResponseEntity putPlusPullAction(@RequestBody String whereJson) { return new ResponseEntity<>(wmstoacsService.putPlusPullAction(whereJson), HttpStatus.OK); } + @PostMapping("/deviceOption") + @Log(value = "WMS下发设备暂停恢复", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS) + @ApiOperation("WMS下发设备暂停恢复") + @SaIgnore + public ResponseEntity deviceOption(@RequestBody String whereJson) { + return new ResponseEntity<>(wmstoacsService.deviceOption(whereJson), HttpStatus.OK); + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java index e86d747..e12f4e8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java @@ -83,4 +83,11 @@ public interface WmsToAcsService { Map putPlusPullAction(String whereJson); + /** + * 设备暂停恢复 + * + * @param whereJson 条件 + * @return JSONObject + */ + JSONObject deviceOption(String whereJson); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index ecc9b90..77a90fd 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -10,6 +10,8 @@ import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; +import org.nl.acs.agv.server.impl.NDCAgvServiceImpl; +import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; import org.nl.acs.common.IDriverService; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver; @@ -32,6 +34,7 @@ import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.dto.ParamDto; import org.nl.modules.wql.core.bean.WQLObject; import org.nl.modules.wql.exception.WDKException; import org.nl.modules.wql.util.SpringContextHolder; @@ -59,6 +62,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { private final RouteLineService routeLineService; private final AcsToLiKuService acsToLiKuService; + private final ParamService paramService; + private String log_file_type = "log_file_type"; private String log_type = "LMS请求ACS"; @@ -469,6 +474,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { String task_type = req.getTask_type(); String remark = req.getRemark(); Map params = req.getParams(); + String start_height = req.getStart_height(); + String next_height = req.getNext_height(); String start_point_code = ""; String next_point_code = ""; @@ -570,6 +577,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { jo.put("remark", remark); jo.put("params", params); jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); + jo.put("start_height", start_height); + jo.put("next_height", next_height); TaskDto task_dto = jo.toJavaObject(TaskDto.class); try { @@ -604,5 +613,76 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } + /** + * 设备暂停恢复 + * + * @param whereJson 条件 + * @return JSONObject + */ + @Override + public JSONObject deviceOption(String whereJson) { + try { + MDC.put(log_file_type, log_type); + log.info("deviceOption-----输入参数{}", whereJson); + String option = JSONObject.parseObject(whereJson).getString("option"); + + JSONObject resultJSON = new JSONObject(); + switch (option) { + case "1": + // 急停AGV车辆 + byte[] bytes1 = { + (byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0C, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X08, + (byte) 0X32, (byte) 0X80, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X01 + }; + OneNDCSocketConnectionAutoRun.write(bytes1); + System.out.println("下发agv指令数据:" + NDCAgvServiceImpl.Bytes2HexString(bytes1)); + break; + case "2": + // 恢复急停AGV车辆 + byte[] bytes2 = { + (byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0C, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X08, + (byte) 0X32, (byte) 0X80, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X00 + }; + OneNDCSocketConnectionAutoRun.write(bytes2); + System.out.println("下发agv指令数据:" + NDCAgvServiceImpl.Bytes2HexString(bytes2)); + break; + case "3": + ParamDto sysParam3 = paramService.findByCode(AcsConfig.SEND_INST); + sysParam3.setValue("0"); + paramService.update(sysParam3); + break; + case "4": + ParamDto sysParam4 = paramService.findByCode(AcsConfig.SEND_INST); + sysParam4.setValue("1"); + paramService.update(sysParam4); + break; + default: + resultJSON.put("status", HttpStatus.BAD_REQUEST.value()); + resultJSON.put("message", "未知操作类型"); + return resultJSON; + } + resultJSON.put("status", HttpStatus.OK.value()); + resultJSON.put("message", "操作成功"); + return resultJSON; + } finally { + MDC.remove(log_file_type); + } + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java index 5a6f574..b741154 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java @@ -348,4 +348,14 @@ public class InstructionDto implements Serializable { */ private String agv_system_type; + /** + * 起点高度 + */ + private String start_height; + + /** + * 终点高度 + */ + private String next_height; + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 820a901..25c5d0b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -302,8 +302,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { dto.setInstruction_type(task.getTask_type()); - } else if (false) { - } else { dto.setInstruction_type("3"); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index c80a62d..f7f8a90 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -290,4 +290,14 @@ public class TaskDto implements Serializable { * 烘箱温度 */ private String temperature; + + /** + * 起点高度 + */ + private String start_height; + + /** + * 终点高度 + */ + private String next_height; } diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index e575119..a9bc0eb 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.AcsConfig; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.DeviceAppService; @@ -13,6 +14,8 @@ import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.dto.ParamDto; import org.nl.modules.wql.util.SpringContextHolder; import org.springframework.stereotype.Component; @@ -31,128 +34,139 @@ public class AutoCreateInst { * 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 */ public void run() throws Exception { - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - List list = taskserver.queryAll("task_status = '0'"); - for (int i = 0; i < list.size(); i++) { - TaskDto acsTask = list.get(i); - if(StrUtil.equals(acsTask.getTask_type(),"7") && !StrUtil.startWith(acsTask.getTask_code(), "-") ){ - continue; - } - String taskid = acsTask.getTask_id(); - String taskcode = acsTask.getTask_code(); - String task_type = acsTask.getTask_type(); - String vehiclecode = acsTask.getVehicle_code(); - String storage_task_type = acsTask.getStorage_task_type(); - String priority = acsTask.getPriority(); - String is_send = acsTask.getIs_send(); + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + + ParamDto sendInst = paramService.findByCode(AcsConfig.SEND_INST); + if ("1".equals(sendInst.getValue())) { + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + List list = taskserver.queryAll("task_status = '0'"); + for (int i = 0; i < list.size(); i++) { + TaskDto acsTask = list.get(i); + if (StrUtil.equals(acsTask.getTask_type(), "7") && !StrUtil.startWith(acsTask.getTask_code(), "-")) { + continue; + } + String taskid = acsTask.getTask_id(); + String taskcode = acsTask.getTask_code(); + String task_type = acsTask.getTask_type(); + String vehiclecode = acsTask.getVehicle_code(); + String storage_task_type = acsTask.getStorage_task_type(); + String priority = acsTask.getPriority(); + String is_send = acsTask.getIs_send(); - String start_device_code = acsTask.getStart_device_code(); - String start_point_code = acsTask.getStart_point_code(); + String start_device_code = acsTask.getStart_device_code(); + String start_point_code = acsTask.getStart_point_code(); - String put_device_code = acsTask.getPut_device_code(); - String put_point_code = acsTask.getPut_point_code(); + String put_device_code = acsTask.getPut_device_code(); + String put_point_code = acsTask.getPut_point_code(); - String next_device_code = acsTask.getNext_device_code(); - String next_point_code = acsTask.getNext_point_code(); + String next_device_code = acsTask.getNext_device_code(); + String next_point_code = acsTask.getNext_point_code(); - String start_point_code2 = acsTask.getStart_point_code2(); - String start_device_code2 = acsTask.getStart_device_code2(); + String start_point_code2 = acsTask.getStart_point_code2(); + String start_device_code2 = acsTask.getStart_device_code2(); - String next_point_code2 = acsTask.getNext_point_code2(); - String next_device_code2 = acsTask.getNext_device_code2(); + String next_point_code2 = acsTask.getNext_point_code2(); + String next_device_code2 = acsTask.getNext_device_code2(); - String route_plan_code = acsTask.getRoute_plan_code(); - String vehicleType = acsTask.getVehicle_type(); - String agv_system_type = acsTask.getAgv_system_type(); + String route_plan_code = acsTask.getRoute_plan_code(); + String vehicleType = acsTask.getVehicle_type(); + String agv_system_type = acsTask.getAgv_system_type(); + String start_height = acsTask.getStart_height(); + String next_height = acsTask.getNext_height(); - if (StrUtil.equals(is_send, "0")) { - continue; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - acsTask.setRemark("路由不通无法生成指令"); - taskserver.updateByCodeFromCache(acsTask); - continue; - } + if (StrUtil.equals(is_send, "0")) { + continue; + } - if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { - continue; - } + //校验路由关系 + List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); + if (ObjectUtils.isEmpty(shortPathsList)) { + acsTask.setRemark("路由不通无法生成指令"); + taskserver.updateByCodeFromCache(acsTask); + continue; + } - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; + if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) { + continue; } - } - next_device_code = pathlist.get(index); - if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); - } else { - next_point_code = next_device_code; - } + RouteLineDto routeLineDto = shortPathsList.get(0); + String path = routeLineDto.getPath(); + String type = routeLineDto.getType(); + String[] str = path.split("->"); + List pathlist = Arrays.asList(str); + int index = 0; + for (int m = 0; m < pathlist.size(); m++) { + if (pathlist.get(m).equals(start_device_code)) { + index = m + 1; + break; + } + } + next_device_code = pathlist.get(index); + if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { + next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); + } else { + next_point_code = next_device_code; + } - Instruction instdto = new Instruction(); - instdto.setInstruction_type(task_type); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(acsTask.getRemark()); - instdto.setMaterial(acsTask.getMaterial()); - instdto.setQuantity(acsTask.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - - instdto.setStart_device_code(start_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setPut_device_code(put_device_code); - instdto.setPut_point_code(put_point_code); - instdto.setNext_device_code(next_device_code); - instdto.setNext_point_code(next_point_code); - - instdto.setStart_point_code2(start_point_code2); - instdto.setStart_device_code2(start_device_code2); - instdto.setNext_point_code2(next_point_code2); - instdto.setNext_device_code2(next_device_code2); - - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(vehicleType); - instdto.setAgv_system_type(agv_system_type); - instdto.setAgv_inst_type("1"); - - - try { - instructionService.create(instdto); - } catch (Exception e) { - acsTask.setRemark(e.getMessage()); - taskserver.updateByCodeFromCache(acsTask); - continue; - } - //创建指令后修改任务状态 - acsTask.setTask_status("1"); - taskserver.update(acsTask); + Instruction instdto = new Instruction(); + instdto.setInstruction_type(task_type); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(acsTask.getRemark()); + instdto.setMaterial(acsTask.getMaterial()); + instdto.setQuantity(acsTask.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + + instdto.setStart_device_code(start_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setPut_device_code(put_device_code); + instdto.setPut_point_code(put_point_code); + instdto.setNext_device_code(next_device_code); + instdto.setNext_point_code(next_point_code); + + instdto.setStart_point_code2(start_point_code2); + instdto.setStart_device_code2(start_device_code2); + instdto.setNext_point_code2(next_point_code2); + instdto.setNext_device_code2(next_device_code2); + + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + instdto.setVehicle_type(vehicleType); + instdto.setAgv_system_type(agv_system_type); + instdto.setAgv_inst_type("1"); + + + instdto.setStart_height(start_height); + instdto.setNext_height(next_height); + + try { + instructionService.create(instdto); + } catch (Exception e) { + acsTask.setRemark(e.getMessage()); + taskserver.updateByCodeFromCache(acsTask); + continue; + } + //创建指令后修改任务状态 + acsTask.setTask_status("1"); + taskserver.update(acsTask); + + } } } }