feat: 新增检测单关联、基础数据优化与入库单升级
1. 新增出库单检测单号字段并添加索引支持溯源 2. 优化基础数据页面物料类型展示与选择逻辑 3. 升级入库单导入功能,支持自动生成单号并返回导入结果 4. 优化接驳台查询排序方式 5. 修复字符串拼接空格问题
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
||||
"bj_power_wms/ent/material"
|
||||
"bj_power_wms/internal/svc"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
@@ -313,14 +312,14 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
continue
|
||||
}
|
||||
if snSeen[pr.sn] {
|
||||
errs = append(errs, importErr{pr.row, pr.code, "SN 在文件中重复: "+pr.sn})
|
||||
errs = append(errs, importErr{pr.row, pr.code, "SN 在文件中重复: " + pr.sn})
|
||||
continue
|
||||
}
|
||||
snSeen[pr.sn] = true
|
||||
exists, _ := ctx.EntClient.Inventory.Query().
|
||||
Where(inventory.ManageModeEQ(2), inventory.SnCodeEQ(pr.sn)).Exist(ctx0())
|
||||
if exists {
|
||||
errs = append(errs, importErr{pr.row, pr.code, "SN 已存在: "+pr.sn})
|
||||
errs = append(errs, importErr{pr.row, pr.code, "SN 已存在: " + pr.sn})
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
@@ -352,6 +351,7 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
fail(w, http.StatusInternalServerError, "开启事务失败: "+e.Error())
|
||||
return
|
||||
}
|
||||
var generatedNos []string
|
||||
committed := false
|
||||
defer func() {
|
||||
if !committed {
|
||||
@@ -360,7 +360,8 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}()
|
||||
|
||||
for _, pr := range plans {
|
||||
inboundNo := "IB" + uuid.NewString()[:12]
|
||||
inboundNo, _ := nextDailyNo(ctx, "IB")
|
||||
generatedNos = append(generatedNos, inboundNo)
|
||||
m, _ := tx.Material.Query().Where(material.CodeEQ(pr.code)).Only(ctx0())
|
||||
if mode == "sn" {
|
||||
if _, e = tx.Inventory.Create().
|
||||
@@ -386,11 +387,11 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
batchNo := pr.batchNo
|
||||
if batchNo == "" {
|
||||
// 自动批次号(物料编码-日期-流水号);同一导入内多行空批次自动取得递增流水,天然唯一
|
||||
batchNo = genBatchNo(ctx, pr.code)
|
||||
}
|
||||
batchNo := pr.batchNo
|
||||
if batchNo == "" {
|
||||
// 自动批次号(物料编码-日期-流水号);同一导入内多行空批次自动取得递增流水,天然唯一
|
||||
batchNo = genBatchNo(ctx, pr.code)
|
||||
}
|
||||
existing, e2 := tx.Inventory.Query().
|
||||
Where(inventory.ManageModeEQ(1), inventory.BatchNoEQ(batchNo)).Only(ctx0())
|
||||
if e2 == nil {
|
||||
@@ -447,7 +448,12 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
committed = true
|
||||
ok(w, map[string]any{"success": len(plans), "failed": 0, "errors": []importErr{}})
|
||||
ok(w, map[string]any{
|
||||
"success": len(plans),
|
||||
"failed": 0,
|
||||
"errors": []importErr{},
|
||||
"inboundNos": generatedNos, // 每张入库单生成的单号(与导入行一一对应)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user