feat: 完成产线与仓储系统多模块迭代升级
本次迭代覆盖MES与WMS核心业务: 1. 新增接驳台托盘传感器读取与AGV对接能力 2. 完善工单排产、备料流程与权限体系拆分 3. 优化看板接口与前端路由、样式 4. 新增操作日志、库存盘点与角色保护逻辑 5. 修复代理地址、BOM保存等已知问题
This commit is contained in:
@@ -40,6 +40,69 @@ func (c *Client) SemiOutbound(ctx context.Context, sn, orderNo string, doneProce
|
||||
})
|
||||
}
|
||||
|
||||
// MaterialExists 批量校验物料编码是否存在于 WMS 物料档案。
|
||||
// 返回 WMS 中不存在的编码列表(全部存在则为空)。WMS 响应 {code,message,data:{missing:[]}}。
|
||||
// 失败(网络/超时/非0响应)返回 err,由调用方决定降级策略。
|
||||
func (c *Client) MaterialExists(ctx context.Context, codes []string) ([]string, error) {
|
||||
b, err := json.Marshal(map[string]any{"codes": codes})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/internal/material/exists", bytes.NewReader(b))
|
||||
if err != nil {
|
||||
return nil, 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 nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var body struct {
|
||||
Code int `json:"code"`
|
||||
Data struct {
|
||||
Missing []string `json:"missing"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode >= 300 || body.Code != 0 {
|
||||
return nil, &RespError{Status: resp.StatusCode}
|
||||
}
|
||||
return body.Data.Missing, nil
|
||||
}
|
||||
|
||||
// DisplayOverview 拉取 WMS 免登录看板总览 /api/display/overview。
|
||||
// 用于看板「仓储动态」屏。WMS 不可达时返回 err,由调用方降级为空对象(看板其余屏不受影响)。
|
||||
func (c *Client) DisplayOverview(ctx context.Context) (map[string]any, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+"/api/display/overview", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("X-API-TOKEN", c.token)
|
||||
resp, err := c.hc.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode >= 300 {
|
||||
return nil, &RespError{Status: resp.StatusCode}
|
||||
}
|
||||
var body struct {
|
||||
Code int `json:"code"`
|
||||
Data map[string]any `json:"data"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if body.Data == nil {
|
||||
return map[string]any{}, nil
|
||||
}
|
||||
return body.Data, nil
|
||||
}
|
||||
|
||||
func (c *Client) post(ctx context.Context, path string, body any) error {
|
||||
b, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user