From 66af1d20d220353733dd9299b9f567bd4fba712e Mon Sep 17 00:00:00 2001 From: psh Date: Fri, 13 Oct 2023 17:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E6=8E=A5=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../acs/device_driver/RequestMethodEnum.java | 9 +- .../StandardInspectSiteDeviceDriver.java | 11 ++- .../nl/wms/sch/task_manage/AbstractTask.java | 1 - .../task_manage/task/tasks/KGHJRKTask.java | 89 +++++++++++++++++- .../sch/task_manage/task/tasks/MJXLTask.java | 2 +- .../task_manage/task/tasks/TBXBKJTask.java | 93 +++++++++++++++++++ .../sch/task_manage/task/tasks/XSCKTask.java | 17 +++- 7 files changed, 212 insertions(+), 10 deletions(-) diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java index fa681a3..2e7c1ed 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/RequestMethodEnum.java @@ -10,9 +10,12 @@ import com.alibaba.fastjson.JSONObject; * https://blog.csdn.net/moneyshi/article/details/82978073 */ public enum RequestMethodEnum { - apply_mjxl(1, "MJXLTask", "涂板线满架下料","1"), - feedback_task_status(2, "feedback_task_status", "反馈任务状态","1"), - apply_bpsl(3, "BPSLTask", "包片上料","1"); + + feedback_task_status(1, "feedback_task_status", "反馈任务状态","1"), + apply_mjxl(2, "MJXLTask", "涂板线满架下料","1"), + apply_bpsl(3, "BPSLTask", "包片上料","1"), + apply_tbxbkj(4, "TBXBKJTask", "涂板线补空架","1"), + apply_kghjrk(5, "KGHJRKTask", "空固化架入库","1"); //驱动索引 diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index 8a30c13..11884d3 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -443,9 +443,18 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest(); request.setDevice_code(devicecode); request.setVehicle_code(String.valueOf(barcode)); - if (devicecode.startsWith("TBX")) { + if (devicecode.startsWith("TBX")&&type==5) { + //满架下料 request.setRequest_medthod_code(RequestMethodEnum.apply_mjxl.getCode()); request.setRequest_medthod_name(RequestMethodEnum.apply_mjxl.getName()); + }else if (devicecode.startsWith("TBX")&&type==6) { + //补空架 + request.setRequest_medthod_code(RequestMethodEnum.apply_tbxbkj.getCode()); + request.setRequest_medthod_name(RequestMethodEnum.apply_tbxbkj.getName()); + }else if (type==7) { + //空托盘出库,包片机和销售出库空位都可以 + request.setRequest_medthod_code(RequestMethodEnum.apply_kghjrk.getCode()); + request.setRequest_medthod_name(RequestMethodEnum.apply_kghjrk.getName()); }else if(devicecode.startsWith("BP")){ request.setRequest_medthod_code(RequestMethodEnum.apply_bpsl.getCode()); request.setRequest_medthod_name(RequestMethodEnum.apply_bpsl.getName()); 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 6e665a2..9184c48 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 @@ -195,7 +195,6 @@ public abstract class AbstractTask { } MdBaseMaterial mdBaseMaterial=materialService.getOne(new LambdaQueryWrapper() .eq(MdBaseMaterial::getMaterial_id,workorder.getMaterial_id())); - param.put("material_type",mdBaseMaterial.getMaterial_code()); param.put("workorder_code", workorder.getWorkorder_code()); // 静置时间 // 设置任务数据 task.setVehicle_type(workorder.getVehicle_type()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java index 2a72516..1199992 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KGHJRKTask.java @@ -66,17 +66,104 @@ public class KGHJRKTask extends AbstractTask { @Override // @Transactional(rollbackFor = Exception.class) protected void create() throws BadRequestException { + // 获取任务 + List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); - } + for (SchBaseTask task : tasks) { + // 找终点 + SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); + SchBasePoint point = findNextPoint(startPoint); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + log.info("空固化架入库未找到当前符合条件的点位"); + continue; + } + // 设置终点并修改创建成功状态 + task.setPoint_code2(point.getPoint_code()); + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setRemark(""); + taskService.update(task); + + //发起任务时先把点位占用,防止发起重复任务 + point.setIng_task_code(task.getTask_code()); + pointService.update(point); + //下发 + this.renotifyAcs(task); + } + } + /** + * 判断目标点位 + * 1.A区的去A区缓存点,B区的去B区 + * 2.倒叙查找,找到满足当前位置数量不足3的即可 + */ private SchBasePoint findNextPoint(SchBasePoint startPoint) { + String regionCode = null; + if (startPoint.getRegion_code().endsWith("1")) { + //1找A区 + regionCode = "KGHJ1"; + + } else if (startPoint.getRegion_code().endsWith("2")) { + //2找B区 + regionCode = "KGHJ2"; + } + List schBasePointList = pointMapper.findPointByRegion(regionCode,null); + for(int i=schBasePointList.size()-1;i>=0;i--) { + SchBasePoint schBasePoint = schBasePointList.get(i); + if(schBasePoint.getVehicle_qty()<3&& + ObjectUtil.isEmpty(schBasePoint.getIng_task_code())){ + log.info("空固化架放货找到当前符合条件的点位{}",schBasePoint.getPoint_code()); + return schBasePoint; + } + } return null; } @Override // @Transactional(rollbackFor = Exception.class) protected void updateStatus(String task_code, TaskStatus status) { + // 校验任务 + SchBaseTask taskObj = taskService.getById(task_code); + if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { + throw new BadRequestException("该任务已完成!"); + } + if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { + throw new BadRequestException("该任务已取消!"); + } + + String startPoint = taskObj.getPoint_code1(); // 获取起点 + String endPoint = taskObj.getPoint_code2(); // 获取终点 + SchBasePoint startPointObj = pointService.getById(startPoint); + SchBasePoint endPointObj = pointService.getById(endPoint); + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { // 执行中 + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + } + if (status.equals(TaskStatus.FINISHED)) { // 完成 + // 终点解锁,库存增加 + startPointObj.setIng_task_code(""); + startPointObj.setVehicle_qty(startPointObj.getVehicle_qty()+1); + pointService.update(endPointObj); + + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark("任务完成"); + } + if (status.equals(TaskStatus.CANCELED)) { // 取消 + // 终点解锁 + if (ObjectUtil.isNotEmpty(endPointObj)) { + endPointObj.setIng_task_code(""); + pointService.update(endPointObj); + } + taskObj.setRemark("任务取消"); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + } + taskService.update(taskObj); } @Override diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java index d9a42d0..6bdd795 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/MJXLTask.java @@ -130,7 +130,7 @@ public class MJXLTask extends AbstractTask { materialType.equals(schBasePoint.getVehicle_type())) && "2".equals(schBasePoint.getPoint_status()) && schBasePoint.getVehicle_qty() < 3) { - log.info("找到当前符合条件的点位{}",schBasePoint.getPoint_code()); + log.info("满架下料找到当前符合条件的点位{}",schBasePoint.getPoint_code()); return schBasePoint; } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java index 8b4315f..5acdcf9 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/TBXBKJTask.java @@ -63,20 +63,113 @@ public class TBXBKJTask extends AbstractTask { @Autowired private WmsToAcsService wmsToAcsService; + /** + * 涂版线工位发起叫料请求 + * 从对应AB区的空固化架缓存位生成搬运任务 + * 不记录组盘,不考虑点位状态 + */ @Override // @Transactional(rollbackFor = Exception.class) protected void create() throws BadRequestException { + // 获取任务 + List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); + // 配置信息 + SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() + .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); + for (SchBaseTask task : tasks) { + // 找起点 + SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, task.getPoint_code1())); + SchBasePoint point = findNextPoint(startPoint); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + log.info("涂板线补空架未找到空架缓存点存在空架!"); + continue; + } + // 设置终点并修改创建成功状态 + task.setPoint_code2(point.getPoint_code()); + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setRemark(""); + taskService.update(task); + //发起任务时先把点位占用,防止发起重复任务 + point.setIng_task_code(task.getTask_code()); + //空固化架区别于组盘,任务完成后再扣除库存 +// point.setVehicle_qty(point.getVehicle_qty() - 1); + pointService.update(point); + + //下发 + this.renotifyAcs(task); + } } + /** + * 从01到10顺序判断最先有货的工位 + */ private SchBasePoint findNextPoint(SchBasePoint startPoint) { + String regionCode = null; + if ("TBX1".equals(startPoint.getRegion_code())) { + //KGHJ1找A区 + regionCode = "KGHJ1"; + + } else if ("TBX2".equals(startPoint.getRegion_code())) { + //KGHJ2找B区 + regionCode = "KGHJ2"; + } + List schBasePointList = pointMapper.findPointByRegion(regionCode,null); + for (SchBasePoint schBasePoint : schBasePointList) { + if (schBasePoint.getVehicle_qty() > 0) { + log.info("涂板线补空架找到当前符合条件的点位{}",schBasePoint.getPoint_code()); + return schBasePoint; + } + } return null; } @Override // @Transactional(rollbackFor = Exception.class) protected void updateStatus(String task_code, TaskStatus status) { + // 校验任务 + SchBaseTask taskObj = taskService.getById(task_code); + if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { + throw new BadRequestException("该任务已完成!"); + } + if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { + throw new BadRequestException("该任务已取消!"); + } + + String startPoint = taskObj.getPoint_code1(); // 获取起点 + String endPoint = taskObj.getPoint_code2(); // 获取终点 + SchBasePoint startPointObj = pointService.getById(startPoint); + SchBasePoint endPointObj = pointService.getById(endPoint); + // 根据传来的类型去对任务进行操作 + if (status.equals(TaskStatus.EXECUTING)) { // 执行中 + taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); + taskObj.setRemark("执行中"); + } + if (status.equals(TaskStatus.FINISHED)) { // 完成 + // 起点解锁,库存减少 + startPointObj.setIng_task_code(""); + startPointObj.setVehicle_qty(startPointObj.getVehicle_qty()-1); + pointService.update(endPointObj); + + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark("任务完成"); + } + if (status.equals(TaskStatus.CANCELED)) { // 取消 + // 终点解锁 + if (ObjectUtil.isNotEmpty(endPointObj)) { + endPointObj.setIng_task_code(""); + pointService.update(endPointObj); + } + taskObj.setRemark("任务取消"); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + } + taskService.update(taskObj); } @Override diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java index 7629cda..64381fd 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/XSCKTask.java @@ -73,10 +73,13 @@ public class XSCKTask extends AbstractTask { SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() .eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); for (SchBaseTask task : tasks) { + // 找起点 + SchBasePoint nextPoint = pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, task.getPoint_code2())); String extGroupData = task.getExt_group_data(); JSONObject jsonObject = JSONObject.parseObject(extGroupData); String materialType = jsonObject.getString("material_type"); - SchBasePoint point = findNextPoint(jsonObject); + SchBasePoint point = findNextPoint(nextPoint,jsonObject); if (ObjectUtil.isEmpty(point)) { task.setRemark("未找到所需点位!"); taskService.update(task); @@ -109,9 +112,17 @@ public class XSCKTask extends AbstractTask { * @param extGroupData * @return */ - private SchBasePoint findNextPoint(JSONObject extGroupData) { - String regionCode = "HCQ1"; + private SchBasePoint findNextPoint(SchBasePoint nextPoint,JSONObject extGroupData) { + String regionCode = null; String materialType = extGroupData.getString("material_type"); + if ("XSQ1".equals(nextPoint.getRegion_code())) { + //XSQ1找A区 + regionCode = "HCQ1"; + + } else if ("XSQ2".equals(nextPoint.getRegion_code())) { + //XSQ2找B区 + regionCode = "HCQ2"; + } List schBasePointList = pointMapper.findPointByRegion(regionCode,"2"); for(int i=schBasePointList.size()-1;i>=0;i--){ SchBasePoint schBasePoint=schBasePointList.get(i);