Commit 47fdb0dbeca62e37a13a2493afa075e3f20c1152

Authored by 谭毅彬
2 parents 724e8c26 6d0db838

Merge branch 'develop' of http://git.huahengcloud.com/wms/wms4.git into develop

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java
1 1 package org.jeecg.modules.wms.api.wcs.service;
2 2  
3   -import static java.util.stream.Collectors.toList;
4   -
5   -import java.util.*;
6   -import java.util.stream.Collectors;
7   -
8   -import javax.annotation.Resource;
9   -
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5 +import com.baomidou.mybatisplus.core.metadata.IPage;
  6 +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  7 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  8 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
10 9 import org.jeecg.common.exception.JeecgBootException;
11 10 import org.jeecg.modules.wms.config.container.entity.Container;
12 11 import org.jeecg.modules.wms.config.container.service.IContainerService;
... ... @@ -32,13 +31,11 @@ import org.jeecg.utils.constant.QuantityConstant;
32 31 import org.springframework.stereotype.Service;
33 32 import org.springframework.transaction.annotation.Transactional;
34 33  
35   -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
36   -import com.baomidou.mybatisplus.core.metadata.IPage;
37   -import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
38   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
39   -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  34 +import javax.annotation.Resource;
  35 +import java.util.*;
  36 +import java.util.stream.Collectors;
40 37  
41   -import cn.hutool.core.collection.CollUtil;
  38 +import static java.util.stream.Collectors.toList;
42 39  
43 40 /**
44 41 * @author 游杰
... ... @@ -74,7 +71,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
74 71 @Override
75 72 @Transactional(rollbackFor = Exception.class)
76 73 public String allocation(int locationRule, List<String> locationTypeCodeList, int high, String zoneCode, List<Integer> raodWays, String warehouseCode,
77   - String containerCode, String materialAreaCode, String materialCode, boolean bypass) {
  74 + String containerCode, String materialAreaCode, String materialCode, boolean bypass) {
78 75 Container container = containerService.getContainerByCode(containerCode, warehouseCode);
79 76 if (container == null) {
80 77 throw new JeecgBootException("分配库位时,容器为空");
... ... @@ -98,7 +95,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
98 95 switch (locationRule) {
99 96 case QuantityConstant.DOUBLE_FORK:
100 97 return locationAllocationService.doubleRk(zoneCode, raodWays, high, warehouseCode, mergelocationTypeCodeList, materialAreaCode, materialCode,
101   - bypass);
  98 + bypass);
102 99 case QuantityConstant.SINGLE_FORK:
103 100 return locationAllocationService.singleRk(zoneCode, raodWays, high, warehouseCode, mergelocationTypeCodeList, materialAreaCode, materialCode);
104 101 }
... ... @@ -111,7 +108,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
111 108 @Override
112 109 @Transactional(rollbackFor = Exception.class)
113 110 public String doubleRk(String zoneCode, List<Integer> roadWays, int high, String warehouseCode, List<String> locationTypeCodeList, String materialAreaCode,
114   - String materialCode, boolean bypass) {
  111 + String materialCode, boolean bypass) {
115 112 if (CollectionUtils.isEmpty(roadWays)) {
116 113 roadWays = locationService.getRoadWayByZoneCode(zoneCode, warehouseCode);
117 114 }
... ... @@ -143,8 +140,8 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
143 140 }
144 141 LambdaQueryWrapper<Location> locationLambdaQueryWrapper1 = Wrappers.lambdaQuery();
145 142 locationLambdaQueryWrapper1.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
146   - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_LOCK).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
147   - .in(Location::getLocationTypeCode, locationTypeCodeList);
  143 + .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_LOCK).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
  144 + .in(Location::getLocationTypeCode, locationTypeCodeList);
148 145 Page<Location> page1 = new Page<Location>(1, searchNumber, false);
149 146 IPage iPage1 = locationService.page(page1, locationLambdaQueryWrapper1);
150 147 List<Location> totalLocationList1 = iPage1.getRecords();
... ... @@ -163,8 +160,8 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
163 160  
164 161 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
165 162 locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
166   - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
167   - .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING);
  163 + .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
  164 + .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING);
168 165 Page<Location> page = new Page<Location>(1, searchNumber, false);
169 166 IPage iPage = locationService.page(page, locationLambdaQueryWrapper);
170 167 List<Location> totalLocationList = iPage.getRecords();
... ... @@ -176,16 +173,15 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
176 173 if (CollectionUtils.isEmpty(roadWays)) {
177 174 throw new JeecgBootException("分配库位时, 可用巷道为空");
178 175 }
179   - roadWays = locationService.getRoadWayByZoneCode(zoneCode, warehouseCode);
180 176 Integer roadWay = locationAllocationService.getRoadWay(roadWays, materialCode, zoneCode, warehouseCode);
181 177  
182 178 // 优先找外侧库位
183 179 LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();
184 180 locationLambda.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
185   - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
186   - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).eq(Location::getRowFlag, QuantityConstant.ROW_OUT)
187   - .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING)
188   - .orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer).orderByAsc(true, Location::getId);
  181 + .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
  182 + .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).eq(Location::getRowFlag, QuantityConstant.ROW_OUT)
  183 + .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING)
  184 + .orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer).orderByAsc(true, Location::getId);
189 185 Page<Location> page = new Page<Location>(1, searchNumber, false);
190 186 IPage iPage = locationService.page(page, locationLambda);
191 187 List<Location> locationList = iPage.getRecords();
... ... @@ -203,10 +199,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
203 199 if (location == null) {
204 200 locationLambda = Wrappers.lambdaQuery();
205 201 locationLambda.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
206   - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
207   - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).eq(Location::getRowFlag, QuantityConstant.ROW_IN)
208   - .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING)
209   - .orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer).orderByAsc(true, Location::getId);
  202 + .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
  203 + .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).eq(Location::getRowFlag, QuantityConstant.ROW_IN)
  204 + .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING)
  205 + .orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer).orderByAsc(true, Location::getId);
210 206 page = new Page<Location>(1, searchNumber, false);
211 207 iPage = locationService.page(page, locationLambda);
212 208 locationList = iPage.getRecords();
... ... @@ -231,7 +227,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
231 227 @Override
232 228 @Transactional(rollbackFor = Exception.class)
233 229 public String singleRk(String zoneCode, List<Integer> roadWays, int high, String warehouseCode, List<String> locationTypeCodeList, String materialAreaCode,
234   - String materialCode) {
  230 + String materialCode) {
235 231 if (CollectionUtils.isEmpty(roadWays)) {
236 232 roadWays = locationService.getRoadWayByZoneCode(zoneCode, warehouseCode);
237 233 }
... ... @@ -240,10 +236,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
240 236 for (Integer roadWay : roadWays) {
241 237 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
242 238 locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
243   - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
244   - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode)
245   - .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING)
246   - .orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer).orderByAsc(true, Location::getId);
  239 + .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
  240 + .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode)
  241 + .in(Location::getLocationTypeCode, locationTypeCodeList).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING)
  242 + .orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer).orderByAsc(true, Location::getId);
247 243 Page<Location> page = new Page<Location>(1, 10, false);
248 244 IPage page1 = locationService.page(page, locationLambdaQueryWrapper);
249 245 List<Location> totalLocationList = page1.getRecords();
... ... @@ -258,10 +254,10 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
258 254 Integer roadWay = locationAllocationService.getRoadWay(roadWays, materialCode, zoneCode, warehouseCode);
259 255 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
260 256 locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
261   - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
262   - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).in(Location::getLocationTypeCode, locationTypeCodeList)
263   - .eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING).orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer)
264   - .orderByAsc(true, Location::getId);
  257 + .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE)
  258 + .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).in(Location::getLocationTypeCode, locationTypeCodeList)
  259 + .eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING).orderByAsc(true, Location::getHigh).orderByAsc(true, Location::getLayer)
  260 + .orderByAsc(true, Location::getId);
265 261 // 单伸位逻辑简单,只需要找到一个空闲库位
266 262 Page page = new Page<Location>(1, 1, 1, false);
267 263 IPage iPage = locationService.page(page, locationLambdaQueryWrapper);
... ... @@ -308,7 +304,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
308 304 }
309 305 // 通过比较每个巷道的库位数,最终找到最大库位数的索引,这个索引是roadWays的第几个。
310 306 for (int i = 0; i < locationSizeList.size(); i++) {
311   - int locationSize = locationSizeList.get(i);;
  307 + int locationSize = locationSizeList.get(i);
312 308 if (max == 0) {
313 309 max = locationSize;
314 310 index = i;
... ... @@ -335,7 +331,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
335 331 }
336 332 LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
337 333 taskHeaderLambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED).eq(TaskHeader::getZoneCode, zoneCode)
338   - .ne(TaskHeader::getToLocationCode, QuantityConstant.EMPTY_STRING).in(TaskHeader::getRoadWay, roadWays);
  334 + .ne(TaskHeader::getToLocationCode, QuantityConstant.EMPTY_STRING).in(TaskHeader::getRoadWay, roadWays);
339 335 List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
340 336 if (CollectionUtils.isNotEmpty(taskHeaderList)) {
341 337 List<Integer> roadWayList = taskHeaderList.stream().map(TaskHeader::getRoadWay).collect(toList());
... ... @@ -368,14 +364,14 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
368 364 List<ReceiptContainerHeader> unCompleteCombineList = receiptContainerHeaderService.getUnCompleteCombineList();
369 365 if (CollUtil.isNotEmpty(unCompleteCombineList)) {
370 366 List<Integer> headerIds =
371   - unCompleteCombineList.stream().filter(r -> StringUtils.isNotEmpty(r.getToLocationCode())).map(ReceiptContainerHeader::getId).collect(toList());
  367 + unCompleteCombineList.stream().filter(r -> StringUtils.isNotEmpty(r.getToLocationCode())).map(ReceiptContainerHeader::getId).collect(toList());
372 368 if (CollUtil.isNotEmpty(headerIds)) {
373 369 List<ReceiptContainerDetail> receiptContainerDetailList = receiptContainerDetailService.getReceiptContainerDetailListByHeaderIds(headerIds);
374 370 Set<Integer> receiptContainerIds = receiptContainerDetailList.stream().filter(r -> r.getMaterialCode().equals(materialCode))
375   - .map(ReceiptContainerDetail::getReceiptContainerId).collect(Collectors.toSet());
  371 + .map(ReceiptContainerDetail::getReceiptContainerId).collect(Collectors.toSet());
376 372 if (CollUtil.isNotEmpty(receiptContainerIds)) {
377 373 List<String> toLocationCodes = unCompleteCombineList.stream().filter(r -> receiptContainerIds.contains(r.getId()))
378   - .map(ReceiptContainerHeader::getToLocationCode).collect(toList());
  374 + .map(ReceiptContainerHeader::getToLocationCode).collect(toList());
379 375 locationCodes.addAll(toLocationCodes);
380 376 }
381 377 }
... ...