Browse Source

出库策略修改

andy 3 years ago
parent
commit
76a4ab3b89

+ 56 - 3
warewms-ams/src/main/java/com/ruoyi/ams/config/service/LocationAllocationStrategy.java

@@ -14,8 +14,10 @@ import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.LotattVO;
 import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
 import com.ruoyi.base.mapper.BaseLocationInfoMapper;
+import com.ruoyi.common.utils.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import java.util.*;
@@ -34,6 +36,8 @@ public class LocationAllocationStrategy {
     private LocationPriorityHeaderMapper locationPriorityHeaderMapper;
     @Autowired
     private InvLotLocIdMapper invLotLocIdMapper;
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
 
     /**
      * 过滤锁定库位
@@ -158,14 +162,12 @@ public class LocationAllocationStrategy {
      * @return
      */
     public BaseLocationInfo filterLockInv(List<BaseLocationLotattVO> locationLotattVOList, OutWarehouseDTO outWarehouseDTO, AsnSoStrategy asnSoStrategy) {
-        if (asnSoStrategy.getSoSameLotatt1Flag().equals("Y")) {
-            //TODO 同批次属性出库
-        }
 
         //将同一列的库位排序好
         LinkedHashMap<String, Boolean> taskingFlag = new LinkedHashMap<>();
         LinkedHashMap<String, List<BaseLocationLotattVO>> map = new LinkedHashMap<>();
         List<LocationSortDTO> list = new ArrayList<>();
+        List<LocationSortDTO> sameLotattList = new ArrayList<>();
         for (BaseLocationLotattVO info : locationLotattVOList) {
             List<BaseLocationLotattVO> infoList;
             if (map.containsKey(info.getColNo())) {
@@ -184,10 +186,52 @@ public class LocationAllocationStrategy {
             map.put(info.getColNo(), infoList);
             LocationSortDTO sortDTO = new LocationSortDTO(info.getColNo(), info.getLotattVO().getLotatt04());
             list.add(sortDTO);
+
+            if (asnSoStrategy.getSoSameLotatt1Flag().equals("Y")) {
+                String lotattValue = redisTemplate.opsForValue().get(asnSoStrategy.getAsnSameLotatt1Value());
+                if (!StringUtils.isEmpty(lotattValue)) {
+                    if (!StringUtils.isEmpty(info.getAttMap().get(asnSoStrategy.getSoSameLotatt1Value())) && info.getAttMap().get(asnSoStrategy.getSoSameLotatt1Value()).equals(lotattValue)) {
+                        sameLotattList.add(sortDTO);
+                    }
+                }
+            }
         }
 
+
         //过滤出每列可以用的库位并进行分配
         BaseLocationInfo currentLocation = null;
+        BaseLocationLotattVO currentLocationLotatt = null;
+
+        //同批次属性优先出库
+        if (asnSoStrategy.getSoSameLotatt1Flag().equals("Y")) {
+            if (asnSoStrategy.getSoPeriodFlag().equals("Y")) {
+                sameLotattList.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;
+                            currentLocationLotatt = b;
+                        }
+                    } else {
+                        //如果前面的库位已阻挡则之前的库位不可用
+                        if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
+                            currentLocation = null;
+                        } else {
+                            continue;
+                        }
+                    }
+                }
+                if (currentLocation != null) {
+                    break;
+                }
+            }
+        }
+
         if (asnSoStrategy.getSoPeriodFlag().equals("Y")) { //近效期
             list.sort(new LocationSortComparator());
             for (LocationSortDTO locationSortDTO : list) {
@@ -198,6 +242,7 @@ public class LocationAllocationStrategy {
                             BaseLocationInfo locationInfo = new BaseLocationInfo();
                             BeanUtils.copyProperties(b, locationInfo);
                             currentLocation = locationInfo;
+                            currentLocationLotatt = b;
                         }
                     } else {
                         //如果前面的库位已阻挡则之前的库位不可用
@@ -209,6 +254,9 @@ public class LocationAllocationStrategy {
                     }
                 }
                 if (currentLocation != null) {
+                    String lotatt = asnSoStrategy.getSoSameLotatt1Value();
+                    String lotattValue = currentLocationLotatt.getAttMap().get(lotatt);
+                    redisTemplate.opsForValue().set(lotatt, lotattValue);
                     break;
                 }
             }
@@ -221,6 +269,7 @@ public class LocationAllocationStrategy {
                             BaseLocationInfo locationInfo = new BaseLocationInfo();
                             BeanUtils.copyProperties(b, locationInfo);
                             currentLocation = locationInfo;
+                            currentLocationLotatt = b;
                         }
                     } else {
                         //如果前面的库位已阻挡则之前的库位不可用
@@ -232,6 +281,10 @@ public class LocationAllocationStrategy {
                     }
                 }
                 if (currentLocation != null) {
+                    //记录出库数据的批次属性
+                    String lotatt = asnSoStrategy.getSoSameLotatt1Value();
+                    String lotattValue = currentLocationLotatt.getAttMap().get(lotatt);
+                    redisTemplate.opsForValue().set(lotatt, lotattValue);
                     break;
                 }
             }