Commit bad59d4ef5d683e679c48f6d992beeb715c70b75

Authored by 游杰
1 parent 85b2a624

优化分配移库位置

src/main/java/com/huaheng/api/wcs/service/taskAssignService/TaskAssignServiceImpl.java
... ... @@ -133,7 +133,7 @@ public class TaskAssignServiceImpl implements TaskAssignService {
133 133 if(taskHeader2 != null) {
134 134 preTaskNo = taskHeader2.getId();
135 135 } else {
136   - Location destinationLocation = locationService.getEmptyInsideLocation(insideLocation);
  136 + Location destinationLocation = locationService.getEmptyLocation(insideLocation);
137 137 if (destinationLocation == null) {
138 138 return AjaxResult.error("移库没有剩余库位");
139 139 }
... ... @@ -167,8 +167,8 @@ public class TaskAssignServiceImpl implements TaskAssignService {
167 167 .lt(TaskHeader::getStatus, 100)
168 168 .in(TaskHeader::getTaskType, 200, 400 , 900)
169 169 .ge(TaskHeader::getStatus, 10);
170   - TaskHeader taskHeader2 = taskHeaderService.getOne(lambdaWrapper);
171   - if(taskHeader2 != null) {
  170 + List<TaskHeader> taskHeader2 = taskHeaderService.list(lambdaWrapper);
  171 + if(taskHeader2 != null && taskHeader2.size() > 0) {
172 172 return AjaxResult.error("执行任务出库时,相应的旁边库位有分拣出库或者补充入库任务,请先执行完旁边库位任务");
173 173 }
174 174  
... ...
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
... ... @@ -258,7 +258,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService
258 258 if(rowFlag == 1) {
259 259 Location insideLocation = locationService.getInsideNear(location);
260 260 if(StringUtils.isNotEmpty(insideLocation.getContainerCode())) {
261   - Location destinationLocation = locationService.getEmptyInsideLocation(insideLocation);
  261 + Location destinationLocation = locationService.getEmptyLocation(insideLocation);
262 262 AjaxResult ajaxResult = transferTaskService.createTransferTask(insideLocation.getCode(), destinationLocation.getCode());
263 263 preTaskNo = (Integer) ajaxResult.getData();
264 264 if(ajaxResult.hasErr()) {
... ...
src/main/java/com/huaheng/pc/config/location/service/LocationService.java
... ... @@ -87,4 +87,7 @@ public interface LocationService extends IService&lt;Location&gt;{
87 87  
88 88 Location getEmptyInsideLocation(Location location);
89 89  
  90 + Location getEmptyOutSideLocation(Location location);
  91 +
  92 + Location getEmptyLocation(Location location);
90 93 }
... ...
src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
... ... @@ -17,10 +17,7 @@ import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
17 17 import org.springframework.stereotype.Service;
18 18 import javax.annotation.Resource;
19 19 import java.text.MessageFormat;
20   -import java.util.ArrayList;
21   -import java.util.LinkedHashMap;
22   -import java.util.List;
23   -import java.util.Map;
  20 +import java.util.*;
24 21  
25 22 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
26 23 import com.huaheng.pc.config.location.domain.Location;
... ... @@ -375,6 +372,54 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
375 372 return locaiton2;
376 373 }
377 374  
  375 + private boolean getOutSideCanMove(Location location) {
  376 + Location locaiton2 = getInsideNear(location);
  377 + if(!locaiton2.getStatus().equals("empty")) {
  378 + return false;
  379 + }
  380 + if(!locaiton2.getContainerCode().equals("")) {
  381 + return false;
  382 + }
  383 + return true;
  384 + }
  385 +
  386 + @Override
  387 + public Location getEmptyOutSideLocation(Location location) {
  388 + LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
  389 + queryWrapper.eq(Location::getWarehouseCode, location.getWarehouseCode());
  390 + queryWrapper.eq(Location::getZoneCode, "L");
  391 + queryWrapper.eq(Location::getRoadway, location.getRoadway());
  392 + queryWrapper.eq(Location::getRowFlag, 1);
  393 + queryWrapper.eq(Location::getContainerCode, "");
  394 + queryWrapper.eq(Location::getStatus, "empty");
  395 + queryWrapper.eq(Location::getLocationType, location.getLocationType());
  396 + List<Location> locationList = list(queryWrapper);
  397 + List<Location> removeLocaationList = new ArrayList<>();
  398 + for(Location location1 : locationList) {
  399 + if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {
  400 + removeLocaationList.add(location1);
  401 + } else if(!getOutSideCanMove(location1)) {
  402 + removeLocaationList.add(location1);
  403 + }
  404 + }
  405 + int column = location.getIColumn();
  406 + locationList.removeAll(removeLocaationList);
  407 + Collections.sort(locationList, new Comparator<Location>(){
  408 + @Override
  409 + public int compare(Location o1, Location o2) {
  410 + int dvalue1 = Math.abs(o1.getIColumn() - column);
  411 + int dvalue2 = Math.abs(o2.getIColumn() - column);
  412 + return dvalue1 - dvalue2;
  413 + }
  414 +; });
  415 + if(locationList == null || locationList.size() <= 0) {
  416 + return null;
  417 + }
  418 + Location location1 = locationList.get(0);
  419 + return location1;
  420 + }
  421 +
  422 +
378 423 @Override
379 424 public Location getEmptyInsideLocation(Location location) {
380 425 LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
... ... @@ -390,17 +435,32 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
390 435 for(Location location1 : locationList) {
391 436 if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {
392 437 removeLocaationList.add(location1);
393   - } else {
394   - break;
395 438 }
396 439 }
  440 + int column = location.getIColumn();
397 441 locationList.removeAll(removeLocaationList);
  442 + Collections.sort(locationList, new Comparator<Location>(){
  443 + @Override
  444 + public int compare(Location o1, Location o2) {
  445 + int dvalue1 = Math.abs(o1.getIColumn() - column);
  446 + int dvalue2 = Math.abs(o2.getIColumn() - column);
  447 + return dvalue1 - dvalue2;
  448 + }
  449 + });
398 450 if(locationList == null || locationList.size() <= 0) {
399 451 return null;
400 452 }
  453 +
401 454 Location location1 = locationList.get(0);
402 455 return location1;
403 456 }
404 457  
405   -
  458 + @Override
  459 + public Location getEmptyLocation(Location location) {
  460 + Location location1 = getEmptyOutSideLocation(location);
  461 + if (location1 == null) {
  462 + location1 = getEmptyInsideLocation(location);
  463 + }
  464 + return location1;
  465 + }
406 466 }
... ...
src/main/java/com/huaheng/pc/receipt/receiving/service/ReceivingService.java
... ... @@ -190,7 +190,7 @@ public class ReceivingService {
190 190 if(rowFlag == 1) {
191 191 Location insideLocation = locationService.getInsideNear(location);
192 192 if(StringUtils.isNotEmpty(insideLocation.getContainerCode())) {
193   - Location destinationLocation = locationService.getEmptyInsideLocation(insideLocation);
  193 + Location destinationLocation = locationService.getEmptyLocation(insideLocation);
194 194 AjaxResult ajaxResult = transferTaskService.createTransferTask(insideLocation.getCode(), destinationLocation.getCode());
195 195 preTaskNo = (Integer) ajaxResult.getData();
196 196 if(ajaxResult.hasErr()) {
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/ReceiptTaskService.java
... ... @@ -125,7 +125,8 @@ public class ReceiptTaskService {
125 125 String locationCode = receiptContainerHeader.getToLocation();
126 126 if(StringUtils.isNotEmpty(locationCode)) {
127 127 Location desLocation = locationService.findLocationByCode(locationCode);
128   - if(desLocation.getWarehouseCode().equals(ShiroUtils.getWarehouseCode())) {
  128 + String loginWarehouse = ShiroUtils.getWarehouseCode();
  129 + if(!desLocation.getWarehouseCode().equals(loginWarehouse)) {
129 130 return AjaxResult.error("库位对应仓库不对");
130 131 }
131 132 if (taskHeaderService.getUncompleteTaskInNear(desLocation) > 0) {
... ...