From 7882eb99079d83efa934095b0651f6f2875e4a2e Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Tue, 12 Sep 2023 15:37:04 +0800 Subject: [PATCH] =?UTF-8?q?rev:=20=E5=8E=8B=E6=9C=BA=E9=80=81=E6=96=99?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E5=88=86=E9=85=8D=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/service/impl/WmsToMesServiceImpl.java | 2 +- .../task_manage/task/tasks/yz/YZSLTask.java | 30 ++++++++++++---- .../src/test/java/org/nl/ext/TestDemo.java | 35 ++++++++++++++++++- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java index 8d02154..c5a8ffa 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/WmsToMesServiceImpl.java @@ -134,7 +134,7 @@ public class WmsToMesServiceImpl implements WmsToMesService { mesProductDataDto.setCHECKERIN_TIM(DateUtil.now()); mesProductDataDto.setPRODATE(workorder.getProduce_date()); mesProductDataDto.setCREATE_TM(DateUtil.now()); - mesProductDataDto.setOP_FLAG("0"); + mesProductDataDto.setOP_FLAG(GeneralDefinition.NO); log.info("返给MES的数据:{}", mesProductDataDto); // 插入mes数据库 try { diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java index 4a37c7a..f41d908 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/yz/YZSLTask.java @@ -39,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.Arrays; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -51,6 +52,8 @@ import java.util.stream.Collectors; @TaskType("YZMLTask") public class YZSLTask extends AbstractTask { private static String TASK_CONFIG_CODE = "YZMLTask"; + private static AtomicInteger countUp = new AtomicInteger(0); // 上层数量 + private static AtomicInteger countLower = new AtomicInteger(0); // 下层数量 @Autowired private ISchBasePointService pointService; @Autowired @@ -96,6 +99,19 @@ public class YZSLTask extends AbstractTask { NoticeTypeEnum.WARN.getCode()); continue; } + int up = countUp.get(); + int lower = countLower.get(); + if (lower == 0 || lower != 5) { + countLower.incrementAndGet(); + } else { + countUp.incrementAndGet(); + } + if (up == 4) { + countLower = new AtomicInteger(0); + } + if (lower == 4 && up == 4) { + countUp = new AtomicInteger(0); + } // 设置终点并修改创建成功状态 task.setPoint_code2(point.getPoint_code()); task.setTask_status(TaskStatus.CREATED.getCode()); @@ -147,12 +163,14 @@ public class YZSLTask extends AbstractTask { regionCode = nextRegionStr.get(0); } } - // 双层缓存货架的一上一下的区分 + // 双层缓存货架的一上一下的区分 -> todo: 上五下五区分 // 计算缓存上和缓存下的空位数量决定是使用desc还是asc - int countUp = yzMapper.countConveyorLine(nextRegionStr.get(0), GeneralDefinition.UPPER_CONVEYOR_LINE, - PointStatusEnum.EMPTY_POINT.getCode()); - int countLower = yzMapper.countConveyorLine(nextRegionStr.get(0), GeneralDefinition.LOWER_CONVEYOR_LINE, - PointStatusEnum.EMPTY_POINT.getCode()); + int up = countUp.get(); + int lower = countLower.get(); + boolean isASC = false; + if (lower == 0 || lower != 5) { + isASC = true; + } LambdaQueryWrapper lam = new QueryWrapper().lambda(); lam.eq(SchBasePoint::getRegion_code, regionCode) .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode()) @@ -161,7 +179,7 @@ public class YZSLTask extends AbstractTask { .or() .eq(SchBasePoint::getIng_task_code, "")) .eq(SchBasePoint::getIs_used, true) - .orderBy(true, countUp <= countLower, SchBasePoint::getPoint_code); + .orderBy(true, isASC, SchBasePoint::getPoint_code); List schBasePoints = pointService.list(lam); return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null; } diff --git a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java index b3f84ed..047d3e3 100644 --- a/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java +++ b/lms/nladmin-system/nlsso-server/src/test/java/org/nl/ext/TestDemo.java @@ -7,6 +7,8 @@ import org.nl.wms.ext.mes.service.dto.MesMudConsumptionDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import java.util.concurrent.atomic.AtomicInteger; + /** * @Author: lyd * @Description: @@ -19,8 +21,39 @@ public class TestDemo { private MesRequestMapper mesRequestMapper; @Autowired private WmsToMesService wmsToMesService; + private static AtomicInteger countUp = new AtomicInteger(0); // 上层数量 + private static AtomicInteger countLower = new AtomicInteger(0); // 下层数量 @Test public void test01() { - wmsToMesService.reportProductData("1701105828406366210"); + for (int i = 0; i < 13; i++) { + toAdd(); + int up = countUp.get(); + int lower = countLower.get(); + if (lower == 0 || lower != 5) { + countLower.incrementAndGet(); + } else { + countUp.incrementAndGet(); + } + if (up == 4) { + countLower = new AtomicInteger(0); + } + if (lower == 4 && up == 4) { + countUp = new AtomicInteger(0); + } + } + } + + public void toAdd() { + int up = countUp.get(); + int lower = countLower.get(); + boolean isASC = false; + if (lower == 0 || lower != 5) { + isASC = true; + } + if (isASC) { + System.out.println("下面第" + lower + "次"); + } else { + System.out.println("上面第" + up + "次"); + } } }