feat: 解耦管理类型与SN管理方式,新增sn_mode字段实现全链路SN管理标准化

本次重构将原manage_mode字段拆分为独立的分类维度(manage_mode)和SN管理维度(sn_mode),实现全链路(MES/WMS/工位终端)的SN管理行为统一依据:
1. 新增sn_mode字段,定义1=序列号件、2=批次件、0=未选择,替代原manage_mode的SN判断逻辑
2. 移除冗余的manage_mode字段在多个实体中的使用,统一使用sn_mode决定业务行为
3. 新增工位接驳台配置,服务端固定接驳台,前端不可修改,确保AGV送达准确性
4. 优化检验记录导出,新增装配物料绑定明细,满足客户追溯需求
5. 修正前端提示文本,统一使用序列号件/批次件表述,与后端逻辑对齐
This commit is contained in:
SunYF
2026-09-30 17:33:11 +08:00
parent 58f67240d7
commit c33acab9c8
136 changed files with 3730 additions and 1174 deletions
+18 -7
View File
@@ -16,21 +16,23 @@ type Inventory struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 管理粒度 1=结构件(批次) 2=电气件(SN)
// 类型 1结构件/2电气件/3其他
ManageMode int `json:"manageMode,omitempty"`
// SN管理 1序列号件(逐件SN)/2批次件(数量)/0未选择
SnMode int `json:"snMode,omitempty"`
// 品类 1=原材料 2=半成品 3=成品
Category int `json:"category,omitempty"`
// 物料编码(关联 materials 表)
MaterialCode string `json:"materialCode,omitempty"`
// 物料名称(冗余,便于直接展示)
MaterialName string `json:"materialName,omitempty"`
// 批次号(系统生成);电气件可关联所属批次
// 批次号(系统生成);序列号件可关联所属批次
BatchNo string `json:"batchNo,omitempty"`
// 序列号(SN,仅电气件);全局唯一,空值表示非 SN 行
// 序列号(SN,仅序列号件);全局唯一,空值表示非 SN 行
SnCode string `json:"snCode,omitempty"`
// 数量:结构件=批次余量;电气件=1
// 数量:批次件=批次余量;序列号件=1
Quantity int `json:"quantity,omitempty"`
// 已锁定数量(库存占用):结构件=件数;电气件=0/1
// 已锁定数量(库存占用):批次件=件数;序列号件=0/1
LockedQty int `json:"lockedQty,omitempty"`
// 检验状态 未检/合格/不合格
QualityStatus string `json:"qualityStatus,omitempty"`
@@ -42,7 +44,7 @@ type Inventory struct {
LayerNo string `json:"layerNo,omitempty"`
// 位置号(手填,如 12)
PositionNo string `json:"positionNo,omitempty"`
// 生命周期:在库/锁定/出库/使用/报废(电气件用;结构件恒在库)
// 生命周期:在库/锁定/出库/使用/报废(序列号件用;批次件恒在库)
Status string `json:"status,omitempty"`
// 生产日期
ProductionDate string `json:"productionDate,omitempty"`
@@ -88,7 +90,7 @@ func (*Inventory) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case inventory.FieldID, inventory.FieldManageMode, inventory.FieldCategory, inventory.FieldQuantity, inventory.FieldLockedQty, inventory.FieldRecordedAt, inventory.FieldCreatedAt, inventory.FieldUpdatedAt:
case inventory.FieldID, inventory.FieldManageMode, inventory.FieldSnMode, inventory.FieldCategory, inventory.FieldQuantity, inventory.FieldLockedQty, inventory.FieldRecordedAt, inventory.FieldCreatedAt, inventory.FieldUpdatedAt:
values[i] = new(sql.NullInt64)
case inventory.FieldMaterialCode, inventory.FieldMaterialName, inventory.FieldBatchNo, inventory.FieldSnCode, inventory.FieldQualityStatus, inventory.FieldZoneCode, inventory.FieldShelfNo, inventory.FieldLayerNo, inventory.FieldPositionNo, inventory.FieldStatus, inventory.FieldProductionDate, inventory.FieldSupplier, inventory.FieldInboundNo, inventory.FieldOrderNo, inventory.FieldProductWorkNo, inventory.FieldCompletedProcess, inventory.FieldOwnershipType, inventory.FieldOwnershipNo, inventory.FieldProductStatus, inventory.FieldRelatedStandard, inventory.FieldTestRecordNo, inventory.FieldRecordedBy, inventory.FieldOutboundReason, inventory.FieldStocktakeNo, inventory.FieldRemark:
values[i] = new(sql.NullString)
@@ -119,6 +121,12 @@ func (_m *Inventory) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.ManageMode = int(value.Int64)
}
case inventory.FieldSnMode:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field sn_mode", values[i])
} else if value.Valid {
_m.SnMode = int(value.Int64)
}
case inventory.FieldCategory:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field category", values[i])
@@ -344,6 +352,9 @@ func (_m *Inventory) String() string {
builder.WriteString("manage_mode=")
builder.WriteString(fmt.Sprintf("%v", _m.ManageMode))
builder.WriteString(", ")
builder.WriteString("sn_mode=")
builder.WriteString(fmt.Sprintf("%v", _m.SnMode))
builder.WriteString(", ")
builder.WriteString("category=")
builder.WriteString(fmt.Sprintf("%v", _m.Category))
builder.WriteString(", ")