|
@@ -1,5 +1,7 @@
|
|
|
package com.ruoyi.ams.config.service;
|
|
|
|
|
|
+import com.ruoyi.ams.business.domain.LocationSortComparator;
|
|
|
+import com.ruoyi.ams.business.domain.LocationSortDTO;
|
|
|
import com.ruoyi.ams.config.domain.dto.InWarehouseDTO;
|
|
|
import com.ruoyi.ams.config.domain.dto.LotattDTO;
|
|
|
import com.ruoyi.ams.config.domain.dto.OutWarehouseDTO;
|
|
@@ -15,10 +17,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by IntelliJ IDEA.
|
|
@@ -220,9 +219,9 @@ public class LocationAllocationStrategy {
|
|
|
}
|
|
|
|
|
|
//将同一列的库位排序好
|
|
|
- Integer parallelCount = 0;
|
|
|
LinkedHashMap<String, Boolean> taskingFlag = new LinkedHashMap<>();
|
|
|
LinkedHashMap<String, List<BaseLocationLotattVO>> map = new LinkedHashMap<>();
|
|
|
+ List<LocationSortDTO> list = new ArrayList<>();
|
|
|
for (BaseLocationLotattVO info : locationLotattVOList) {
|
|
|
List<BaseLocationLotattVO> infoList;
|
|
|
if (map.containsKey(info.getColNo())) {
|
|
@@ -232,7 +231,6 @@ public class LocationAllocationStrategy {
|
|
|
}
|
|
|
if (info.getStockStatus().equals("10")) {
|
|
|
taskingFlag.put(info.getColNo(), true);
|
|
|
- parallelCount++;
|
|
|
} else {
|
|
|
if (taskingFlag.get(info.getColNo()) == null || taskingFlag.get(info.getColNo()).booleanValue() == false) {
|
|
|
taskingFlag.put(info.getColNo(), false);
|
|
@@ -240,48 +238,66 @@ public class LocationAllocationStrategy {
|
|
|
}
|
|
|
infoList.add(info);
|
|
|
map.put(info.getColNo(), infoList);
|
|
|
+ LocationSortDTO sortDTO = new LocationSortDTO(info.getColNo(), info.getLotattVO().getLotatt04());
|
|
|
+ list.add(sortDTO);
|
|
|
}
|
|
|
- //TODO 近效期
|
|
|
+
|
|
|
//过滤出每列可以用的库位并进行分配
|
|
|
BaseLocationInfo currentLocation = null;
|
|
|
- for (Map.Entry<String, List<BaseLocationLotattVO>> entry : map.entrySet()) {
|
|
|
- List<BaseLocationLotattVO> locationInfoList = entry.getValue();
|
|
|
- for (BaseLocationLotattVO b : locationInfoList) {
|
|
|
- if (locationPriorityHeaderVO.getSameLotattFlag().equals("N")) {
|
|
|
- //如果外围优先则跳过当前出
|
|
|
- if (locationPriorityHeaderVO.getOuterFlag().equals("Y")) {
|
|
|
- if (taskingFlag.get(b.getColNo())) {
|
|
|
+ if (locationPriorityHeaderVO.getPeriodFlag().equals("Y")) { //近效期
|
|
|
+ list.sort(new LocationSortComparator());
|
|
|
+ for (LocationSortDTO locationSortDTO : list) {
|
|
|
+ List<BaseLocationLotattVO> locationInfoList = map.get(locationSortDTO.getColNo());
|
|
|
+ for (BaseLocationLotattVO b : locationInfoList) {
|
|
|
+ if (currentLocation == null) {
|
|
|
+ if (b.getIsEmpty().equals("N") && b.getStockStatus().equals("00")) {
|
|
|
+ BaseLocationInfo locationInfo = new BaseLocationInfo();
|
|
|
+ BeanUtils.copyProperties(b, locationInfo);
|
|
|
+ currentLocation = locationInfo;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //如果前面的库位已阻挡则之前的库位不可用
|
|
|
+ if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
|
|
|
+ currentLocation = null;
|
|
|
+ } else {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /*if (locationPriorityHeaderVO.getParallelFlag().equals("Y")) {
|
|
|
- //如果达到并行数量,则当前区域不再进行分配
|
|
|
- if (parallelCount + 1 > locationPriorityHeaderVO.getParallelCount()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- if (taskingFlag.get(b.getColNo())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- if (currentLocation == null) {
|
|
|
- if (b.getIsEmpty().equals("N") && b.getStockStatus().equals("00")) {
|
|
|
- BaseLocationInfo locationInfo = new BaseLocationInfo();
|
|
|
- BeanUtils.copyProperties(b, locationInfo);
|
|
|
- currentLocation = locationInfo;
|
|
|
+ if (currentLocation != null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (Map.Entry<String, List<BaseLocationLotattVO>> entry : map.entrySet()) {
|
|
|
+ List<BaseLocationLotattVO> locationInfoList = entry.getValue();
|
|
|
+ for (BaseLocationLotattVO b : locationInfoList) {
|
|
|
+ if (locationPriorityHeaderVO.getSameLotattFlag().equals("N")) {
|
|
|
+ //如果外围优先则跳过当前出
|
|
|
+ if (locationPriorityHeaderVO.getOuterFlag().equals("Y")) {
|
|
|
+ if (taskingFlag.get(b.getColNo())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- //如果前面的库位已阻挡则之前的库位不可用
|
|
|
- if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
|
|
|
- currentLocation = null;
|
|
|
+ if (currentLocation == null) {
|
|
|
+ if (b.getIsEmpty().equals("N") && b.getStockStatus().equals("00")) {
|
|
|
+ BaseLocationInfo locationInfo = new BaseLocationInfo();
|
|
|
+ BeanUtils.copyProperties(b, locationInfo);
|
|
|
+ currentLocation = locationInfo;
|
|
|
+ }
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ //如果前面的库位已阻挡则之前的库位不可用
|
|
|
+ if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
|
|
|
+ currentLocation = null;
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- if (currentLocation != null) {
|
|
|
- break;
|
|
|
+ if (currentLocation != null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return currentLocation;
|