|
@@ -63,7 +63,9 @@ import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
|
|
|
+import io.jsonwebtoken.lang.Assert;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -2774,6 +2776,37 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
return wmsDocOrderHeaderService.reversePickInventoryMatch(orderNos);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 出库释放
|
|
|
+ * @param lineReleaseFrom
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean releaseWarehouse(LineReleaseFrom lineReleaseFrom) {
|
|
|
+ String palletNo = lineReleaseFrom.getPalletNo();
|
|
|
+ WmsDocOrderHeader wmsDocOrderHeader = selectWmsDocOrderHeaderByErpNo(lineReleaseFrom.getOrderNo());
|
|
|
+ Assert.isTrue(ObjectUtil.isNotNull(wmsDocOrderHeader), "出库单不存在!");
|
|
|
+ Assert.isTrue(Constant.ORDER_TYP.BH.getValue().equals(wmsDocOrderHeader.getOrderType()), "单据类型为备货单才可出库!");
|
|
|
+ String orderNo = wmsDocOrderHeader.getOrderNo();
|
|
|
+ List<InvLotAtt> invLotAttList = invLotAttService.queryInvLotAtt(lineReleaseFrom.getPalletNo());
|
|
|
+ List<InvLotAtt> invLotAttFilterList = invLotAttList.stream().filter(item ->
|
|
|
+ CompareUtil.compare(item.getLotatt14(), lineReleaseFrom.getOrderNo()) == 0).collect(Collectors.toList());
|
|
|
+ Assert.isTrue(CollectionUtil.isNotEmpty(invLotAttFilterList), "托盘无出库单备货库存!");
|
|
|
+ List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(invLotAttFilterList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
|
|
|
+ Assert.isTrue(CollectionUtil.isNotEmpty(invLotLocIdList), "该托盘出库单备货库存已全部出库!");
|
|
|
+ Long locationId = Long.parseLong(invLotLocIdList.stream().map(InvLotLocId::getLocationId).findFirst().orElseThrow(() -> new BaseException("库存库位信息丢失!")));
|
|
|
+ // 清除库存
|
|
|
+ invLotLocIdService.clear(locationId, palletNo, Constant.WAREHOUSE_ID, "PDA");
|
|
|
+ // 修改出库单状态
|
|
|
+ List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.selectWmsDocOrderDetailsByOrderNo(orderNo);
|
|
|
+ List<WmsDocOrderDetails> wmsDocOrderDetailsFilterList = wmsDocOrderDetailsList.stream().filter(item ->
|
|
|
+ CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS23.getValue()) != 0).collect(Collectors.toList());
|
|
|
+ return wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
|
|
|
+ .set(WmsDocOrderHeader::getOrderStatus, CollectionUtil.isNotEmpty(wmsDocOrderDetailsFilterList) ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS99.getValue())
|
|
|
+ .set(WmsDocOrderHeader::getUpdateTime, DateUtils.getNowDate())
|
|
|
+ .eq(WmsDocOrderHeader::getOrderNo, orderNo)) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 库存匹配
|
|
|
*/
|
|
@@ -2782,7 +2815,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
public Boolean inventoryMatch(String orderNos) {
|
|
|
List<String> orderList = JSONArray.parseArray(orderNos, String.class);
|
|
|
List<PalletMatchLog> palletMatchLogList = palletMatchLogService.checkOrderNoAndGetPalletMatchLogList(orderList);
|
|
|
- List<InvLotAttPalletTotalDTO> result = buildInventoryMatchList(orderList, palletMatchLogList);
|
|
|
+ List<InvLotAttPalletTotalDTO> result = buildInventoryMatchList(orderList, Constant.ORDER_TYP.BH.getValue(), palletMatchLogList);
|
|
|
return palletMatchLogService.insertBatch(buildPalletMatchLogList(result, orderList));
|
|
|
}
|
|
|
|
|
@@ -2793,11 +2826,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
public Boolean reversePickInventoryMatch(String orderNos) {
|
|
|
List<String> orderList = JSONArray.parseArray(orderNos, String.class);
|
|
|
- List<PalletMatchLog> palletMatchLogList = palletMatchLogService.checkOrderNoAndGetPalletMatchLogList(orderList);
|
|
|
- LinkedList<Object> reversePickInventoryMatchList = buildReversePickInventoryMatchList(orderList, palletMatchLogList);
|
|
|
+ palletMatchLogService.checkOrderNoAndGetPalletMatchLogList(orderList);
|
|
|
+ //反拣暂时不考虑呼出托盘重复问题 传入空list
|
|
|
+ LinkedList<Object> reversePickInventoryMatchList = buildReversePickInventoryMatchList(orderList, Lists.newArrayList());
|
|
|
Boolean flag = (Boolean) reversePickInventoryMatchList.pop();
|
|
|
List<InvLotAttPalletTotalDTO> result = (List<InvLotAttPalletTotalDTO>) reversePickInventoryMatchList.pop();
|
|
|
- if (flag) result.addAll(buildInventoryMatchList(orderList, palletMatchLogList));
|
|
|
+ if (flag) result.addAll(buildInventoryMatchList(orderList, Constant.ORDER_TYP.FJ.getValue(), Lists.newArrayList()));
|
|
|
return palletMatchLogService.insertBatch(buildPalletMatchLogList(result, orderList));
|
|
|
}
|
|
|
|
|
@@ -2879,10 +2913,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
return AjaxResult.success("托盘:" + unbindDTO.getPalletTo() + "解绑成功!托盘数量: " + invLotAttService.queryPalletTotal(unbindDTO.getPalletTo()));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * PDA托盘出库:构建匹配列表
|
|
|
- */
|
|
|
- private List<InvLotAttPalletTotalDTO> buildInventoryMatchList(List<String> orderList, List<PalletMatchLog> palletMatchLogList){
|
|
|
+ private List<WmsDocOrderDetails> getWmsDocOrderDetailsList(List<String> orderList, String orderType){
|
|
|
//根据erp单号获取出库单头列表
|
|
|
List<WmsDocOrderHeader> wmsDocOrderHeaderList = wmsDocOrderHeaderMapper.selectList(Wrappers.<WmsDocOrderHeader>lambdaQuery().in(WmsDocOrderHeader::getSoReference1, orderList).orderByDesc(WmsDocOrderHeader::getCreateTime));
|
|
|
if (CollectionUtil.isEmpty(wmsDocOrderHeaderList)) {
|
|
@@ -2899,7 +2930,18 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) {
|
|
|
throw new BaseException("出库单明细为空!");
|
|
|
}
|
|
|
- Map<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupBySkuMap = wmsDocOrderDetailsList.stream().filter(item -> StringUtils.isNotBlank(item.getSku())).collect(Collectors.groupingBy(WmsDocOrderDetails::getSku));
|
|
|
+ return wmsDocOrderDetailsList.stream().filter(item -> StringUtils.isNotBlank(item.getSku())
|
|
|
+ && orderType.equals(Constant.ORDER_TYP.FJ.getValue()) ?
|
|
|
+ NumberUtil.isGreater(item.getQtyAllocated(), BigDecimal.ZERO) : Boolean.TRUE).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PDA托盘出库:构建匹配列表
|
|
|
+ */
|
|
|
+ private List<InvLotAttPalletTotalDTO> buildInventoryMatchList(List<String> orderList, String orderType, List<PalletMatchLog> palletMatchLogList){
|
|
|
+ //出库类型多可通过map维护
|
|
|
+ List<WmsDocOrderDetails> wmsDocOrderDetailsList = getWmsDocOrderDetailsList(orderList, orderType);
|
|
|
+ Map<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupBySkuMap = wmsDocOrderDetailsList.stream().collect(Collectors.groupingBy(WmsDocOrderDetails::getSku));
|
|
|
if (CollectionUtil.isEmpty(wmsDocOrderDetailsGroupBySkuMap)) {
|
|
|
throw new BaseException("出库单明细绑定sku为空!");
|
|
|
}
|
|
@@ -2927,21 +2969,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
* PDA反拣出库:构建匹配列表
|
|
|
*/
|
|
|
private LinkedList<Object> buildReversePickInventoryMatchList(List<String> orderList, List<PalletMatchLog> palletMatchLogList){
|
|
|
- //根据erp单号获取出库单头列表
|
|
|
- List<WmsDocOrderHeader> wmsDocOrderHeaderList = wmsDocOrderHeaderMapper.selectList(Wrappers.<WmsDocOrderHeader>lambdaQuery().in(WmsDocOrderHeader::getSoReference1, orderList).orderByDesc(WmsDocOrderHeader::getCreateTime));
|
|
|
- if (CollectionUtil.isEmpty(wmsDocOrderHeaderList)) {
|
|
|
- throw new BaseException("请扫描正确的出库单号");
|
|
|
- }
|
|
|
- List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(
|
|
|
- wmsDocOrderHeaderList.stream().filter(item -> StringUtils.isNotBlank(item.getOrderNo()))
|
|
|
- .map(WmsDocOrderHeader::getOrderNo).collect(Collectors.toList()));
|
|
|
- if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) {
|
|
|
- throw new BaseException("出库单明细为空!");
|
|
|
- }
|
|
|
+ List<WmsDocOrderDetails> wmsDocOrderDetailsList = getWmsDocOrderDetailsList(orderList, Constant.ORDER_TYP.FJ.getValue());
|
|
|
//所需出库托盘
|
|
|
List<InvLotAttPalletTotalDTO> invLotAttPalletTotalDTOList = new ArrayList<>();
|
|
|
- Boolean flag = Boolean.FALSE;
|
|
|
+ boolean flag = Boolean.FALSE;
|
|
|
Map<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupByOrderNoMap = wmsDocOrderDetailsList.stream().collect(Collectors.groupingBy(WmsDocOrderDetails::getOrderNo));
|
|
|
+ if (CollectionUtil.isEmpty(wmsDocOrderDetailsGroupByOrderNoMap)) throw new BaseException("该出库单未进行理货备货!");
|
|
|
List<ReversePickInventoryMatchDTO> reversePickInventoryMatchDTOList = new ArrayList<>();
|
|
|
for (Map.Entry<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupByOrderNoEntry : wmsDocOrderDetailsGroupByOrderNoMap.entrySet()) {
|
|
|
List<String> skuList = wmsDocOrderDetailsGroupByOrderNoEntry.getValue().stream().map(WmsDocOrderDetails::getSku).distinct().collect(Collectors.toList());
|
|
@@ -2969,8 +3002,10 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
for (ReversePickInventoryMatchDTO reversePickInventoryMatchDTO : reversePickInventoryMatchDTOList) {
|
|
|
List<InvLotAttPalletTotalDTO> skuPalletTotalList = invLotAttPalletTotalMap.get(reversePickInventoryMatchDTO.getSku());
|
|
|
if (CollectionUtil.isEmpty(skuPalletTotalList)) continue;
|
|
|
- List<InvLotAttPalletTotalDTO> palletTotalFilterByOrderNoList = skuPalletTotalList.stream().filter(item -> reversePickInventoryMatchDTO.getOrderNo().equals(item.getOrderNo())).collect(Collectors.toList());
|
|
|
- List<InvLotAttPalletTotalDTO> invLotAttPalletTotalList = buildInvLotAttPalletTotalList(palletTotalFilterByOrderNoList, reversePickInventoryMatchDTO.getQty(), palletMatchLogList);
|
|
|
+ List<InvLotAttPalletTotalDTO> palletTotalFilterByOrderNoList = skuPalletTotalList.stream().filter(item ->
|
|
|
+ reversePickInventoryMatchDTO.getOrderNo().equals(item.getOrderNo())).collect(Collectors.toList());
|
|
|
+ List<InvLotAttPalletTotalDTO> invLotAttPalletTotalList = buildInvLotAttPalletTotalList(palletTotalFilterByOrderNoList,
|
|
|
+ reversePickInventoryMatchDTO.getQty(), palletMatchLogList);
|
|
|
invLotAttPalletTotalDTOList.addAll(invLotAttPalletTotalList);
|
|
|
}
|
|
|
LinkedList<Object> result = ListUtil.toLinkedList(flag, invLotAttPalletTotalDTOList);
|
|
@@ -3099,7 +3134,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
*/
|
|
|
private BigDecimal judgeReversePickType(String sku, String orderNo){
|
|
|
List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo, sku);
|
|
|
- BigDecimal orderRequireQty = wmsDocOrderDetailsList.stream().map(WmsDocOrderDetails::getQtyOrdered).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal orderRequireQty = wmsDocOrderDetailsList.stream().filter(item -> !NumberUtil.equals(BigDecimal.ZERO, item.getQtyAllocated())).map(WmsDocOrderDetails::getQtyOrdered).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
List<InvLotAtt> invLotAttList = invLotAttService.queryOrderSameSkuInvLotAttList(sku, orderNo);
|
|
|
if (CollectionUtil.isEmpty(invLotAttList)) return NumberUtil.sub(BigDecimal.ZERO, orderRequireQty);
|
|
|
List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(invLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
|
|
@@ -3180,7 +3215,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
|
|
|
List<WmsDocOrderDetails> wmsDocOrderDetailsByOrderNo = wmsDocOrderDetailsService.queryWmsDocOrderDetails(groupDiskConvertDTO.getWmsOrderNo());
|
|
|
List<WmsDocOrderDetails> docOrderDetailsList = wmsDocOrderDetailsByOrderNo.stream()
|
|
|
- .filter(item -> CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS20.getValue()) != 0).collect(Collectors.toList());
|
|
|
+ .filter(item -> CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS23.getValue()) != 0).collect(Collectors.toList());
|
|
|
wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
|
|
|
.set(WmsDocOrderHeader::getOrderStatus, CollectionUtil.isNotEmpty(docOrderDetailsList) ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS23.getValue()).eq(WmsDocOrderHeader::getOrderNo, groupDiskConvertDTO.getWmsOrderNo()));
|
|
|
}
|