Commit 6e4f19a13376382a1263bd264ed90eb80a80bc4b

Authored by xumiao
1 parent aaebeb90

修改请求库位的代码

src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java
@@ -8,6 +8,6 @@ public interface LocationAllocationService { @@ -8,6 +8,6 @@ public interface LocationAllocationService {
8 8
9 9
10 String allocation(int locationRule, List<String> locationTypeCodeList, int high, String area, 10 String allocation(int locationRule, List<String> locationTypeCodeList, int high, String area,
11 - List<String> roadWay, String warehouseCode, String containerCode, String materialAreaCode); 11 + List<String> roadWays, String warehouseCode, String containerCode, String materialAreaCode);
12 12
13 } 13 }
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java
1 package com.huaheng.api.wcs.service.warecellAllocation; 1 package com.huaheng.api.wcs.service.warecellAllocation;
2 2
3 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 3 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
4 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 import com.huaheng.common.constant.Constants; 6 import com.huaheng.common.constant.Constants;
6 import com.huaheng.common.constant.QuantityConstant; 7 import com.huaheng.common.constant.QuantityConstant;
@@ -16,6 +17,7 @@ import com.huaheng.pc.config.locationType.domain.LocationType; @@ -16,6 +17,7 @@ import com.huaheng.pc.config.locationType.domain.LocationType;
16 import com.huaheng.pc.config.locationType.service.LocationTypeService; 17 import com.huaheng.pc.config.locationType.service.LocationTypeService;
17 import com.huaheng.pc.config.zone.domain.Zone; 18 import com.huaheng.pc.config.zone.domain.Zone;
18 import com.huaheng.pc.config.zone.service.ZoneService; 19 import com.huaheng.pc.config.zone.service.ZoneService;
  20 +import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
19 import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; 21 import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
20 import org.springframework.stereotype.Service; 22 import org.springframework.stereotype.Service;
21 23
@@ -44,7 +46,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService @@ -44,7 +46,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
44 46
45 @Override 47 @Override
46 public String allocation(int locationRule, List<String> locationTypeCodeList, 48 public String allocation(int locationRule, List<String> locationTypeCodeList,
47 - int high, String area, List<String> raodWays, String warehouseCode, 49 + int high, String area, List<String> roadWays, String warehouseCode,
48 String containerCode, String materialAreaCode) { 50 String containerCode, String materialAreaCode) {
49 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); 51 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
50 containerLambdaQueryWrapper.eq(Container::getCode, containerCode) 52 containerLambdaQueryWrapper.eq(Container::getCode, containerCode)
@@ -84,9 +86,9 @@ public class LocationAllocationServiceImpl implements LocationAllocationService @@ -84,9 +86,9 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
84 List<String> mergelocationTypeCodeList = locationTypeCodeList.stream().filter(item -> locationTypeCodes.contains(item)).collect(toList()); 86 List<String> mergelocationTypeCodeList = locationTypeCodeList.stream().filter(item -> locationTypeCodes.contains(item)).collect(toList());
85 switch (locationRule) { 87 switch (locationRule) {
86 case QuantityConstant.DOUBLE_FORK: 88 case QuantityConstant.DOUBLE_FORK:
87 - return doubleRk(area, raodWays, high, warehouseCode, mergelocationTypeCodeList, materialAreaCode); 89 + return doubleRk(area, roadWays, high, warehouseCode, mergelocationTypeCodeList, materialAreaCode);
88 case QuantityConstant.SINGLE_FORK: 90 case QuantityConstant.SINGLE_FORK:
89 - return singleRk(area, raodWays, high, warehouseCode, mergelocationTypeCodeList, materialAreaCode); 91 + return singleRk(area, roadWays, high, warehouseCode, mergelocationTypeCodeList, materialAreaCode);
90 } 92 }
91 return null; 93 return null;
92 } 94 }
@@ -97,71 +99,50 @@ public class LocationAllocationServiceImpl implements LocationAllocationService @@ -97,71 +99,50 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
97 private String doubleRk(String area, List<String> roadWays, int high, String warehouseCode, 99 private String doubleRk(String area, List<String> roadWays, int high, String warehouseCode,
98 List<String> locationTypeCodeList, String materialAreaCode) { 100 List<String> locationTypeCodeList, String materialAreaCode) {
99 101
100 - LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();  
101 - locationLambdaQueryWrapper.eq(Location::getArea, area).  
102 - eq(Location::getWarehouseCode, warehouseCode)  
103 - .in(StringUtils.isNotEmpty(roadWays), Location::getRoadway, roadWays)  
104 - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY)  
105 - .eq(Location::getHigh, high)  
106 - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode)  
107 - .in(Location::getLocationType, locationTypeCodeList)  
108 - .eq(Location::getContainerCode, "");  
109 - List<Location> totalLocationList = locationService.list(locationLambdaQueryWrapper);  
110 - if(totalLocationList.size() <= 4) { 102 + if(CollectionUtils.isEmpty(roadWays)){
111 return null; 103 return null;
112 } 104 }
113 -  
114 - LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();  
115 - locationLambda.eq(Location::getArea, area).  
116 - eq(Location::getWarehouseCode, warehouseCode)  
117 - .in(StringUtils.isNotEmpty(roadWays), Location::getRoadway, roadWays)  
118 - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY)  
119 - .eq(Location::getHigh, high)  
120 - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode)  
121 - .eq(Location::getRowFlag, QuantityConstant.ROW_OUT)  
122 - .in(Location::getLocationType, locationTypeCodeList)  
123 - .eq(Location::getContainerCode, "");  
124 - List<Location> locationList = locationService.list(locationLambda);  
125 - List<Location> removeLocaationList = new ArrayList<>();  
126 - if(locationList != null && locationList.size() > 0) {  
127 - for (Location location1 : locationList) {  
128 - if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {  
129 - removeLocaationList.add(location1);  
130 - }  
131 - }  
132 - }  
133 - locationList.removeAll(removeLocaationList);  
134 -  
135 -  
136 -  
137 - if (locationList == null || locationList.size() == 0) {  
138 - locationLambda = Wrappers.lambdaQuery();  
139 - locationLambda.eq(Location::getArea, area).  
140 - eq(Location::getWarehouseCode, warehouseCode)  
141 - .in(StringUtils.isNotEmpty(roadWays), Location::getRoadway, roadWays)  
142 - .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY) 105 + for (String roadWay : roadWays) {
  106 + List<Location> roadwaylist=null;
  107 + List<String> locationss=new ArrayList<>();
  108 + LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();
  109 + locationLambda
  110 + .eq(Location::getArea, area)
  111 + .eq(Location::getWarehouseCode, warehouseCode)
143 .eq(Location::getHigh, high) 112 .eq(Location::getHigh, high)
144 - .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode)  
145 - .eq(Location::getRowFlag, QuantityConstant.ROW_IN) 113 + .eq(Location::getRoadway,roadWay)
  114 + .eq(Location::getContainerCode,"")
146 .in(Location::getLocationType, locationTypeCodeList) 115 .in(Location::getLocationType, locationTypeCodeList)
147 - .eq(Location::getContainerCode, "");  
148 - locationList = locationService.list(locationLambda);  
149 - removeLocaationList = new ArrayList<>();  
150 - if(locationList != null && locationList.size() > 0) {  
151 - for (Location location1 : locationList) {  
152 - if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {  
153 - removeLocaationList.add(location1); 116 + .eq(Location::getStatus,QuantityConstant.STATUS_LOCATION_EMPTY);
  117 + roadwaylist = locationService.list(locationLambda);
  118 + if(CollectionUtils.isEmpty(roadwaylist)||roadwaylist.size()<11){
  119 + return null;
  120 + }
  121 + //查出外侧有货或者锁住(即有任务),内测无货的库位
  122 + List<String> locationlist =locationService.selectlistEnpty(roadWay);
  123 + if(!locationlist.isEmpty()){
  124 + locationss.addAll(locationlist);
  125 + }
  126 +
  127 + //查出内侧有任务的库位
  128 + List<Location> locations = locationService.selectCode(roadWay);
  129 + if(!locations.isEmpty()) {
  130 + //筛选内部库位
  131 + for(Location item :locations){
  132 + Location condition = locationService.getInsideNear(item);
  133 + if(condition!=null) {
  134 + locationss.add(condition.getCode());
154 } 135 }
155 } 136 }
  137 +
156 } 138 }
157 - locationList.removeAll(removeLocaationList);  
158 - }  
159 - if (locationList == null || locationList.size() == 0) {  
160 - return null; 139 + Location location = locationService.getEmptyLocationOne(roadWay, Integer.valueOf(high).toString(), locationss);
  140 + if(StringUtils.isNull(location)){
  141 + continue;
  142 + }
  143 + return location.getCode();
161 } 144 }
162 - Location location = locationList.stream().findFirst().orElse(null);  
163 - String locationCode = location.getCode();  
164 - return locationCode; 145 + return null;
165 } 146 }
166 147
167 /** 148 /**
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
@@ -49,6 +49,7 @@ import com.huaheng.api.wcs.domain.WcsTask; @@ -49,6 +49,7 @@ import com.huaheng.api.wcs.domain.WcsTask;
49 49
50 import javax.annotation.Resource; 50 import javax.annotation.Resource;
51 import java.util.ArrayList; 51 import java.util.ArrayList;
  52 +import java.util.Arrays;
52 import java.util.List; 53 import java.util.List;
53 import java.util.stream.Collectors; 54 import java.util.stream.Collectors;
54 55
@@ -124,6 +125,9 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService @@ -124,6 +125,9 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService
124 if (StringUtils.isNull(wcsTask.getHeight())) { 125 if (StringUtils.isNull(wcsTask.getHeight())) {
125 return AjaxResult.error("高为空"); 126 return AjaxResult.error("高为空");
126 } 127 }
  128 + if(StringUtils.isEmpty(wcsTask.getRoadWay())){
  129 + return AjaxResult.error("巷道为空");
  130 + }
127 return verticalWarehouseAllocation(wcsTask); 131 return verticalWarehouseAllocation(wcsTask);
128 } 132 }
129 133
@@ -132,6 +136,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService @@ -132,6 +136,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService
132 String area = wcsTask.getArea(); 136 String area = wcsTask.getArea();
133 String locationCode = null; 137 String locationCode = null;
134 String height = wcsTask.getHeight(); 138 String height = wcsTask.getHeight();
  139 + List<String> roadWay = Arrays.asList(wcsTask.getRoadWay().split(","));
135 if(height == null) { 140 if(height == null) {
136 return AjaxResult.error("分配库位时,高度为空"); 141 return AjaxResult.error("分配库位时,高度为空");
137 } 142 }
@@ -197,7 +202,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService @@ -197,7 +202,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService
197 } 202 }
198 //1、双升位:值1 2、库位类型:值L 3、高低库位:值0 4、库区:值L 5、巷道:值null 6、仓库 7、托盘号 8、物料分区 203 //1、双升位:值1 2、库位类型:值L 3、高低库位:值0 4、库区:值L 5、巷道:值null 6、仓库 7、托盘号 8、物料分区
199 locationCode = locationAllocationService.allocation(allocationRule, 204 locationCode = locationAllocationService.allocation(allocationRule,
200 - locationTypeCodeList, high, area, null, warehouseCode, containerCode, materialAreaCode); 205 + locationTypeCodeList, high, area, roadWay, warehouseCode, containerCode, materialAreaCode);
201 if (StringUtils.isEmpty(locationCode)) { 206 if (StringUtils.isEmpty(locationCode)) {
202 return AjaxResult.error("没有库位可分配"); 207 return AjaxResult.error("没有库位可分配");
203 } 208 }
src/main/java/com/huaheng/pc/config/location/mapper/LocationMapper.java
@@ -31,4 +31,15 @@ public interface LocationMapper extends BaseMapper&lt;Location&gt; { @@ -31,4 +31,15 @@ public interface LocationMapper extends BaseMapper&lt;Location&gt; {
31 int getFirstRowOfZone(@Param("warehouseCode") String warehouseCode, @Param("locationType") String locationType); 31 int getFirstRowOfZone(@Param("warehouseCode") String warehouseCode, @Param("locationType") String locationType);
32 32
33 int getLastRowOfZone(@Param("warehouseCode") String warehouseCode, @Param("locationType") String locationType); 33 int getLastRowOfZone(@Param("warehouseCode") String warehouseCode, @Param("locationType") String locationType);
  34 +
  35 + //查出外侧有货,内测无货的库位
  36 + List<String> selectlistEnpty(@Param("roadWay")String roadWay);
  37 +
  38 +
  39 + List<Location> selectCode(@Param("roadWay")String roadWay);
  40 +
  41 + Location selectModelByHg(@Param("roadWay")String roadWay, @Param("heght")String heght);
  42 +
  43 + Location selectModelByOld(@Param("roadWay")String roadWay, @Param("heght")String heght,@Param("codes")List<String> codes);
  44 +
34 } 45 }
35 \ No newline at end of file 46 \ No newline at end of file
src/main/java/com/huaheng/pc/config/location/service/LocationService.java
@@ -114,4 +114,14 @@ public interface LocationService extends IService&lt;Location&gt;{ @@ -114,4 +114,14 @@ public interface LocationService extends IService&lt;Location&gt;{
114 public List<Location> remoteList(String type); 114 public List<Location> remoteList(String type);
115 115
116 void upstatus(String code); 116 void upstatus(String code);
  117 +
  118 + List<String> selectlistEnpty(String roadWay);
  119 +
  120 + List<Location> selectCode(String roadWay);
  121 +
  122 + Location getEmptyLocationOne(String roadWay,String heght,List<String> codes);
  123 +
  124 + Location selectModelByHg(String roadWay, String heght);
  125 +
  126 + Location selectModelByOld(String roadWay, String heght,List<String> codes);
117 } 127 }
src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
@@ -659,4 +659,37 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i @@ -659,4 +659,37 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
659 int update = locationMapper.update(user, userUpdateWrapper); 659 int update = locationMapper.update(user, userUpdateWrapper);
660 System.out.println(update); 660 System.out.println(update);
661 } 661 }
  662 +
  663 + @Override
  664 + public List<String> selectlistEnpty(String roadWay) {
  665 + return locationMapper.selectlistEnpty(roadWay);
  666 + }
  667 +
  668 + @Override
  669 + public List<Location> selectCode(String roadWay) {
  670 + return locationMapper.selectCode(roadWay);
  671 + }
  672 +
  673 + @Override
  674 + public Location getEmptyLocationOne(String roadWay, String heght, List<String> codes) {
  675 + Location location = new Location();
  676 + if(codes.isEmpty()){
  677 + location =
  678 + locationService.selectModelByHg(roadWay,heght);
  679 + }else {
  680 + location =
  681 + locationService.selectModelByOld(roadWay, heght,codes);
  682 + }
  683 + return location;
  684 + }
  685 +
  686 + @Override
  687 + public Location selectModelByHg(String roadWay, String heght) {
  688 + return locationMapper.selectModelByHg(roadWay,heght);
  689 + }
  690 +
  691 + @Override
  692 + public Location selectModelByOld(String roadWay, String heght, List<String> codes) {
  693 + return locationMapper.selectModelByOld(roadWay, heght,codes);
  694 + }
662 } 695 }
src/main/resources/mybatis/config/LocationMapper.xml
@@ -161,5 +161,32 @@ @@ -161,5 +161,32 @@
161 select max(iRow) from location where warehouseCode=#{warehouseCode} and locationType = #{locationType} 161 select max(iRow) from location where warehouseCode=#{warehouseCode} and locationType = #{locationType}
162 </select> 162 </select>
163 163
  164 + <select id="selectlistEnpty" resultType="java.lang.String">
  165 + SELECT a.code from (SELECT * from location where rowFlag=1 and containerCode='' and zoneCode='L' and roadWay =#{roadWay}) a
  166 + INNER JOIN (SELECT * from location where rowFlag=0 and (containerCode != '' or `status`='lock') and zoneCode='L' and roadWay =#{roadWay}) b on a.iColumn=b.iColumn and a.iLayer=b.iLayer
  167 + </select>
  168 +
  169 +
  170 + <select id="selectCode" resultType="com.huaheng.pc.config.location.domain.Location">
  171 + select l.* from location l inner join task_header t on t.status !=100 and l.roadWay=#{roadWay} and l.zoneCode='L' and l.rowFlag=1 and (t.fromLocation = l.code or t.toLocation =l.code)
  172 + </select>
  173 +
  174 + <select id="selectModelByHg" resultType="com.huaheng.pc.config.location.domain.Location">
  175 + select * from location where locationType='L' and containerCode ='' and status='empty'
  176 + and roadWay = #{roadWay} and high=#{heght}
  177 + order by rowFlag desc,iColumn desc,iLayer asc limit 1
  178 +
  179 + </select>
  180 +
  181 +
  182 + <select id="selectModelByOld" resultType="com.huaheng.pc.config.location.domain.Location">
  183 + select * from location where locationType='L' and containerCode ='' and status='empty'
  184 + and roadWay = #{roadWay} and high=#{heght}
  185 + and code not in
  186 + <foreach item="item" index="index" collection="codes" open="(" separator="," close=")">
  187 + #{item}
  188 + </foreach>
  189 + order by rowFlag desc,iColumn desc,iLayer asc limit 1
  190 + </select>
164 191
165 </mapper> 192 </mapper>
166 \ No newline at end of file 193 \ No newline at end of file