refactor: 未匹配收款金额列改名unclaimed_amount为unmatch_amount_rec
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ public class KingdeeReceiptFlow extends TenantEntity {
|
||||
/**
|
||||
* 未匹配收款金额(A301-1 unmatchamountrec,认领上限口径)
|
||||
*/
|
||||
private BigDecimal unclaimedAmount;
|
||||
private BigDecimal unmatchAmountRec;
|
||||
/**
|
||||
* 已匹配收款金额(A301-1 matchamountrec)
|
||||
*/
|
||||
|
||||
+1
-1
@@ -301,7 +301,7 @@ public class ReceiptClaimRecordServiceImpl extends BaseServiceImpl<ReceiptClaimM
|
||||
* 可认领上限:未匹配收款金额(A301-1 unmatchamountrec)与收款金额取较小正值(与收款流水侧口径一致)
|
||||
*/
|
||||
private BigDecimal claimCeiling(KingdeeReceiptFlow flow) {
|
||||
BigDecimal unclaimed = money(flow.getUnclaimedAmount());
|
||||
BigDecimal unclaimed = money(flow.getUnmatchAmountRec());
|
||||
BigDecimal receipt = money(flow.getReceiptAmount());
|
||||
if (receipt.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return unclaimed;
|
||||
|
||||
+8
-7
@@ -42,6 +42,7 @@ import org.springblade.thirdparty.bfi.pojo.dto.BfiRecBillQueryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiRecBillVO;
|
||||
import org.springblade.thirdparty.bfi.service.IBfiService;
|
||||
import org.springblade.thirdparty.bfi.util.BfiUtil;
|
||||
import org.springblade.transport.config.BfiProperties;
|
||||
import org.springblade.transport.constant.KingdeeBfiConstant;
|
||||
import org.springblade.transport.mapper.FormalSettlementMapper;
|
||||
@@ -69,7 +70,6 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -113,7 +113,8 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
|
||||
*/
|
||||
private static final int SYNC_BATCH_SIZE = 5000;
|
||||
/**
|
||||
* A301-1 翻页最大页数保护,防金蝶侧 lastPage 异常死循环(200条/页 × 500页)
|
||||
* A301-1 单片翻页最大页数保护(200条/页 × 500页):触顶说明该时间片数据超过单查询窗口上限,
|
||||
* 由 BfiUtil 二分切片续扫保证尾部不漏
|
||||
*/
|
||||
private static final int SYNC_MAX_PAGES = 500;
|
||||
/**
|
||||
@@ -344,7 +345,7 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
|
||||
}
|
||||
|
||||
// 认领上限:未匹配收款金额(A301-1 unmatchamountrec)与收款金额取较小值(避免未匹配金额异常偏大导致无法认领完成)
|
||||
if (flow.getUnclaimedAmount() == null) {
|
||||
if (flow.getUnmatchAmountRec() == null) {
|
||||
throw new ServiceException("未匹配收款金额缺失,请先手动同步金蝶收款流水");
|
||||
}
|
||||
BigDecimal claimCeiling = claimCeiling(flow);
|
||||
@@ -461,7 +462,7 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
|
||||
long start = System.currentTimeMillis();
|
||||
// 同步口径:按业务日期窗口拉取金蝶收款单(收款处理),按流水分录展开,
|
||||
// 以金蝶明细流水号为幂等键 upsert 收款流水表;本地已认领金额/状态(claimedAmount/claimStatus)
|
||||
// 由认领、作废驱动,不被同步顺带覆盖,未匹配收款金额单独存 unclaimed_amount 作为认领上限。
|
||||
// 由认领、作废驱动,不被同步顺带覆盖,未匹配收款金额单独存 unmatch_amount_rec 作为认领上限。
|
||||
BfiRecBillQueryDTO queryDTO = new BfiRecBillQueryDTO();
|
||||
queryDTO.setBeginBizdate(beginBizdate);
|
||||
queryDTO.setEndBizdate(endBizdate);
|
||||
@@ -759,7 +760,7 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
|
||||
* 主口径为金蝶侧未匹配收款金额;与收款金额取 min,避免未匹配金额异常偏大导致无法进入「认领完成」。
|
||||
*/
|
||||
private BigDecimal claimCeiling(KingdeeReceiptFlow flow) {
|
||||
BigDecimal unclaimed = money(flow.getUnclaimedAmount());
|
||||
BigDecimal unclaimed = money(flow.getUnmatchAmountRec());
|
||||
BigDecimal receipt = money(flow.getReceiptAmount());
|
||||
if (receipt.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return unclaimed;
|
||||
@@ -806,7 +807,7 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
|
||||
|
||||
/**
|
||||
* A301-1 收款单 → 收款流水表字段拷贝(仅覆盖金蝶侧来源字段,不覆盖本地认领金额与状态)。
|
||||
* 认领上限口径:未匹配收款金额 unmatchamountrec 存 unclaimed_amount。
|
||||
* 认领上限口径:未匹配收款金额 unmatchamountrec 存 unmatch_amount_rec。
|
||||
*/
|
||||
private void copyRecBillRow(KingdeeReceiptFlow target, BfiRecBillRow row) {
|
||||
BfiRecBillVO source = row.recBill();
|
||||
@@ -838,7 +839,7 @@ public class ReceiptFlowServiceImpl extends BaseServiceImpl<KingdeeReceiptFlowMa
|
||||
// 明细流水号
|
||||
target.setDetailSerialNo(row.detailSerialNo());
|
||||
// 未匹配收款金额(认领上限口径)
|
||||
target.setUnclaimedAmount(money(source.getUnmatchamountrec()));
|
||||
target.setUnmatchAmountRec(money(source.getUnmatchamountrec()));
|
||||
// 已匹配收款金额 / 已匹配付款金额 / 未匹配付款金额
|
||||
target.setMatchAmountRec(money(source.getMatchamountrec()));
|
||||
target.setMatchAmountPay(money(source.getMatchamountpay()));
|
||||
|
||||
+5
-5
@@ -70,12 +70,12 @@ public class ReceiptFlowWrapper extends BaseEntityWrapper<KingdeeReceiptFlow, Re
|
||||
case "failed" -> "处理失败";
|
||||
default -> "未推送";
|
||||
});
|
||||
// 剩余可认领金额 = 可认领上限 − 累计认领金额(上限取公告未认领与收款金额较小值)
|
||||
BigDecimal unclaimedAmount = money(entity.getUnclaimedAmount());
|
||||
// 剩余可认领金额 = 可认领上限 − 累计认领金额(上限取未匹配收款金额与收款金额较小值)
|
||||
BigDecimal unmatchAmountRec = money(entity.getUnmatchAmountRec());
|
||||
BigDecimal receiptAmount = money(entity.getReceiptAmount());
|
||||
BigDecimal claimCeiling = unclaimedAmount;
|
||||
if (receiptAmount.compareTo(BigDecimal.ZERO) > 0 && unclaimedAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
claimCeiling = unclaimedAmount.min(receiptAmount);
|
||||
BigDecimal claimCeiling = unmatchAmountRec;
|
||||
if (receiptAmount.compareTo(BigDecimal.ZERO) > 0 && unmatchAmountRec.compareTo(BigDecimal.ZERO) > 0) {
|
||||
claimCeiling = unmatchAmountRec.min(receiptAmount);
|
||||
}
|
||||
BigDecimal claimedAmount = money(entity.getClaimedAmount());
|
||||
vo.setRemainingAmount(claimCeiling.subtract(claimedAmount).max(BigDecimal.ZERO));
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ A301-1 收款单查询(业务日期窗口取 `thirdParty.bfi.recBillSync.days`
|
||||
| kingdee_bill_status | `billstatus` 映射 | A/B已提交→pushed、C已审核→approved、D已收款→received、其余(含G退单)→failed |
|
||||
| detail_serial_no | 主单 `billno` | 明细流水号=收款单号,**幂等键**;主单粒度,一张收款单一条流水,不展开流水分录 |
|
||||
| receipt_amount | 主单 `actrecamt` | 收款金额(金蝶收款金额口径) |
|
||||
| unclaimed_amount | `unmatchamountrec` | 未匹配收款金额(认领上限口径) |
|
||||
| unmatch_amount_rec | `unmatchamountrec` | 未匹配收款金额(认领上限口径;原列名 unclaimed_amount 已改名) |
|
||||
| match_amount_rec | `matchamountrec` | 已匹配收款金额 |
|
||||
| match_amount_pay | `matchamountpay` | 已匹配付款金额 |
|
||||
| unmatch_amount_pay | `unmatchamountpay` | 未匹配付款金额 |
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
-- 收款流水表未匹配收款金额列改名:unclaimed_amount(A301-2 公告未认领金额遗留列名)
|
||||
-- → unmatch_amount_rec(与 A301-1 字段口径及其他匹配金额列命名统一)
|
||||
|
||||
SET @ddl_sql = (
|
||||
SELECT IF(COUNT(*) = 1,
|
||||
'ALTER TABLE `blade_kingdee_receipt_flow` RENAME COLUMN `unclaimed_amount` TO `unmatch_amount_rec`',
|
||||
'SELECT 1')
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'blade_kingdee_receipt_flow'
|
||||
AND COLUMN_NAME = 'unclaimed_amount'
|
||||
);
|
||||
PREPARE ddl_stmt FROM @ddl_sql;
|
||||
EXECUTE ddl_stmt;
|
||||
DEALLOCATE PREPARE ddl_stmt;
|
||||
Reference in New Issue
Block a user