refactor(wms): 合并库存表为统一inventory,重构业务逻辑
1. 合并inventory_batch与serial_number为统一inventory表,用manage_mode区分结构件批次/精密件SN 2. 移除冗余的material_type字段与相关逻辑 3. 重构库存查询、检验、入库出库等业务逻辑适配新表结构 4. 调整前端路由与菜单,拆分基础数据为区域维护和物料档案 5. 优化入库校验逻辑,避免空单问题 6. 调整Vite构建配置,关闭自动清空输出目录 7. 为各模块添加详细中文注释,统一业务术语 8. 生成并更新Ent自动代码文件
This commit is contained in:
@@ -19,8 +19,8 @@ func SeedIfEmpty(client *ent.Client) error {
|
||||
if zones == 0 {
|
||||
for _, z := range []struct{ code, name string }{
|
||||
{"Z01", "待检区"},
|
||||
{"Z02", "合格品区"},
|
||||
{"Z03", "不合格品区"},
|
||||
{"Z02", "标准存储区"},
|
||||
{"Z03", "暂存区"},
|
||||
{"Z04", "退货区"},
|
||||
} {
|
||||
client.Zone.Create().
|
||||
@@ -65,15 +65,14 @@ func SeedIfEmpty(client *ent.Client) error {
|
||||
mats := []struct {
|
||||
code, name, spec, unit string
|
||||
mode int
|
||||
mtype string
|
||||
isBatch, isSerial bool
|
||||
}{
|
||||
{"GJ-BAN-001", "10mm钢板(结构件)", "2000x1000x10", "张", 1, "raw", true, false},
|
||||
{"GJ-GANGGUAN-002", "无缝钢管114x8", "114x8x6000", "根", 1, "raw", true, false},
|
||||
{"LJ-LUOSI-M16", "M16高强度螺栓", "M16x80 10.9级", "件", 1, "raw", true, false},
|
||||
{"JM-ZHOUCHENG-6020", "精密轴承6020", "6020-2RS", "套", 2, "raw", false, true},
|
||||
{"JM-DIANJI-750W", "伺服电机750W", "ECMA-C21307", "台", 2, "raw", false, true},
|
||||
{"BCP-JIEKOUTI", "接驳体半成品", "-", "件", 2, "semi", false, true},
|
||||
{"GJ-BAN-001", "10mm钢板(结构件)", "2000x1000x10", "张", 1, true, false},
|
||||
{"GJ-GANGGUAN-002", "无缝钢管114x8", "114x8x6000", "根", 1, true, false},
|
||||
{"LJ-LUOSI-M16", "M16高强度螺栓", "M16x80 10.9级", "件", 1, true, false},
|
||||
{"JM-ZHOUCHENG-6020", "精密轴承6020", "6020-2RS", "套", 2, false, true},
|
||||
{"JM-DIANJI-750W", "伺服电机750W", "ECMA-C21307", "台", 2, false, true},
|
||||
{"BCP-JIEKOUTI", "接驳体半成品", "-", "件", 2, false, true},
|
||||
}
|
||||
for _, m := range mats {
|
||||
client.Material.Create().
|
||||
@@ -84,42 +83,48 @@ func SeedIfEmpty(client *ent.Client) error {
|
||||
SetManageMode(m.mode).
|
||||
SetIsBatchManaged(m.isBatch).
|
||||
SetIsSerialManaged(m.isSerial).
|
||||
SetMaterialType(m.mtype).
|
||||
SaveX(ctx)
|
||||
}
|
||||
|
||||
// 演示批次(已检合格)
|
||||
// 演示库存(统一 inventory 表,manage_mode 区分结构件/精密件)
|
||||
today := time.Now().Format("2006-01-02")
|
||||
client.InventoryBatch.Create().
|
||||
SetBatchNo("B2026060100001").
|
||||
// 结构件批次(已检合格)
|
||||
client.Inventory.Create().
|
||||
SetManageMode(1).
|
||||
SetMaterialCode("GJ-BAN-001").
|
||||
SetNillableMaterialName(strPtrNil("10mm钢板(结构件)")).
|
||||
SetBatchNo("B2026060100001").
|
||||
SetQuantity(120).SetLockedQty(0).
|
||||
SetNillableProductionDate(strPtrNil("2026-06-01")).
|
||||
SetNillableSupplier(strPtrNil("宝钢供应商")).
|
||||
SetQualityStatus("合格").
|
||||
SetNillableZoneCode(strPtrNil("Z02")).
|
||||
SetStatus("在库").
|
||||
SaveX(ctx)
|
||||
client.InventoryBatch.Create().
|
||||
SetBatchNo("B2026060200034").
|
||||
client.Inventory.Create().
|
||||
SetManageMode(1).
|
||||
SetMaterialCode("GJ-GANGGUAN-002").
|
||||
SetNillableMaterialName(strPtrNil("无缝钢管114x8")).
|
||||
SetBatchNo("B2026060200034").
|
||||
SetQuantity(50).SetLockedQty(0).
|
||||
SetNillableProductionDate(strPtrNil(today)).
|
||||
SetNillableSupplier(strPtrNil("天津钢管")).
|
||||
SetQualityStatus("未检").
|
||||
SetNillableZoneCode(strPtrNil("Z01")).
|
||||
SetStatus("在库").
|
||||
SaveX(ctx)
|
||||
|
||||
// 演示 SN(在库)
|
||||
// 精密件 SN(在库,合格)
|
||||
for i := 1; i <= 5; i++ {
|
||||
sn := "SN20260601001" + time.Now().Format("02")
|
||||
client.SerialNumber.Create().
|
||||
SetSnCode(sn + itoaPad(i)).
|
||||
client.Inventory.Create().
|
||||
SetManageMode(2).
|
||||
SetMaterialCode("JM-ZHOUCHENG-6020").
|
||||
SetStatus("在库").
|
||||
SetNillableMaterialName(strPtrNil("精密轴承6020")).
|
||||
SetSnCode("SN20260601001" + itoaPad(i)).
|
||||
SetQuantity(1).SetLockedQty(0).
|
||||
SetQualityStatus("合格").
|
||||
SetNillableCurrentZone(strPtrNil("Z02")).
|
||||
SetNillableZoneCode(strPtrNil("Z02")).
|
||||
SetStatus("在库").
|
||||
SaveX(ctx)
|
||||
}
|
||||
slog.Info("seed: demo materials & stock created")
|
||||
|
||||
Reference in New Issue
Block a user