feat: 新增预警定时扫描器,移除附件归档字段并为角色表补充更新时间
This commit is contained in:
@@ -602,48 +602,8 @@ func getMaterialHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// materialTypesHandler 内部接口:批量查询物料类别(item_type)。
|
||||
// body: {"codes":["A","B"]} → data: {"types":{"A":1,"B":3}}(1原材料/3成品/4其他)。
|
||||
// 供 MES 递归展开产品物料清单使用:成品子项(item_type=3)需继续展开到原材料。
|
||||
func materialTypesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Codes []string `json:"codes"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
codes := []string{}
|
||||
for _, c := range req.Codes {
|
||||
c = strings.TrimSpace(c)
|
||||
if c == "" || seen[c] {
|
||||
continue
|
||||
}
|
||||
seen[c] = true
|
||||
codes = append(codes, c)
|
||||
}
|
||||
types := map[string]int{}
|
||||
if len(codes) > 0 {
|
||||
list, err := ctx.EntClient.Material.Query().
|
||||
Where(material.CodeIn(codes...)).
|
||||
Select(material.FieldCode, material.FieldItemType).
|
||||
All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询物料类别失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
for _, m := range list {
|
||||
types[m.Code] = m.ItemType
|
||||
}
|
||||
}
|
||||
ok(w, map[string]any{"types": types})
|
||||
}
|
||||
}
|
||||
|
||||
// materialManageModesHandler 内部接口:批量查询物料「类型」(manage_mode: 1结构件/2电气件/3其他)。
|
||||
// 与 materialTypesHandler(物料类别 item_type)相互独立:物料类别=成品/组件类,类型=结构件/电气件/其他。
|
||||
// 注意:物料类别(item_type=1原材料/2半成品/3成品/4其他,成品/组件类维度)与「类型」(结构件/电气件/其他)是两个独立维度,本接口只查后者。
|
||||
// body: {"codes":["A","B"]} → data: {"manageModes": {"A":1}}(不存在的编码不返回)。
|
||||
func materialManageModesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user