|
@@ -1,11 +1,13 @@
|
|
|
package com.ruoyi.ams.config.service;
|
|
|
|
|
|
+import com.ruoyi.ams.config.domain.dto.InWarehouseDTO;
|
|
|
import com.ruoyi.ams.config.domain.vo.LocationPriorityDetailsVO;
|
|
|
import com.ruoyi.ams.config.domain.vo.LocationPriorityHeaderVO;
|
|
|
import com.ruoyi.ams.config.mapper.LocationPriorityHeaderMapper;
|
|
|
import com.ruoyi.base.domain.BaseLocationInfo;
|
|
|
import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
|
|
|
import com.ruoyi.base.mapper.BaseLocationInfoMapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -75,33 +77,100 @@ public class LocationAllocationStrategy {
|
|
|
/**
|
|
|
* 根据策略过滤锁定库位
|
|
|
*
|
|
|
- * @param zoneId 区域id
|
|
|
+ * @param zoneId 入库区域
|
|
|
+ * @param inWarehouseDTO 入库信息
|
|
|
* @param locationPriorityHeaderVO 出入库策略
|
|
|
* @return
|
|
|
*/
|
|
|
- public BaseLocationInfo filterLockLocation(Long zoneId, Long warehouseId, LocationPriorityHeaderVO locationPriorityHeaderVO) {
|
|
|
- /*BaseLocationInfo query = new BaseLocationInfo();
|
|
|
- query.setWarehouseId(warehouseId);
|
|
|
+ public BaseLocationInfo filterLockLocation(Long zoneId, InWarehouseDTO inWarehouseDTO, LocationPriorityHeaderVO locationPriorityHeaderVO) {
|
|
|
+ BaseLocationInfo query = new BaseLocationInfo();
|
|
|
+ query.setWarehouseId(inWarehouseDTO.getWarehouseId());
|
|
|
query.setZoneId(zoneId);
|
|
|
List<BaseLocationLotattVO> locationLotattVOList = baseLocationInfoMapper.selectSortedLocationLotattListByZoneId(query);
|
|
|
List<LocationPriorityDetailsVO> locationPriorityDetails = locationPriorityHeaderMapper.selectLocationPriorityDetailsList(locationPriorityHeaderVO.getId());
|
|
|
//批次属性
|
|
|
LinkedHashMap<String, String> lotatt = new LinkedHashMap<>();
|
|
|
- for (LocationPriorityDetailsVO vo : locationPriorityDetails) {
|
|
|
- lotatt.put(vo.getLotattId(),vo.getLotattValue());
|
|
|
+ if (locationPriorityDetails != null && locationPriorityDetails.size() > 0) {
|
|
|
+ for (LocationPriorityDetailsVO vo : locationPriorityDetails) {
|
|
|
+ lotatt.put(vo.getLotattId(), vo.getLotattValue());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
//将同一列的库位排序好
|
|
|
- LinkedHashMap<String, List<BaseLocationInfo>> map = new LinkedHashMap<>();
|
|
|
+ Integer parallelCount = 0;
|
|
|
+ LinkedHashMap<String, Boolean> taskingFlag = new LinkedHashMap<>();
|
|
|
+ LinkedHashMap<String, List<BaseLocationLotattVO>> map = new LinkedHashMap<>();
|
|
|
for (BaseLocationLotattVO info : locationLotattVOList) {
|
|
|
- List<BaseLocationInfo> infoList;
|
|
|
+ List<BaseLocationLotattVO> infoList;
|
|
|
if (map.containsKey(info.getColNo())) {
|
|
|
infoList = map.get(info.getColNo());
|
|
|
} else {
|
|
|
infoList = new ArrayList<>();
|
|
|
}
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
infoList.add(info);
|
|
|
map.put(info.getColNo(), infoList);
|
|
|
- }*/
|
|
|
- return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //过滤出每列可以用的库位并进行分配
|
|
|
+ BaseLocationInfo currentLocation = null;
|
|
|
+ for (Map.Entry<String, List<BaseLocationLotattVO>> entry : map.entrySet()) {
|
|
|
+ List<BaseLocationLotattVO> locationInfoList = entry.getValue();
|
|
|
+ for (BaseLocationLotattVO b : locationInfoList) {
|
|
|
+ //如果允许并行则跳过已经分配过的列
|
|
|
+ if (locationPriorityHeaderVO.getParallelFlag().equals("Y")) {
|
|
|
+ //如果达到并行数量,则当前区域不再进行分配
|
|
|
+ if (parallelCount + 1 > locationPriorityHeaderVO.getParallelCount()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (taskingFlag.get(b.getColNo())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // TODO 优先寻找匹配批次属性的库存库位进行存放
|
|
|
+ if (lotatt.size() > 0 && b.getLotattVO() != null) { //指定了批次属性的需要对相同批次属性的库存进行匹配
|
|
|
+ b.initLotatt();
|
|
|
+ boolean isSame = true;
|
|
|
+ for (Map.Entry<String, String> attEntry : lotatt.entrySet()) {
|
|
|
+ if (!b.getAttMap().get(attEntry.getKey()).equals(attEntry.getValue())) {
|
|
|
+ isSame = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isSame == false) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (currentLocation == null) {
|
|
|
+ if (b.getIsEmpty().equals("Y") && 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 (currentLocation != null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return currentLocation;
|
|
|
}
|
|
|
+
|
|
|
+ /*public BaseLocationInfo filterLockInv() {
|
|
|
+
|
|
|
+ }*/
|
|
|
}
|