From fdeb37426561591c9312d743de2f68a14a5cfdfa Mon Sep 17 00:00:00 2001 From: psh Date: Fri, 13 Oct 2023 10:39:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=80=E5=94=AE=E5=87=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sch/task_manage/task/tasks/BPSLTask.java | 9 +- .../sch/task_manage/task/tasks/XSCKTask.java | 129 +++++++++++++++++- .../task_manage/task/tasks/ghs/GHSQHTask.java | 5 + .../task/tasks/mapper/PointMapper.java | 4 +- .../task/tasks/mapper/PointMapper.xml | 10 ++ .../src/test/java/org/nl/ApplicationTest.java | 6 +- 6 files changed, 153 insertions(+), 10 deletions(-) diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java index 8845fb6..53c8a94 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/BPSLTask.java @@ -73,9 +73,6 @@ public class BPSLTask 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"); @@ -117,7 +114,7 @@ public class BPSLTask extends AbstractTask { List schBasePointList = pointMapper.findPointByRegion(regionCode,"2"); for(int i=schBasePointList.size()-1;i>=0;i--){ SchBasePoint schBasePoint=schBasePointList.get(i); - if (schBasePoint.getVehicle_qty()!=0 + if (!"2".equals(schBasePoint.getPoint_type())&&schBasePoint.getVehicle_qty()!=0 &&ObjectUtil.isEmpty(schBasePoint.getIng_task_code()) &&(ObjectUtil.isEmpty(schBasePoint.getVehicle_type())||materialType.equals(schBasePoint.getVehicle_type()))){ log.info("包片上料任务找到当前符合条件的缓存区位置{}",schBasePoint.getPoint_code()); @@ -128,7 +125,7 @@ public class BPSLTask extends AbstractTask { } /** - * 1.取货完毕后起点减少最后一份组盘,,并且该组盘视为已结束 + * 1.取货完毕后起点减少最后一份组盘,并且该组盘视为已结束 * 2.包片机LMS不记录点位信息,由人工对组盘进行操作 */ @Override @@ -183,6 +180,8 @@ public class BPSLTask extends AbstractTask { startPointObj.setIng_task_code(""); startPointObj.setUpdate_time(DateUtil.now()); pointService.updateById(startPointObj); + //包片上料完毕后,整排打上记号只允许包片上料 + pointMapper.updatePointType(endPointObj.getPoint_code().substring(0,endPointObj.getPoint_code().length()-2),"1"); // 任务完成 taskObj.setTask_status(TaskStatus.FINISHED.getCode()); taskObj.setGroup_id(one.getGroup_id()); 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 9f950f2..7629cda 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 @@ -20,6 +20,7 @@ import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; import org.nl.wms.sch.task.service.dao.SchBaseTask; import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; import org.nl.wms.sch.task_manage.AbstractTask; +import org.nl.wms.sch.task_manage.GeneralDefinition; import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum; import org.nl.wms.sch.task_manage.enums.GroupStatusEnum; import org.nl.wms.sch.task_manage.task.TaskType; @@ -66,17 +67,143 @@ public class XSCKTask extends AbstractTask { @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) { + String extGroupData = task.getExt_group_data(); + JSONObject jsonObject = JSONObject.parseObject(extGroupData); + String materialType = jsonObject.getString("material_type"); + SchBasePoint point = findNextPoint(jsonObject); + if (ObjectUtil.isEmpty(point)) { + task.setRemark("未找到所需点位!"); + taskService.update(task); + // 消息通知 + log.info("销售出库未找到当前符合条件的点位materialType:{},", materialType); + continue; + } + // 设置起点并修改创建成功状态 + task.setPoint_code1(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); + point.setVehicle_type(materialType); + pointService.update(point); + + //下发 + this.renotifyAcs(task); + } } - private SchBasePoint findNextPoint(SchBasePoint startPoint) { + /** + * 判断目标点位 + * 从10-1查找可以物料一致且有货的点位 + * + * @param extGroupData + * @return + */ + private SchBasePoint findNextPoint(JSONObject extGroupData) { + String regionCode = "HCQ1"; + String materialType = extGroupData.getString("material_type"); + List schBasePointList = pointMapper.findPointByRegion(regionCode,"2"); + for(int i=schBasePointList.size()-1;i>=0;i--){ + SchBasePoint schBasePoint=schBasePointList.get(i); + if (!"1".equals(schBasePoint.getPoint_type())&&schBasePoint.getVehicle_qty()!=0 + &&ObjectUtil.isEmpty(schBasePoint.getIng_task_code()) + &&(ObjectUtil.isEmpty(schBasePoint.getVehicle_type())||materialType.equals(schBasePoint.getVehicle_type()))){ + log.info("销售出库任务找到当前符合条件的缓存区位置{}",schBasePoint.getPoint_code()); + return schBasePoint; + } + } return null; } + /** + * 1.取货完毕后起点减少最后一份组盘,并且该组盘视为已结束 + * 2.销售出库LMS不记录点位信息,由人工对组盘进行操作 + */ @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)) { // 完成 + List vehicleCodeList = Arrays.stream(startPointObj.getVehicle_code().split(",")).collect(Collectors.toList()); + String vehicleCode=vehicleCodeList.get(vehicleCodeList.size()-1); + SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper() + .eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode) + .eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, + GroupBindMaterialStatusEnum.BOUND.getValue())); + if (ObjectUtil.isEmpty(one)) { + throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到"); + } + one.setTask_code(taskObj.getTask_code()); + one.setPoint_code(endPointObj.getPoint_code()); // 当前位置 + one.setPoint_name(endPointObj.getPoint_name()); + one.setMove_way(one.getMove_way()==null?"":(one.getMove_way() + " -> ") + endPointObj.getPoint_code()); + one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); + one.setUpdate_id(GeneralDefinition.ACS_ID); + one.setUpdate_name(GeneralDefinition.ACS_NAME); + one.setUpdate_time(DateUtil.now()); + vehiclematerialgroupService.updateById(one); + // 起点清空 + if (vehicleCodeList.size()==1) { + startPointObj.setVehicle_code(""); + }else{ + StringBuilder vehicle_code=new StringBuilder(); + for(int i=0;i<=vehicleCodeList.size()-2;i++){ + vehicle_code.append(vehicleCodeList.get(i)).append(','); + } + startPointObj.setVehicle_code(vehicle_code.toString()); + } + startPointObj.setIng_task_code(""); + startPointObj.setUpdate_time(DateUtil.now()); + pointService.updateById(startPointObj); + //销售出库完毕后,整排打上记号只允许销售出库 + pointMapper.updatePointType(endPointObj.getPoint_code().substring(0,endPointObj.getPoint_code().length()-2),"2"); + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setGroup_id(one.getGroup_id()); + taskObj.setRemark("任务完成"); + } + if (status.equals(TaskStatus.CANCELED)) { // 取消 + // 终点解锁 + if (ObjectUtil.isNotEmpty(endPointObj)) { + endPointObj.setIng_task_code(""); + pointService.update(endPointObj); + } + // 起点解锁 + if (ObjectUtil.isNotEmpty(startPointObj)) { + startPointObj.setIng_task_code(""); + startPointObj.setVehicle_qty(startPointObj.getVehicle_qty()+1); + 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/ghs/GHSQHTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java index 3506ab8..a7e9a06 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSQHTask.java @@ -186,6 +186,9 @@ public class GHSQHTask extends AbstractTask { temp=tempPoint; } } + if(temp==null){ + continue; + } log.info("固化室取货任务找到当前符合条件的缓存区位置{}",schBasePoint.getPoint_code()); return temp; } @@ -226,6 +229,8 @@ public class GHSQHTask extends AbstractTask { endPointObj.setVehicle_qty(startPointObj.getVehicle_qty()); endPointObj.setUpdate_time(DateUtil.now()); pointService.update(endPointObj); + //固化室放料完毕后,将当前一整排都标记上物料信息,防止出现混放情况 + pointMapper.updateVehicleType(endPointObj.getPoint_code().substring(0,endPointObj.getPoint_code().length()-2),endPointObj.getVehicle_type()); List vehicleCodeList = Arrays.stream(startPointObj.getVehicle_code().split(",")).collect(Collectors.toList()); for(String vehicleCode:vehicleCodeList) { SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper() diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java index 9735d4c..6c3d260 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java @@ -16,5 +16,7 @@ public interface PointMapper { List findPointByParentPoint(String pointCode); void updatePointStatus(String device_code,String state); - List findPointForYZSL(JSONObject param); + + void updateVehicleType(String device_code,String vehicle_type); + void updatePointType(String device_code,String point_type); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml index c1e408e..de6e64d 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml @@ -24,4 +24,14 @@ update sch_base_point set point_status = #{state} where point_code like CONCAT('%', #{device_code}, '%') + + + update sch_base_point set vehicle_type = #{vehicle_type} + where point_code like CONCAT('%', #{device_code}, '%') + + + + update sch_base_point set point_type = #{point_type} + where point_code like CONCAT('%', #{device_code}, '%') + diff --git a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ApplicationTest.java b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ApplicationTest.java index d48e6a1..9d7fb11 100644 --- a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ApplicationTest.java +++ b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ApplicationTest.java @@ -28,8 +28,8 @@ public class ApplicationTest { } @Test void yzMapperTest() { - List pointForYZSL = yzMapper.findPointForYZSL(new JSONObject( - MapOf.of("regionCode", "HCSSX", "pointType", "1"))); - System.out.println(pointForYZSL); +// List pointForYZSL = yzMapper.findPointForYZSL(new JSONObject( +// MapOf.of("regionCode", "HCSSX", "pointType", "1"))); +// System.out.println(pointForYZSL); } }