feat: 核心业务实体扩充(混产模板/产品BOM/试制记录)、WMS 库存检验增强与前端通用能力
- MES 新增实体:混产模板、产品BOM、产品工艺物料、试制记录(schema + ent 生成码 + logic/handler/前端页) - WMS 实体增强:检验记录、库存、半成品重构;新增序列号库存与短缺代报 - AGV 与产能:AGV 手动点位与链路、物料守卫、短缺预测、原因字典 - 前端通用能力:新增下一步引导组件 NextStepBar,统一帮助文档/布局/请求拦截与操作列 - 工位终端:界面与各 handler 调整(api/store/绑定/PLC/拧紧/上报等) - 配置与文档:更新 mes-api.yaml、WMS README 及案例/产线API/问题记录/项目说明/流程说明
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"bj_power_wms/ent/inventory"
|
||||
"bj_power_wms/internal/svc"
|
||||
)
|
||||
|
||||
// inventorySnExistsInternalHandler 按成品序列号精确核验 WMS 库存(X-API-TOKEN 内部接口,只读)。
|
||||
// GET /api/internal/inventory/sn-exists?sn=
|
||||
// MES「成品试验」登记前调用:成品 SN 必须对应一条仍有效在库的库存行。
|
||||
// 判定口径:sn_code 精确相等 + 数量>0(inventories 无软删字段,不臆造删除标记,
|
||||
// 与库存聚合查询 /api/internal/material/query 的 QuantityGT(0) 口径一致)。
|
||||
// 命中返回 found=true 并带出 materialCode/qty;未命中返回 found=false,不写任何表。
|
||||
func inventorySnExistsInternalHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
sn := strings.TrimSpace(r.URL.Query().Get("sn"))
|
||||
if sn == "" {
|
||||
fail(w, http.StatusBadRequest, "成品序列号不能为空")
|
||||
return
|
||||
}
|
||||
rows, err := ctx.EntClient.Inventory.Query().
|
||||
Where(inventory.SnCodeEQ(sn), inventory.QuantityGT(0)).
|
||||
Limit(1).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询成品库存失败,请稍后重试")
|
||||
return
|
||||
}
|
||||
if len(rows) == 0 {
|
||||
ok(w, map[string]any{"found": false, "sn": sn})
|
||||
return
|
||||
}
|
||||
ok(w, map[string]any{
|
||||
"found": true,
|
||||
"sn": sn,
|
||||
"materialCode": rows[0].MaterialCode,
|
||||
"qty": rows[0].Quantity,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user