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:
@@ -15,7 +15,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Client WMS 内部接口客户端(半成品流转等)
|
||||
// Client WMS 内部接口客户端(在制品流转等)
|
||||
// baseURL 支持运行时热切换(系统管理员「基础设置」页保存 WMS 地址后 SetBaseURL 即生效),
|
||||
// 因此用 atomic.Value 存储,读侧无需加锁。
|
||||
type Client struct {
|
||||
@@ -58,8 +58,23 @@ func (c *Client) Ping(ctx context.Context) error {
|
||||
return c.get(ctx, "/api/internal/material/query", nil)
|
||||
}
|
||||
|
||||
// SemiPayload MES→WMS 半成品入库/出库载荷。
|
||||
// 归属三字段(2026-09-30):半成品归属自动继承其产品工号的工单归属——
|
||||
// FinishedSnExists 核验成品序列号是否已在 WMS 成品库入库(MES「成品试验」登记前校验)。
|
||||
// GET /api/internal/inventory/sn-exists?sn= → 复用 c.get 解析 WMS 统一 {code,data} 响应取 found。
|
||||
// found=false 表示未入库;网络异常或业务码非 0 返回中文业务错误,由调用方拒绝登记(不放行)。
|
||||
func (c *Client) FinishedSnExists(ctx context.Context, sn string) (bool, error) {
|
||||
q := url.Values{}
|
||||
q.Set("sn", sn)
|
||||
var out struct {
|
||||
Found bool `json:"found"`
|
||||
}
|
||||
if err := c.get(ctx, "/api/internal/inventory/sn-exists?"+q.Encode(), &out); err != nil {
|
||||
return false, errors.New("WMS 库房不可达,无法核验成品序列号")
|
||||
}
|
||||
return out.Found, nil
|
||||
}
|
||||
|
||||
// SemiPayload MES→WMS 在制品入库/出库载荷。
|
||||
// 归属三字段(2026-09-30):在制品归属自动继承其产品工号的工单归属——
|
||||
// ownershipType/ownershipNo 取自工单归属(workorder=合同号/project=科技项目号/other=其他),
|
||||
// productWorkNo=产品工号(即工单号),均由 MES 从工单带出后传入,不做人工手选。
|
||||
type SemiPayload struct {
|
||||
@@ -70,9 +85,12 @@ type SemiPayload struct {
|
||||
OwnershipType string // 归属类型:workorder=合同号/project=科技项目号/other=其他
|
||||
OwnershipNo string // 归属编号(合同号或科技项目号)
|
||||
ProductWorkNo string // 产品工号(=所属工单号)
|
||||
// 2026-11-13 修复:WMS /api/internal/semi/outbound 要求 reason 必填,
|
||||
// 原 MES 载荷不含该字段 → 重上线必然 400,在制品(在制品)流转链跑不通。
|
||||
Reason string // 出库原因(重上线场景由 MES 固定填「重上线继续剩余工序」)
|
||||
}
|
||||
|
||||
// SemiInbound 调 WMS /api/internal/semi/inbound 半成品入库。
|
||||
// SemiInbound 调 WMS /api/internal/semi/inbound 在制品入库。
|
||||
// 统一契约:payload={sn,orderNo,completedText,operator,ownershipType,ownershipNo,productWorkNo},
|
||||
// completedText 由 MES 生成("已完成至工位N",N=workpiece.currentStationNo;0/无记录传空串),
|
||||
// 旧 doneProcessCodes 已废除。
|
||||
@@ -83,15 +101,21 @@ func (c *Client) SemiInbound(ctx context.Context, p SemiPayload) error {
|
||||
})
|
||||
}
|
||||
|
||||
// SemiOutbound 调 WMS /api/internal/semi/outbound 半成品出库(重上线),契约同 SemiInbound。
|
||||
// SemiOutbound 调 WMS /api/internal/semi/outbound 在制品出库(重上线)。
|
||||
// WMS 侧 reason 为必填(misc.go 校验),MES 必须带上,否则重上线必然 400。
|
||||
func (c *Client) SemiOutbound(ctx context.Context, p SemiPayload) error {
|
||||
reason := p.Reason
|
||||
if reason == "" {
|
||||
reason = "重上线继续剩余工序"
|
||||
}
|
||||
return c.postSemi(ctx, "/api/internal/semi/outbound", map[string]any{
|
||||
"sn": p.Sn, "orderNo": p.OrderNo, "completedText": p.CompletedText, "operator": p.Operator,
|
||||
"ownershipType": p.OwnershipType, "ownershipNo": p.OwnershipNo, "productWorkNo": p.ProductWorkNo,
|
||||
"reason": reason,
|
||||
})
|
||||
}
|
||||
|
||||
// postSemi 调 WMS 半成品接口并解析业务响应 {code,message}:
|
||||
// postSemi 调 WMS 在制品接口并解析业务响应 {code,message}:
|
||||
// 网络/超时、非2xx、业务码非0 均返回 error,且优先携带 WMS 原文 message,
|
||||
// 供上线登记重上线路径直接透出(WMS 出库失败必须阻断并让操作工看到原因)。
|
||||
func (c *Client) postSemi(ctx context.Context, path string, body any) error {
|
||||
@@ -174,7 +198,7 @@ func (c *Client) DisposeInventory(ctx context.Context, req DisposeInventoryReq)
|
||||
}
|
||||
|
||||
// FinishedPayload MES→WMS 成品回流入库载荷(完工检合格触发,调 /api/internal/finished/inbound)。
|
||||
// 归属三字段照 semi.go 半成品归属继承模式取自工单:ownershipType/ownershipNo 取工单归属,
|
||||
// 归属三字段照 semi.go 在制品归属继承模式取自工单:ownershipType/ownershipNo 取工单归属,
|
||||
// productWorkNo=产品工号(即工单号),由 MES 自动带出,不做人工手选。
|
||||
// productStatus=完工检结论(已通过/部分通过,WMS 侧映射 qualityStatus 合格);
|
||||
// relatedStandard=相关标准、testRecordNo=试验记录单号(MES 完工检记录暂无专用字段时传空)。
|
||||
|
||||
Reference in New Issue
Block a user