本次重构将原manage_mode字段拆分为独立的分类维度(manage_mode)和SN管理维度(sn_mode),实现全链路(MES/WMS/工位终端)的SN管理行为统一依据: 1. 新增sn_mode字段,定义1=序列号件、2=批次件、0=未选择,替代原manage_mode的SN判断逻辑 2. 移除冗余的manage_mode字段在多个实体中的使用,统一使用sn_mode决定业务行为 3. 新增工位接驳台配置,服务端固定接驳台,前端不可修改,确保AGV送达准确性 4. 优化检验记录导出,新增装配物料绑定明细,满足客户追溯需求 5. 修正前端提示文本,统一使用序列号件/批次件表述,与后端逻辑对齐
88 lines
2.8 KiB
Go
88 lines
2.8 KiB
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
"bj_power_wms/ent"
|
|
"bj_power_wms/ent/inboundorder"
|
|
"bj_power_wms/ent/inventory"
|
|
"bj_power_wms/internal/svc"
|
|
)
|
|
|
|
// lastInboundLocationHandler 入库库位联动:返回该物料最近一次入库的库位(区域/货架/层/位置号)。
|
|
// 前端在「选物料」后自动回填到入库表单(可手动修改),替代原「推荐库位」按钮式交互。
|
|
func lastInboundLocationHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
materialCode := strings.TrimSpace(r.URL.Query().Get("materialCode"))
|
|
if materialCode == "" {
|
|
fail(w, http.StatusBadRequest, "materialCode 必填")
|
|
return
|
|
}
|
|
ib, err := ctx.EntClient.InboundOrder.Query().
|
|
Where(inboundorder.MaterialCodeEQ(materialCode)).
|
|
Order(ent.Desc("created_at"), ent.Desc("id")).
|
|
First(ctx0())
|
|
if err != nil {
|
|
if ent.IsNotFound(err) {
|
|
ok(w, map[string]any{"zoneCode": "", "shelfNo": "", "layerNo": "", "positionNo": ""})
|
|
return
|
|
}
|
|
fail(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
ok(w, map[string]any{
|
|
"zoneCode": ib.ZoneCode,
|
|
"shelfNo": ib.ShelfNo,
|
|
"layerNo": ib.LayerNo,
|
|
"positionNo": ib.PositionNo,
|
|
})
|
|
}
|
|
}
|
|
|
|
// outboundLocationHintHandler 出库库位联动(客户诉求 一.9「出库相同」)。
|
|
// 取值优先级:① 指定批次在库的实际四级库位(最准,出库就是从该货位取货)
|
|
// ② 该物料最近一次入库的库位(历史常用库位)③ 均无则返回空,前端可继续走同区空位推荐。
|
|
func outboundLocationHintHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
materialCode := strings.TrimSpace(r.URL.Query().Get("materialCode"))
|
|
batchNo := strings.TrimSpace(r.URL.Query().Get("batchNo"))
|
|
emptyHint := map[string]any{"zoneCode": "", "shelfNo": "", "layerNo": "", "positionNo": ""}
|
|
if materialCode == "" && batchNo == "" {
|
|
ok(w, emptyHint)
|
|
return
|
|
}
|
|
if batchNo != "" {
|
|
if b, err := ctx.EntClient.Inventory.Query().
|
|
Where(inventory.SnModeEQ(snModeBatch), inventory.BatchNoEQ(batchNo)).
|
|
Only(ctx0()); err == nil {
|
|
ok(w, map[string]any{
|
|
"zoneCode": b.ZoneCode,
|
|
"shelfNo": b.ShelfNo,
|
|
"layerNo": b.LayerNo,
|
|
"positionNo": b.PositionNo,
|
|
})
|
|
return
|
|
}
|
|
}
|
|
if materialCode == "" {
|
|
ok(w, emptyHint)
|
|
return
|
|
}
|
|
ib, err := ctx.EntClient.InboundOrder.Query().
|
|
Where(inboundorder.MaterialCodeEQ(materialCode)).
|
|
Order(ent.Desc("created_at"), ent.Desc("id")).
|
|
First(ctx0())
|
|
if err != nil {
|
|
ok(w, emptyHint)
|
|
return
|
|
}
|
|
ok(w, map[string]any{
|
|
"zoneCode": ib.ZoneCode,
|
|
"shelfNo": ib.ShelfNo,
|
|
"layerNo": ib.LayerNo,
|
|
"positionNo": ib.PositionNo,
|
|
})
|
|
}
|
|
}
|