refactor: 清理MES端本地product_type冗余代码,对齐WMS主数据架构
1. 移除MES端本地product_type实体、schema及相关CRUD代码,改为通过WMS内部API代理获取物料主数据 2. 更新物料管理粒度逻辑,新增"其他"类型(3)支持,同步更新入库校验规则 3. 修复前端物料选择、库存筛选等页面的类型判断逻辑,统一使用manage_mode区分管理类型 4. 清理静态资源文件冗余的样式代码,调整前端页面展示逻辑 5. 更新帮助文档,修正物料类型的说明描述
This commit is contained in:
@@ -132,12 +132,12 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// 「其他」类物料(item_type=4)单独记对象类型 OTHER(§B1:其他类此前混在批次(结构件)里无法单独识别)
|
||||
// 「其他」类物料(类型 manage_mode=3)单独记对象类型 OTHER(§B1:其他类此前混在批次(结构件)里无法单独识别)
|
||||
if len(codes) > 0 {
|
||||
if mats, e := ctx.EntClient.Material.Query().Where(material.CodeIn(codes...)).All(ctx0()); e == nil {
|
||||
otherSet := map[string]bool{}
|
||||
for _, m := range mats {
|
||||
if m.ItemType == invItemOther {
|
||||
if m.ManageMode == invManageOther {
|
||||
otherSet[m.Code] = true
|
||||
}
|
||||
}
|
||||
@@ -652,7 +652,7 @@ func statsInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// materialCodesByItemType 按品类(itemType)取物料编码集合(来料检验「其他」类过滤用,B1)。
|
||||
// materialCodesByItemType 按品类(itemType)取物料编码集合。
|
||||
// 先查 material 取编码集,再 IN 查 inventory/inspection_record,避免逐行 join(同 materialCodesBySpec 套路)。
|
||||
func materialCodesByItemType(ctx *svc.ServiceContext, itemType int) []string {
|
||||
mats, err := ctx.EntClient.Material.Query().Where(material.ItemTypeEQ(itemType)).All(ctx0())
|
||||
@@ -666,6 +666,20 @@ func materialCodesByItemType(ctx *svc.ServiceContext, itemType int) []string {
|
||||
return codes
|
||||
}
|
||||
|
||||
// materialCodesByManageMode 按类型(manageMode=1结构件/2电气件/3其他)取物料编码集合(来料检验/库存「其他」类过滤用)。
|
||||
// 库存行里「其他」与结构件同为 manage_mode=1(批次数量管理),只能借物料档案的类型区分,故先取编码集再 IN。
|
||||
func materialCodesByManageMode(ctx *svc.ServiceContext, manageMode int) []string {
|
||||
mats, err := ctx.EntClient.Material.Query().Where(material.ManageModeEQ(manageMode)).All(ctx0())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
codes := make([]string, 0, len(mats))
|
||||
for _, m := range mats {
|
||||
codes = append(codes, m.Code)
|
||||
}
|
||||
return codes
|
||||
}
|
||||
|
||||
// inboundNosByType 取符合入库类型的入库单号集合(待检清单按入库类型过滤用,B1)。
|
||||
func inboundNosByType(ctx *svc.ServiceContext, inboundType string) ([]string, error) {
|
||||
orders, err := ctx.EntClient.InboundOrder.Query().Where(inboundorder.InboundTypeEQ(inboundType)).All(ctx0())
|
||||
@@ -690,6 +704,7 @@ type pendingInspectionRow struct {
|
||||
OwnershipNo string `json:"ownershipNo"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
MatManageMode int `json:"matManageMode"` // 物料档案类型(1结构件/2电气件/3其他)
|
||||
UnInspectedQty int `json:"unInspectedQty"` // 未检数量(结构件=数量求和;电气件=SN 行数)
|
||||
DetailsTotal int `json:"detailsTotal"` // 未检批次数/SN 总数(抽屉分页拉明细)
|
||||
InboundTime int64 `json:"inboundTime"`
|
||||
@@ -718,8 +733,8 @@ func pendingInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
case "SN":
|
||||
q = q.Where(inventory.ManageModeEQ(2))
|
||||
case "OTHER":
|
||||
// 其他入库物料:itemType=4(先取编码集再 IN,避免逐行 join)
|
||||
codes := materialCodesByItemType(ctx, 4)
|
||||
// 其他入库物料:类型 manage_mode=3(先取编码集再 IN,避免逐行 join)
|
||||
codes := materialCodesByManageMode(ctx, invManageOther)
|
||||
if len(codes) == 0 {
|
||||
ok(w, map[string]any{"list": []any{}, "total": 0})
|
||||
return
|
||||
@@ -760,8 +775,9 @@ func pendingInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// 物料名称 map
|
||||
// 物料名称 / 类型 map
|
||||
matName := map[string]string{}
|
||||
matManageMode := map[string]int{}
|
||||
codeSet := []string{}
|
||||
seenC := map[string]bool{}
|
||||
for _, inv := range all {
|
||||
@@ -774,6 +790,7 @@ func pendingInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if mats, e := ctx.EntClient.Material.Query().Where(material.CodeIn(codeSet...)).All(ctx0()); e == nil {
|
||||
for _, m := range mats {
|
||||
matName[m.Code] = m.Name
|
||||
matManageMode[m.Code] = m.ManageMode
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -798,6 +815,7 @@ func pendingInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
OwnershipNo: ownNo,
|
||||
MaterialCode: inv.MaterialCode,
|
||||
MaterialName: matName[inv.MaterialCode],
|
||||
MatManageMode: matManageMode[inv.MaterialCode],
|
||||
}
|
||||
group[key] = g
|
||||
order = append(order, key)
|
||||
@@ -880,10 +898,12 @@ func pendingDetailsInspectionHandler(svcCtx *svc.ServiceContext) http.HandlerFun
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
// itemType 从物料档案补查(一个 materialCode 唯一)
|
||||
// itemType / 类型 从物料档案补查(一个 materialCode 唯一)
|
||||
itemType := 0
|
||||
matManageMode := 0
|
||||
if m, e := svcCtx.EntClient.Material.Query().Where(material.CodeEQ(materialCode)).Only(ctx0()); e == nil {
|
||||
itemType = m.ItemType
|
||||
matManageMode = m.ManageMode
|
||||
}
|
||||
rows := make([]map[string]any, 0, len(list))
|
||||
for _, inv := range list {
|
||||
@@ -892,12 +912,13 @@ func pendingDetailsInspectionHandler(svcCtx *svc.ServiceContext) http.HandlerFun
|
||||
tid = inv.SnCode
|
||||
}
|
||||
rows = append(rows, map[string]any{
|
||||
"targetId": tid,
|
||||
"manageMode": inv.ManageMode,
|
||||
"itemType": itemType,
|
||||
"quantity": inv.Quantity,
|
||||
"zoneCode": inv.ZoneCode,
|
||||
"id": inv.ID,
|
||||
"targetId": tid,
|
||||
"manageMode": inv.ManageMode,
|
||||
"matManageMode": matManageMode,
|
||||
"itemType": itemType,
|
||||
"quantity": inv.Quantity,
|
||||
"zoneCode": inv.ZoneCode,
|
||||
"id": inv.ID,
|
||||
})
|
||||
}
|
||||
ok(w, map[string]any{"list": rows, "total": total, "page": page, "pageSize": pageSize})
|
||||
|
||||
Reference in New Issue
Block a user