From f51ffedaa2083e96de6d2d3bd075ca71b08e25a8 Mon Sep 17 00:00:00 2001 From: yanps Date: Wed, 7 Aug 2024 14:27:11 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=B7=BB=E5=8A=A0=E5=8F=96=E6=94=BE?= =?UTF-8?q?=E8=B4=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../run/OneNDCSocketConnectionAutoRun.java | 4 +- .../agv/ndcone/AgvNdcOneDeviceDriver.java | 60 ++++---- .../wms/service/impl/AcsToWmsServiceImpl.java | 2 + .../src/main/resources/logback-spring.xml | 13 +- .../device/driver/standard_ordinary_site.vue | 7 +- .../java/org/nl/common/enums/GoodsEnum.java | 4 +- .../acs/controller/AcsToWmsController.java | 13 +- .../wms/ext/acs/service/AcsToWmsService.java | 7 + .../acs/service/impl/AcsToWmsServiceImpl.java | 135 ++++++++++++++---- .../connector/service/dto/ConnectorDto.java | 2 +- .../impl/ConnectorToWmsServiceImpl.java | 18 ++- .../dao/SchBaseVehiclematerialgroup.java | 3 + .../point/service/ISchBasePointService.java | 8 ++ .../service/impl/SchBasePointServiceImpl.java | 30 ++-- .../nl/wms/sch/task_manage/AbstractTask.java | 3 +- .../task_manage/task/tasks/cnt/CNTTask.java | 10 +- .../task_manage/task/tasks/cnt/FTGTask.java | 10 +- .../main/java/org/nl/wms/util/PointUtils.java | 3 +- 18 files changed, 235 insertions(+), 97 deletions(-) diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index 55b9d09..4c10308 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -236,9 +236,9 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { //上报异常信息 //(不需要WCS反馈) if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) { - device = deviceAppService.findDeviceByCode(Integer.toString(agvaddr)); + device = deviceAppService.findDeviceByCode("agv"+ Integer.toString(agvaddr)); } else { - device = deviceAppService.findDeviceByCode(Integer.toString(arr[20])); + device = deviceAppService.findDeviceByCode("agv"+ Integer.toString(arr[20])); } if (ObjectUtil.isNotEmpty(device)) { if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index afd27cc..9527a12 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -154,7 +154,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic return; } device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (agvaddr != 0) { + /*if (agvaddr != 0) { old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); if (StrUtil.contains(old_device_code, "-")) { String[] point = old_device_code.split("-"); @@ -166,6 +166,11 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } else { device_code = old_device_code; } + }*/ + + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + device_code = old_device_code; } device = deviceAppService.findDeviceByCode(device_code); @@ -188,13 +193,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if ("1".equals(plc_to_agv)) { plcToAgvDeviceDriver.writing("AGVSetOutReqUpper", "1"); if (plcToAgvDeviceDriver.getAGVSetOutUpperAllowed() == 1) { - data = feedBackStatus(data, index, 1, inst, task); + data = feedBackStatus(data, index, 1, inst, task,2,false); plcToAgvDeviceDriver.writing("AGVInOP", "1"); } } else if ("2".equals(plc_to_agv)) { plcToAgvDeviceDriver.writing("AGVSetOutReqLower", "1"); if (plcToAgvDeviceDriver.getAGVSetOutLowerAllowed() == 1) { - data = feedBackStatus(data, index, 1, inst, task); + data = feedBackStatus(data, index, 1, inst, task,2,false); plcToAgvDeviceDriver.writing("AGVInOP", "1"); } } @@ -206,7 +211,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } } else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { try { - data = feedBackStatus(data, index, 1, inst, task); + data = feedBackStatus(data, index, 1, inst, task,1,false); } catch (Exception e) { log.info("到达取货点反馈AGV状态失败:{}", e.getMessage()); } @@ -229,16 +234,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } if (agvaddr != 0) { old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } + device_code = old_device_code; } device = deviceAppService.findDeviceByCode(device_code); @@ -260,10 +256,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } catch (Exception e) { log.info("下发AGVInOP信号:{}失败", "0"); } - data = feedBackStatus(data, index, 2, inst, task); + data = feedBackStatus(data, index, 2, inst, task,2,false); } else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { try { - data = feedBackStatus(data, index, 2, inst, task); + data = feedBackStatus(data, index, 2, inst, task,1,false); } catch (Exception e) { log.info("取货完成反馈AGV状态失败:{}", e.getMessage()); } @@ -284,18 +280,22 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); return; } - if (agvaddr != 0) { + /*if (agvaddr != 0) { old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); if (StrUtil.contains(old_device_code, "-")) { String[] point = old_device_code.split("-"); + emptyNum = point[1]; device_code = point[0]; } else if (StrUtil.contains(old_device_code, ".")) { String[] point = old_device_code.split("\\."); device_code = point[0]; - emptyNum = point[1]; } else { device_code = old_device_code; } + }*/ + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + device_code = old_device_code; } device = deviceAppService.findDeviceByCode(device_code); if (ObjectUtil.isEmpty(device_code)) { @@ -315,13 +315,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic if ("1".equals(plc_to_agv)) { plcToAgvDeviceDriver.writing("AGVSetInReqUpper", "1"); if (plcToAgvDeviceDriver.getAGVSetInUpperAllowed() == 1) { - data = feedBackStatus(data, index, 3, inst, task); + data = feedBackStatus(data, index, 3, inst, task,2,false); plcToAgvDeviceDriver.writing("AGVInOP", "1"); } } else if ("2".equals(plc_to_agv)) { plcToAgvDeviceDriver.writing("AGVSetInReqLower", "1"); if (plcToAgvDeviceDriver.getAGVSetInLowerAllowed() == 1) { - data = feedBackStatus(data, index, 3, inst, task); + data = feedBackStatus(data, index, 3, inst, task,2,false); plcToAgvDeviceDriver.writing("AGVInOP", "1"); } } @@ -333,7 +333,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } } else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { try { - data = feedBackStatus(data, index, 3, inst, task); + data = feedBackStatus(data, index, 2, inst, task,1,false); } catch (Exception e) { log.info("到达放货点反馈AGV状态失败:{}", e.getMessage()); } @@ -351,7 +351,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); return; } - if (agvaddr != 0) { + /*if (agvaddr != 0) { old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); if (StrUtil.contains(old_device_code, "-")) { String[] point = old_device_code.split("-"); @@ -363,6 +363,11 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } else { device_code = old_device_code; } + }*/ + + if (agvaddr != 0) { + old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + device_code = old_device_code; } device = deviceAppService.findDeviceByCode(device_code); @@ -387,10 +392,12 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } catch (Exception e) { log.info("下发AGVInOP信号:{}失败", "0"); } - data = feedBackStatus(data, index, 4, inst, task); + data = feedBackStatus(data, index, 4, inst, task,2,false); } else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { try { - data = feedBackStatus(data, index, 4, inst, task); + StandardOrdinarySiteDeviceDriver standar = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); + boolean is_empty = (boolean)standar.getDevice().getExtraValue().get("is_empty"); + data = feedBackStatus(data, index, 2, inst, task,1,false); } catch (Exception e) { log.info("放货完成反馈AGV状态失败:{},", e.getMessage()); } @@ -458,16 +465,19 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic return data; } - private byte[] feedBackStatus(byte[] data, int index, int agvStatus, Instruction inst, TaskDto task) { + private byte[] feedBackStatus(byte[] data, int index, int agvStatus, Instruction inst, TaskDto task,int connector_and_sorting,boolean is_empty) { String hasWms = paramService.findByCode("hasWms").getValue(); if (StrUtil.isNotEmpty(hasWms) && "1".equals(hasWms)) { log.info("存在LMS系统,需要反馈,指令号:{}",inst.getInstruction_code()); JSONArray ja = new JSONArray(); JSONObject jo = new JSONObject(); + jo.put("is_connector", connector_and_sorting == 1? 1:2); + jo.put("task_type",task.getTask_type()); jo.put("vehicle_code", inst.getVehicle_code()); jo.put("status", agvStatus); jo.put("device_code", this.device_code); jo.put("task_code", inst.getTask_code()); + jo.put("is_empty", is_empty); ja.add(jo); HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(ja); log.info("指令号:{},phase:{},acs反馈wms结果:{}", inst.getInstruction_code(), phase, httpResponse); diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 5d85266..615322b 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -150,6 +150,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); JSONObject jo = new JSONObject(); jo.put("task_id", task_id); + jo.put("vehicle_code", vehicle_code); + jo.put("device_code",address); String result2 = null; AddressDto addressDto = addressService.findByCode("requestTaskAgain"); diff --git a/acs/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml b/acs/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml index 04a1da0..0d4311e 100644 --- a/acs/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml @@ -18,13 +18,12 @@ https://juejin.cn/post/6844903775631572999 - - - - - - - + + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue b/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue index 0cd0926..7af3bdb 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/standard_ordinary_site.vue @@ -74,8 +74,8 @@ - - + + @@ -179,7 +179,8 @@ export default { station_manager: true, auto_clean_task: true, input_material: true, - reqWms: true + reqWms: true, + is_empty: true }, rules: {} } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/common/enums/GoodsEnum.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/common/enums/GoodsEnum.java index 987c4a8..c394622 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/common/enums/GoodsEnum.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/common/enums/GoodsEnum.java @@ -13,10 +13,10 @@ public enum GoodsEnum { OUT_OF_STOCK("无货","0"), - IN_STOCK("有货","1"), - EMPTY_PALLETS("空料容","1"), + IN_STOCK("有货","2"), + PICK_UP("取货","1"), DELIVER_GOODS("送货","2"); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java index 0e42154..aeba769 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/controller/AcsToWmsController.java @@ -91,11 +91,20 @@ public class AcsToWmsController { @PostMapping("/feedAgvTaskStatus") - @Log("acs通知wms") - @ApiOperation("acs通知wms") + @Log("agv取放货反馈") + @ApiOperation("agv取放货反馈") @SaIgnore @Deprecated public ResponseEntity feedAgvTaskStatus(@RequestBody JSONObject param) { return new ResponseEntity<>(acsToWmsService.feedAgvTaskStatus(param), HttpStatus.OK); } + + @PostMapping("/feedAgvAgain") + @Log("acs申请二次放货点") + @ApiOperation("acs申请二次放货点") + @SaIgnore + @Deprecated + public ResponseEntity feedAgvAgain(@RequestBody JSONObject param) { + return new ResponseEntity<>(acsToWmsService.feedAgvAgain(param), HttpStatus.OK); + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java index 74b33f8..4882080 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/AcsToWmsService.java @@ -35,4 +35,11 @@ public interface AcsToWmsService { * @return */ Object feedAgvTaskStatus(JSONObject param); + + /** + * 申请二次分配点位 + * @param param + * @return + */ + Object feedAgvAgain(JSONObject param); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index eed508c..74c8c67 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -1,6 +1,7 @@ package org.nl.wms.ext.acs.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -8,12 +9,15 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpStatus; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.extern.slf4j.Slf4j; import org.nl.common.enums.GoodsEnum; import org.nl.common.exception.BadRequestException; import org.nl.system.service.notice.ISysNoticeService; import org.nl.wms.cockpit.service.dao.DasDeviceFault; import org.nl.wms.cockpit.service.mapper.CockpitMapper; +import org.nl.wms.database.vehicle.service.IMdBaseVehicleService; +import org.nl.wms.database.vehicle.service.dao.MdBaseVehicle; import org.nl.wms.ext.acs.service.AcsToWmsService; import org.nl.wms.ext.acs.service.dto.to.BaseResponse; import org.nl.wms.ext.acs.service.dto.to.acs.AgainApplyResponse; @@ -23,6 +27,7 @@ import org.nl.wms.ext.connector.service.WmsToConnectorService; import org.nl.wms.ext.connector.service.dto.ConnectorDto; import org.nl.wms.ext.record.service.ISysInteractRecordService; import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; +import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; import org.nl.wms.sch.point.service.ISchBasePointService; import org.nl.wms.sch.point.service.dao.SchBasePoint; import org.nl.wms.sch.task.service.ISchBaseTaskService; @@ -34,6 +39,7 @@ import org.nl.wms.sch.task_manage.GeneralDefinition; import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; import org.nl.wms.sch.task_manage.task.TaskFactory; import org.nl.wms.sch.task_manage.task.core.TaskStatus; +import org.nl.wms.sch.task_manage.task.core.TaskType; import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -67,7 +73,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { @Autowired private ISchBasePointService pointService; @Autowired - private ISchBaseVehiclematerialgroupService vehiclematerialgroupService; + private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService; @Autowired private TaskFactory taskFactory; @Autowired @@ -82,6 +88,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { private WmsToConnectorService connectorService; @Autowired private ISchBaseTaskconfigService taskConfigService; + @Autowired + private IMdBaseVehicleService iMdBaseVehicleService; /** * 初始化反射方法 @@ -269,7 +277,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { if (ObjectUtil.isNotEmpty(param)) { String status = param.getString("status"); String task_code = param.getString("task_code"); + // 1.connector;2.sorting String is_connector = param.getString("is_connector"); + String task_type = param.getString("task_type"); + boolean is_empty = param.getBoolean("is_empty"); if (StrUtil.isEmpty(status) || StrUtil.isEmpty(task_code)) { throw new BadRequestException("状态或任务号为空!"); } @@ -280,15 +291,15 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { switch (status) { case "1": //申请取货 - requestPickup(schBaseTask, status); + requestPickup(schBaseTask, status, is_connector); break; case "2": //取货完成 - pickupComplete(schBaseTask, status, is_connector); + pickupComplete(schBaseTask, status, is_connector, task_type); break; case "4": //放货完成 - releaseComplete(schBaseTask, status); + releaseComplete(schBaseTask, status, is_connector, task_type, is_empty); break; default: break; @@ -297,15 +308,56 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { return null; } + @Override + public Object feedAgvAgain(JSONObject param) { + if(ObjectUtil.isNotEmpty(param)){ + String task_id = param.getString("task_id"); + String device_code = param.getString("device_code"); + if(StrUtil.isEmpty(task_id) || StrUtil.isEmpty(device_code)){ + throw new BadRequestException("task_id或device_code为空!"); + } + SchBaseTask schBaseTask = taskService.getById(task_id); + if(ObjectUtil.isEmpty(schBaseTask)){ + throw new BadRequestException("任务不存在!task_id:" + task_id); + } + if(device_code.equals(schBaseTask.getPoint_code2())) throw new BadRequestException("设备号与任务设备不匹配!"); + //查询点位是否存在 + SchBasePoint schBasePoint = pointService.selectByPointCode(device_code); + if(ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("点位不存在!device_code:" + device_code); + SchBasePoint schBasePoint1 = pointService.selectByNextWaitPoint(device_code); + // + } + return null; + } + /** * 放货完成 * * @param schBaseTask * @param status */ - private void releaseComplete(SchBaseTask schBaseTask, String status) { - //TODO:放货完成反馈给Connector + private void releaseComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType, boolean is_empty) { + //TODO:空料容放货完成反馈给Connector + if ("1".equals(is_connector)) { + if (!is_empty) { + finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code2()); + } else { + JSONObject json = new JSONObject(); + json.put("vehicle_code", schBaseTask.getVehicle_code()); + json.put("status", status); + json.put("device_code", schBaseTask.getPoint_code2()); + json.put("task_code", schBaseTask.getTask_code()); + AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); + finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code1()); + } + } + } + private void finishTask(String task_code, String point_code) { + pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code) + .set(SchBasePoint::getIs_lock, false)); + taskService.update(Wrappers.lambdaUpdate(SchBaseTask.class).eq(SchBaseTask::getTask_code, task_code) + .set(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())); } /** @@ -314,20 +366,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { * @param schBaseTask * @param status */ - private void pickupComplete(SchBaseTask schBaseTask, String status, String is_connector) { + private void pickupComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType) { //TODO:取货完成创建第二条任务:补空托盘 - if("1".equals(is_connector)){ + if ("1".equals(is_connector)) { + List list = taskService.list(Wrappers.lambdaQuery(SchBaseTask.class).eq(SchBaseTask::getPoint_code2, schBaseTask.getPoint_code1()) + .in(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(), TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode())); + if (CollUtil.isNotEmpty(list) || list.size() > 0) { + throw new BadRequestException("该点位已有任务,请等待任务完成"); + } + MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getById(schBaseTask.getVehicle_code()); AbstractTask connectorTask = taskFactory.getTask("FTGTask"); // 准备参数:设备编码 JSONObject param = new JSONObject(); - param.put("device_code", schBaseTask.getPoint_code2()); + param.put("device_code", schBaseTask.getPoint_code1()); param.put("config_code", "FTGTask"); param.put("create_mode", GeneralDefinition.AUTO_CREATION); - /*param.put("vehicle_code", vehicle_code); - param.put("task_type", task_type); - param.put("task_code", task_code); - param.put("remark",remark);*/ + param.put("vehicle_type", StrUtil.isNotEmpty(mdBaseVehicle.getVehicle_type()) ? mdBaseVehicle.getVehicle_type() : ""); connectorTask.apply(param); + pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) + .eq(SchBasePoint::getPoint_code, schBaseTask.getPoint_code1()).set(SchBasePoint::getIs_lock, true)); + JSONObject json = new JSONObject(); + json.put("vehicle_code", schBaseTask.getVehicle_code()); + json.put("status", status); + json.put("device_code", schBaseTask.getPoint_code1()); + json.put("task_code", schBaseTask.getTask_code()); + AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); } } @@ -336,27 +399,39 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { * * @param schBaseTask */ - private void requestPickup(SchBaseTask schBaseTask, String status) { - //反馈connector申请取货 - SchBaseTaskconfig schBaseTaskconfig = taskConfigService.selectByConfigCode(schBaseTask.getConfig_code()); - JSONObject json = new JSONObject(); - if (GoodsEnum.PICK_UP.getValue().equals(schBaseTaskconfig.getTask_qf_type())) { - json.put("vehicle_code", schBaseTask.getVehicle_code()); - json.put("status", status); - json.put("device_code", schBaseTask.getPoint_code2()); - json.put("task_code", schBaseTask.getTask_code()); - } else if (GoodsEnum.DELIVER_GOODS.getValue().equals(schBaseTaskconfig.getTask_qf_type())) { + private void requestPickup(SchBaseTask schBaseTask, String status, String is_connector) { + if ("1".equals(is_connector)) { + //反馈connector申请取货 + /*SchBaseTaskconfig schBaseTaskconfig = taskConfigService.selectByConfigCode(schBaseTask.getConfig_code());*/ + JSONObject json = new JSONObject(); + // if (GoodsEnum.PICK_UP.getValue().equals(schBaseTaskconfig.getTask_qf_type())) { + // json.put("vehicle_code", schBaseTask.getVehicle_code()); + // json.put("status", status); + // json.put("device_code", schBaseTask.getPoint_code2()); + // json.put("task_code", schBaseTask.getTask_code()); + // } else if (GoodsEnum.DELIVER_GOODS.getValue().equals(schBaseTaskconfig.getTask_qf_type())) { json.put("vehicle_code", schBaseTask.getVehicle_code()); json.put("status", status); json.put("device_code", schBaseTask.getPoint_code1()); json.put("task_code", schBaseTask.getTask_code()); - } - boolean flag = true; - while (flag) { - AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); - if (acsResponse.getStatus() == 200 && StrUtil.isNotEmpty(acsResponse.getData())) { - vehiclematerialgroupService.updateByVehicleCode(schBaseTask.getVehicle_code(), acsResponse.getData()); - flag = false; + boolean flag = true; + while (flag) { + AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); + if (acsResponse.getStatus() == 200 && StrUtil.isNotEmpty(acsResponse.getData())) { + JSONArray objects = JSONObject.parseArray(acsResponse.getData()); + List connectorDtos = BeanUtil.copyToList(objects, ConnectorDto.class); + for (ConnectorDto connectorDto : connectorDtos) { + SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup(); + schBaseVehiclematerialgroup.setVehicle_code(connectorDto.getVehicle_code()); + schBaseVehiclematerialgroup.setJob_name(connectorDto.getJobname()); + schBaseVehiclematerialgroup.setMaterial_id(connectorDto.getProductID()); + schBaseVehiclematerialgroup.setMaterial_qty(connectorDto.getCurrentqty()); + schBaseVehiclematerialgroup.setRegion_code(connectorDto.getProductionOrder()); + iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); + } + // vehiclematerialgroupService.updateByVehicleCode(schBaseTask.getVehicle_code(), acsResponse.getData()); + flag = false; + } } } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/dto/ConnectorDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/dto/ConnectorDto.java index 469533b..b637d8d 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/dto/ConnectorDto.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/dto/ConnectorDto.java @@ -31,7 +31,7 @@ public class ConnectorDto { /** * 装载数量 */ - private String Currentqty; + private Integer Currentqty; /** * X尺寸 */ diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/impl/ConnectorToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/impl/ConnectorToWmsServiceImpl.java index bc9c447..b03138f 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/impl/ConnectorToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/connector/service/impl/ConnectorToWmsServiceImpl.java @@ -59,17 +59,22 @@ public class ConnectorToWmsServiceImpl implements ConnectorToWmsService { if (StrUtil.isEmpty(task_code) || StrUtil.isEmpty(start_device_code) || StrUtil.isEmpty(vehicle_code)) { map1.put("task_code", task_code); map1.put("status", HttpStatus.HTTP_INTERNAL_ERROR); - map1.put("message",StrUtil.isEmpty(task_code) ? "任务号不能为空!" + map1.put("message", StrUtil.isEmpty(task_code) ? "任务号不能为空!" : StrUtil.isEmpty(start_device_code) ? "起点参数不能为空!" : StrUtil.isEmpty(vehicle_code) ? "载具号不能为空!" : "未知"); objects.add(map1); continue; } SchBasePoint schBasePoint = schBasePointService.selectByPointCode(start_device_code); - if(ObjectUtil.isEmpty(schBasePoint) || StrUtil.isNotEmpty(schBasePoint.getIng_task_code())){ + if (ObjectUtil.isEmpty(schBasePoint)) { map1.put("task_code", task_code); map1.put("status", HttpStatus.HTTP_INTERNAL_ERROR); - map1.put("message",ObjectUtil.isEmpty(schBasePoint) - ? start_device_code + "起点设备不存在!" : start_device_code + "该设备正在执行任务!"); + map1.put("message", start_device_code + "起点设备不存在!"); + objects.add(map1); + continue; + } else if (schBasePoint.getIs_lock()) { + map1.put("task_code", task_code); + map1.put("status", HttpStatus.HTTP_INTERNAL_ERROR); + map1.put("message", start_device_code + "该设备正在执行任务!"); objects.add(map1); continue; } @@ -88,9 +93,10 @@ public class ConnectorToWmsServiceImpl implements ConnectorToWmsService { param.put("vehicle_code", vehicle_code); param.put("task_type", task_type); param.put("task_code", task_code); - param.put("remark",remark); + param.put("remark", remark); + param.put("ext_data", data); connectorTask.apply(param); - /*schBasePoint.setIng_task_code(task_code); + /*schBasePoint.setIs_lock(true); schBasePointService.updateById(schBasePoint);*/ map1.put("task_code", task_code); map1.put("status", HttpStatus.HTTP_OK); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/SchBaseVehiclematerialgroup.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/SchBaseVehiclematerialgroup.java index 31bd077..e8dfc6b 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/SchBaseVehiclematerialgroup.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/group/service/dao/SchBaseVehiclematerialgroup.java @@ -65,6 +65,9 @@ public class SchBaseVehiclematerialgroup implements Serializable { @ApiModelProperty(value = "物料数量") private Integer material_qty; + @ApiModelProperty(value = "connector任务号") + private String job_name; + @ApiModelProperty(value = "物料重量") private BigDecimal material_weight; diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java index a0f8564..889b27c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java @@ -101,4 +101,12 @@ public interface ISchBasePointService extends IService { * @return */ SchBasePoint selectByReassign(String region_code ,String vehicleCode); + + /** + * 根据终点等待设备查询 + * @param device_code + * @return + */ + SchBasePoint selectByNextWaitPoint(String device_code); + } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java index d6e8634..0a794c6 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java @@ -237,8 +237,8 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). - isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getRegion_code, region_code) - .eq(SchBasePoint::getVehicle_type, mdBaseVehicle.getVehicle_type()).eq(SchBasePoint::getIs_used, true)); + isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getRegion_code, region_code).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) + .eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()).eq(SchBasePoint::getIs_used, true)); if(CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0){ SchBasePoint schBasePoint = schBasePoints.get(0); schBasePoint.setVehicle_code(vehicleCode); @@ -254,8 +254,8 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). - isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getVehicle_type, mdBaseVehicle.getVehicle_type()) - .eq(SchBasePoint::getIs_used, true)); + isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) + .eq(SchBasePoint::getIs_used, true).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); if(CollUtil.isNotEmpty(schBasePoints1) && schBasePoints1.size() > 0){ SchBasePoint schBasePoint = schBasePoints.get(0); schBasePoint.setVehicle_code(vehicleCode); @@ -274,7 +274,8 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). - isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getRegion_code, region_code) - .eq(SchBasePoint::getVehicle_type, mdBaseVehicle.getVehicle_type()).eq(SchBasePoint::getIs_used, true)); + isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getRegion_code, region_code).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) + .eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()).eq(SchBasePoint::getIs_used, true)); if(CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0){ SchBasePoint schBasePoint = pointMapper.selectById(schBasePoints.get(0).getNext_wait_point()); if(ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("没有找到等待点!"); @@ -302,8 +303,8 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). - isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getVehicle_type, mdBaseVehicle.getVehicle_type()) - .eq(SchBasePoint::getIs_used, true)); + isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) + .eq(SchBasePoint::getIs_used, true).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); if(CollUtil.isNotEmpty(schBasePoints1) && schBasePoints1.size() > 0){ SchBasePoint schBasePoint = pointMapper.selectById(schBasePoints.get(0).getNext_wait_point()); if(ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("没有找到等待点!"); @@ -321,6 +322,17 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getNext_wait_point, device_code).eq(SchBasePoint::getIs_used, true) + .eq(SchBasePoint::getIs_lock, false).isNull(SchBasePoint::getVehicle_code) + .eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); + if(CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0){ + return schBasePoints.get(0); + } + return null; + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public SchBasePoint selectEmpVehicleByRegionCode(String region_code, String...vehicleType) { diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java index 32f2cf8..46f3d71 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java @@ -266,13 +266,14 @@ public abstract class AbstractTask { ? param.getString("create_mode") : GeneralDefinition.ACS_CREATION); task.setVehicle_code(param.getString("vehicle_code")); task.setVehicle_qty(param.getInteger("vehicle_qty")); + task.setVehicle_type(param.getString("vehicle_type")); task.setTask_status(TaskStatus.APPLY.getCode()); task.setTask_type(StrUtil.isNotEmpty(param.getString("task_type")) ? param.getString("task_type") : taskConfig.getTask_type()); task.setWorkshop_code(taskConfig.getWorkshop_code()); task.setRemark(param.getString("remark")); // 设置起/终点 this.setTaskPoint(taskConfig, task, apply_point_code); - task.setRequest_param(JSONObject.toJSONString(param)); + task.setRequest_param(JSONObject.toJSONString(param.get("ext_data"))); // 设置创建人信息 TaskUtils.setCreateByAcsOrPda(task, param); AbstractTask bean = SpringContextHolder.getBean(this.getClass()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/CNTTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/CNTTask.java index 6b9ef31..0bef331 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/CNTTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/CNTTask.java @@ -3,7 +3,9 @@ package org.nl.wms.sch.task_manage.task.tasks.cnt; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.extern.slf4j.Slf4j; +import org.nl.common.enums.GoodsEnum; import org.nl.common.enums.region.RegionEnum; import org.nl.common.exception.BadRequestException; import org.nl.system.service.notice.ISysNoticeService; @@ -87,7 +89,7 @@ public class CNTTask extends AbstractTask { task.setTask_status(TaskStatus.CREATED.getCode()); taskService.updateById(task); - schBasePoint.setIng_task_code(task.getTask_code()); + schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); PointUtils.setUpdateByAcs(schBasePoint); pointService.updateById(schBasePoint); } @@ -153,13 +155,15 @@ public class CNTTask extends AbstractTask { // 起点清空 if (ObjectUtil.isNotEmpty(schBasePoint)) { PointUtils.updateByIngTaskCode(schBasePoint); - pointService.updateById(schBasePoint); + pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint) + .set(SchBasePoint::getIs_lock, false).set(SchBasePoint::getVehicle_code, null)); } String point_code2 = taskObj.getPoint_code2(); SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); if (ObjectUtil.isNotEmpty(schBasePoint2)) { PointUtils.updateByIngTaskCode(schBasePoint2); - pointService.updateById(schBasePoint2); + pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2) + .set(SchBasePoint::getIs_lock, false).set(SchBasePoint::getVehicle_code, null)); } taskObj.setTask_status(TaskStatus.CANCELED.getCode()); taskObj.setRemark(GeneralDefinition.TASK_CANCEL); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/FTGTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/FTGTask.java index c03ec2c..bd2eb95 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/FTGTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cnt/FTGTask.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; +import org.nl.common.enums.GoodsEnum; import org.nl.common.enums.region.RegionEnum; import org.nl.common.exception.BadRequestException; import org.nl.system.service.notice.ISysNoticeService; @@ -56,10 +57,8 @@ public class FTGTask extends AbstractTask { // 找起点 String requestParam = task.getRequest_param(); JSONObject jsonObject = JSONObject.parseObject(requestParam); - // 根据对接位查找对应的载具类型 - SchBasePoint schBasePoint = schBasePointService.selectByRegionCode(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code(),task.getVehicle_code()); - if(ObjectUtil.isEmpty(schBasePoint)) continue; - jsonObject.put("vehicle_type", schBasePoint.getCan_vehicle_type()); + // 查找空载具点位 + SchBasePoint schBasePoint = schBasePointService.selectEmpVehicleByRegionCode(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code(),task.getVehicle_type()); if (ObjectUtil.isEmpty(schBasePoint)) { task.setRemark("未找到所需点位!"); taskService.updateById(task); @@ -81,7 +80,8 @@ public class FTGTask extends AbstractTask { task.setTask_status(TaskStatus.CREATED.getCode()); taskService.updateById(task); - schBasePoint.setIng_task_code(task.getTask_code()); + schBasePoint.setIs_lock(true); + schBasePoint.setPoint_status(GoodsEnum.OUT_OF_STOCK.getValue()); PointUtils.setUpdateByAcs(schBasePoint); pointService.updateById(schBasePoint); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java index 48a1f33..be28a2a 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java @@ -117,7 +117,8 @@ public class PointUtils { * @param schBasePoint */ public static void updateByIngTaskCode(SchBasePoint schBasePoint) { - schBasePoint.setIng_task_code(null); + schBasePoint.setVehicle_code(null); + schBasePoint.setIs_lock(false); }