docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
This commit is contained in:
@@ -56,7 +56,7 @@ type InspectionReq struct {
|
||||
DisposalType string `json:"disposalType"` // 处置类型 退货/返修/退换/报废
|
||||
DisposalRemark string `json:"disposalRemark"` // 处置说明
|
||||
// 判不合格联动 WMS 在库处置的定位字段(可空=不联动):
|
||||
// 序列号件(sn_mode=1)填 SN、批次件(sn_mode=2)填批次号;
|
||||
// 序列号=是(sn_mode=1)填 SN、序列号=否(sn_mode=2)填批次号;
|
||||
// 定位口径由后端按物料档案 sn_mode 判定(SN=按序列号定位 / 批次=按批次定位)
|
||||
BatchSn string `json:"batchSn"`
|
||||
ReturnTrackingNo string `json:"returnTrackingNo"` // 退货运单号(退货/退换处置必填)
|
||||
@@ -156,7 +156,7 @@ func (s *Service) CreateInspection(ctx context.Context, req InspectionReq, opera
|
||||
|
||||
// 判不合格 → 联动 WMS 在库处置(缺口 B):
|
||||
// 前提:结论 NG + 已选可映射的处置方式 + 物料编码与批次号/SN 齐全;
|
||||
// 定位口径由后端按物料档案 sn_mode 判定:序列号件按 SN(material_code+序列号)、批次件按批次(material_code+批次号)。
|
||||
// 定位口径由后端按物料档案 sn_mode 判定:序列号=是按 SN(material_code+序列号)、序列号=否按批次(material_code+批次号)。
|
||||
// WMS 调用失败不阻断检验留痕,返回信息提示「库存联动失败」,并写事件日志便于追溯。
|
||||
msg := "巡检记录已提交"
|
||||
if result == "NG" && req.MaterialCode != "" && req.BatchSn != "" {
|
||||
@@ -292,14 +292,13 @@ func (s *Service) GetInspectionRecord(ctx context.Context, id int) (*ent.Inspect
|
||||
return rec, nil
|
||||
}
|
||||
|
||||
// SetInspectionDisposal 质量检验处置:区分 退货/返修/退换/报废/让步接收,写处置说明。
|
||||
// 让步接收(CONCESSION):完工检不合格品经审批后入库(质量状态=让步接收,可发货但标记)——与用户既定口径一致,不再「仅记录」。
|
||||
// SetInspectionDisposal 质量检验处置:区分 退货/返修/退换/报废,写处置说明。
|
||||
func (s *Service) SetInspectionDisposal(ctx context.Context, id int, disposalType, disposalRemark, operator string) (string, error) {
|
||||
if id <= 0 {
|
||||
return "", errors.New("缺少 id")
|
||||
}
|
||||
if !oneOf(disposalType, "退货", "返修", "退换", "报废", "让步接收") {
|
||||
return "", errors.New("处置类型仅支持 退货/返修/退换/报废/让步接收")
|
||||
if !oneOf(disposalType, "退货", "返修", "退换", "报废") {
|
||||
return "", errors.New("处置类型仅支持 退货/返修/退换/报废")
|
||||
}
|
||||
rec, err := s.ctx.EntClient.InspectionRecord.Get(ctx, id)
|
||||
if err != nil {
|
||||
@@ -312,41 +311,24 @@ func (s *Service) SetInspectionDisposal(ctx context.Context, id int, disposalTyp
|
||||
}
|
||||
s.ctx.EventLog.Write(ctx, "inspection.disposal", rec.OrderNo, operator, "inspection_record", rec.Sn,
|
||||
"质量检验处置 "+disposalType, map[string]any{"id": id, "remark": disposalRemark})
|
||||
// 让步接收:完工检不合格品经审批后入库(质量状态=让步接收,可发货但标记)
|
||||
if disposalType == "让步接收" && rec.Category == "FINAL" {
|
||||
inboundMsg := s.finishedInspectionInbound(ctx, rec, InspectionReq{Sn: rec.Sn, DisposalType: "让步接收"}, "",
|
||||
"检验记录已保存")
|
||||
if inboundMsg != "" {
|
||||
s.ctx.EventLog.Write(ctx, "wms.finished.concession_inbound", rec.OrderNo, operator, "inspection_record", rec.Sn,
|
||||
"让步接收成品已入库(质量状态=让步接收)", map[string]any{"id": id, "msg": inboundMsg})
|
||||
}
|
||||
return "处置已记录;让步接收成品已回流WMS入库(质量状态=让步接收)", nil
|
||||
}
|
||||
return "处置已记录", nil
|
||||
}
|
||||
|
||||
// finishedInspectionInbound 完工检记录保存后按结论触发成品回流入库(方案A定稿)。
|
||||
// 结论映射:OK=已通过→入库(qualityStatus=合格);PARTIAL=部分通过→入库(qualityStatus=合格,
|
||||
// 由 WMS 侧按 productStatus 映射);CONCESSION(让步接收)=入库(qualityStatus=让步接收,可发货但标记);
|
||||
// NG(含报废处置)→不入库,仅记事件日志待返修/报废。
|
||||
// 由 WMS 侧按 productStatus 映射);NG(含报废处置)→不入库,仅记事件日志待返修/报废。
|
||||
// 归属三字段照 semi.go workpieceWorkOrder 继承模式取自工单;
|
||||
// relatedStandard/testRecordNo:取自完工检记录(录入弹窗选填),随成品回流 WMS。
|
||||
// WMS 409(SN 防重,返修后复检重复入库)转成「已入库勿重复」友好提示;其余失败仅提示不阻断留痕。
|
||||
func (s *Service) finishedInspectionInbound(ctx context.Context, rec *ent.InspectionRecord, req InspectionReq, result, msg string) string {
|
||||
productStatus := ""
|
||||
concession := false
|
||||
switch result {
|
||||
case "OK":
|
||||
productStatus = "已通过"
|
||||
case "PARTIAL":
|
||||
productStatus = "部分通过"
|
||||
case "CONCESSION":
|
||||
concession = true
|
||||
}
|
||||
if req.DisposalType == "让步接收" {
|
||||
concession = true
|
||||
}
|
||||
if productStatus == "" && !concession {
|
||||
if productStatus == "" {
|
||||
// 不合格(含处置=报废/退货/退换):不入库,留痕待返修/报废
|
||||
note := "成品" + rec.Sn + "完工检不合格,未入库,待返修/报废"
|
||||
if req.DisposalType == "报废" {
|
||||
@@ -356,7 +338,7 @@ func (s *Service) finishedInspectionInbound(ctx context.Context, rec *ent.Inspec
|
||||
note, map[string]any{"reportNo": rec.ReportNo, "result": result, "disposalType": req.DisposalType})
|
||||
return msg
|
||||
}
|
||||
// 成品 SN:优先工件SN栏,缺省回退批次号/SN 栏(序列号件该栏填的即 SN)
|
||||
// 成品 SN:优先工件SN栏,缺省回退批次号/SN 栏(序列号=是该栏填的即 SN)
|
||||
sn := strings.TrimSpace(req.Sn)
|
||||
if sn == "" {
|
||||
sn = strings.TrimSpace(req.BatchSn)
|
||||
@@ -378,12 +360,9 @@ func (s *Service) finishedInspectionInbound(ctx context.Context, rec *ent.Inspec
|
||||
"完工检合格但成品回流WMS入库失败:工单不存在", map[string]any{"error": "work order not found"})
|
||||
return "检验记录已保存;WMS 入库失败:工件所属工单不存在"
|
||||
}
|
||||
// 质量状态落库值:合格类(已通过/部分通过)统一传「合格」;让步接收传「让步接收」。
|
||||
// 不再传「已通过/部分通过」等非库存枚举值(WMS 库存质量状态仅认 合格/不合格/让步接收/未检/待退)。
|
||||
// 质量状态落库值:合格类(已通过/部分通过)统一传「合格」。
|
||||
// 不传「已通过/部分通过」等非库存枚举值(WMS 库存质量状态仅认 合格/不合格/未检/待退)。
|
||||
qualityStatusForWMS := "合格"
|
||||
if concession {
|
||||
qualityStatusForWMS = "让步接收"
|
||||
}
|
||||
if wmsErr := s.ctx.Wms.FinishedInbound(ctx, wmsclient.FinishedPayload{
|
||||
ProductCode: wo.ProductCode, ProductName: wo.ProductName, Sn: wp.Sn, OrderNo: wp.OrderNo,
|
||||
Operator: rec.Operator, ProductStatus: productStatus, QualityStatus: qualityStatusForWMS,
|
||||
|
||||
Reference in New Issue
Block a user