贴标申请,仓储转运

This commit is contained in:
2026-10-13 15:55:31 +08:00
parent c84b5f460a
commit 03601ab0aa
2 changed files with 20 additions and 6 deletions
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
import java.util.Collection;
@Mapper
public interface InventoryPositionMapper extends BaseMapper<InventoryPosition> {
@@ -17,6 +18,14 @@ public interface InventoryPositionMapper extends BaseMapper<InventoryPosition> {
List<InventoryPosition> listBalance(@Param("customerId") String customerId,
@Param("balanceId") Long balanceId);
@Select({"<script>",
"SELECT p.* FROM ll_inventory_position p JOIN ll_inventory_balance b ON b.id=p.balance_id",
"WHERE b.customer_id=#{customerId} AND p.balance_id IN",
"<foreach collection='balanceIds' item='id' open='(' separator=',' close=')'>#{id}</foreach>",
"ORDER BY p.balance_id,p.pallet_no,p.batch_no", "</script>"})
List<InventoryPosition> listBalances(@Param("customerId") String customerId,
@Param("balanceIds") Collection<Long> balanceIds);
@Select("SELECT * FROM ll_inventory_position WHERE id=#{positionId} AND customer_id=#{customerId} LIMIT 1")
InventoryPosition findTenantPosition(@Param("customerId") String customerId,
@Param("positionId") Long positionId);
@@ -253,10 +253,13 @@ public class RelabelApplicationService implements WalletResultHandler {
.gt(InventoryBalance::getAvailablePackages, 0)
.like(StringUtils.hasText(inboundCode), InventoryBalance::getInboundCode, trim(inboundCode))
.orderByDesc(InventoryBalance::getUpdatedAt));
List<RelabelResponses.InventoryCandidate> result = new java.util.ArrayList<>(balances.stream().map(balance -> {
List<RelabelResponses.InventoryPosition> positions = inventoryPositions.listBalance(customerId, balance.getId())
Map<Long, List<InventoryPosition>> positionsByBalance = balances.isEmpty() ? Map.of()
: inventoryPositions.listBalances(customerId, balances.stream().map(InventoryBalance::getId).toList())
.stream().filter(position -> value(position.getAvailablePackages()) > 0)
.map(position -> new RelabelResponses.InventoryPosition(position.getId(), position.getPalletNo(),
.collect(Collectors.groupingBy(InventoryPosition::getBalanceId, LinkedHashMap::new, Collectors.toList()));
List<RelabelResponses.InventoryCandidate> result = new java.util.ArrayList<>(balances.stream().map(balance -> {
List<RelabelResponses.InventoryPosition> positions = positionsByBalance.getOrDefault(balance.getId(), List.of())
.stream().map(position -> new RelabelResponses.InventoryPosition(position.getId(), position.getPalletNo(),
position.getBatchNo(), position.getWarehouseLocationCode(), value(position.getAvailablePackages())))
.toList();
long available = positions.stream().mapToLong(RelabelResponses.InventoryPosition::availablePackages).sum();
@@ -298,14 +301,16 @@ public class RelabelApplicationService implements WalletResultHandler {
cartonLines.stream().mapToLong(line -> value(line.getRelabelledQuantity())
+ returnCartons.completedSkuQuantity(carton.getId(), line.getSkuCode())).sum());
long reserved = returnCartons.relabelReservedQuantity(carton.getId());
List<String> mergedCartonMarks = StringUtils.hasText(carton.getSourceReturnNo()) ? List.of()
: returnPackingTraces.listCartonHistory(customerId, carton.getCartonMark()).stream()
.filter(history -> carton.getCartonMark().equals(history.sourceCartonMark()))
.map(history -> history.targetCartonMark()).distinct().toList();
result.add(new RelabelResponses.InventoryCandidate(null, null, carton.getSourceReturnNo(),
null, carton.getOverseasWarehouseId(), null, null, carton.getDestinationWarehouseCode(),
carton.getDestinationWarehouseName(), skuCodes, productNames, availablePackages, 0, List.of(),
"PARCEL".equals(carton.getSourceUnitType()) ? "RETURN_PARCEL" : "RETURN_CARTON", carton.getId(), carton.getCartonMark(), cartonSkus, relabelledPackages,
com.baiyue.lastleg.returnreceipt.service.ReturnRelabelProgress.status(value(carton.getTotalQuantity()), relabelledPackages, reserved), relabelledPackages, reserved, java.util.Set.of("MERGED", "OUTBOUNDED").contains(carton.getStatus()) ? 0L : value(carton.getTotalQuantity()), carton.getStatus(), carton.getRelabelNo(),
returnPackingTraces.listCartonHistory(customerId, carton.getCartonMark()).stream()
.filter(history -> carton.getCartonMark().equals(history.sourceCartonMark()))
.map(history -> history.targetCartonMark()).distinct().toList(), returnCartons.hasOutbound(carton.getId()),
mergedCartonMarks, returnCartons.hasOutbound(carton.getId()),
skuConversionRows.listCarton(customerId, carton.getId()).stream()
.map(com.baiyue.lastleg.returnreceipt.dto.ReturnInventoryResponses.SkuConversion::from).toList(), physicalSkus, cartonAvailable));
}