feat&refactor: 2026-09-22 半成品业务模型重构与功能完善
- 重构半成品流转逻辑:进度权威源改为 workpiece.currentStationNo,新增 completedText 快照字段,废除 doneProcessCodes - 清理物料品类中半成品类型,存量数据幂等清理,调整物料管理方式文案为批次/序列号 - 新增日排产状态专用更新接口,修复工单工艺校验逻辑 - 新增物料档案代理接口、深路径文件下载接口 - 优化前端界面文案与工位选择逻辑,补充追溯页半成品流转展示 - 调整WMS端物料品类校验与入库接口契约 - 新增/更新数据库表结构与实体类代码
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package wmsclient
|
||||
package wmsclient
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -31,20 +31,56 @@ func New(baseURL, token string) *Client {
|
||||
}
|
||||
}
|
||||
|
||||
// SemiInbound 调 WMS /api/internal/semi/inbound 半成品入库
|
||||
func (c *Client) SemiInbound(ctx context.Context, sn, orderNo string, doneProcessCodes []int, operator string) error {
|
||||
return c.post(ctx, "/api/internal/semi/inbound", map[string]any{
|
||||
"sn": sn, "orderNo": orderNo, "doneProcessCodes": doneProcessCodes, "operator": operator,
|
||||
// SemiInbound 调 WMS /api/internal/semi/inbound 半成品入库。
|
||||
// 统一契约:payload={sn,orderNo,completedText,operator},completedText 由 MES 生成
|
||||
// ("已完成至工位N",N=workpiece.currentStationNo;0/无记录传空串),旧 doneProcessCodes 已废除。
|
||||
func (c *Client) SemiInbound(ctx context.Context, sn, orderNo, completedText, operator string) error {
|
||||
return c.postSemi(ctx, "/api/internal/semi/inbound", map[string]any{
|
||||
"sn": sn, "orderNo": orderNo, "completedText": completedText, "operator": operator,
|
||||
})
|
||||
}
|
||||
|
||||
// SemiOutbound 调 WMS /api/internal/semi/outbound 半成品出库(重上线)
|
||||
func (c *Client) SemiOutbound(ctx context.Context, sn, orderNo string, doneProcessCodes []int, operator string) error {
|
||||
return c.post(ctx, "/api/internal/semi/outbound", map[string]any{
|
||||
"sn": sn, "orderNo": orderNo, "doneProcessCodes": doneProcessCodes, "operator": operator,
|
||||
// SemiOutbound 调 WMS /api/internal/semi/outbound 半成品出库(重上线),契约同 SemiInbound。
|
||||
func (c *Client) SemiOutbound(ctx context.Context, sn, orderNo, completedText, operator string) error {
|
||||
return c.postSemi(ctx, "/api/internal/semi/outbound", map[string]any{
|
||||
"sn": sn, "orderNo": orderNo, "completedText": completedText, "operator": operator,
|
||||
})
|
||||
}
|
||||
|
||||
// postSemi 调 WMS 半成品接口并解析业务响应 {code,message}:
|
||||
// 网络/超时、非2xx、业务码非0 均返回 error,且优先携带 WMS 原文 message,
|
||||
// 供上线登记重上线路径直接透出(WMS 出库失败必须阻断并让操作工看到原因)。
|
||||
func (c *Client) postSemi(ctx context.Context, path string, body any) error {
|
||||
b, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+path, bytes.NewReader(b))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("X-API-TOKEN", c.token)
|
||||
resp, err := c.hc.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
raw, _ := io.ReadAll(resp.Body)
|
||||
var br struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
_ = json.Unmarshal(raw, &br)
|
||||
if resp.StatusCode >= 300 || br.Code != 0 {
|
||||
if br.Message != "" {
|
||||
return errors.New(br.Message)
|
||||
}
|
||||
return &RespError{Status: resp.StatusCode}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FinishedInbound 成品完工回流入库:调 WMS /api/internal/finished/inbound。
|
||||
// 成品 SN 由 MES 系统生成(工件SN),统一库存主表 category=3;失败返回 err 由调用方降级。
|
||||
func (c *Client) FinishedInbound(ctx context.Context, productCode, productName, sn, orderNo, operator string) error {
|
||||
|
||||
Reference in New Issue
Block a user