fix: use API workdays and final delivery date in bot replies

This commit is contained in:
ar51
2026-09-20 14:28:51 +08:00
parent 24469372fb
commit 1c25c9e1d9
6 changed files with 139 additions and 207 deletions

View File

@@ -5,7 +5,7 @@
**日期**:2026-09-02
**目的**:将 AM516 交期预测输出的自然日转换为工作日,并据此得到最终交货日期。
**当前临时处理**:因 AR836 排期较晚,AM516 飞书机器人先在 API 返回后的输出层执行同一换算;不修改 AR836 API 原始数据。待 API 正式提供工作日口径后,应移除本地临时换算,避免重复转换。
**2026-09-20 实现更新**:API 已返回 `AM516工作日交期` 和 `AM516最终交货日期`。本仓库机器人回复已改为直接使用这两个字段,移除本地临时换算及日期推算;运行端需同步本次改动后生效。下文保留为原始需求与验证记录。
## 一、需求背景

View File

@@ -40,17 +40,18 @@ Expected:
- record-table columns follow this order: 序号、记录时间、型号、推荐类型、差异项、API状态、AM516预测交期、可用库存、主导因素;
- unavailable candidates remain in their original rule order and are recorded as `❌ 不存在` with unavailable result fields shown as `—`;
## Sample 1B | Natural Days To Workdays
## Sample 1B | API Workdays And Final Delivery Date
Rules and expected results:
- treat `AM516总交期`, or numeric `总交期` when the AM516 field is absent, as the original natural-day lead time `N`;
- convert `N` with the approved quotient-and-remainder rule, including `r = 4` as one rest day and `r = 0` as no remainder workday;
- exclude the local query date itself, then count the converted workdays using the configured China statutory workday calendar;
- statutory holidays are excluded and official makeup weekend workdays are included;
- for a query date of `2026-09-02`, `31` natural days convert to `22` workdays and produce `2026-10-09`;
- output `2026-10-09(原始31个自然日,折算22个工作日)` instead of adding a separate National Day exception;
- when counting reaches an unconfigured calendar year, do not silently fall back to a Monday-Friday estimate.
- read `data.交期汇总.AM516工作日交期` and `data.交期汇总.AM516最终交货日期` directly;
- when the API returns `8` and `2026-10-08`, output `AM516预测交期:8个工作日,最终交货日期:2026-10-08`;
- use the same workdays-and-date form in the fastest-candidate summary, initial and continuation candidate details, and newly appended record rows;
- ignore natural-day totals and the old `AM516预测交期` field when selecting the displayed result; do not recalculate workdays or dates locally;
- a valid API date in another calendar year remains usable without a local holiday calendar;
- accept zero workdays; reject negative, fractional, boolean, or non-numeric workday values and invalid dates;
- if either new field is missing or invalid, report the lead-time result as unavailable instead of falling back to old fields or estimating;
- choose the fastest candidate using the API workday count, even when the natural-day totals would rank candidates differently.
## Sample 1A | Continue With Other Candidates

View File

@@ -10,8 +10,8 @@
6. Use model recommendation rules to generate the complete ordered internal candidate pool.
7. Immediately add the Feishu `OnIt` (typing) reaction to the original message to acknowledge the valid request.
8. Run the controlled script for the original model baseline and only the first four candidate models.
9. Convert each numeric natural-day lead time to workdays with the approved quotient-and-remainder rule, then count those workdays from the local query date through the configured China statutory workday calendar. The query date itself is excluded.
10. Summarize the current batch, including the original natural days, converted workdays, and calculated delivery date; state how many candidates remain and invite the same sender to ask naturally for more when candidates remain.
9. Read `data.交期汇总.AM516工作日交期` and `data.交期汇总.AM516最终交货日期` directly. Require a nonnegative whole-number workday count and a valid `YYYY-MM-DD` date; missing or invalid fields make the result unavailable. Do not convert natural days or recalculate dates locally.
10. Summarize the current batch with the API workdays and final delivery date, for example `AM516预测交期:8个工作日,最终交货日期:2026-10-08`; state how many candidates remain and invite the same sender to ask naturally for more when candidates remain. Newly appended records use the same form; historical records are unchanged.
11. Append a non-secret record.
12. Return Feishu-friendly text with the fixed disclaimer.