Commit 5937598bb5ff67de64bcdda560e9bef4e54f4541

Authored by 易文鹏
1 parent 382c4984

feat:出库组盘限制增加二期5号巷道大小托盘逻辑,排除执行中的任务后,可用的(大托盘库位/小托盘库位)空闲库位数,小于指定的值就不允许继续组盘,避免分拣任务无法回库

src/main/java/com/huaheng/common/constant/QuantityConstant.java
... ... @@ -490,6 +490,8 @@ public class QuantityConstant {
490 490 public static final String DOUBLE_FORK_RESERVE_LOCATION = "doubleForkReserveLocation";
491 491 public static final String DYNAMIC_DOUBLE_FORK_RESERVE_LOCATION = "dynamicDoubleForkReserveLocation";
492 492  
  493 + //组盘限制预留库位数
  494 + public static final String LIMIT_COMBINATION_COUNT = "limitCombinationCount";
493 495  
494 496 // 自动出库状态
495 497 public static final String AUTO_SHIPMENT_STATUS = "autoShipmentStatus";
... ...
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
... ... @@ -673,6 +673,19 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont
673 673 Location location = locationService.getLocationByCode(inventory.getLocationCode());
674 674 // 获取巷道信息
675 675 String roadway = location.getRoadway();
  676 + if (roadway.equals("9") || roadway.equals("10")) {//9、10号巷道是单伸位
  677 + return AjaxResult.success();
  678 + }
  679 + int count = Integer.parseInt(configService.getKey(LIMIT_COMBINATION_COUNT));
  680 +
  681 + //5号巷道
  682 + if (roadway.equals(DYNAMIC_ROADWAY)) {
  683 + AjaxResult ajaxResult = fiveStacker(location, count, inventory.getContainerCode());
  684 + if (ajaxResult.hasErr()) {
  685 + AjaxResult.error(ajaxResult.getMsg());
  686 + }
  687 + }
  688 +
676 689  
677 690 LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
678 691 wrapper.eq(Location::getRoadway, roadway)
... ... @@ -683,7 +696,7 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
683 696 .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION);
684 697 List<Location> locationList = locationService.list(wrapper);
685 698  
686   - if (locationList.size() < 3) {
  699 + if (locationList.size() <= count) {
687 700 return AjaxResult.error("该库存出库可能无法回库了");
688 701 }
689 702  
... ... @@ -693,8 +706,8 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
693 706 if (taskHeaderService.getUncompleteTaskInNear(location1) == 0) {
694 707 availableLocations.add(location1);
695 708 }
696   - // 如果已经找到了 3 个可用库位,则直接返回成功
697   - if (availableLocations.size() >= 3) {
  709 + // 如果已经找到了 2 个可用库位,则直接返回成功
  710 + if (availableLocations.size() >= count) {
698 711 return AjaxResult.success();
699 712 }
700 713 }
... ... @@ -722,6 +735,72 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
722 735 //}
723 736 }
724 737  
  738 + private AjaxResult fiveStacker(Location location, int count, String containerCode) {
  739 + LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
  740 + wrapper
  741 + .eq(Location::getRoadway, DYNAMIC_ROADWAY)
  742 + .eq(Location::getStatus, STATUS_LOCATION_EMPTY)
  743 + .eq(Location::getHigh, location.getHigh())
  744 + .eq(Location::getContainerCode, EMPTY_STRING)
  745 + .ne(Location::getIColumn, "26");
  746 + List<Location> list = locationService.list(wrapper);
  747 + String containerType = countContainerType(containerCode);
  748 + //大托盘
  749 + if (containerType.equals(BIG_CONTAINER_TYPE)) {
  750 + List<Location> bigContainerLocations = countBigContainer(list);
  751 + if (bigContainerLocations.size() <= count) {
  752 + return AjaxResult.error("大托盘库位不够了");
  753 + }
  754 + //小托盘
  755 + } else {
  756 + List<Location> smallContainerLocations = list.stream().filter(smallLocation -> smallLocation.getIColumn() != 25
  757 + && !String.valueOf(smallLocation.getTemporaryType()).startsWith(BIG_CONTAINER_TYPE)).collect(Collectors.toList());
  758 + if (smallContainerLocations.size() <= count) {
  759 + return AjaxResult.error("小托盘库位不够了");
  760 + }
  761 +
  762 + List<Location> availableLocations = new ArrayList<>();
  763 + for (Location location1 : smallContainerLocations) {
  764 + // 如果库位内侧没有未完成的任务,则将其添加到可用库位列表中
  765 + if (taskHeaderService.getUncompleteTaskInNear(location1) == 0) {
  766 + availableLocations.add(location1);
  767 + }
  768 + // 如果已经找到了 2 个可用库位,则直接返回成功
  769 + if (availableLocations.size() >= count) {
  770 + return AjaxResult.success();
  771 + }
  772 + }
  773 + return AjaxResult.error("小托盘库位不够了");
  774 + }
  775 + return AjaxResult.success("");
  776 + }
  777 +
  778 + private List<Location> countBigContainer(List<Location> list) {
  779 + List<Location> bigContainerLocations = new ArrayList<>();
  780 +
  781 + //大托盘占两个库位,只放奇数列,且右侧有空库位,且当前库位类型不是小托盘
  782 + List<Location> filteredLocations = list.stream().filter(location -> location.getIColumn() % 2 != 0 && !location.getTemporaryType()
  783 + .startsWith(SMALL_CONTAINER_TYPE)).collect(Collectors.toList());
  784 +
  785 + for (Location filteredLocation : filteredLocations) {
  786 + Location rightLocation = locationService.getRightEmptyLocation(filteredLocation);
  787 + if (rightLocation != null) {
  788 + bigContainerLocations.add(filteredLocation);
  789 + }
  790 + }
  791 + return bigContainerLocations;
  792 + }
  793 +
  794 + private String countContainerType(String containerCode) {
  795 + Container container = containerService.getOne(new LambdaQueryWrapper<Container>().eq(Container::getCode, containerCode));
  796 + String containerType = container.getContainerType();
  797 + if (containerType.equals(CONTAINER_TYPE_X) || containerType.equals(CONTAINER_TYPE_W)) {
  798 + return BIG_CONTAINER_TYPE;
  799 + } else {
  800 + return SMALL_CONTAINER_TYPE;
  801 + }
  802 + }
  803 +
725 804 /**
726 805 * 检查是否可以进行取消配盘
727 806 *
... ...