fix: use API workdays and final delivery date in bot replies
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
**日期**:2026-09-02
|
||||
**目的**:将 AM516 交期预测输出的自然日转换为工作日,并据此得到最终交货日期。
|
||||
|
||||
**当前临时处理**:因 AR836 排期较晚,AM516 飞书机器人先在 API 返回后的输出层执行同一换算;不修改 AR836 API 原始数据。待 API 正式提供工作日口径后,应移除本地临时换算,避免重复转换。
|
||||
**2026-09-20 实现更新**:API 已返回 `AM516工作日交期` 和 `AM516最终交货日期`。本仓库机器人回复已改为直接使用这两个字段,移除本地临时换算及日期推算;运行端需同步本次改动后生效。下文保留为原始需求与验证记录。
|
||||
|
||||
## 一、需求背景
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -93,12 +93,10 @@ Do not use temporary curl, WebFetch, or any API method outside the controlled sc
|
||||
|
||||
## Output Selection
|
||||
|
||||
- Prefer numeric `data.交期汇总.AM516总交期`; if it is absent, fall back to numeric `data.交期汇总.总交期`. Treat this value as the original natural-day lead time `N`.
|
||||
- Convert `N` with `(q, r) = divmod(N, 7)`: `r = 0` gives `q × 5`; `1 ≤ r ≤ 4` gives `q × 5 + MAX(r - 1, 0)`; `5 ≤ r ≤ 6` gives `q × 5 + r - 2`. The result is workday lead time `W`.
|
||||
- Starting from the local query date, exclude the query date itself and count forward `W` workdays using the configured China statutory calendar. Statutory holidays are not workdays, ordinary Saturdays and Sundays are not workdays, and official makeup Saturdays or Sundays are workdays.
|
||||
- The configured 2026 calendar follows `国办发明电〔2025〕7号`. If counting reaches a year whose official calendar is not configured, do not silently estimate a delivery date; mark that calendar year as pending.
|
||||
- Display the calculated delivery date together with both `N` and `W`, for example `2026-10-09(原始31个自然日,折算22个工作日)`.
|
||||
- Use `data.交期汇总.AM516预测交期` only as a fallback when the API does not return a usable whole-number natural-day lead time, and explicitly mark that no conversion was performed.
|
||||
- Read the workday count directly from `data.交期汇总.AM516工作日交期` and the corresponding final delivery date from `data.交期汇总.AM516最终交货日期`.
|
||||
- Require a nonnegative whole-number workday count (including zero) and a valid `YYYY-MM-DD` date. Both must be returned by the API; missing or invalid values make the lead-time result unavailable.
|
||||
- Display `8个工作日,最终交货日期:2026-10-08` consistently in the overall judgment, candidate details, and newly appended records. Rank the fastest candidate by the API workday count.
|
||||
- Do not convert natural days, recalculate dates from the local query date, or fall back to the old `AM516预测交期` field. `AM516总交期` and `总交期` remain natural-day reference fields and are not shown in the reply.
|
||||
|
||||
## Candidate Batch Rule
|
||||
|
||||
@@ -163,13 +161,13 @@ Use this field order for a successful Feishu report:
|
||||
总体判断:
|
||||
- 现货候选:{fully covered candidate or none}
|
||||
- 最快候选型号:{fastest candidate}
|
||||
- 最快候选交期:{calculated delivery date, original natural days, and converted workdays}
|
||||
- 最快候选交期:{API workdays}个工作日,最终交货日期:{API final delivery date}
|
||||
- 是否完全覆盖数量:{yes / no / unavailable}
|
||||
- 主导因素:{main factor}
|
||||
|
||||
1. {model}({candidate type and reducer brand})
|
||||
- 数量:{quantity}台
|
||||
- AM516预测交期:{calculated delivery date}(原始{N}个自然日,折算{W}个工作日)
|
||||
- AM516预测交期:{API workdays}个工作日,最终交货日期:{API final delivery date}
|
||||
- 可用库存/覆盖情况:{summary-level inventory and coverage only}
|
||||
- 主导因素:{main factor}
|
||||
- 推荐理由:{rule-based recommendation reason}
|
||||
|
||||
Reference in New Issue
Block a user