优化计费任务列表状态过滤逻辑,更新计费重和客户确认重字段名称

This commit is contained in:
wuweihua
2026-11-17 10:13:09 +08:00
committed by caojia
parent ea62697b98
commit 7500728c1d
12 changed files with 85 additions and 75 deletions
@@ -33,9 +33,9 @@ public class PrcBillingBillListExportRow implements Serializable
private String countryName;
@Excel(name = "件数", width = 10)
private Integer pieces;
@Excel(name = "计费重", scale = 3, width = 12)
@Excel(name = "客户确认重", scale = 3, width = 12)
private BigDecimal chargeWeight;
@Excel(name = "原计费重", scale = 3, width = 12)
@Excel(name = "计费重", scale = 3, width = 12)
private BigDecimal weight;
@Excel(name = "收货重", scale = 3, width = 12)
private BigDecimal receiveWeight;
@@ -35,6 +35,8 @@ public class PrcOrderBillListExportRow implements Serializable
private Integer pieces;
@Excel(name = "计费重", scale = 3, width = 12)
private BigDecimal weight;
@Excel(name = "客户确认重", scale = 3, width = 12)
private BigDecimal chargeWeight;
@Excel(name = "体积重", scale = 3, width = 12)
private BigDecimal volumeWeight;
@Excel(name = "实重", scale = 3, width = 12)
@@ -42,6 +42,8 @@ public class TmsPriceBillRequest extends TmsPriceQuoteRequest
private BigDecimal actualWeight;
/** 上游 TAB_ORDER.WEIGHT(收货重量) */
private BigDecimal receiveWeight;
/** 计费重覆盖:上游 CONFIRM_WEIGHT(客户确认重)或本地人工修改;无值则为 null */
private BigDecimal chargeWeight;
private BigDecimal volume;
private BigDecimal volumeWeight;
private BigDecimal pkgLength;
@@ -49,9 +49,11 @@ public class OracleOrderBillMapper
String countryName = firstStr(row, "COUNTRY_NAME", "COUNTRY_EINGTH_NAME", "COUNTRY");
req.setCountryName(countryName);
req.setDestPostcode(StringUtils.normalizePostcode(firstStr(row, "CONSIGNEE_POSTCODE")));
// 优先取 CONFIRM_WEIGHT(客户确认重量);回退取 DIMENSIONAL_WEIGHT_FACTOR(计费重量)。
BigDecimal weight = firstPositiveDecimal(row, "CONFIRM_WEIGHT", "DIMENSIONAL_WEIGHT_FACTOR");
// weight = 上游计费重 DIMENSIONAL_WEIGHT_FACTOR
BigDecimal weight = firstPositiveDecimal(row, "DIMENSIONAL_WEIGHT_FACTOR");
req.setWeight(weight);
// charge_weight 仅在客户确认重 CONFIRM_WEIGHT 有值时落库
req.setChargeWeight(firstPositiveDecimal(row, "CONFIRM_WEIGHT"));
// TAB_ORDER.WEIGHT = 收货重
req.setReceiveWeight(firstDecimal(row, "WEIGHT"));
req.setActualWeight(firstPositiveDecimal(row, "ACTUAL_WEIGHT", "PUSH_WEIGHT", "WEIGHT"));
@@ -2061,9 +2061,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
{
bill.setCountryName(result.getCountryName());
}
// weight = 系统/上游原始重量;当 VOL_8000(或人工覆盖)提高/降低了计费重量时,
// charge_weight 可能与之不同。
bill.setWeight(weight);
// weight=上游计费重(DIMENSIONAL_WEIGHT_FACTOR);charge_weight=客户确认重/人工修改
bill.setWeight(weight);
bill.setBizDate(bizDate);
bill.setTmsId(request.getTmsId() == null ? null : Long.valueOf(request.getTmsId()));
bill.setPriceSetId(result.getPriceSetId());
@@ -2078,16 +2077,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
bill.setWeightMax(result.getWeightMax());
bill.setWeightLabel(result.getWeightLabel());
bill.setEffectiveDate(result.getEffectiveDate());
if (isUpstreamSyncRequest(request))
{
// request.weight 已携带用于报价的规则/计算重量
BigDecimal cw = request.getWeight() != null ? request.getWeight() : weight;
bill.setChargeWeight(cw);
}
else
{
bill.setChargeWeight(resolvePersistChargeWeight(weight, result.getChargeWeight()));
}
// charge_weight:仅上游客户确认重或本地人工修改有值时落库
bill.setChargeWeight(resolvePersistChargeWeight(request, existed));
Integer billingFailStatus = result.getBillingFailStatus();
if (billingFailStatus == null)
{
@@ -2838,6 +2829,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
}
BigDecimal cw = chargeWeight.setScale(3, RoundingMode.HALF_UP);
TmsPriceBillRequest req = buildBillRequestFromBill(bill);
// 人工修改计费重:charge_weight 优先级最高
req.setChargeWeight(cw);
req.setWeight(cw);
Date bizDate = bill.getBizDate();
if (bizDate == null)
@@ -3085,55 +3078,54 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
return request != null && request.getUpstreamRow() != null && !request.getUpstreamRow().isEmpty();
}
/** charge_weight 与 weight 不同 => 视为人工覆盖。 */
private static boolean isManualChargeWeight(PrcOrderBill bill)
/** charge_weight 有效值(上游客户确认重或本地人工修改)。 */
private static boolean hasChargeWeightOverride(BigDecimal chargeWeight)
{
if (bill == null || bill.getChargeWeight() == null || bill.getWeight() == null)
{
return false;
}
return bill.getChargeWeight().compareTo(bill.getWeight()) != 0;
return chargeWeight != null && chargeWeight.compareTo(BigDecimal.ZERO) > 0;
}
/** 存在人工 charge_weight 时优先使用,否则使用系统重量。 */
private static BigDecimal resolveCalcWeight(PrcOrderBill existed, BigDecimal systemWeight)
private static boolean hasChargeWeightOverride(PrcOrderBill bill)
{
if (isManualChargeWeight(existed))
{
return existed.getChargeWeight();
}
return systemWeight;
return bill != null && hasChargeWeightOverride(bill.getChargeWeight());
}
private static BigDecimal positiveOrNull(BigDecimal value)
{
return hasChargeWeightOverride(value) ? value : null;
}
/**
* 解析用于报价/持久化的重量。
* 上游:先取 TAB_ORDER 重量再按业务规则。本地:人工 charge_weight 优先,否则按业务规则。
* 计费取重:charge_weight 优先级最高;无则用系统 weight 再走业务规则。
*/
private BigDecimal resolveBillCalcWeight(TmsPriceBillRequest request, PrcOrderBill existed,
BigDecimal systemWeight)
{
BigDecimal calcWeight = isUpstreamSyncRequest(request)
? systemWeight
: resolveCalcWeight(existed, systemWeight);
if (isUpstreamSyncRequest(request) || !isManualChargeWeight(existed))
BigDecimal preferred = positiveOrNull(request == null ? null : request.getChargeWeight());
if (preferred == null && !isUpstreamSyncRequest(request) && hasChargeWeightOverride(existed))
{
calcWeight = applyBizRuleWeight(request, calcWeight);
preferred = existed.getChargeWeight();
}
return calcWeight;
if (preferred != null)
{
return preferred;
}
return applyBizRuleWeight(request, systemWeight);
}
/**
* 上游同步/软失败:保留原始重量,charge_weight 可按业务规则计算。
* 上游同步/软失败:weight=上游计费重;charge_weight=客户确认重(无值则 null)。
*/
private void applyUpstreamWeightFields(PrcOrderBill bill, TmsPriceBillRequest request)
{
if (bill == null || request == null || request.getWeight() == null)
if (bill == null || request == null)
{
return;
}
BigDecimal systemWeight = request.getWeight();
bill.setWeight(systemWeight);
bill.setChargeWeight(applyBizRuleWeight(request, systemWeight));
if (request.getWeight() != null)
{
bill.setWeight(request.getWeight());
}
bill.setChargeWeight(positiveOrNull(request.getChargeWeight()));
}
/**
@@ -3151,18 +3143,25 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
}
/**
* 持久化 charge_weight:当计算重量 != 系统重量,
* 或已有账单本就是人工覆盖时,保留人工覆盖值。
* 落库 charge_weight:仅上游客户确认重或本地人工修改有值时保留。
* 业务规则推出的重量不写入 charge_weight。
*/
private static BigDecimal resolvePersistChargeWeight(BigDecimal systemWeight, BigDecimal resultChargeWeight)
private static BigDecimal resolvePersistChargeWeight(TmsPriceBillRequest request, PrcOrderBill existed)
{
// 计算重量 != 系统重量 => 将结果作为人工 charge_weight 保留
if (systemWeight != null && resultChargeWeight != null
&& systemWeight.compareTo(resultChargeWeight) != 0)
if (isUpstreamSyncRequest(request))
{
return resultChargeWeight;
return positiveOrNull(request.getChargeWeight());
}
return resultChargeWeight;
BigDecimal reqCw = positiveOrNull(request == null ? null : request.getChargeWeight());
if (reqCw != null)
{
return reqCw;
}
if (hasChargeWeightOverride(existed))
{
return existed.getChargeWeight();
}
return null;
}
private TmsPriceBillRequest buildBillRequestFromBill(PrcOrderBill bill)
@@ -3210,8 +3209,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
{
req.setBizDate(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", bill.getBizDate()));
}
BigDecimal w = bill.getChargeWeight() != null ? bill.getChargeWeight() : bill.getWeight();
req.setWeight(w);
// weight=系统重;charge_weight=覆盖重(计费优先)
req.setWeight(bill.getWeight());
req.setChargeWeight(positiveOrNull(bill.getChargeWeight()));
return req;
}
@@ -147,6 +147,7 @@ public final class OrderBillExportSupport
row.setCountryName(bill.getCountryName());
row.setPieces(bill.getPieces());
row.setWeight(bill.getWeight());
row.setChargeWeight(bill.getChargeWeight());
row.setVolumeWeight(bill.getVolumeWeight());
row.setReceiveWeight(bill.getReceiveWeight());
row.setDestPostcode(bill.getDestPostcode());