docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
This commit is contained in:
@@ -17,9 +17,9 @@ import (
|
||||
// MES 侧维护改为「本地优先」:先写 MES 本地 materials 表,再推 WMS /api/internal/materials/upsert,
|
||||
// 推失败置 sync_pending 由列表请求异步重推,不回滚本地(M3)。
|
||||
// 查询全部读本地——WMS 宕机时 MES 建单/排产/型号下拉照常可用(M6)。
|
||||
// 与 WMS product-types 接口同口径:品类固定 3(成品)、编码留空自动生成 PROD-YYYYMMDD-当日流水、
|
||||
// 与 WMS product-types 接口同口径:物料类别固定 3(成品)、编码留空自动生成 PROD-YYYYMMDD-当日流水、
|
||||
// Category 列取说明列(历史迁移约定)。「类型」(manageMode) 与「是否逐件SN管理」(snMode) 解耦,
|
||||
// 两者均为建档必选:snMode 1序列号件(录SN)/2批次件(不录SN),0=未选择不可保存。
|
||||
// 两者均为建档必选:snMode 1序列号=是(录SN)/2序列号=否(不录SN),0=未选择不可保存。
|
||||
// 备料"物料在 WMS 档案存在"校验仍直查 WMS(M8,库存真源在 WMS,见 logic/material.go)。
|
||||
|
||||
type ProductTypeReq struct {
|
||||
@@ -29,18 +29,18 @@ type ProductTypeReq struct {
|
||||
Spec string `json:"spec"`
|
||||
Unit string `json:"unit"`
|
||||
ManageMode int `json:"manageMode"` // 类型 1结构件/2电气件/3其他(必选)
|
||||
SnMode int `json:"snMode"` // 是否逐件SN管理 1序列号件/2批次件(必选,0=未选择不可保存)
|
||||
SnMode int `json:"snMode"` // 是否逐件SN管理 1序列号=是/2序列号=否(必选,0=未选择不可保存)
|
||||
IsActive bool `json:"isActive"`
|
||||
Description string `json:"description"` // 说明(与 WMS 物料档案同口径,可空)
|
||||
}
|
||||
|
||||
// validateTypeAndSnMode 建档必选校验:类型 1/2/3、序列号件 1/2(0=未选择直接拒绝)。
|
||||
// validateTypeAndSnMode 建档必选校验:类型 1/2/3、序列号=是 1/2(0=未选择直接拒绝)。
|
||||
func validateTypeAndSnMode(manageMode, snMode int) error {
|
||||
if manageMode != 1 && manageMode != 2 && manageMode != 3 {
|
||||
return errors.New("请选择类型(结构件/电气件/其他)")
|
||||
}
|
||||
if snMode != 1 && snMode != 2 {
|
||||
return errors.New("请先选择序列号件(序列号件/批次件)")
|
||||
return errors.New("请先选择序列号管理方式(序列号=是/序列号=否)")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -175,19 +175,29 @@ func (s *Service) UpdateProductType(ctx context.Context, req ProductTypeReq) err
|
||||
// DeleteProductType 「删除」=停用(客户裁决"都不可删除",M5 两库一致):
|
||||
// 本地置 isActive=false → 推 WMS 同步停用。停用不影响历史工单/库存引用(行保留)。
|
||||
func (s *Service) DeleteProductType(ctx context.Context, id int) error {
|
||||
return s.SetProductTypeStatus(ctx, id, false)
|
||||
}
|
||||
|
||||
// SetProductTypeStatus 物料档案启用/停用专用通道(POST /product-types/status)。
|
||||
// 本地置 isActive → 推 WMS 同步;停用不影响历史工单/库存引用(行保留)。
|
||||
func (s *Service) SetProductTypeStatus(ctx context.Context, id int, isActive bool) error {
|
||||
cur, err := s.ctx.EntClient.Material.Get(ctx, id)
|
||||
if err != nil || cur.ItemType != 3 {
|
||||
return errors.New("物料档案不存在")
|
||||
}
|
||||
if !cur.IsActive {
|
||||
return nil // 已停用,幂等
|
||||
if cur.IsActive == isActive {
|
||||
return nil // 幂等
|
||||
}
|
||||
m, err := s.ctx.EntClient.Material.UpdateOneID(id).SetIsActive(false).Save(ctx)
|
||||
m, err := s.ctx.EntClient.Material.UpdateOneID(id).SetIsActive(isActive).Save(ctx)
|
||||
if err != nil {
|
||||
return errors.New("停用物料档案失败:" + err.Error())
|
||||
return errors.New("更新物料档案状态失败:" + err.Error())
|
||||
}
|
||||
if err := s.pushMaterialToWMS(ctx, m); err != nil {
|
||||
log.Printf("[material-sync] 停用 %s 已落本地,推送 WMS 失败(待重推): %v", cur.Code, err)
|
||||
act := "启用"
|
||||
if !isActive {
|
||||
act = "停用"
|
||||
}
|
||||
log.Printf("[material-sync] %s %s 已落本地,推送 WMS 失败(待重推): %v", act, cur.Code, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -216,7 +226,9 @@ func (s *Service) ListProductTypes(ctx context.Context, isActive string) ([]wmsc
|
||||
// ListProductTypesPage 分页+搜索(管理页真分页,真源=本地)。
|
||||
// 2026-09-08 禁止关键字混搜:编码/名称各自独立模糊。wmsOnline 恒为 true(仅兼容前端字段)。
|
||||
// 本地副本为空时异步自 WMS 全量拉取补齐(M7),并顺带重推 pending 行(M3)。
|
||||
func (s *Service) ListProductTypesPage(ctx context.Context, code, name, isActive string, page, pageSize int) (int64, []wmsclient.ProductTypeRow, bool, error) {
|
||||
// 筛选参数:code/name/spec 独立模糊(大小写无关),manageMode(1结构件/2电气件/3其他)与
|
||||
// snMode(1序列号=是/2序列号=否)精确筛选,isActive 启用状态筛选。
|
||||
func (s *Service) ListProductTypesPage(ctx context.Context, code, name, spec string, manageMode, snMode int, isActive string, page, pageSize int) (int64, []wmsclient.ProductTypeRow, bool, error) {
|
||||
s.EnsureMaterialCacheAsync()
|
||||
q := s.ctx.EntClient.Material.Query().Where(material.ItemTypeEQ(3))
|
||||
if code != "" {
|
||||
@@ -225,6 +237,15 @@ func (s *Service) ListProductTypesPage(ctx context.Context, code, name, isActive
|
||||
if name != "" {
|
||||
q = q.Where(material.NameContainsFold(name))
|
||||
}
|
||||
if spec != "" {
|
||||
q = q.Where(material.SpecContainsFold(spec))
|
||||
}
|
||||
if manageMode > 0 {
|
||||
q = q.Where(material.ManageModeEQ(manageMode))
|
||||
}
|
||||
if snMode > 0 {
|
||||
q = q.Where(material.SnModeEQ(snMode))
|
||||
}
|
||||
switch isActive {
|
||||
case "true":
|
||||
q = q.Where(material.IsActiveEQ(true))
|
||||
|
||||
Reference in New Issue
Block a user