feat: 核心业务实体扩充(混产模板/产品BOM/试制记录)、WMS 库存检验增强与前端通用能力
- MES 新增实体:混产模板、产品BOM、产品工艺物料、试制记录(schema + ent 生成码 + logic/handler/前端页) - WMS 实体增强:检验记录、库存、半成品重构;新增序列号库存与短缺代报 - AGV 与产能:AGV 手动点位与链路、物料守卫、短缺预测、原因字典 - 前端通用能力:新增下一步引导组件 NextStepBar,统一帮助文档/布局/请求拦截与操作列 - 工位终端:界面与各 handler 调整(api/store/绑定/PLC/拧紧/上报等) - 配置与文档:更新 mes-api.yaml、WMS README 及案例/产线API/问题记录/项目说明/流程说明
This commit is contained in:
@@ -14,6 +14,7 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -203,6 +204,14 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
matName = m.Name
|
||||
}
|
||||
}
|
||||
// 2026-11-13 拍板「来料检验三维度正交重构」:
|
||||
// ① 检验结论 inspection_conclusion(只答判定成什么)
|
||||
// ② 数量拆分(inspectQty/passQty/rejectQty)——提交时【自动拆库存行】,不再等人工二次点处置
|
||||
// ③ 不合格品处置 disposal_status 独立状态机:不合格部分一律先挂「待处置」
|
||||
dispStatus := ""
|
||||
if it.rejectQty > 0 {
|
||||
dispStatus = "待处置"
|
||||
}
|
||||
if _, err = tx.InspectionRecord.Create().
|
||||
SetTargetType(it.targetType).
|
||||
SetTargetID(it.id).
|
||||
@@ -213,6 +222,9 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetNillableRelatedStandard(strPtr(it.relStd)).
|
||||
SetNillableManufacturer(strPtr(it.mfr)).
|
||||
SetStatus(it.status).
|
||||
SetInspectionConclusion(it.status).
|
||||
SetDisposalStatus(dispStatus).
|
||||
SetParentRecordID(0).
|
||||
SetInspectQty(it.inspectQty).
|
||||
SetPassQty(it.passQty).
|
||||
SetRejectQty(it.rejectQty).
|
||||
@@ -230,7 +242,38 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
fail(w, http.StatusInternalServerError, "创建检验记录失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = tx.Inventory.UpdateOneID(it.inv.ID).
|
||||
// 自动拆分:原行保留「合格数 + 未检数」,不合格数单独生成 -NG 隔离行并挂「待处置」。
|
||||
// 未检件不再被算成不合格(旧 dispose 用 total-passQty 的口径已废止)。
|
||||
// -NG 行本身不会再进待检清单,故用后缀判断即可防重复拆分,无需额外 import。
|
||||
if it.rejectQty > 0 && it.inv.SnMode == snModeBatch && !strings.HasSuffix(it.inv.BatchNo, "-NG") {
|
||||
kept := it.passQty + (it.inv.Quantity - it.inspectQty)
|
||||
if kept < 0 {
|
||||
kept = 0
|
||||
}
|
||||
keptQuality := "未检"
|
||||
if it.passQty > 0 {
|
||||
keptQuality = "合格"
|
||||
}
|
||||
if _, err = tx.Inventory.UpdateOneID(it.inv.ID).
|
||||
SetQuantity(kept).SetQualityStatus(keptQuality).Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "拆分合格/未检数量失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
if _, err = tx.Inventory.Create().
|
||||
SetManageMode(it.inv.ManageMode).SetSnMode(it.inv.SnMode).SetCategory(it.inv.Category).
|
||||
SetMaterialCode(it.inv.MaterialCode).
|
||||
SetNillableMaterialName(strPtr(it.inv.MaterialName)).
|
||||
SetBatchNo(it.inv.BatchNo + "-NG").
|
||||
SetQuantity(it.rejectQty).SetLockedQty(0).
|
||||
SetQualityStatus("不合格").SetStatus("待处置").
|
||||
SetNillableZoneCode(strPtr(it.inv.ZoneCode)).
|
||||
SetNillableInboundNo(strPtr(it.inv.InboundNo)).
|
||||
SetRemark("检验自动拆分:不合格部分(待处置)").
|
||||
Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "生成不合格隔离行失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
} else if _, err = tx.Inventory.UpdateOneID(it.inv.ID).
|
||||
SetQualityStatus(qualityAfterInspection(it.status, it.disposal)).Save(ctx0()); err != nil {
|
||||
fail(w, http.StatusInternalServerError, "同步库存检验状态失败: "+err.Error())
|
||||
return
|
||||
@@ -541,8 +584,11 @@ func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}()
|
||||
|
||||
// 2026-11-13 拍板:三维度正交——处置状态与检验结论、数量拆分互不混用。
|
||||
// 退货/换修/报废/部分入库四种处置统一推进「已处置」,不再只有 PARTIAL 推进。
|
||||
if _, err = tx.InspectionRecord.UpdateOneID(rec.ID).
|
||||
SetDisposalType(dt).
|
||||
SetDisposalStatus("已处置").
|
||||
SetNillableDisposalRemark(strPtr(req.DisposalRemark)).
|
||||
SetNillableReturnTrackingNo(strPtr(req.ReturnTrackingNo)).
|
||||
Save(ctx0()); err != nil {
|
||||
@@ -568,6 +614,11 @@ func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
case "PARTIAL":
|
||||
// 2026-11-13:处置状态已在上方统一推进;此处只做数量拆分兼容分支
|
||||
// (送检判定时已自动拆分并生成隔离行,避免重复拆行 / 旧口径把未检件算成不合格)。
|
||||
if rec.DisposalStatus == "待处置" {
|
||||
break
|
||||
}
|
||||
if inv.SnMode != snModeBatch {
|
||||
fail(w, http.StatusBadRequest, "部分入库仅适用于序列号=否(按数量管理)")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user