feat: 新增检测单关联、基础数据优化与入库单升级

1. 新增出库单检测单号字段并添加索引支持溯源
2. 优化基础数据页面物料类型展示与选择逻辑
3. 升级入库单导入功能,支持自动生成单号并返回导入结果
4. 优化接驳台查询排序方式
5. 修复字符串拼接空格问题
This commit is contained in:
SunYF
2026-09-21 15:28:14 +08:00
parent 0e769f3813
commit 12ca493c61
70 changed files with 25782 additions and 119 deletions
+36 -3
View File
@@ -13,7 +13,6 @@ import (
"bj_power_wms/ent/outboundorder"
"bj_power_wms/internal/svc"
"github.com/google/uuid"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -37,6 +36,7 @@ type deductStockRequest struct {
LayerNo string `json:"layerNo"`
PositionNo string `json:"positionNo"`
Remark string `json:"remark"`
OutboundNo string `json:"outboundNo"` // 可选:留空自动生成;填了必须唯一(如 OB20260921-001
// OutboundType 出库类型:workorder(备料出库,默认) / refill(工位叫料·补料出库)
OutboundType string `json:"outboundType"`
// NeedAgv 是否需要 AGV 配送到接驳台(备料/补料一般为 true)
@@ -92,7 +92,20 @@ func deductStockHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return
}
outboundNo := "OB" + uuid.NewString()[:12]
outboundNo := strings.TrimSpace(req.OutboundNo)
if outboundNo != "" {
if err := validateUniqueNo(ctx, "OB", outboundNo); err != nil {
fail(w, http.StatusBadRequest, err.Error())
return
}
} else {
no, err := nextDailyNo(ctx, "OB")
if err != nil {
fail(w, http.StatusInternalServerError, "生成出库单号失败: "+err.Error())
return
}
outboundNo = no
}
// 开启事务:出库单 + 库存扣减 + 明细 + 台账 原子提交
tx, err := ctx.EntClient.Tx(ctx0())
@@ -316,6 +329,7 @@ func queryOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
materialName := r.URL.Query().Get("materialName")
targetStation := r.URL.Query().Get("targetStation")
status := r.URL.Query().Get("status")
inspectionNo := r.URL.Query().Get("inspectionNo")
q := ctx.EntClient.OutboundOrder.Query()
if status != "" {
@@ -348,6 +362,9 @@ func queryOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
if targetStation != "" {
q = q.Where(outboundorder.TargetStationEQ(targetStation))
}
if inspectionNo != "" {
q = q.Where(outboundorder.InspectionNoContainsFold(inspectionNo))
}
if v := r.URL.Query().Get("startDate"); v != "" {
if t, err := time.ParseInLocation("2006-01-02", v, time.Local); err == nil {
q = q.Where(outboundorder.CreatedAtGTE(t.Unix()))
@@ -409,7 +426,9 @@ type generalOutboundRequest struct {
BoxNo string `json:"boxNo"`
ContractNo string `json:"contractNo"`
Remark string `json:"remark"`
OutboundNo string `json:"outboundNo"` // 可选:留空自动生成;填了必须唯一(如 OB20260921-001
OutboundCategory string `json:"outboundCategory"` // return(退料)/supplier_return(退货退供应商)/sample(样品)/scrap(报废)/deliver(发货)/other(其他)
InspectionNo string `json:"inspectionNo"` // 可选:检测单号,退货/报废等需溯源检验单据
OwnershipType string `json:"ownershipType"` // workorder/project/other
OwnershipNo string `json:"ownershipNo"`
TargetStation string `json:"targetStation"`
@@ -469,7 +488,20 @@ func generalOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
req.ZoneCode, req.ShelfNo, req.LayerNo, req.PositionNo =
outboundLocationFallback(ctx, req.BatchNo, req.SnList, req.ZoneCode, req.ShelfNo, req.LayerNo, req.PositionNo)
outboundNo := "OB" + uuid.NewString()[:12]
outboundNo := strings.TrimSpace(req.OutboundNo)
if outboundNo != "" {
if err := validateUniqueNo(ctx, "OB", outboundNo); err != nil {
fail(w, http.StatusBadRequest, err.Error())
return
}
} else {
no, err := nextDailyNo(ctx, "OB")
if err != nil {
fail(w, http.StatusInternalServerError, "生成出库单号失败: "+err.Error())
return
}
outboundNo = no
}
tx, err := ctx.EntClient.Tx(ctx0())
if err != nil {
@@ -492,6 +524,7 @@ func generalOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
SetNillableOutboundCategory(strPtr(req.OutboundCategory)).
SetNillableOwnershipType(strPtr(req.OwnershipType)).
SetNillableOwnershipNo(strPtr(req.OwnershipNo)).
SetNillableInspectionNo(strPtr(req.InspectionNo)).
SetNillableTargetStation(strPtr(req.TargetStation)).
SetMaterialCode(req.MaterialCode).
SetManageMode(manageMode).