fix: pass original demand to delivery prediction API
This commit is contained in:
@@ -14,7 +14,7 @@ Expected:
|
||||
|
||||
- model parses successfully;
|
||||
- quantity is accepted;
|
||||
- original demand 10 remains visible; read each model's own stock first, then deduct it before applying 95% yield and rounding to five. With zero stock production is 15; stock of at least 10 gives zero production and retains the first stock-delivery result;
|
||||
- original demand 10 remains visible and each model is queried exactly once with quantity 10; stock accounting is handled by the API, with no local inventory deduction, yield adjustment or batch rounding;
|
||||
- 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;
|
||||
@@ -269,12 +269,11 @@ Expected:
|
||||
以上为内部候选方案,不构成客户正式交期承诺;需 AR516 或授权责任人结合库存、生产、采购、客户优先级和最新系统数据人工复核后使用。
|
||||
```
|
||||
|
||||
## Stock-First Production Quantity Acceptance
|
||||
## Original-Demand API Quantity Acceptance
|
||||
|
||||
- D=24, S=6: query D=24 to read stock, calculate net demand 18 and production 20, query with 20. Display shortage gap 18 and use the final API workdays/date and shortage details.
|
||||
- D=24, S=0: production 30; D=25, S=6: net demand 19 and production exactly 20.
|
||||
- D=24, S>=24: production 0, retain original-query stock-delivery result, no quantity=0 request. D=5, S=1: production 5, so reuse the first query.
|
||||
- Different candidates use different stock and production quantities; initial and continuation batches retain original demand and never compound yield allowance.
|
||||
- Missing/invalid stock is unavailable, never zero; changed stock between the two queries invalidates that model's result without an automatic retry.
|
||||
- D=24, S=20: calculate net demand 4, production 5, but report delivery unavailable because the current API would take the stock shortcut with quantity=5; never claim full coverage or invent a date.
|
||||
- New record metadata preserves each model's net/production/API quantities without changing existing table columns or historical records.
|
||||
- Regression: `eRob70F50I-FHM-18ET[V4] 12台`, with API stock 10. Send quantity 12 once per model; show stock partly covering demand with a gap of 2. Preserve the API workdays/date and shortages. Do not show the old false-stock-branch error or calculate production 5 locally.
|
||||
- D=8/S=5: send 8; D=24/S=6: send 24; D=24/S=0: send 24; D=24/S>=24: still send 24 once and preserve the API response.
|
||||
- Different candidates display their own stock, but all use unchanged original demand. Initial and continuation batches query each current-batch model once.
|
||||
- Missing/invalid stock is unknown, never zero; valid API workdays/date remain usable with an explicit inventory-review item. Missing/invalid workdays/date or failed requests retain existing error handling.
|
||||
- New report and record metadata contain actual API quantities, with no local net-demand or production-quantity fields. Historical records and existing candidate-table columns remain unchanged.
|
||||
- These checks use mocked responses locally. Runtime acceptance must verify actual API arguments and compare the displayed workdays/date with the same returned response; mocked dates do not constitute delivery predictions.
|
||||
|
||||
@@ -1,57 +1,43 @@
|
||||
# 交期预测数量规则
|
||||
# 交期预测数量传递规则
|
||||
|
||||
可用成品库存已视为100%可用,只对需要新生产的缺口考虑合格率。
|
||||
## 计算责任
|
||||
|
||||
AR51 于 2026-10-15 检查上游 API 的交期预测逻辑后确认:接口已核算可用库存;并明确取消机器人本地的扣库存、95% 合格率折算和向上取 5 台倍数规则。此确认是本次修正依据,不代表已经实时验证服务端或运行电脑。
|
||||
|
||||
```text
|
||||
D = 原始需求数量
|
||||
S = 该型号可用库存(API字段:可用库存(扣除了待产数量))
|
||||
净需求 = max(D - max(S, 0), 0)
|
||||
最终排产测算数量 P = 5 × ceil(净需求 ÷ 0.95 ÷ 5)
|
||||
D = 用户原始需求数量(正整数)
|
||||
API quantity = D
|
||||
```
|
||||
|
||||
净需求为0时,P为0;固定不良率5%,对应合格率95%。先扣库存,再除以合格率,最后向上取5的倍数。使用整数运算,避免边界浮点误差。库存缺失或不是有效整数时不能视作0;负整数余额按无可用库存参与计算。
|
||||
每个型号只通过受控脚本查询一次,原型号和各候选型号都传原始需求 D。机器人保留型号推荐、结果整理和记录能力;库存扣减及交期测算由上游 API 处理。
|
||||
|
||||
| 原始需求 | 可用库存 | 净需求 | 排产测算数量 |
|
||||
|---:|---:|---:|---:|
|
||||
| 24 | 6 | 18 | 20 |
|
||||
| 24 | 0 | 24 | 30 |
|
||||
| 24 | 24 | 0 | 0 |
|
||||
| 24 | 30 | 0 | 0 |
|
||||
| 25 | 6 | 19 | 20 |
|
||||
| 5 | 1 | 4 | 5 |
|
||||
| 95 | 0 | 95 | 100 |
|
||||
## 示例与输出
|
||||
|
||||
每个候选使用自己的库存,不累计多个候选的库存。续批保留原始需求,对新候选重新读取库存及计算,不对已折算数量重复折算。
|
||||
| 原始需求 | API 返回可用库存 | API 查询数量 | 库存展示 |
|
||||
|---:|---:|---:|---|
|
||||
| 12 | 10 | 12 | 部分覆盖,仍需补齐 2 台 |
|
||||
| 8 | 5 | 8 | 部分覆盖,仍需补齐 3 台 |
|
||||
| 24 | 0 | 24 | 需生产/采购 |
|
||||
| 24 | 24 | 24 | 完全覆盖 |
|
||||
| 24 | 30 | 24 | 完全覆盖 |
|
||||
|
||||
报告示例(需求24,可用库存6):
|
||||
库存覆盖按原始需求与该型号 API 返回的库存比较,仅用于展示。展示差额不回传 API,不作为机器人计算的排产数量。每个候选展示自己的库存,不能沿用原型号或其他候选的库存。
|
||||
|
||||
```text
|
||||
需求数量:24台
|
||||
扣库存后净需求:18台
|
||||
排产测算数量:20台
|
||||
可用库存/覆盖情况:整机可用库存6台(部分覆盖,仍需补齐18台)
|
||||
```
|
||||
库存缺失或无效时显示待复核,不视作 0;如果 API 已返回有效工作日交期和最终交货日期,机器人保留该交期并标明库存覆盖无法判断。缺失有效交期字段或请求失败时继续执行原有异常处理。
|
||||
|
||||
库存覆盖始终比较原始需求,不能比较排产量。各型号排产量可能不同,报告顶部显示计算规则,各型号明细及新记录元数据分别显示数量;历史记录不改写,候选表列不改变。
|
||||
报告展示需求数量、API 查询数量、API 返回交期和库存覆盖情况,不再输出本地净需求或排产测算数量。新记录保存原始需求及每个型号实际 API 查询数量,历史记录不改写。
|
||||
|
||||
## 受控API查询
|
||||
## 已取消的旧逻辑
|
||||
|
||||
1. 先以D调用受控脚本,读取该型号库存。
|
||||
2. 库存足量:P=0,沿用第一次查询的现货交期;不发送quantity=0。
|
||||
3. 库存不足且P=D:第一次查询已符合排产数量,不重复查询。
|
||||
4. 库存不足且P与D不同:以P调用同一受控脚本,交期、缺料明细及主导因素取第二次响应。两次库存必须一致,否则结果不可用,需要重新查询。
|
||||
5. 第一响应无有效库存或必需工作日/日期字段时,结果不可用。
|
||||
|
||||
低层脚本仍原样传递quantity。日期与工作日仍直接使用API返回值,不在本地推算。
|
||||
|
||||
## 现有接口限制
|
||||
|
||||
现有WithTransit交接口径中,quantity同时参与成品现货判断和本次生产/BOM数量测算。若 `0 < P <= S < D`,传P会误判现货。例如D=24、S=20,净需求4、P=5,但20台库存不能覆盖24台需求。此时本地能计算正确排产量,却不能从现有单数量参数获得可靠生产交期;明确报交期不可用,原型号停止出具报告,候选列入不可用清单。需要AR836接口支持分别输入原需求和排产量后解除该限制。
|
||||
|
||||
不能改传S+P:这会使API按包含库存的数量测算物料和生产。也不能使用第一次D查询的交期充当P的交期。该限制依据既有接口交接说明,尚未完成当前服务端的实时验证;本次本机测试使用模拟响应。
|
||||
- 不再先读取库存、在本地扣减后发起第二次生产数量查询。
|
||||
- 不再按 95% 合格率放大需求或取 5 台倍数。
|
||||
- 不再根据“库存不足原需求、但足以覆盖本地排产量”拦截结果。
|
||||
- 不再要求接口为这个本地拦截增加“原始需求、排产数量”双参数。
|
||||
|
||||
## 运行电脑同步验收
|
||||
|
||||
运行电脑须拉取包含桥接代码、项目内Skill、测试及说明的完整版本并重启交期回复机器人。无需新增依赖、配置或重装物料名称刷新服务。
|
||||
运行电脑须拉取包含桥接代码、项目内 Skill、测试及说明的完整版本并重启交期回复机器人。本次无需新增依赖或配置。
|
||||
|
||||
执行 `python3 -m unittest discover -s tests -q`,并在既有API审批及功能测试授权范围内检查需求24/库存6、库存完全覆盖、不同候选库存、续批,以及部分库存误走现货分支样例。核对数量、实际API参数、库存变化处理与API最终日期。推送成功不代表运行电脑已生效。
|
||||
先执行 `python3 -m unittest discover -s tests -q`。随后在既有 API 审批及功能测试授权范围内验证 `eRob70F50I-FHM-18ET[V4] 12台`,核对实际发送的 quantity 为 12,机器人显示的工作日、最终日期及缺料摘要与同一 API 响应一致。API 库存以验证时实时返回值为准,不能假定仍为 10 台。
|
||||
|
||||
分别报告本机验证、远端同步和运行电脑验证;本地模拟测试通过不代表服务端或运行电脑已验证,推送成功不代表运行端已生效。
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
5. If that domain-and-permission record is absent, stop before any outbound request; a general functional-test approval is insufficient by itself.
|
||||
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. For the baseline and first four candidate models, follow [stock-first quantity rules](production_quantity.md): read each model's own stock with original demand, deduct it, then divide the net gap by 95% yield and round up to five. Query production quantity when required; do not send zero, mix changed stock snapshots or accept a false stock shortcut.
|
||||
8. For the baseline and first four candidate models, follow [original-demand quantity rules](production_quantity.md): call the controlled script once per model with the unchanged original demand. The upstream API accounts for stock. Do not deduct stock, apply local yield/batch adjustments, or query again with a local production quantity. Display each model's API inventory coverage against original demand only.
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user