feat: 完成附件存储重构与磁盘监控功能,同步物料档案与入库单规则更新
1. 新增跨平台磁盘空间监控能力,每日7点自动检测附件目录剩余空间,触发阈值告警 2. 重构附件存储方案为年/月/日/文件类型分层结构,统一MES与WMS的附件管理逻辑 3. 对齐物料档案与入库单的质量状态校验规则,仅合格品计入库存与出库 4. 实现入库单作废功能与区域库位的多级父子结构管理 5. 删除物料简称字段,补充规格型号与单位必填项,统一系统数据口径 6. 新增附件中心与磁盘状态查询接口,完善权限控制与操作日志
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"bj_power_wms/ent/inventorylock"
|
||||
"bj_power_wms/ent/material"
|
||||
"bj_power_wms/ent/predicate"
|
||||
"bj_power_wms/ent/zone"
|
||||
"bj_power_wms/internal/svc"
|
||||
)
|
||||
|
||||
@@ -678,7 +679,7 @@ type zoneSummRow struct {
|
||||
// buildZoneSummary 区域汇总聚合:供列表接口与导出共用。
|
||||
// 行排序固定(区域编码 → 质量 → 类型),避免 map 迭代顺序随机导致每次刷新行序跳动。
|
||||
func buildZoneSummary(ctx *svc.ServiceContext) ([]zoneSummRow, error) {
|
||||
zones, err := ctx.EntClient.Zone.Query().All(ctx0())
|
||||
zones, err := ctx.EntClient.Zone.Query().Where(zone.LevelEQ(1)).All(ctx0())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -826,10 +827,11 @@ func lockStockHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if item.MaterialCode == "" {
|
||||
continue
|
||||
}
|
||||
// 电气件:锁 SN(原子:仅 在库 才能锁)
|
||||
// 电气件:锁 SN(原子:仅 在库 且 合格 才能锁)
|
||||
if item.Sn != "" {
|
||||
aff, err := ctx.EntClient.Inventory.Update().
|
||||
Where(inventory.ManageModeEQ(2), inventory.SnCodeEQ(item.Sn), inventory.StatusEQ("在库")).
|
||||
Where(inventory.ManageModeEQ(2), inventory.SnCodeEQ(item.Sn), inventory.StatusEQ("在库"),
|
||||
inventory.QualityStatusEQ(QStatusPass)).
|
||||
SetStatus("锁定").SetLockedQty(1).
|
||||
Save(ctx0())
|
||||
if err != nil {
|
||||
@@ -837,7 +839,7 @@ func lockStockHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
if aff == 0 {
|
||||
fail(w, http.StatusBadRequest, "SN 不在库或不存在: "+item.Sn)
|
||||
fail(w, http.StatusBadRequest, "SN 不在库、不存在,或质量状态非「合格」: "+item.Sn)
|
||||
return
|
||||
}
|
||||
ctx.EntClient.InventoryLock.Create().
|
||||
@@ -868,6 +870,11 @@ func lockStockHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
fail(w, http.StatusConflict, "批次库存不足: "+item.BatchNo+" 可用 "+itoa(avail))
|
||||
return
|
||||
}
|
||||
// 质量门禁(客户口径):仅「合格」批次可锁库(未检/不合格/待退 不可锁)
|
||||
if b.QualityStatus != QStatusPass {
|
||||
fail(w, http.StatusConflict, "批次 "+item.BatchNo+" 质量状态为「"+qualityLabel(b.QualityStatus)+"」,仅合格品可锁库")
|
||||
return
|
||||
}
|
||||
aff, err := ctx.EntClient.Inventory.Update().
|
||||
Where(inventory.ID(b.ID), invAvailGTE(qty)).
|
||||
AddLockedQty(qty).
|
||||
@@ -1028,7 +1035,7 @@ type shortageRow struct {
|
||||
|
||||
// shortageHandler 缺货预警:安全库存 > 0 且可用量低于安全库存的物料。
|
||||
// 客户诉求《问题记录》L473「安全库存/缺货预警进 WMS 首页」。
|
||||
// 可用量口径与出库门禁一致:在库/锁定 且质量状态非 不合格/待退。
|
||||
// 可用量口径与出库门禁一致:在库/锁定 且质量状态=合格(未检/不合格/待退不计可用)。
|
||||
func shortageHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// 缺货预警只统计纳入库存体系的品类:半成品为自产中间品、不参与常规库存统计,故排除。
|
||||
@@ -1045,7 +1052,7 @@ func shortageHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
Where(
|
||||
inventory.MaterialCodeEQ(m.Code),
|
||||
inventory.StatusIn("在库", "锁定"),
|
||||
inventory.QualityStatusNotIn("不合格", "待退"),
|
||||
inventory.QualityStatusEQ(QStatusPass),
|
||||
).All(ctx0())
|
||||
if err != nil {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user