Commit afb8728e1fecdfaa6f19be30c75a5d7efb2e982c

Authored by 曾湘平
1 parent a04ddc15

查询有货库位,没货库位优化

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java
@@ -9,6 +9,7 @@ import java.util.stream.Collectors; @@ -9,6 +9,7 @@ import java.util.stream.Collectors;
9 import javax.annotation.Resource; 9 import javax.annotation.Resource;
10 import javax.transaction.Transactional; 10 import javax.transaction.Transactional;
11 11
  12 +import org.apache.commons.collections4.ListUtils;
12 import org.jeecg.common.api.vo.Result; 13 import org.jeecg.common.api.vo.Result;
13 import org.jeecg.common.exception.JeecgBootException; 14 import org.jeecg.common.exception.JeecgBootException;
14 import org.jeecg.modules.wms.config.container.entity.Container; 15 import org.jeecg.modules.wms.config.container.entity.Container;
@@ -173,9 +174,14 @@ public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container @@ -173,9 +174,14 @@ public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container
173 174
174 @Override 175 @Override
175 public List<Container> getContainerListByCodeList(List<String> containerCodeList, String warehouseCode) { 176 public List<Container> getContainerListByCodeList(List<String> containerCodeList, String warehouseCode) {
176 - LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();  
177 - containerLambdaQueryWrapper.in(Container::getCode, containerCodeList).eq(Container::getWarehouseCode, warehouseCode);  
178 - return list(containerLambdaQueryWrapper); 177 + List<List<String>> partition = ListUtils.partition(containerCodeList, 2000);
  178 + List<Container> containerList = new ArrayList<>();
  179 + for (List<String> code : partition) {
  180 + LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
  181 + containerLambdaQueryWrapper.in(Container::getCode, code).eq(Container::getWarehouseCode, warehouseCode);
  182 + containerList.addAll(list(containerLambdaQueryWrapper));
  183 + }
  184 + return containerList;
179 } 185 }
180 186
181 @Override 187 @Override
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/controller/LocationController.java
@@ -90,7 +90,9 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi @@ -90,7 +90,9 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi
90 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { 90 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
91 Page<Location> page = new Page<Location>(pageNo, pageSize); 91 Page<Location> page = new Page<Location>(pageNo, pageSize);
92 HuahengJwtUtil.setWarehouseCode(req, location); 92 HuahengJwtUtil.setWarehouseCode(req, location);
93 - IPage<Location> pageList = locationService.listEmptyContainerInLocation(page, location); 93 + IPage<Location> pageList = locationService.getContainerInLocation(page, QuantityConstant.STATUS_LOCATION_EMPTY,
  94 + QuantityConstant.STATUS_CONTAINER_EMPTY,QuantityConstant.STATUS_CONTAINER_EMPTY,QuantityConstant.DEFAULT_WAREHOUSE,
  95 + location.getZoneCode(),location.getContainerCode(),location.getCode(),location.getRoadWay());
94 return Result.OK(pageList); 96 return Result.OK(pageList);
95 } 97 }
96 98
@@ -100,7 +102,9 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi @@ -100,7 +102,9 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi
100 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { 102 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
101 Page<Location> page = new Page<Location>(pageNo, pageSize); 103 Page<Location> page = new Page<Location>(pageNo, pageSize);
102 HuahengJwtUtil.setWarehouseCode(req, location); 104 HuahengJwtUtil.setWarehouseCode(req, location);
103 - IPage<Location> pageList = locationService.listSomeContainerInLocation(page, location); 105 + IPage<Location> pageList = locationService.getContainerInLocation(page, QuantityConstant.STATUS_LOCATION_EMPTY,
  106 + QuantityConstant.STATUS_CONTAINER_EMPTY,QuantityConstant.STATUS_CONTAINER_FILL_SOME,QuantityConstant.DEFAULT_WAREHOUSE,
  107 + location.getZoneCode(),location.getContainerCode(),location.getCode(),location.getRoadWay());
104 return Result.OK(pageList); 108 return Result.OK(pageList);
105 } 109 }
106 110
@@ -255,13 +259,14 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi @@ -255,13 +259,14 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi
255 @AutoLog(value = "选取在库内的空托盘") 259 @AutoLog(value = "选取在库内的空托盘")
256 @ApiOperation(value = "库位管理-选取在库内的空托盘", notes = "库位管理-选取在库内的空托盘") 260 @ApiOperation(value = "库位管理-选取在库内的空托盘", notes = "库位管理-选取在库内的空托盘")
257 @GetMapping(value = "/getEmptyContainerInLocation") 261 @GetMapping(value = "/getEmptyContainerInLocation")
258 - public Result getEmptyContainerInLocation(Location location, HttpServletRequest req) {  
259 - String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);  
260 - String containerCode = location.getContainerCode();  
261 - String locationCode = location.getCode();  
262 - List<Location> locationList =  
263 - locationService.getContainerInLocation(containerCode, QuantityConstant.STATUS_CONTAINER_FILL_EMPTY, locationCode, warehouseCode);  
264 - return Result.OK(locationList); 262 + public Result<IPage<Location>> getEmptyContainerInLocation(Location location, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
  263 + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
  264 + Page<Location> page = new Page<Location>(pageNo, pageSize);
  265 + HuahengJwtUtil.setWarehouseCode(req, location);
  266 + IPage<Location> pageList = locationService.getContainerInLocation(page, QuantityConstant.STATUS_LOCATION_EMPTY,
  267 + QuantityConstant.STATUS_CONTAINER_EMPTY,QuantityConstant.STATUS_CONTAINER_EMPTY,QuantityConstant.DEFAULT_WAREHOUSE,
  268 + location.getZoneCode(),location.getContainerCode(),location.getCode(),location.getRoadWay());
  269 + return Result.OK(pageList);
265 } 270 }
266 271
267 /** 272 /**
@@ -272,13 +277,14 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi @@ -272,13 +277,14 @@ public class LocationController extends JeecgController&lt;Location, ILocationServi
272 @AutoLog(value = "选取在库内的空托盘组") 277 @AutoLog(value = "选取在库内的空托盘组")
273 @ApiOperation(value = "库位管理-选取在库内的空托盘组", notes = "库位管理-选取在库内的空托盘组") 278 @ApiOperation(value = "库位管理-选取在库内的空托盘组", notes = "库位管理-选取在库内的空托盘组")
274 @GetMapping(value = "/getManyContainerInLocation") 279 @GetMapping(value = "/getManyContainerInLocation")
275 - public Result getManyContainerInLocation(Location location, HttpServletRequest req) {  
276 - String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);  
277 - String containerCode = location.getContainerCode();  
278 - String locationCode = location.getCode();  
279 - List<Location> locationList =  
280 - locationService.getContainerInLocation(containerCode, QuantityConstant.STATUS_CONTAINER_FILL_MANY, locationCode, warehouseCode);  
281 - return Result.OK(locationList); 280 + public Result<IPage<Location>> getManyContainerInLocation(Location location, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
  281 + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
  282 + Page<Location> page = new Page<Location>(pageNo, pageSize);
  283 + HuahengJwtUtil.setWarehouseCode(req, location);
  284 + IPage<Location> pageList = locationService.getContainerInLocation(page, QuantityConstant.STATUS_LOCATION_EMPTY,
  285 + QuantityConstant.STATUS_CONTAINER_EMPTY,QuantityConstant.STATUS_CONTAINER_FILL_MANY,QuantityConstant.DEFAULT_WAREHOUSE,
  286 + location.getZoneCode(),location.getContainerCode(),location.getCode(),location.getRoadWay());
  287 + return Result.OK(pageList);
282 } 288 }
283 289
284 /** 290 /**
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/mapper/LocationMapper.java
1 package org.jeecg.modules.wms.config.location.mapper; 1 package org.jeecg.modules.wms.config.location.mapper;
2 2
3 import java.util.List; 3 import java.util.List;
  4 +import java.util.Map;
4 5
5 import com.baomidou.mybatisplus.core.metadata.IPage; 6 import com.baomidou.mybatisplus.core.metadata.IPage;
6 import org.apache.ibatis.annotations.Param; 7 import org.apache.ibatis.annotations.Param;
@@ -18,5 +19,5 @@ public interface LocationMapper extends BaseMapper&lt;Location&gt; { @@ -18,5 +19,5 @@ public interface LocationMapper extends BaseMapper&lt;Location&gt; {
18 19
19 LocationInfo getAllLocation(Location location); 20 LocationInfo getAllLocation(Location location);
20 21
21 - IPage<Location> listEmptyContainerInLocation(IPage<?> page, @Param("location") Location location); 22 + IPage<Location> getContainerInLocation(IPage<?> page, @Param("map") Map<Object, Object> map);
22 } 23 }
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/mapper/xml/LocationMapper.xml
@@ -8,36 +8,44 @@ @@ -8,36 +8,44 @@
8 IFNULL(max(layer),0) as maxLayer, 8 IFNULL(max(layer),0) as maxLayer,
9 IFNULL(max(grid),0) as maxGrid, 9 IFNULL(max(grid),0) as maxGrid,
10 IFNULL(min(row),0) as minRow 10 IFNULL(min(row),0) as minRow
11 - FROM location 11 + FROM location
12 WHERE zone_code = #{zoneCode} 12 WHERE zone_code = #{zoneCode}
13 <if test="warehouseCode != null and warehouseCode !=''"> 13 <if test="warehouseCode != null and warehouseCode !=''">
14 - AND warehouse_code = #{warehouseCode} 14 + AND warehouse_code = #{warehouseCode}
15 </if> 15 </if>
16 </select> 16 </select>
17 -  
18 - <select id="listEmptyContainerInLocation" parameterType="org.jeecg.modules.wms.config.location.entity.Location"  
19 - resultType="org.jeecg.modules.wms.config.location.entity.Location">  
20 - SELECT *  
21 - FROM location t 17 +
  18 + <select id="getContainerInLocation" parameterType="Map" resultType="org.jeecg.modules.wms.config.location.entity.Location">
  19 + SELECT *
  20 + FROM location t
22 <where> 21 <where>
23 - AND t.warehouse_code = #{location.warehouseCode}  
24 - AND t.status = 'empty' 22 + t.warehouse_code = #{map.warehouseCode}
25 AND t.container_code != '' 23 AND t.container_code != ''
26 AND t.container_code is not NULL 24 AND t.container_code is not NULL
27 - AND t.container_code NOT IN (SELECT h.container_code from task_header h WHERE status &lt; 100 AND warehouse_code = #{location.warehouseCode})  
28 - AND t.`code` IN (SELECT cc.location_code FROM container cc WHERE cc.`status`='empty' AND cc.warehouse_code = #{location.warehouseCode})  
29 - <if test="location.zoneCode != null and location.zoneCode !=''">  
30 - and t.zone_code = #{location.zoneCode} 25 + AND t.code IN (SELECT cc.location_code FROM container cc WHERE 1 = 1
  26 + <if test="map.containerCodeStatus != null and map.containerCodeStatus !=''">
  27 + AND cc.status = #{map.containerCodeStatus}
  28 + </if>
  29 + <if test="map.containerCodeFillStatus != null and map.containerCodeFillStatus !=''">
  30 + AND cc.fill_status = #{map.containerCodeFillStatus}
  31 + </if>
  32 + AND cc.warehouse_code = #{map.warehouseCode})
  33 + <if test="map.locationStatus != null and map.locationStatus !=''">
  34 + and t.status = #{map.locationStatus}
  35 + </if>
  36 + <if test="map.zoneCode != null and map.zoneCode !=''">
  37 + and t.zone_code = #{map.zoneCode}
31 </if> 38 </if>
32 - <if test="location.containerCode != null and location.containerCode !=''">  
33 - and t.container_code = #{location.containerCode} 39 + <if test="map.containerCode != null and map.containerCode !=''">
  40 + and t.container_code = #{map.containerCode}
34 </if> 41 </if>
35 - <if test="location.code != null and location.code !=''">  
36 - and t.`code` = #{location.code} 42 + <if test="map.locationCode != null and map.locationCode !=''">
  43 + and t.code = #{map.locationCode}
37 </if> 44 </if>
38 - <if test="location.roadWay != null and location.roadWay !=''">  
39 - and t.`road_way` = #{location.roadWay} 45 + <if test="map.roadWay != null and map.roadWay !=''">
  46 + and t.road_way = #{map.roadWay}
40 </if> 47 </if>
41 </where> 48 </where>
42 </select> 49 </select>
  50 +
43 </mapper> 51 </mapper>
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java
@@ -53,9 +53,8 @@ public interface ILocationService extends IService&lt;Location&gt; { @@ -53,9 +53,8 @@ public interface ILocationService extends IService&lt;Location&gt; {
53 53
54 LocationInfo getAllLocation(Location location); 54 LocationInfo getAllLocation(Location location);
55 55
56 - IPage<Location> listEmptyContainerInLocation(Page<Location> page, Location location);  
57 -  
58 - IPage<Location> listSomeContainerInLocation(Page<Location> page, Location location); 56 + IPage<Location> getContainerInLocation(Page<Location> page, String locationStatus, String containerCodeStatus, String containerCodeFillStatus,
  57 + String warehouseCode, String zoneCode, String containerCode, String locationCode, Integer roadWay);
59 58
60 /** 59 /**
61 * 判断系统是否已经有同样的托盘号,如果有证明数据混乱了 60 * 判断系统是否已经有同样的托盘号,如果有证明数据混乱了
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
@@ -396,23 +396,18 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i @@ -396,23 +396,18 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
396 } 396 }
397 397
398 @Override 398 @Override
399 - public IPage<Location> listSomeContainerInLocation(Page<Location> page, Location location) {  
400 - List<Location> locationList =  
401 - locationService.getContainerInLocation(null, QuantityConstant.STATUS_CONTAINER_FILL_SOME, null, QuantityConstant.DEFAULT_WAREHOUSE);  
402 - List<String> locationCode =  
403 - locationList.stream().filter(i -> i.getZoneCode().equals(location.getZoneCode())).map(Location::getCode).collect(Collectors.toList());  
404 - // 最多返回2000条数据  
405 - List<List<String>> partition = ListUtils.partition(locationCode, 2000);  
406 - for (List<String> strings : partition) {  
407 - LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();  
408 - locationLambdaQueryWrapper.eq(Location::getZoneCode, location.getZoneCode()).in(Location::getCode, strings);  
409 - Page<Location> locationPage = locationService.page(page, locationLambdaQueryWrapper);  
410 - if (CollectionUtils.isEmpty(Collections.singleton(locationPage))) {  
411 - return null;  
412 - }  
413 - return locationPage;  
414 - }  
415 - return null; 399 + public IPage<Location> getContainerInLocation(Page<Location> page, String locationStatus, String containerCodeStatus, String containerCodeFillStatus,
  400 + String warehouseCode, String zoneCode, String containerCode, String locationCode, Integer roadWay) {
  401 + Map<Object, Object> map = new HashMap<>();
  402 + map.put("locationStatus", locationStatus);
  403 + map.put("containerCodeStatus", containerCodeStatus);
  404 + map.put("containerCodeFillStatus", containerCodeFillStatus);
  405 + map.put("warehouseCode", warehouseCode);
  406 + map.put("zoneCode", zoneCode);
  407 + map.put("containerCode", containerCode);
  408 + map.put("locationCode", locationCode);
  409 + map.put("roadWay", roadWay);
  410 + return locationMapper.getContainerInLocation(page, map);
416 } 411 }
417 412
418 @Override 413 @Override
@@ -451,11 +446,6 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i @@ -451,11 +446,6 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
451 return locationList; 446 return locationList;
452 } 447 }
453 448
454 - @Override  
455 - public IPage<Location> listEmptyContainerInLocation(Page page, Location location) {  
456 - return locationMapper.listEmptyContainerInLocation(page, location);  
457 - }  
458 -  
459 private boolean getOutSideCanMove(Location location) { 449 private boolean getOutSideCanMove(Location location) {
460 Location locaiton2 = getInsideNear(location); 450 Location locaiton2 = getInsideNear(location);
461 if (locaiton2.getStatus().equals(QuantityConstant.STATUS_LOCATION_LOCK)) { 451 if (locaiton2.getStatus().equals(QuantityConstant.STATUS_LOCATION_LOCK)) {