1. 合并inventory_batch与serial_number为统一inventory表,用manage_mode区分结构件批次/精密件SN 2. 移除冗余的material_type字段与相关逻辑 3. 重构库存查询、检验、入库出库等业务逻辑适配新表结构 4. 调整前端路由与菜单,拆分基础数据为区域维护和物料档案 5. 优化入库校验逻辑,避免空单问题 6. 调整Vite构建配置,关闭自动清空输出目录 7. 为各模块添加详细中文注释,统一业务术语 8. 生成并更新Ent自动代码文件
269 lines
9.6 KiB
Go
269 lines
9.6 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/inventory"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Inventory is the model entity for the Inventory schema.
|
|
type Inventory struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// 管理粒度 1=结构件(批次) 2=精密件(SN)
|
|
ManageMode int `json:"manageMode,omitempty"`
|
|
// 物料编码(关联 materials 表)
|
|
MaterialCode string `json:"materialCode,omitempty"`
|
|
// 物料名称(冗余,便于直接展示)
|
|
MaterialName string `json:"materialName,omitempty"`
|
|
// 批次号(系统生成);精密件可关联所属批次
|
|
BatchNo string `json:"batchNo,omitempty"`
|
|
// 序列号(SN,仅精密件);空值表示非 SN 行
|
|
SnCode string `json:"snCode,omitempty"`
|
|
// 数量:结构件=批次余量;精密件=1
|
|
Quantity int `json:"quantity,omitempty"`
|
|
// 已锁定数量(库存占用):结构件=件数;精密件=0/1
|
|
LockedQty int `json:"lockedQty,omitempty"`
|
|
// 检验状态 未检/合格/不合格
|
|
QualityStatus string `json:"qualityStatus,omitempty"`
|
|
// 所在区域(Z01~Z04 大分区)
|
|
ZoneCode string `json:"zoneCode,omitempty"`
|
|
// 生命周期:在库/锁定/出库/使用/报废(精密件用;结构件恒在库)
|
|
Status string `json:"status,omitempty"`
|
|
// 生产日期
|
|
ProductionDate string `json:"productionDate,omitempty"`
|
|
// 供应商
|
|
Supplier string `json:"supplier,omitempty"`
|
|
// 关联入库单号
|
|
InboundNo string `json:"inboundNo,omitempty"`
|
|
// 备注
|
|
Remark string `json:"remark,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt int64 `json:"createdAt,omitempty"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
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.FieldQuantity, inventory.FieldLockedQty, inventory.FieldCreatedAt, inventory.FieldUpdatedAt:
|
|
values[i] = new(sql.NullInt64)
|
|
case inventory.FieldMaterialCode, inventory.FieldMaterialName, inventory.FieldBatchNo, inventory.FieldSnCode, inventory.FieldQualityStatus, inventory.FieldZoneCode, inventory.FieldStatus, inventory.FieldProductionDate, inventory.FieldSupplier, inventory.FieldInboundNo, inventory.FieldRemark:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Inventory fields.
|
|
func (_m *Inventory) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case inventory.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
_m.ID = int(value.Int64)
|
|
case inventory.FieldManageMode:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field manage_mode", values[i])
|
|
} else if value.Valid {
|
|
_m.ManageMode = int(value.Int64)
|
|
}
|
|
case inventory.FieldMaterialCode:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field material_code", values[i])
|
|
} else if value.Valid {
|
|
_m.MaterialCode = value.String
|
|
}
|
|
case inventory.FieldMaterialName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field material_name", values[i])
|
|
} else if value.Valid {
|
|
_m.MaterialName = value.String
|
|
}
|
|
case inventory.FieldBatchNo:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field batch_no", values[i])
|
|
} else if value.Valid {
|
|
_m.BatchNo = value.String
|
|
}
|
|
case inventory.FieldSnCode:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sn_code", values[i])
|
|
} else if value.Valid {
|
|
_m.SnCode = value.String
|
|
}
|
|
case inventory.FieldQuantity:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field quantity", values[i])
|
|
} else if value.Valid {
|
|
_m.Quantity = int(value.Int64)
|
|
}
|
|
case inventory.FieldLockedQty:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field locked_qty", values[i])
|
|
} else if value.Valid {
|
|
_m.LockedQty = int(value.Int64)
|
|
}
|
|
case inventory.FieldQualityStatus:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field quality_status", values[i])
|
|
} else if value.Valid {
|
|
_m.QualityStatus = value.String
|
|
}
|
|
case inventory.FieldZoneCode:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field zone_code", values[i])
|
|
} else if value.Valid {
|
|
_m.ZoneCode = value.String
|
|
}
|
|
case inventory.FieldStatus:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field status", values[i])
|
|
} else if value.Valid {
|
|
_m.Status = value.String
|
|
}
|
|
case inventory.FieldProductionDate:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field production_date", values[i])
|
|
} else if value.Valid {
|
|
_m.ProductionDate = value.String
|
|
}
|
|
case inventory.FieldSupplier:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field supplier", values[i])
|
|
} else if value.Valid {
|
|
_m.Supplier = value.String
|
|
}
|
|
case inventory.FieldInboundNo:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field inbound_no", values[i])
|
|
} else if value.Valid {
|
|
_m.InboundNo = value.String
|
|
}
|
|
case inventory.FieldRemark:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field remark", values[i])
|
|
} else if value.Valid {
|
|
_m.Remark = value.String
|
|
}
|
|
case inventory.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Int64
|
|
}
|
|
case inventory.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = value.Int64
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Inventory.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *Inventory) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this Inventory.
|
|
// Note that you need to call Inventory.Unwrap() before calling this method if this Inventory
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *Inventory) Update() *InventoryUpdateOne {
|
|
return NewInventoryClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the Inventory entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *Inventory) Unwrap() *Inventory {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Inventory is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *Inventory) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Inventory(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("manage_mode=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ManageMode))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("material_code=")
|
|
builder.WriteString(_m.MaterialCode)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("material_name=")
|
|
builder.WriteString(_m.MaterialName)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("batch_no=")
|
|
builder.WriteString(_m.BatchNo)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sn_code=")
|
|
builder.WriteString(_m.SnCode)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("quantity=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Quantity))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("locked_qty=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.LockedQty))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("quality_status=")
|
|
builder.WriteString(_m.QualityStatus)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("zone_code=")
|
|
builder.WriteString(_m.ZoneCode)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("status=")
|
|
builder.WriteString(_m.Status)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("production_date=")
|
|
builder.WriteString(_m.ProductionDate)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("supplier=")
|
|
builder.WriteString(_m.Supplier)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("inbound_no=")
|
|
builder.WriteString(_m.InboundNo)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("remark=")
|
|
builder.WriteString(_m.Remark)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.UpdatedAt))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Inventories is a parsable slice of Inventory.
|
|
type Inventories []*Inventory
|