|
@@ -18,6 +18,7 @@ import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
|
|
|
import com.ruoyi.ams.order.mapper.WmsDocOrderHeaderMapper;
|
|
|
import com.ruoyi.ams.order.service.IWmsDocOrderDetailsService;
|
|
|
import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
|
|
|
+import com.ruoyi.ams.xuankuang.domain.dto.PartitionLocationDTO;
|
|
|
import com.ruoyi.ams.xuankuang.domain.form.OutTaskForm;
|
|
|
import com.ruoyi.ams.xuankuang.domain.vo.WcsResponseVo;
|
|
|
import com.ruoyi.base.constant.Constant;
|
|
@@ -33,7 +34,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.system.service.ISysConfigService;
|
|
|
-import com.sun.xml.internal.ws.api.model.CheckedException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -42,7 +42,10 @@ import org.springframework.util.Assert;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ruoyi.ams.xuankuang.service.BaseLocationInfoSubService.OUT_ZONES;
|
|
@@ -90,6 +93,7 @@ public class WmsDocOrderSubService {
|
|
|
|
|
|
@Transactional
|
|
|
public AjaxResult initOrderDetails(@PathVariable("orderNo") String orderNo) {
|
|
|
+ Boolean orderRuleConfig = Boolean.valueOf(sysConfigService.selectConfigByKey(SceneConstants.WMS_ORDER_RULE_CONFIG));
|
|
|
// 根据单号,和创建状态为00
|
|
|
WmsDocOrderDetails wmsDocOrderDetails = new WmsDocOrderDetails();
|
|
|
wmsDocOrderDetails.setOrderNo(orderNo);
|
|
@@ -103,7 +107,7 @@ public class WmsDocOrderSubService {
|
|
|
List<BaseLocationLotattDTO> baseLocationLotattList = addConfirmAllocationAuto(orderNo);
|
|
|
|
|
|
//筛选库存 由于选矿项目出库单头只对应一个
|
|
|
- List<BaseLocationLotattDTO> filteredLocationLotattList = selectInventoriesByLocation(baseLocationLotattList, list.get(0));
|
|
|
+ List<BaseLocationLotattDTO> filteredLocationLotattList = orderRuleConfig ? selectInventoriesByLocation(baseLocationLotattList, list.get(0)) : filterInv(baseLocationLotattList, orderNo);
|
|
|
// 匹配库存(撇开先进先出)
|
|
|
// baseLocationLotattVOS = addConfirmAllocationAuto(orderNo);
|
|
|
|
|
@@ -199,7 +203,7 @@ public class WmsDocOrderSubService {
|
|
|
|
|
|
List<String> locationIdList = baseLocationLotattList.stream()
|
|
|
.filter(ObjectUtil::isNotNull).map(item -> NumberUtil.toStr(item.getId())).collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<BaseLocationLotattDTO> baseLocationAllList = Lists.newArrayList(baseLocationLotattList);
|
|
|
List<InvLotLocId> sourceInvLotLocIdList = invLotLocIdService.selectInvLotLocIdList(locationIdList);
|
|
|
BigDecimal quantity = docOrderDetail.getQtyOrdered();
|
|
|
//从最老的库存开始,计算库存所在的列是否符合要求
|
|
@@ -216,76 +220,54 @@ public class WmsDocOrderSubService {
|
|
|
//获取到这个库位命中的子列在两边还是中间
|
|
|
Integer firstWayNo = CollectionUtil.getFirst(wayRowNoList);
|
|
|
Integer lastWayNo = CollectionUtil.getLast(wayRowNoList);
|
|
|
- String partitionRowKey = getPartitionRowKey(firstWayNo, lastWayNo, locationInfo.getRowIndex());
|
|
|
+ String partitionRowKey = getPartitionRowKey(firstWayNo, lastWayNo, locationInfo.getRowNo());
|
|
|
List<Long> partitionLocationIdList = partitionRowNoListMapper.get(partitionRowKey);
|
|
|
+ if (CollectionUtil.isEmpty(partitionLocationIdList)) continue;
|
|
|
int locationIndex = partitionLocationIdList.indexOf(locationInfo.getId());
|
|
|
- if(StringUtils.equals(partitionRowKey, Constants.FIRST)) {
|
|
|
- //TODO 张馨
|
|
|
- List<Long> firstRightSubList = ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size());
|
|
|
- List<Long> resultLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, firstRightSubList,
|
|
|
- baseLocationLotattList, quantity);
|
|
|
- if(CollectionUtil.isEmpty(resultLocationIdList)) continue;
|
|
|
- BigDecimal firstRightCount = sourceInvLotLocIdList.stream()
|
|
|
- .filter(item -> CollectionUtil.contains(resultLocationIdList, Long.parseLong(item.getLocationId()))
|
|
|
- && ObjectUtil.isNotNull(item.getQty()))
|
|
|
- .map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- quantity = NumberUtil.sub(quantity, firstRightCount);
|
|
|
- baseLocationLotattList = baseLocationLotattList.stream()
|
|
|
- .filter(item -> !CollectionUtil.contains(resultLocationIdList, item.getId())).collect(Collectors.toList());
|
|
|
- selectedLocationIdList.addAll(resultLocationIdList);
|
|
|
- if(CompareUtil.compare(quantity, BigDecimal.ZERO) <= 0) break;
|
|
|
- }
|
|
|
|
|
|
- if(StringUtils.equals(partitionRowKey, Constants.MIDDLE)){
|
|
|
- //TODO 张馨
|
|
|
- List<Long> middleLeftSubList = ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1);
|
|
|
- List<Long> middleLeftLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, middleLeftSubList,
|
|
|
- baseLocationLotattList, quantity);
|
|
|
- if(CollectionUtil.isEmpty(middleLeftLocationIdList)) continue;
|
|
|
- BigDecimal middleLeftCount = sourceInvLotLocIdList.stream()
|
|
|
- .filter(item -> CollectionUtil.contains(middleLeftLocationIdList, Long.parseLong(item.getLocationId()))
|
|
|
- && ObjectUtil.isNotNull(item.getQty()))
|
|
|
- .map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
- List<Long> middleRightSubList = ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size());
|
|
|
- List<Long> middleRightLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, middleRightSubList,
|
|
|
- baseLocationLotattList, quantity);
|
|
|
- if(CollectionUtil.isEmpty(middleRightLocationIdList)) continue;
|
|
|
- BigDecimal middleRightCount = sourceInvLotLocIdList.stream()
|
|
|
- .filter(item -> CollectionUtil.contains(middleRightLocationIdList, Long.parseLong(item.getLocationId()))
|
|
|
- && ObjectUtil.isNotNull(item.getQty()))
|
|
|
- .map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
- BigDecimal singleRowInvCount = CompareUtil.compare(middleLeftCount, middleRightCount) > 0 ? middleLeftCount : middleRightCount;
|
|
|
- quantity = NumberUtil.sub(quantity, singleRowInvCount);
|
|
|
-
|
|
|
- selectedLocationIdList.addAll(CompareUtil.compare(middleLeftCount, middleRightCount) > 0
|
|
|
- ? middleLeftLocationIdList : middleRightLocationIdList);
|
|
|
- if(CompareUtil.compare(quantity, BigDecimal.ZERO) <= 0) break;
|
|
|
- }
|
|
|
+ List<Long> partitionLocationRightSubList = !StringUtils.equals(partitionRowKey, Constants.LAST) ?
|
|
|
+ ListUtil.sub(partitionLocationIdList, locationIndex, partitionLocationIdList.size()) : Lists.newArrayList();
|
|
|
+ List<Long> partitionLocationLeftSubList = !StringUtils.equals(partitionRowKey, Constants.FIRST)
|
|
|
+ ? ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1) : Lists.newArrayList();
|
|
|
+ List<Long> partitionLocationSubList = CollectionUtil.isNotEmpty(partitionLocationRightSubList) ? partitionLocationRightSubList : partitionLocationLeftSubList;
|
|
|
+ PartitionLocationDTO partitionLocationDTO = buildPartitionLocationDTO(locationInfo.getId(), quantity, baseLocationLotattList,
|
|
|
+ sourceInvLotLocIdList, partitionLocationSubList);
|
|
|
+ if (ObjectUtil.isNull(partitionLocationDTO)) continue;
|
|
|
+ BigDecimal qtyCount = partitionLocationDTO.getQtyCount();
|
|
|
+ List<Long> resultLocationIdList = partitionLocationDTO.getResultLocationIdList();
|
|
|
|
|
|
- if(StringUtils.equals(partitionRowKey, Constants.LAST)) {
|
|
|
- //TODO 张馨
|
|
|
- List<Long> lastLeftSubList = ListUtil.sub(partitionLocationIdList, Constants.START_VALUE, locationIndex + 1);
|
|
|
- List<Long> lastLeftLocationIdList = checkLocationIdList(locationInfo.getId(), sourceInvLotLocIdList, lastLeftSubList,
|
|
|
- baseLocationLotattList, quantity);
|
|
|
- if(CollectionUtil.isEmpty(lastLeftLocationIdList)) continue;
|
|
|
- BigDecimal lastLeftCount = sourceInvLotLocIdList.stream()
|
|
|
- .filter(item -> CollectionUtil.contains(lastLeftLocationIdList, Long.parseLong(item.getLocationId()))
|
|
|
- && ObjectUtil.isNotNull(item.getQty()))
|
|
|
- .map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
- quantity = NumberUtil.sub(quantity, lastLeftCount);
|
|
|
- baseLocationLotattList = baseLocationLotattList.stream()
|
|
|
- .filter(item -> !CollectionUtil.contains(lastLeftLocationIdList, item.getId())).collect(Collectors.toList());
|
|
|
- selectedLocationIdList.addAll(lastLeftLocationIdList);
|
|
|
- if(CompareUtil.compare(quantity, BigDecimal.ZERO) <= 0) break;
|
|
|
+ if(StringUtils.equals(partitionRowKey, Constants.MIDDLE)){
|
|
|
+ PartitionLocationDTO partitionLocationLeftDTO = buildPartitionLocationDTO(locationInfo.getId(), quantity, baseLocationLotattList,
|
|
|
+ sourceInvLotLocIdList, partitionLocationLeftSubList);
|
|
|
+ if (ObjectUtil.isNull(partitionLocationLeftDTO)) continue;
|
|
|
+ qtyCount = CompareUtil.compare(partitionLocationLeftDTO.getQtyCount(), qtyCount) > 0
|
|
|
+ ? partitionLocationLeftDTO.getQtyCount() : qtyCount;
|
|
|
+ resultLocationIdList = CompareUtil.compare(partitionLocationLeftDTO.getQtyCount(), qtyCount) > 0
|
|
|
+ ? partitionLocationLeftDTO.getResultLocationIdList() : resultLocationIdList;
|
|
|
}
|
|
|
+ List<Long> partitionLocationList = resultLocationIdList;
|
|
|
+ quantity = NumberUtil.sub(quantity, qtyCount);
|
|
|
+ selectedLocationIdList.addAll(resultLocationIdList);
|
|
|
+ baseLocationLotattList = baseLocationLotattList.stream()
|
|
|
+ .filter(item -> !CollectionUtil.contains(partitionLocationList, item.getId())).collect(Collectors.toList());
|
|
|
+ if (CompareUtil.compare(quantity, BigDecimal.ZERO) <= 0) break;
|
|
|
}
|
|
|
|
|
|
- //TODO 张馨 加过滤 删掉注释
|
|
|
- System.err.println(JSONObject.toJSONString(selectedLocationIdList));
|
|
|
- return null;
|
|
|
+ return baseLocationAllList.stream().filter(item -> CollectionUtil.contains(selectedLocationIdList, item.getId())).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private PartitionLocationDTO buildPartitionLocationDTO(Long locationId, BigDecimal quantity, List<BaseLocationLotattDTO> baseLocationLotattList, List<InvLotLocId> sourceInvLotLocIdList, List<Long> partitionLocationSubList){
|
|
|
+ List<Long> checkLocationIdList = checkLocationIdList(locationId, sourceInvLotLocIdList, partitionLocationSubList,
|
|
|
+ baseLocationLotattList, quantity);
|
|
|
+ if(CollectionUtil.isEmpty(checkLocationIdList)) return null;
|
|
|
+ BigDecimal qtyCount = sourceInvLotLocIdList.stream()
|
|
|
+ .filter(item -> CollectionUtil.contains(checkLocationIdList, Long.parseLong(item.getLocationId()))
|
|
|
+ && ObjectUtil.isNotNull(item.getQty()))
|
|
|
+ .map(item -> item.getQty()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ PartitionLocationDTO partitionLocationDTO = new PartitionLocationDTO();
|
|
|
+ partitionLocationDTO.setResultLocationIdList(checkLocationIdList);
|
|
|
+ partitionLocationDTO.setQtyCount(qtyCount);
|
|
|
+ return partitionLocationDTO;
|
|
|
}
|
|
|
|
|
|
|