diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java index 91e8ef9e6..9a70c32bc 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/AgvWaitUtil.java @@ -1,21 +1,17 @@ package org.nl.acs.agv; -import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.domain.Device; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.conveyor.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.one_conveyor.box_subvolumes_conveyor.BoxSubvolumesConveyorDeviceDriver; -import org.nl.acs.device_driver.one_manipulator.box_storage_manipulator.BoxStorageManipulatorDeviceDriver; import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.ManipulatorAgvStationDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.task.enums.ActionTypeEnum; import org.nl.acs.task.enums.AgvSystemTypeEnum; import org.nl.common.exception.BadRequestException; import org.nl.config.lucene.service.LuceneExecuteLogService; @@ -80,6 +76,12 @@ public class AgvWaitUtil { throw new BadRequestException("上位系统不允许取货"); } } + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("200:允许取货") + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); JSONObject map = new JSONObject(); map.put("status", 200); map.put("message", "允许取货!"); @@ -101,6 +103,7 @@ public class AgvWaitUtil { boxSubvolumesConveyorDeviceDriver.writing(3); } if(inst.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())){ + applyLmsGetOut(inst); manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) startDevice.getDeviceDriver(); manipulatorAgvStationDeviceDriver.writing(3); @@ -112,6 +115,40 @@ public class AgvWaitUtil { return map; } + private void applyLmsGetOut(Instruction inst) { + try { + JSONObject param = new JSONObject(); + param.put("taskCode", inst.getTask_code()); + param.put("actionType", ActionTypeEnum.IN_FINISHING.getCode().toString()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("诺宝取货完成:" + inst.getTask_code() + "--" + ActionTypeEnum.IN_FINISHING.getCode().toString()) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + String response = acsToWmsService.secondaryAllocationPoint(param); + JSONObject jo = JSON.parseObject(response); + if (jo.getInteger("status") == 200) { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("追加动诺宝作块,参数,接口返回:" + jo) + .build(); + logDto2.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto2); + } else { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(inst.getCarno()) + .content("追加动诺宝作块失败,返回参数:" + jo.getString("body")) + .build(); + logDto2.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto2); + throw new BadRequestException("追加动诺宝作块返回失败"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + //放货前等待 public JSONObject waitInPut(String endDeviceCode, Instruction inst) { log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index 26fbd3f67..9ba83d160 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -336,10 +336,18 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { //动作块id jo.put("blockId", IdUtil.simpleUUID()); //目的地名称 - jo.put("location", pointCode + "INGET"); + if (AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) { + jo.put("location", pointCode + "WAIT"); + } else { + jo.put("location", pointCode + "INGET"); + } //执行脚本 jo.put("operation", "script"); - jo.put("id", pointCode + "INGET"); + if (AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) { + jo.put("id", pointCode + "WAIT"); + } else { + jo.put("id", pointCode + "INGET"); + } //通信脚本,动作前后与现场设备交互的场景 jo.put("script_name", "userpy/interact.py"); JSONObject script_args = new JSONObject(); @@ -348,7 +356,11 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { JSONObject data = new JSONObject(); JSONObject reach = new JSONObject(); reach.put("task_code", instCode); - reach.put("address", pointCode + "INGET"); + if (AgvActionTypeEnum.IN_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) { + reach.put("address", pointCode + "WAIT"); + } else { + reach.put("address", pointCode + "INGET"); + } data.put("reach", reach); script_args.put("data", data); script_args.put("protocol", "HTTP"); @@ -403,16 +415,28 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { //放货前等待 JSONObject jo3 = new JSONObject(); jo3.put("blockId", IdUtil.simpleUUID()); - jo3.put("location", pointCode + "INPUT"); + if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) { + jo3.put("location", pointCode + "WAIT"); + } else { + jo3.put("location", pointCode + "INPUT"); + } jo3.put("operation", "script"); - jo3.put("id", pointCode + "INPUT"); + if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) { + jo3.put("id", pointCode + "WAIT"); + } else { + jo3.put("id", pointCode + "INPUT"); + } jo3.put("script_name", "userpy/interact.py"); JSONObject script_args3 = new JSONObject(); script_args3.put("addr", addr); JSONObject data3 = new JSONObject(); JSONObject reach3 = new JSONObject(); reach3.put("task_code", instCode); - reach3.put("address", pointCode + "INPUT"); + if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(agv_action_type) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(agv_action_type)) { + reach3.put("address", pointCode + "WAIT"); + } else { + reach3.put("address", pointCode + "INPUT"); + } data3.put("reach", reach3); script_args3.put("data", data3); script_args3.put("protocol", "HTTP"); @@ -695,14 +719,18 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { if (StrUtil.isBlank(address)) { throw new BadRequestException("请求失败,地址为空!"); } - if (address.contains("IN") || address.contains("WAITE")) { + if (address.contains("IN") || address.contains("WAIT")) { String task_code = instructionDto.getTask_code(); - String instructionCode = instructionDto.getInstruction_code(); - String deviceCodeNow = address.substring(0, address.length() - 5); + String deviceCodeNow; + if (address.contains("WAIT")) { + deviceCodeNow = address.substring(0, address.length() - 4); + } else { + deviceCodeNow = address.substring(0, address.length() - 5); + } if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); } - if (address.contains("GET")) { + if (address.contains("GET") || address.contains("WAIT")) { if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) { //如果是取货二次分配,取放货二次分配需要重新追加动作块 if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { @@ -721,7 +749,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } } return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto); - } else if (address.contains("PUT") || address.contains("WAITE")) { + } else if (address.contains("PUT") || address.contains("WAIT")) { if (instructionDto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) { //如果是放货二次分配,取放货二次分配需要重新追加动作块 if (AgvActionTypeEnum.OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type()) || AgvActionTypeEnum.IN_OUT_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { @@ -909,7 +937,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { luceneExecuteLogService.deviceExecuteLog(logDto2); if (!ActionTypeEnum.IN_FINISHING.getCode().equals(actionType)) { //请求成功调用诺宝追加动作块 - sendAddSequencesToNBAgv(task_code, jo.getString("data"), instructionDto); + sendAddSequencesToNBAgv(instructionDto.getInstruction_code(), jo.getString("data"), instructionDto); } return jo.getString("data"); @@ -1019,7 +1047,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { .timeout(20000) .execute(); LuceneLogDto logDto1 = LuceneLogDto.builder() - .device_code("叉车运单响应") + .device_code("追加诺宝运单参数") .content("指令号:" + instructionCode + ",下发追加诺宝运单反馈参数:" + jo) .build(); logDto.setLog_level(4); @@ -1079,25 +1107,25 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } private void sendEndDeviceOrder2(JSONArray ja, String nextDeviceCode, String instructionCode, Instruction instructionDto) { - //放货前等待 - JSONObject jo3 = new JSONObject(); - jo3.put("blockId", IdUtil.simpleUUID()); - jo3.put("location", nextDeviceCode + "INPUT"); - jo3.put("operation", "script"); - jo3.put("id", nextDeviceCode + "INPUT"); - jo3.put("script_name", "userpy/interact.py"); - JSONObject script_args3 = new JSONObject(); - script_args3.put("addr", addr); - JSONObject data3 = new JSONObject(); - JSONObject reach3 = new JSONObject(); - reach3.put("task_code", instructionCode); - reach3.put("address", nextDeviceCode + "INPUT"); - data3.put("reach", reach3); - script_args3.put("data", data3); - script_args3.put("protocol", "HTTP"); - jo3.put("script_args", script_args3); - ja.add(jo3); if (AgvActionTypeEnum.IN_STOCK.getCode().equals(instructionDto.getAgv_action_type())) { + //放货前等待 + JSONObject jo3 = new JSONObject(); + jo3.put("blockId", IdUtil.simpleUUID()); + jo3.put("location", nextDeviceCode + "INPUT"); + jo3.put("operation", "script"); + jo3.put("id", nextDeviceCode + "INPUT"); + jo3.put("script_name", "userpy/interact.py"); + JSONObject script_args3 = new JSONObject(); + script_args3.put("addr", addr); + JSONObject data3 = new JSONObject(); + JSONObject reach3 = new JSONObject(); + reach3.put("task_code", instructionCode); + reach3.put("address", nextDeviceCode + "INPUT"); + data3.put("reach", reach3); + script_args3.put("data", data3); + script_args3.put("protocol", "HTTP"); + jo3.put("script_args", script_args3); + ja.add(jo3); //将货物放下 com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject(); jo4.put("blockId", IdUtil.simpleUUID()); @@ -1376,16 +1404,16 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { JSONObject jo9 = new JSONObject(); jo9.put("blockId", IdUtil.simpleUUID()); - jo9.put("location", inst.getNext_device_code() + "WAITE"); + jo9.put("location", inst.getNext_device_code() + "WAIT"); jo9.put("operation", "script"); - jo9.put("id", inst.getNext_device_code() + "WAITE"); + jo9.put("id", inst.getNext_device_code() + "WAIT"); jo9.put("script_name", "userpy/interact.py"); JSONObject script_args5 = new JSONObject(); script_args5.put("addr", addr); JSONObject data3 = new JSONObject(); JSONObject reach3 = new JSONObject(); reach3.put("task_code", inst.getInstruction_code()); - reach3.put("address", inst.getNext_device_code() + "WAITE"); + reach3.put("address", inst.getNext_device_code() + "WAIT"); data3.put("reach", reach3); script_args5.put("data", data3); script_args5.put("protocol", "HTTP"); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java index b71c2b5eb..4e1267bd1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -482,6 +482,14 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } else { //查看是否存在输送线到对接为的指令 Instruction byNextDeviceCodeFromCache = instructionService.findByNextDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isNotEmpty(byNextDeviceCodeFromCache)){ + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("存在堆垛机对接为的指令") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } //补码生成堆垛机对接位到货架的指令 if (StrUtil.isNotEmpty(hand_barcode) && ObjectUtil.isEmpty(byNextDeviceCodeFromCache)) { TaskDto taskDtoHandCode = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java index 93b818581..e83d76910 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java @@ -45,10 +45,8 @@ import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.dto.LuceneLogDto; import org.springframework.beans.factory.annotation.Autowired; -import java.time.LocalDateTime; import java.util.*; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * 单工位堆垛机驱动 @@ -996,7 +994,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } List list = new ArrayList(); pakageCommand(list, inst.getInstruction_code()); - packagePlcCoordinate(startDevice, list); + packagePlcCoordinate(startDevice, list,"1"); if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name()) && !prohibitOutWarehouse) { pakagePlc(inst, list,"1"); } @@ -1009,7 +1007,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme return true; } - private void packagePlcCoordinate(Device startDevice, List list) { + private void packagePlcCoordinate(Device startDevice, List list, String toCommand) { if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name()) && !prohibitInWarehouse) { if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z"))) { HashMap map4 = new HashMap(); @@ -1029,6 +1027,10 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme map6.put("value", startDevice.getExtraValue().get("y")); list.add(map6); } + HashMap map2 = new HashMap(); + map2.put("code", "to_command"); + map2.put("value", toCommand); + list.add(map2); } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 1e611a0ce..bddbcc1d5 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -546,14 +546,14 @@ public class InstructionServiceImpl extends CommonServiceImpl instructionMybatis = instructionMapper.selectList(Wrappers.lambdaQuery(InstructionMybatis.class) - .eq(InstructionMybatis::getTask_code, dto.getTask_code())); - if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code() - .equals(start_device_code))) { - return; - } - } +// if (StrUtil.isNotEmpty(dto.getTask_code())) { +// List instructionMybatis = instructionMapper.selectList(Wrappers.lambdaQuery(InstructionMybatis.class) +// .eq(InstructionMybatis::getTask_code, dto.getTask_code())); +// if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code() +// .equals(start_device_code))) { +// return; +// } +// } String currentUsername = SecurityUtils.getCurrentNickName(); String now = DateUtil.now(); if (StrUtil.isEmpty(dto.getRoute_plan_code())) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java index 6acfbbef1..abf9625ed 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/AgvSystemTypeEnum.java @@ -11,14 +11,17 @@ import lombok.Getter; @AllArgsConstructor public enum AgvSystemTypeEnum { /** + * 二期一楼AGV任务 * 一期1楼叉车NDC系统 */ One_NDC_System_Type("1", "1", "一期1楼叉车NDC系统"), /** + * 二期二楼NDC系统 * 一期2楼NDC系统 */ Two_NDC_System_Type("2", "2", "一期2楼NDC系统"), /** + * 二期一楼叉车任务 * 仙工AGV系统 */ XG_System_Type("3", "3", "仙工AGV系统");