完成LSFX Mock第二期稳定随机命中后端实施
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
# LSFX Mock 第二期稳定随机命中后端实施记录
|
||||
|
||||
## 修改范围
|
||||
|
||||
- `lsfx-mock-server/services/file_service.py`
|
||||
- `lsfx-mock-server/services/statement_rule_samples.py`
|
||||
- `lsfx-mock-server/services/statement_service.py`
|
||||
- `lsfx-mock-server/services/phase2_baseline_service.py`
|
||||
- `lsfx-mock-server/tests/test_file_service.py`
|
||||
- `lsfx-mock-server/tests/test_statement_service.py`
|
||||
- `lsfx-mock-server/tests/test_phase2_baseline_service.py`
|
||||
- `lsfx-mock-server/tests/integration/test_full_workflow.py`
|
||||
- `sql/migration/2026-03-20-lsfx-mock-phase2-hit-baseline.sql`
|
||||
|
||||
## 第二期规则分层
|
||||
|
||||
- 流水样本驱动规则:
|
||||
- `LOW_INCOME_RELATIVE_LARGE_TRANSACTION`
|
||||
- `MULTI_PARTY_GAMBLING_TRANSFER`
|
||||
- `MONTHLY_FIXED_INCOME`
|
||||
- `FIXED_COUNTERPARTY_TRANSFER`
|
||||
- `SALARY_QUICK_TRANSFER`
|
||||
- `SALARY_UNUSED`
|
||||
- 数据库基线驱动规则:
|
||||
- `HOUSE_REGISTRATION_MISMATCH`
|
||||
- `PROPERTY_FEE_REGISTRATION_MISMATCH`
|
||||
- `TAX_ASSET_REGISTRATION_MISMATCH`
|
||||
- `SUPPLIER_CONCENTRATION`
|
||||
|
||||
## 职责边界
|
||||
|
||||
- `FileService`
|
||||
- 为同一 `logId` 稳定生成并持久化第二期规则命中计划。
|
||||
- 在 `upload_file()` 与 `fetch_inner_flow()` 链路中写入 `phase2_statement_hit_rules` 与 `phase2_baseline_hit_rules`。
|
||||
- 在记录创建后立即调用第二期基线服务,避免出现“流水已返回但基线未写”的假成功状态。
|
||||
- `StatementService`
|
||||
- 从 `FileRecord` 读取第二期流水规则子集。
|
||||
- 继续保持 `FIXED_TOTAL_COUNT = 200`、稳定 ID 分配与缓存分页语义。
|
||||
- `Phase2BaselineService`
|
||||
- 复用项目数据库配置生成并执行第二期幂等 SQL 计划。
|
||||
- 采购基线通过 `ccdi_base_staff.id_card -> staff_id` 映射到真实员工工号。
|
||||
- 资产基线使用固定 `asset_name` 先删后插,并保持“故意不匹配”的资产枚举口径。
|
||||
|
||||
## 第二期流水样本策略
|
||||
|
||||
- `MULTI_PARTY_GAMBLING_TRANSFER`
|
||||
- 为同一证件号生成同日多对手方、多笔区间金额转出。
|
||||
- `MONTHLY_FIXED_INCOME`
|
||||
- 生成连续 4 个月的稳定非工资转入。
|
||||
- `FIXED_COUNTERPARTY_TRANSFER`
|
||||
- 为固定对手方生成跨季度稳定转入样本。
|
||||
- `SALARY_QUICK_TRANSFER`
|
||||
- 生成工资入账后 6 小时内的大额转出。
|
||||
- `SALARY_UNUSED`
|
||||
- 生成独立证件号的工资入账与代扣样本,不与 `SALARY_QUICK_TRANSFER` 共用同一对象。
|
||||
|
||||
## 幂等 SQL 基线方案
|
||||
|
||||
- `SUPPLIER_CONCENTRATION`
|
||||
- 固定采购主键 `LSFXMOCKP2PUR001`,先删后插。
|
||||
- 插入 SQL 通过 `ccdi_base_staff` 按身份证反查真实 `staff_id` 与姓名,确保可被真实规则 SQL 关联。
|
||||
- 三条资产不匹配规则
|
||||
- 固定资产名称前缀 `LSFX Mock P2 ...`,先删后插。
|
||||
- 统一使用当前项目真实口径中的 `asset_main_type = '房产'`、`asset_status = '正常'`。
|
||||
- `asset_sub_type` 故意使用非 `住宅` 的值,维持“存在资产事实但不满足房产登记匹配”的状态。
|
||||
- 亲属资产记录遵循 `family_id = 员工身份证号`、`person_id = 亲属身份证号`。
|
||||
|
||||
## 实施结果
|
||||
|
||||
- 第二期规则命中计划已接入 `FileService -> StatementService -> 缓存分页` 主链路。
|
||||
- 第二期数据库基线已在拉取链路内接通,并支持通过独立 SQL 脚本重复重放。
|
||||
- 单元测试、集成测试和全量 `lsfx-mock-server` 回归均已通过。
|
||||
@@ -19,4 +19,5 @@
|
||||
|
||||
## 后续动作
|
||||
|
||||
- 待用户审核设计文档后,再进入实施计划编写。
|
||||
- 已基于设计文档完成后端实施计划与后端代码落地。
|
||||
- 第二期稳定随机命中计划、流水样本与数据库基线已在 `lsfx-mock-server` 中接通。
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# LSFX Mock 第二期稳定随机命中后端验证记录
|
||||
|
||||
## 验证时间
|
||||
|
||||
- 2026-03-20
|
||||
|
||||
## pytest 验证
|
||||
|
||||
- 聚焦验证命令:
|
||||
- `python3 -m pytest lsfx-mock-server/tests/test_file_service.py -k "phase2_rule_hit_plan" -v`
|
||||
- `python3 -m pytest lsfx-mock-server/tests/test_phase2_baseline_service.py -v`
|
||||
- `python3 -m pytest lsfx-mock-server/tests/test_statement_service.py -k "phase2 or salary_quick_transfer_and_salary_unused" -v`
|
||||
- `python3 -m pytest lsfx-mock-server/tests/integration/test_full_workflow.py -k "phase2" -v`
|
||||
- 聚焦验证结果:
|
||||
- 上述 4 组命令全部通过。
|
||||
- 全量回归命令:
|
||||
- `python3 -m pytest lsfx-mock-server/tests/test_file_service.py lsfx-mock-server/tests/test_statement_service.py lsfx-mock-server/tests/test_phase2_baseline_service.py lsfx-mock-server/tests/test_api.py lsfx-mock-server/tests/integration/test_full_workflow.py -v`
|
||||
- 全量回归结果:
|
||||
- `48 passed`
|
||||
|
||||
## SQL 执行与核验
|
||||
|
||||
- 执行命令:
|
||||
- `bin/mysql_utf8_exec.sh sql/migration/2026-03-20-lsfx-mock-phase2-hit-baseline.sql`
|
||||
- 只读核验结果:
|
||||
- `ccdi_purchase_transaction` 中存在 `LSFXMOCKP2PUR001 / 兰溪市联调供应链有限公司 / 186000.00`
|
||||
- `ccdi_asset_info` 中存在 3 条 `LSFX Mock P2` 资产基线记录
|
||||
- 资产记录写回查询时,`asset_status` 读数为 `NORMAL`;结合现网样例数据的 `正常` 口径,推测当前库内存在状态值归一化或历史兼容现象,但本次“不匹配”目标仍由非 `住宅` 子类型稳定满足
|
||||
- 幂等性复核:
|
||||
- 脚本重复执行 1 次后再次查询
|
||||
- `ccdi_purchase_transaction` 计数为 `1`
|
||||
- `ccdi_asset_info` 计数为 `3`
|
||||
|
||||
## 端到端链路结果
|
||||
|
||||
- `test_inner_flow_should_apply_phase2_baselines_before_get_bank_statement` 通过。
|
||||
- 结果表明:
|
||||
- `getJZFileOrZjrcuFile` 在返回 `logId` 前已调用第二期基线写入。
|
||||
- `getBSByLogId` 仍可在同一 `logId` 下稳定读取流水列表。
|
||||
|
||||
## 结论
|
||||
|
||||
- 第二期稳定随机命中计划、流水样本装配、数据库基线写入和集成链路均已接通。
|
||||
- 当前 `lsfx-mock-server` 回归通过,数据库基线可重复执行且未产生重复脏数据。
|
||||
|
||||
## 环境清理
|
||||
|
||||
- 本次验证未启动长期驻留的前后端开发进程,无残留进程需要额外关闭。
|
||||
Reference in New Issue
Block a user