docs: 统一修正全项目“SN管理”相关术语为“序列号”
本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
This commit is contained in:
@@ -48,9 +48,13 @@ type zoneNodeVO struct {
|
||||
Status string `json:"status"`
|
||||
Description string `json:"description"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
// StockQty 本级实时库存总量(需求E/需求7):每次查询实时聚合 inventories(quantity>0 且非出库/报废),不缓存。
|
||||
// StockQty 本级实时库存总量(需求E/需求7):每次查询实时聚合 inventories(quantity>0 且 status∈{在库,锁定} 且非半成品),不缓存。
|
||||
// level1=区域合计、level2=货架合计、level3=层合计、level4=该位置合计。
|
||||
StockQty int `json:"stockQty"`
|
||||
// UnshelvedQty 区域级「未分配货架」库存合计(货位为空但已填区域的合法状态,见库存口径说明);仅 level1 有意义。
|
||||
UnshelvedQty int `json:"unshelvedQty"`
|
||||
// IsSynthetic 是否为合成行(如「(未分配货架)」虚拟货架);合成行不可编辑/删除,仅用于展示未上架库存。
|
||||
IsSynthetic bool `json:"isSynthetic"`
|
||||
}
|
||||
|
||||
func toZoneNodeVO(z *ent.Zone) zoneNodeVO {
|
||||
@@ -118,7 +122,7 @@ func listZonesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
list := make([]zoneNodeVO, 0, len(rows))
|
||||
byZone, byShelf, byLayer, byPos := zoneStockMaps(ctx)
|
||||
byZone, byShelf, byLayer, byPos, byUnshelved := zoneStockMaps(ctx)
|
||||
for _, z := range rows {
|
||||
vo := toZoneNodeVO(z)
|
||||
zc := strings.ToLower(strings.TrimSpace(z.ZoneCode))
|
||||
@@ -127,6 +131,7 @@ func listZonesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
switch z.Level {
|
||||
case zoneLevelRegion:
|
||||
vo.StockQty = byZone[zc]
|
||||
vo.UnshelvedQty = byUnshelved[zc]
|
||||
case zoneLevelShelf:
|
||||
vo.StockQty = byShelf[zc+"|"+sh]
|
||||
case zoneLevelLayer:
|
||||
@@ -136,17 +141,60 @@ func listZonesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
list = append(list, vo)
|
||||
}
|
||||
// 货架(level2)列表置顶固定合成行「(未分配货架)」:汇总本页所属区域的未上架库存,
|
||||
// 灰显不可编辑,不参与分页计数(见库存口径说明:缺货位为合法状态)。
|
||||
if level == zoneLevelShelf {
|
||||
unshelvedTotal := 0
|
||||
seenZc := map[string]bool{}
|
||||
for _, z2 := range rows {
|
||||
zc2 := strings.ToLower(strings.TrimSpace(z2.ZoneCode))
|
||||
if !seenZc[zc2] {
|
||||
seenZc[zc2] = true
|
||||
unshelvedTotal += byUnshelved[zc2]
|
||||
}
|
||||
}
|
||||
if unshelvedTotal > 0 && len(rows) > 0 {
|
||||
synth := zoneNodeVO{
|
||||
Level: zoneLevelShelf,
|
||||
Code: "",
|
||||
Name: "(未分配货架)",
|
||||
ZoneCode: rows[0].ZoneCode,
|
||||
ZoneName: rows[0].ZoneName,
|
||||
Status: "启用",
|
||||
StockQty: unshelvedTotal,
|
||||
IsSynthetic: true,
|
||||
}
|
||||
list = append([]zoneNodeVO{synth}, list...)
|
||||
}
|
||||
}
|
||||
// 区域(level1)列表置顶固定合成行「(未分区)」:zone_code 为空的库存合计(入库不强制货位的合法状态),
|
||||
// 与货架级「(未分配货架)」同款处理:灰显不可编辑,不参与分页计数;使区域维护页与区域汇总/库位明细的「未分区」行对账一致。
|
||||
if level == zoneLevelRegion {
|
||||
if unpartitioned := byZone[""]; unpartitioned > 0 {
|
||||
synth := zoneNodeVO{
|
||||
Level: zoneLevelRegion,
|
||||
Code: "",
|
||||
Name: "(未分区)",
|
||||
Status: "启用",
|
||||
StockQty: unpartitioned,
|
||||
UnshelvedQty: byUnshelved[""],
|
||||
IsSynthetic: true,
|
||||
}
|
||||
list = append([]zoneNodeVO{synth}, list...)
|
||||
}
|
||||
}
|
||||
ok(w, map[string]any{"total": total, "list": list, "page": page, "pageSize": pageSize})
|
||||
}
|
||||
}
|
||||
|
||||
// zoneStockMaps 实时聚合各级库存总量(需求E):一次扫描在库 inventories(quantity>0 且 status 非出库/报废),
|
||||
// zoneStockMaps 实时聚合各级库存总量(需求E):一次扫描在库 inventories(quantity>0 且 status∈{在库,锁定} 且非半成品),
|
||||
// 分别按 区域 / 区域+货架 / 区域+货架+层 / 完整四级货位 累加,供四级列表展示实时库存。
|
||||
// byUnshelved 为区域级「未分配货架」库存合计(货位为空但已填区域的合法状态),供未上架标识与合成行使用。
|
||||
// 键归一与 locKey 一致:区域/货架小写,层/位置原样 trim。
|
||||
func zoneStockMaps(ctx *svc.ServiceContext) (byZone, byShelf, byLayer, byPos map[string]int) {
|
||||
byZone, byShelf, byLayer, byPos = map[string]int{}, map[string]int{}, map[string]int{}, map[string]int{}
|
||||
func zoneStockMaps(ctx *svc.ServiceContext) (byZone, byShelf, byLayer, byPos, byUnshelved map[string]int) {
|
||||
byZone, byShelf, byLayer, byPos, byUnshelved = map[string]int{}, map[string]int{}, map[string]int{}, map[string]int{}, map[string]int{}
|
||||
invs, err := ctx.EntClient.Inventory.Query().
|
||||
Where(inventory.QuantityGT(0), inventory.StatusNotIn("出库", "报废")).All(ctx0())
|
||||
Where(inventory.QuantityGT(0), inventory.StatusIn("在库", "锁定"), inventory.CategoryNEQ(invCatSemi)).All(ctx0())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -158,6 +206,9 @@ func zoneStockMaps(ctx *svc.ServiceContext) (byZone, byShelf, byLayer, byPos map
|
||||
byShelf[zc+"|"+sh] += iv.Quantity
|
||||
byLayer[zc+"|"+sh+"|"+ly] += iv.Quantity
|
||||
byPos[locKey(iv.ZoneCode, iv.ShelfNo, iv.LayerNo, iv.PositionNo)] += iv.Quantity
|
||||
if sh == "" {
|
||||
byUnshelved[zc] += iv.Quantity
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user