diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java index 3fcfc02..259eeec 100644 --- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java +++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java @@ -11,7 +11,7 @@ public interface LocationAllocationService { String allocation(int high, String area, String roadWay, String containerCode, Integer frequencyLocation, Integer emptyContainerTask, Integer isSelfCreated, boolean isFlammable); - String fiveStacker(int high, String containerCode); + String fiveStacker(int high, String containerCode, boolean isFlammable); void setTemporaryLocationType(Location location, boolean isBigContainer); diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java index f7f3268..687cdf3 100644 --- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java +++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java @@ -59,7 +59,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService //二期5号巷道 if (roadWay.equals(DYNAMIC_ROADWAY)) { - return locationAllocationService.fiveStacker(high, containerCode); + return locationAllocationService.fiveStacker(high, containerCode, isFlammable); } else { return locationAllocationService.doubleRk(area, roadWay, high, frequencyLocation, emptyContainerTask, isSelfCreated, isFlammable); } @@ -70,7 +70,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService //分配库位排序,(层-外侧-内侧-列) @Override @Transactional(rollbackFor = Exception.class) - public String fiveStacker(int high, String containerCode) { + public String fiveStacker(int high, String containerCode, boolean isFlammable) { Container container = containerService.getOne(new LambdaQueryWrapper<Container>().eq(Container::getCode, containerCode)); String containerType = container.getContainerType(); //判断预留库位 @@ -82,14 +82,24 @@ public class LocationAllocationServiceImpl implements LocationAllocationService .eq(Location::getHigh, high) .eq(Location::getContainerCode, EMPTY_STRING) .ne(Location::getIColumn, "26")//26列机器臂夹不到,只有大托盘的右侧可以刚好放到 - .orderByAsc(Location::getILayer) .orderByDesc(Location::getRowFlag) .orderByAsc(Location::getIColumn) .orderByAsc(Location::getIRow); + List<Location> list = locationService.list(wrapper); if (list.size() <= reserveNumber) { return "可能是库位不够用了,请检查预留库位数"; } + //可燃物料 + list.sort((location1, location2) -> { + if (isFlammable) { + return Integer.compare(location1.getILayer(), location2.getILayer()); + } else { + int layer1 = location1.getILayer() >= 4 ? location1.getILayer() : location1.getILayer() + 10; + int layer2 = location2.getILayer() >= 4 ? location2.getILayer() : location2.getILayer() + 10; + return Integer.compare(layer1, layer2); + } + }); //大托盘占两个库位 if (containerType.equals(CONTAINER_TYPE_X) || containerType.equals(CONTAINER_TYPE_W)) { @@ -222,6 +232,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService .eq(Location::getContainerCode, "") .last(" limit 20"); + //空托盘 if (emptyContainerTask == 1) { locationLambda.ge(Location::getOnlyEmptyContainer, 0);//大于等于0 locationLambda.orderByDesc(Location::getOnlyEmptyContainer); @@ -252,11 +263,13 @@ public class LocationAllocationServiceImpl implements LocationAllocationService //locationLambda.orderByDesc(Location::getFrequencyLocation);//倒序 } - //可燃物料 - if (isFlammable) { - locationLambda.orderByAsc(Location::getILayer); - } else { - locationLambda.last("ORDER BY " + str + ", (CASE WHEN iLayer >= 4 THEN iLayer ELSE iLayer + 10 END) ASC"); + //可燃物料(空托盘不用进来判断) + if (emptyContainerTask != 1) { + if (isFlammable) { + locationLambda.orderByAsc(Location::getILayer); + } else { + locationLambda.last("ORDER BY " + str + ", (CASE WHEN iLayer >= 4 THEN iLayer ELSE iLayer + 10 END) ASC"); + } } List<Location> locationList = locationService.list(locationLambda); @@ -284,6 +297,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService .eq(Location::getRowFlag, ROW_IN) .eq(Location::getContainerCode, "") .last(" limit 20"); + if (emptyContainerTask == 1) { locationLambda.ge(Location::getOnlyEmptyContainer, 0);//大于等于0 locationLambda.orderByDesc(Location::getOnlyEmptyContainer); @@ -291,7 +305,6 @@ public class LocationAllocationServiceImpl implements LocationAllocationService locationLambda.eq(Location::getOnlyEmptyContainer, 0); } - //自建单据 if (isSelfCreated == 1) { locationLambda.eq(Location::getSelfCreated, 1); } else { @@ -309,11 +322,13 @@ public class LocationAllocationServiceImpl implements LocationAllocationService // //不常用 // locationLambda.orderByDesc(Location::getFrequencyLocation);//倒序 //} - //可燃物料 - if (isFlammable) { - locationLambda.last("ORDER BY " + str + ", (CASE WHEN iLayer >= 4 THEN iLayer ELSE iLayer + 10 END) ASC"); - } else { - locationLambda.orderByAsc(Location::getILayer); + //可燃物料(空托盘不用进来判断) + if (emptyContainerTask != 1) { + if (isFlammable) { + locationLambda.orderByAsc(Location::getILayer); + } else { + locationLambda.last("ORDER BY " + str + ", (CASE WHEN iLayer >= 4 THEN iLayer ELSE iLayer + 10 END) ASC"); + } } locationList = locationService.list(locationLambda);