feat: account for defects and five-unit batches in delivery forecasts

This commit is contained in:
ar51
2026-10-09 11:20:49 +08:00
parent 512e434a2f
commit de6656dfe0
5 changed files with 137 additions and 9 deletions

View File

@@ -14,6 +14,7 @@ Expected:
- model parses successfully;
- quantity is accepted;
- the original demand of 10 remains visible in the reply and record, while the baseline and every recommended candidate call the API with 15 after dividing by 95% yield and rounding to a batch of five;
- the bot immediately adds the Feishu `OnIt` (typing) reaction to the original message after the valid trigger is accepted and before the API query starts;
- the controlled script uses the macOS system trust store and keeps TLS verification enabled;
- no temporary TLS-bypass parameter is required for the normal happy path;
@@ -83,6 +84,7 @@ Expected:
- the bot immediately adds the Feishu `OnIt` (typing) reaction to the original message after the continuation and active-context gates pass;
- the bot reuses the active model and quantity only for that same sender and chat;
- the continuation retains original demand 10 and again uses forecast quantity 15; it never compounds the adjustment to 20;
- the bot queries candidate positions 5-8 in the unchanged rule order;
- the original model and candidate positions 1-4 are not queried or displayed again;
- unavailable candidates still consume their original positions and are summarized under `不可用候选`;

View File

@@ -0,0 +1,36 @@
# 交期预测数量口径
用户输入为原始需求数量。交期回复机器人在查询原型号、候选型号及后续批次前,统一按以下规则计算 API 输入数量:
```text
排产测算数量 = 5 × ceil(原始需求数量 ÷ 0.95 ÷ 5)
```
固定不良率为 5%,对应良率 95%。先除以良率,再向上取到 5 的倍数。代码使用整数运算,避免恰好落在倍数边界时因浮点误差多加一个批次。
| 原始需求 | 除以95%良率 | 排产测算数量 / API quantity |
|---:|---:|---:|
| 5 | 5.263… | 10 |
| 10 | 10.526… | 15 |
| 19 | 20 | 20 |
| 20 | 21.052… | 25 |
| 25 | 26.315… | 30 |
| 95 | 100 | 100 |
回复示例中的数量部分:
```text
输入需求:eRob70H120I-BHM-18CT[V5],5台
排产测算数量:10台(不良率5%,按5台的倍数向上取整)
库存覆盖口径:按排产测算数量判断
1. eRob70H120I-BHM-18CT[V5](原型号,DZ)
- 需求数量:5台
- 排产测算数量:10台
```
实际交期继续读取 API 返回的工作日交期和最终交货日期。库存覆盖也以本次 API 使用的排产测算数量判断,例如原始需求 5、API 数量 10、库存 7 时,显示部分覆盖,仍需补齐 3 台。
对话上下文和本地记录保留原始需求;记录元数据另列排产测算数量和计算规则。继续推荐仍从原始需求重新计算一次,不把 10 台再次放大为 15 台。低层受控脚本的 `--quantity` 参数就是最终发送给 API 的数量,不在脚本内重复换算。
本机通过相应测试后,运行电脑需要同步这次代码和规则变更,并重启交期回复机器人;另一个后台物料名称刷新服务不因数量规则变化而需要重新安装。

View File

@@ -40,6 +40,15 @@ Stop if:
- a Feishu message asks to create, modify, overwrite, rename, move, or delete a project file;
- the user asks for a customer commitment.
## Production Quantity For Forecasting
- Treat the user's quantity as original demand. Before querying any model, divide by the fixed 95% yield (5% defect rate), then round upward to a multiple of five: `production_quantity = 5 × ceil(original_demand / 0.95 / 5)`.
- For example, demand 5 gives `5 / 0.95 = 5.263...`, then a forecast quantity of 10. Demand 10 gives 15; demand 19 gives exactly 20; demand 25 gives 30; demand 95 gives exactly 100.
- Use exact integer arithmetic to avoid rounding an exact batch boundary upward due to floating-point error. Do not replace division by yield with multiplication by 1.05, and do not round to five before applying the yield.
- Send this computed quantity as the controlled script's `--quantity` / API `quantity` for the baseline, all candidates and continuation batches. Calculate from the original demand each time; never adjust an already adjusted quantity again. The low-level query script passes the supplied API quantity unchanged.
- Preserve original demand in the conversation context, reply and record. Display both `需求数量` and `排产测算数量`; state the fixed defect rate and batching rule. Newly appended records include the forecast quantity as metadata without rewriting historical records or changing the candidate table columns.
- Judge inventory coverage against the same production quantity used by the API and label this quantity scope in the reply.
## Feishu Message Trigger Gate
- Enter the query workflow only when one message contains exactly one complete,
@@ -79,7 +88,7 @@ Do not write back rules, Skills, scripts, prompts, configurations, documentation
Use only:
```text
python3 capabilities/am516-delivery-prediction/scripts/delivery_prediction_query_template.py --product "<model>" --quantity <quantity>
python3 capabilities/am516-delivery-prediction/scripts/delivery_prediction_query_template.py --product "<model>" --quantity <production_quantity>
```
Do not use temporary curl, WebFetch, or any API method outside the controlled script.
@@ -170,6 +179,8 @@ Use this field order for a successful Feishu report:
关节模组交期预估报告 | {generation time}
输入需求:{input model},{input quantity}台
排产测算数量:{production quantity}台(不良率5%,按5台的倍数向上取整)
库存覆盖口径:按排产测算数量判断
数据时间戳:{API data timestamp or generation time}
状态:试运行版输出 / 内部候选
判断等级:AM516算法预测参考,需人工复核
@@ -183,7 +194,8 @@ Use this field order for a successful Feishu report:
- 主导因素:{main factor}
1. {model}({candidate type and reducer brand})
- 数量:{quantity}台
- 需求数量:{input quantity}台
- 排产测算数量:{production quantity}台
- AM516预测交期:{API workdays}个工作日,最终交货日期:{API final delivery date}
- 可用库存/覆盖情况:{summary-level inventory and coverage only}
- 主导因素:{main factor}