feat: 新增预警定时扫描器,移除附件归档字段并为角色表补充更新时间
This commit is contained in:
@@ -486,49 +486,8 @@ type ProducibleDemand struct {
|
||||
Future5Qty int `json:"future5Qty"`
|
||||
}
|
||||
|
||||
// MaterialTypes 批量查询物料在 WMS 的物料类别(1原材料/2半成品/3成品/4其他)。
|
||||
// 供产品物料清单递归展开使用:成品子项需继续向下展开到原材料/外购件。
|
||||
// WMS 不可达返回 err,由调用方按"全部视为叶子物料"降级(不阻塞产线)。
|
||||
func (c *Client) MaterialTypes(ctx context.Context, codes []string) (map[string]int, 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/types", 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 {
|
||||
Types map[string]int `json:"types"`
|
||||
} `json:"data"`
|
||||
Msg string `json:"message"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if body.Code != 0 {
|
||||
if body.Msg != "" {
|
||||
return nil, errors.New(body.Msg)
|
||||
}
|
||||
return nil, errors.New("WMS 查询物料物料类别失败")
|
||||
}
|
||||
if body.Data.Types == nil {
|
||||
return map[string]int{}, nil
|
||||
}
|
||||
return body.Data.Types, nil
|
||||
}
|
||||
|
||||
// MaterialManageModes 批量查询物料在 WMS 的「类型」(manage_mode: 1结构件/2电气件/3其他)。
|
||||
// 与 MaterialTypes(物料类别 item_type)相互独立:物料类别=成品/组件类,类型=结构件/电气件/其他。
|
||||
// 物料类别(item_type=成品/组件类)与「类型」(结构件/电气件/其他)是两个独立维度,本接口只查后者。
|
||||
// WMS 不可达返回 err,由调用方降级(不阻塞产线)。
|
||||
func (c *Client) MaterialManageModes(ctx context.Context, codes []string) (map[string]int, error) {
|
||||
b, err := json.Marshal(map[string]any{"codes": codes})
|
||||
|
||||
Reference in New Issue
Block a user