上架数量显示异常1
This commit is contained in:
+31
-11
@@ -872,12 +872,32 @@ public class StockOutOrderApplicationService {
|
|||||||
*/
|
*/
|
||||||
public Boolean cancelAssign(StockOutOrderDO stockOutOrderDO){
|
public Boolean cancelAssign(StockOutOrderDO stockOutOrderDO){
|
||||||
StockOutOrderPO infoChildren = getInfoChildren(stockOutOrderDO.getOutOrderId());
|
StockOutOrderPO infoChildren = getInfoChildren(stockOutOrderDO.getOutOrderId());
|
||||||
BigDecimal alreadyAllocationQuantityAll = infoChildren.getMaterialDetailList().stream().map(OutMaterialDetailPO::getAlreadyAllocationQuantity)
|
BigDecimal alreadyAllocationQuantityAll = BigDecimal.ZERO;
|
||||||
.filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
if (infoChildren != null && !CollectionUtils.isEmpty(infoChildren.getMaterialDetailList())) {
|
||||||
|
for (OutMaterialDetailPO line : infoChildren.getMaterialDetailList()) {
|
||||||
|
alreadyAllocationQuantityAll = alreadyAllocationQuantityAll.add(sumAlreadyAllocationInclusive(line));
|
||||||
|
}
|
||||||
|
}
|
||||||
stockOutOrderDO.setAlreadyAllocationQuantityAll(alreadyAllocationQuantityAll);
|
stockOutOrderDO.setAlreadyAllocationQuantityAll(alreadyAllocationQuantityAll);
|
||||||
return stockOutOrderDomainService.cancelAssign(stockOutOrderDO);
|
return stockOutOrderDomainService.cancelAssign(stockOutOrderDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 计划行(含子行)已分配数量之和,用于单头汇总、取消分配等 */
|
||||||
|
private static BigDecimal sumAlreadyAllocationInclusive(OutMaterialDetailPO node) {
|
||||||
|
if (node == null) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
BigDecimal s = node.getAlreadyAllocationQuantity() != null ? node.getAlreadyAllocationQuantity() : BigDecimal.ZERO;
|
||||||
|
List<OutMaterialDetailPO> ch = node.getChildren();
|
||||||
|
if (CollectionUtils.isEmpty(ch)) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
for (OutMaterialDetailPO c : ch) {
|
||||||
|
s = s.add(sumAlreadyAllocationInclusive(c));
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 手动取消分配(点击确认后直接取消分配)
|
* @description 手动取消分配(点击确认后直接取消分配)
|
||||||
* @author ZhouGY
|
* @author ZhouGY
|
||||||
@@ -1061,16 +1081,15 @@ public class StockOutOrderApplicationService {
|
|||||||
outMaterialDetailDO.setAllowModify(2);
|
outMaterialDetailDO.setAllowModify(2);
|
||||||
//未分配过货 统计到当前分配单作业分配数
|
//未分配过货 统计到当前分配单作业分配数
|
||||||
}
|
}
|
||||||
totalAllocationQuantity = outMaterialDetailDO.getAllocationQuantity();
|
// 主行「已分配数量」仅记主行本行分配量;子行各自带自己的已分配,不累加到主行(避免双库位时主项显示成主+子)
|
||||||
|
BigDecimal parentAllocationQuantity = outMaterialDetailDO.getAllocationQuantity();
|
||||||
//判断是否存在子项
|
//判断是否存在子项
|
||||||
List<OutMaterialDetailDO> returnOutMaterialDetailDOChildList = new ArrayList<>();
|
List<OutMaterialDetailDO> returnOutMaterialDetailDOChildList = new ArrayList<>();
|
||||||
List<OutMaterialDetailDO> outMaterialDetailDOChildList = outMaterialDetailDO.getChildren();
|
List<OutMaterialDetailDO> outMaterialDetailDOChildList = outMaterialDetailDO.getChildren();
|
||||||
if (!CollectionUtils.isEmpty(outMaterialDetailDOChildList)){
|
if (!CollectionUtils.isEmpty(outMaterialDetailDOChildList)){
|
||||||
BigDecimal totalNowAllocationQuantity = BigDecimal.ZERO;//当前作业分配数量
|
|
||||||
for (OutMaterialDetailDO outMaterialDetailDOChild : outMaterialDetailDOChildList){
|
for (OutMaterialDetailDO outMaterialDetailDOChild : outMaterialDetailDOChildList){
|
||||||
OutMaterialDetailPO outMaterialDetailPOChildDb = outMaterialDetailDbMap.get(outMaterialDetailDOChild.getMaterialDetailId());
|
OutMaterialDetailPO outMaterialDetailPOChildDb = outMaterialDetailDbMap.get(outMaterialDetailDOChild.getMaterialDetailId());
|
||||||
if (outMaterialDetailPOChildDb != null){
|
if (outMaterialDetailPOChildDb != null){
|
||||||
totalAllocationQuantity = totalAllocationQuantity.add(outMaterialDetailDOChild.getAllocationQuantity());
|
|
||||||
returnOutMaterialDetailDOChildList.add(outMaterialDetailDOChild);
|
returnOutMaterialDetailDOChildList.add(outMaterialDetailDOChild);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1092,11 +1111,9 @@ public class StockOutOrderApplicationService {
|
|||||||
returnOutMaterialDetailDOChild.setLevel(2);
|
returnOutMaterialDetailDOChild.setLevel(2);
|
||||||
returnOutMaterialDetailDOChild.setParentUniqueId(outMaterialDetailPO.getUniqueId());
|
returnOutMaterialDetailDOChild.setParentUniqueId(outMaterialDetailPO.getUniqueId());
|
||||||
returnOutMaterialDetailDOChildList.add(returnOutMaterialDetailDOChild);
|
returnOutMaterialDetailDOChildList.add(returnOutMaterialDetailDOChild);
|
||||||
totalAllocationQuantity = totalAllocationQuantity.add(returnOutMaterialDetailDOChild.getAllocationQuantity());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//主单当分配作业数量和
|
outMaterialDetailDO.setAlreadyAllocationQuantity(parentAllocationQuantity);
|
||||||
outMaterialDetailDO.setAlreadyAllocationQuantity(totalAllocationQuantity);
|
|
||||||
OutMaterialDetailDO returnOutMaterialDetailDO = new OutMaterialDetailDO();
|
OutMaterialDetailDO returnOutMaterialDetailDO = new OutMaterialDetailDO();
|
||||||
BeanUtils.copyProperties(outMaterialDetailPO, returnOutMaterialDetailDO);
|
BeanUtils.copyProperties(outMaterialDetailPO, returnOutMaterialDetailDO);
|
||||||
BeanUtils.copyProperties(outMaterialDetailDO, returnOutMaterialDetailDO, IgnoreNullUtil.getNullPropertyNames(outMaterialDetailDO));
|
BeanUtils.copyProperties(outMaterialDetailDO, returnOutMaterialDetailDO, IgnoreNullUtil.getNullPropertyNames(outMaterialDetailDO));
|
||||||
@@ -1295,6 +1312,10 @@ public class StockOutOrderApplicationService {
|
|||||||
outMaterialDetailPOList.forEach(outMaterialDetailPO -> {
|
outMaterialDetailPOList.forEach(outMaterialDetailPO -> {
|
||||||
BigDecimal quantity = outMaterialDetailPO.getQuantity(); // 计划数量
|
BigDecimal quantity = outMaterialDetailPO.getQuantity(); // 计划数量
|
||||||
BigDecimal alreadyAllocationQuantity = outMaterialDetailPO.getAlreadyAllocationQuantity(); // 已分配数量
|
BigDecimal alreadyAllocationQuantity = outMaterialDetailPO.getAlreadyAllocationQuantity(); // 已分配数量
|
||||||
|
List<OutMaterialDetailPO> ch = outMaterialDetailPO.getChildren();
|
||||||
|
if (!CollectionUtils.isEmpty(ch)) {
|
||||||
|
alreadyAllocationQuantity = sumAlreadyAllocationInclusive(outMaterialDetailPO);
|
||||||
|
}
|
||||||
|
|
||||||
// 判断按钮显示类型
|
// 判断按钮显示类型
|
||||||
// 已分配数量 = 0:显示"库存分配"按钮(类型1)
|
// 已分配数量 = 0:显示"库存分配"按钮(类型1)
|
||||||
@@ -1311,9 +1332,8 @@ public class StockOutOrderApplicationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 递归处理子级
|
// 递归处理子级
|
||||||
List<OutMaterialDetailPO> children = outMaterialDetailPO.getChildren();
|
if (!CollectionUtils.isEmpty(ch)) {
|
||||||
if (!CollectionUtils.isEmpty(children)) {
|
setAllocationButtonTypeRecursively(ch);
|
||||||
setAllocationButtonTypeRecursively(children);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-3
@@ -311,7 +311,7 @@ public class StockShelfOrderApplicationService {
|
|||||||
// 第一次上架:主项无子项时,上架数量默认等于收货数量(quantity 由上架单生成时取自收货数量),供 PDA 表单默认展示
|
// 第一次上架:主项无子项时,上架数量默认等于收货数量(quantity 由上架单生成时取自收货数量),供 PDA 表单默认展示
|
||||||
fillFirstShelvesQuantityDefault(shelfMaterialDetailPOList);
|
fillFirstShelvesQuantityDefault(shelfMaterialDetailPOList);
|
||||||
|
|
||||||
// PC 端(addParentCopyWhenNoChildren==false):与收货单 getInfo 相同流水线——先按行递归汇总部净重/毛重/体面积,再扁平化主行、清空子行计划数量、待上架数量,最后按「计划−已上架」覆盖 total* 展示(对齐收货详情计算口径)
|
// PC 端(addParentCopyWhenNoChildren==false):单头 total* 仍按明细树递归汇总;明细行净重/毛重/体积/面积<strong>不</strong>做「计划−已上架」覆盖,保持 shelf_material_detail 库表值
|
||||||
if (!addParentCopyWhenNoChildren) {
|
if (!addParentCopyWhenNoChildren) {
|
||||||
BigDecimal totalNetWeight = BigDecimal.ZERO;
|
BigDecimal totalNetWeight = BigDecimal.ZERO;
|
||||||
BigDecimal totalGrossWeight = BigDecimal.ZERO;
|
BigDecimal totalGrossWeight = BigDecimal.ZERO;
|
||||||
@@ -333,8 +333,6 @@ public class StockShelfOrderApplicationService {
|
|||||||
flattenShelfMaterialDetailList(shelfMaterialDetailPOList, shelfOrderCompleted);
|
flattenShelfMaterialDetailList(shelfMaterialDetailPOList, shelfOrderCompleted);
|
||||||
clearChildQuantityShelfRecursively(shelfMaterialDetailPOList);
|
clearChildQuantityShelfRecursively(shelfMaterialDetailPOList);
|
||||||
fillPendingShelvesQuantityRecursively(shelfMaterialDetailPOList);
|
fillPendingShelvesQuantityRecursively(shelfMaterialDetailPOList);
|
||||||
Map<Long, WeightMetrics> planWeightMetrics = loadReceiptPlanWeightMetrics(stockShelfOrderPO.getReceiptOrderNumber());
|
|
||||||
overwriteTotalWithPendingForPdaWeightDisplayRecursively(shelfMaterialDetailPOList, planWeightMetrics);
|
|
||||||
syncMaterialMoreDetailWeightValuesRecursively(shelfMaterialDetailPOList);
|
syncMaterialMoreDetailWeightValuesRecursively(shelfMaterialDetailPOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1094,6 +1092,14 @@ public class StockShelfOrderApplicationService {
|
|||||||
BigDecimal alreadyVol = d.getAlreadyShelvesVolume() != null ? d.getAlreadyShelvesVolume() : BigDecimal.ZERO;
|
BigDecimal alreadyVol = d.getAlreadyShelvesVolume() != null ? d.getAlreadyShelvesVolume() : BigDecimal.ZERO;
|
||||||
BigDecimal alreadyArea = d.getAlreadyShelvesArea() != null ? d.getAlreadyShelvesArea() : BigDecimal.ZERO;
|
BigDecimal alreadyArea = d.getAlreadyShelvesArea() != null ? d.getAlreadyShelvesArea() : BigDecimal.ZERO;
|
||||||
|
|
||||||
|
// level=1 有子行:待上架 = 计划 − (主行+子行)已上架;flatten 不再把主行重量汇总后,此处必须用整卡累计参与扣减,否则会只减主行
|
||||||
|
if (d.getLevel() != null && d.getLevel() == 1 && !CollectionUtils.isEmpty(d.getChildren())) {
|
||||||
|
alreadyNet = sumShelfPlanRowAggregatedAlreadyMetric(d, ShelfMaterialDetailPO::getAlreadyShelvesNetWeight);
|
||||||
|
alreadyGross = sumShelfPlanRowAggregatedAlreadyMetric(d, ShelfMaterialDetailPO::getAlreadyShelvesGrossWeight);
|
||||||
|
alreadyVol = sumShelfPlanRowAggregatedAlreadyMetric(d, ShelfMaterialDetailPO::getAlreadyShelvesVolume);
|
||||||
|
alreadyArea = sumShelfPlanRowAggregatedAlreadyMetric(d, ShelfMaterialDetailPO::getAlreadyShelvesArea);
|
||||||
|
}
|
||||||
|
|
||||||
// level=2 子行:计划为整张卡;已上架量用主行+子行 DB 累计之和(主行自身字段不再汇总时仍按整卡扣计划)
|
// level=2 子行:计划为整张卡;已上架量用主行+子行 DB 累计之和(主行自身字段不再汇总时仍按整卡扣计划)
|
||||||
if (planParent != null && d.getLevel() != null && d.getLevel() == 2) {
|
if (planParent != null && d.getLevel() != null && d.getLevel() == 2) {
|
||||||
alreadyNet = sumShelfPlanRowAggregatedAlreadyMetric(planParent, ShelfMaterialDetailPO::getAlreadyShelvesNetWeight);
|
alreadyNet = sumShelfPlanRowAggregatedAlreadyMetric(planParent, ShelfMaterialDetailPO::getAlreadyShelvesNetWeight);
|
||||||
|
|||||||
+11
-2
@@ -317,8 +317,17 @@ public class OutMaterialDetailImpl extends ServiceImpl<OutMaterialDetailMapper,
|
|||||||
// 有子项时,父项不参与库存扣减,避免父项+子项重复扣减导致数量翻倍(子项已代表实际分配)
|
// 有子项时,父项不参与库存扣减,避免父项+子项重复扣减导致数量翻倍(子项已代表实际分配)
|
||||||
outMaterialDetail.setNowAllocationQuantity(BigDecimal.ZERO);
|
outMaterialDetail.setNowAllocationQuantity(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
//记录收货单收货总数
|
// 单头「分配数量」= 本计划行主行已分配 + 各子行已分配(主行字段不再存主+子合计)
|
||||||
totalAllocationQuantity = totalAllocationQuantity.add(outMaterialDetail.getAlreadyAllocationQuantity());
|
BigDecimal lineAllocatedSum = outMaterialDetail.getAlreadyAllocationQuantity() != null
|
||||||
|
? outMaterialDetail.getAlreadyAllocationQuantity() : BigDecimal.ZERO;
|
||||||
|
if (!CollectionUtils.isEmpty(materialDetailDOChildList)) {
|
||||||
|
for (OutMaterialDetailDO childDo : materialDetailDOChildList) {
|
||||||
|
BigDecimal childAlloc = childDo.getAlreadyAllocationQuantity() != null
|
||||||
|
? childDo.getAlreadyAllocationQuantity() : BigDecimal.ZERO;
|
||||||
|
lineAllocatedSum = lineAllocatedSum.add(childAlloc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
totalAllocationQuantity = totalAllocationQuantity.add(lineAllocatedSum);
|
||||||
}
|
}
|
||||||
stockOutOrderPO.setAllocationQuantity(totalAllocationQuantity);
|
stockOutOrderPO.setAllocationQuantity(totalAllocationQuantity);
|
||||||
//分配(修改库存)
|
//分配(修改库存)
|
||||||
|
|||||||
Reference in New Issue
Block a user