docs(test): 更新电表箱装配业务回归测试文档
- 将文档从代码审计任务转换为端到端业务回归测试链路 - 重新组织文档结构为链路总览、示例数据基线和详细步骤 - 添加完整的业务场景清单涵盖WMS/MES/工位终端三大系统 - 定义统一的测试数据包括产品型号、物料清单、工位派工等 - 提供详细的步骤断言和数量等式验证方法 - 建立贯穿全链路的数据流向和状态变更追踪体系
This commit is contained in:
@@ -2,132 +2,15 @@ package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"bj_power_wms/ent"
|
||||
"bj_power_wms/ent/dock"
|
||||
"bj_power_wms/internal/svc"
|
||||
)
|
||||
|
||||
// dockRow 接驳台返回 DTO(显式 json 标签,避免依赖 ent 默认编组)。
|
||||
type dockRow struct {
|
||||
DockCode string `json:"dockCode"`
|
||||
Name string `json:"name"`
|
||||
DockType string `json:"dockType"`
|
||||
StationNo int `json:"stationNo"`
|
||||
HasPallet bool `json:"hasPallet"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// listDocksInternalHandler 返回接驳台主数据列表(dock 真源在 WMS)。
|
||||
// MES 工位维护页拉取此接口填充「送达接驳台」下拉,避免写死 DOCK01..20 留后患。
|
||||
func listDocksInternalHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
list, err := ctx.EntClient.Dock.Query().
|
||||
Order(ent.Asc("dock_code")).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询接驳台失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
rows := make([]dockRow, 0, len(list))
|
||||
for _, d := range list {
|
||||
rows = append(rows, dockRow{
|
||||
DockCode: d.DockCode,
|
||||
Name: d.Name,
|
||||
DockType: d.DockType,
|
||||
StationNo: d.StationNo,
|
||||
HasPallet: d.HasPallet,
|
||||
Status: d.Status,
|
||||
})
|
||||
}
|
||||
ok(w, map[string]any{"list": rows})
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 接驳台主数据维护 ----------
|
||||
// 接驳台是独立主数据:除产线工位旁,库房、缓存区等其他位置也有接驳台位。
|
||||
// 类型:line=产线(绑定工位,与工位 1:1)/ store=库房 / other=其他(均不绑定工位)。
|
||||
|
||||
// dockMaintRow 接驳台维护页返回行(显式 json,避免 ent omitempty 吞掉 hasPallet=false)
|
||||
type dockMaintRow struct {
|
||||
ID int64 `json:"id"`
|
||||
DockCode string `json:"dockCode"`
|
||||
Name string `json:"name"`
|
||||
DockType string `json:"dockType"`
|
||||
StationNo int `json:"stationNo"`
|
||||
Status string `json:"status"`
|
||||
HasPallet bool `json:"hasPallet"`
|
||||
PalletRef string `json:"palletRef"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
}
|
||||
|
||||
func dockMaintRowOf(d *ent.Dock) dockMaintRow {
|
||||
return dockMaintRow{
|
||||
ID: int64(d.ID),
|
||||
DockCode: d.DockCode,
|
||||
Name: d.Name,
|
||||
DockType: d.DockType,
|
||||
StationNo: d.StationNo,
|
||||
Status: d.Status,
|
||||
HasPallet: d.HasPallet,
|
||||
PalletRef: d.PalletRef,
|
||||
CreatedAt: d.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// listDocksMaintHandler GET /api/docks?dockType=&dockCode=&name=&status=&page=&pageSize=
|
||||
// 接驳台主数据只读分页查询(真分页在 SQL 层),编码精确/名称模糊/状态精确各自独立筛选。
|
||||
func listDocksMaintHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
query := ctx.EntClient.Dock.Query()
|
||||
if typ := q.Get("dockType"); typ != "" {
|
||||
query = query.Where(dock.DockType(typ))
|
||||
}
|
||||
// 列表页禁止关键字混搜:编码精确、名称模糊、状态精确,各字段独立筛选(需求5、N)
|
||||
if code := strings.TrimSpace(q.Get("dockCode")); code != "" {
|
||||
query = query.Where(dock.DockCodeEqualFold(code))
|
||||
}
|
||||
if name := strings.TrimSpace(q.Get("name")); name != "" {
|
||||
query = query.Where(dock.NameContainsFold(name))
|
||||
}
|
||||
if status := strings.TrimSpace(q.Get("status")); status != "" {
|
||||
query = query.Where(dock.StatusEQ(status))
|
||||
}
|
||||
total, err := query.Count(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询接驳台失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
page := atoi(q.Get("page"), 1)
|
||||
size := atoi(q.Get("pageSize"), 20)
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if size < 1 || size > 200 {
|
||||
size = 20
|
||||
}
|
||||
list, err := query.
|
||||
Order(ent.Desc("created_at"), ent.Desc("id")).
|
||||
Offset((page - 1) * size).Limit(size).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询接驳台失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
rows := make([]dockMaintRow, 0, len(list))
|
||||
for _, d := range list {
|
||||
rows = append(rows, dockMaintRowOf(d))
|
||||
}
|
||||
ok(w, map[string]any{"list": rows, "total": total, "page": page, "pageSize": size})
|
||||
}
|
||||
}
|
||||
|
||||
// 接驳台为系统预置只读主数据(需求5):不提供新增/修改/删除,仅保留查询。
|
||||
// 原 createDockHandler / updateDockHandler / deleteDockHandler / validateDock / dockReq 已彻底移除,
|
||||
// 接驳台数据由 db/seed.go 种子初始化,调整由实施维护种子或数据库完成。
|
||||
// 接驳台主数据真源已迁 MES(2026-09-21):仓库不再维护 dock 表,也不给接驳台派任务。
|
||||
// WMS 仅在「出库目标工位下拉」处只读派生 MES 接驳台中 line 类型(产线接驳台与工位 1:1)。
|
||||
|
||||
// stationOption 出库目标工位下拉项(需求20:目标工位可下拉选择、不允许手输)。
|
||||
// 客户口径「出库工位号来自 MES 工位列表」——WMS 侧以接驳台主数据中 line 类型
|
||||
// 客户口径「出库工位号来自 MES 工位列表」——以 MES 接驳台主数据中 line 类型
|
||||
// (产线接驳台与工位 1:1 绑定)为真源派生工位选项,避免前端写死 1~20。
|
||||
type stationOption struct {
|
||||
StationNo int `json:"stationNo"`
|
||||
@@ -136,18 +19,17 @@ type stationOption struct {
|
||||
}
|
||||
|
||||
// listStationOptionsHandler GET /api/outbound/stations 返回产线工位下拉选项(无权限包裹,供出库页调用)。
|
||||
// 数据改读 MES 接驳台主数据(dock 真源已迁 MES):过滤 line 类型且绑定工位号者。
|
||||
func listStationOptionsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
list, err := ctx.EntClient.Dock.Query().
|
||||
Where(dock.DockType("line")).
|
||||
Order(ent.Asc("station_no")).All(ctx0())
|
||||
list, err := ctx.Mes.ListDocks(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询工位失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
rows := make([]stationOption, 0, len(list))
|
||||
for _, d := range list {
|
||||
if d.StationNo <= 0 {
|
||||
if d.DockType != "line" || d.StationNo <= 0 {
|
||||
continue
|
||||
}
|
||||
rows = append(rows, stationOption{StationNo: d.StationNo, Name: d.Name, DockCode: d.DockCode})
|
||||
|
||||
Reference in New Issue
Block a user