feat(mes/wms/终端): 签字循环业务重构 + 叫料池实物账两列 + 工位流水按包真分页 + 下线单据提示条(2026-11-30 现场整改)
【MES · 签字循环重构(业务重构,非修 bug)】 - 旧模型作废(签字随报工落库、检验员分支永不生效的死代码);新口径: 工人干完点「呼叫签字」→ 检验员巡检端签 OK/NG → OK 后工人再点一次「报工」;NG 整改后重新呼叫(新一轮) - 内容指纹(SHA256):呼叫时算一次落库,报工时重算比对,变了即「签字后改数据作废本轮」要求重呼; 只覆盖步骤录入(值/文本/勾选/拧紧结果),装机绑定不进指纹(独立台账)、改备注不触发 - 轮次统一:一次呼叫=一轮,操作工/检验员共用 round;NG/撤回/重呼=新一轮,旧轮作废历史保留 - 三档状态(作业中/签字中/待整改/可报工)从签字记录推导,不建表不存终端 - 报工闸门:本轮需签步骤齐全(操作工+检验员OK)+ 指纹未变才放行 - 撤回呼叫整轮作废;超时巡检每分钟扫描(阈值 30 分钟可在基础设置调),超时落预警中心+异常角标不进铃铛,60 分钟窗口去重 - 工位终端新增签字交互接口与呼叫/撤回/状态查询;巡检端保留 NG 回看 【MES · 叫料池实物账(十五节 Q1/Q16 + 17.6 裁决)】 - call_pool 新增 receivedQty(已收累计,拒收按退库单冲减)/ returnedQty(已退累计,按退库单号防重)两列实物账,与 sentQty 额度账并存 - 台面在手(可用)= 已收 − 已装 − 已退;在途 = 已发 − 已收 【工位终端 · 物料/叫料页重构(十五节 Q1~Q17 拍板落地)】 - 「本工位物料明细」改名「物料明细」,四数列改为:可用/需求/已发/已收/已装,量为 0 也显示不分左右托盘 - 去除「刷新池子」「刷新」按钮(有长连接);「我的叫料单」扩为类银行流水(叫料/退料/等等) - 叫料/退料数量列直排,提交时弹窗确认数量并选接驳台;管理端叫料与退料 AGV 派车流程统一收归库管 - 工位流水按包真分页(2026-11-29 拍板):后端按包号分组 Count+Limit/Offset,每页 20 包,前端不再内存聚合 【下线 · 单据流转提示条】 - MES/WMS 前端整体删除 NextStepBar / nextStep / nextStepRules(35 条规则表整套下线),页面不再出现常驻「下一步」提示条 【文档】 - 问题临时.md 新增十四节(主控独立审计:终端账号删除/心跳/闸门函数 8 处对码全过)+ 十五节(工位物料叫料 8 条原话逐字留档与 Q1~Q17 拍板底稿) - 新增《工位终端页面.md》;案例.md 同步更新验收口径
This commit is contained in:
@@ -21,6 +21,8 @@ var pathPermMap = map[string]string{
|
||||
"GET:/api/v1/product-types/template": "produce.product:add",
|
||||
"POST:/api/v1/work-orders": "produce.workorder:add",
|
||||
"PUT:/api/v1/work-orders": "produce.workorder:edit",
|
||||
// 工艺工位独立按钮权限(2026-11-30 用户拍板:禁止与编辑合并)
|
||||
"PUT:/api/v1/work-orders/flow": "produce.workorder:flow",
|
||||
"POST:/api/v1/work-orders/status": "produce.workorder:edit",
|
||||
"POST:/api/v1/work-orders/auto-schedule": "produce.workorder:dailyplan",
|
||||
"DELETE:/api/v1/work-orders/*": "produce.workorder:delete",
|
||||
@@ -58,6 +60,8 @@ var pathPermMap = map[string]string{
|
||||
//(produce.quality:process / produce.quality:final),此处不映射单一码,避免误拦/误放。
|
||||
// 检验员签字确认(需求B 第二签,巡检终端「待签任务」)
|
||||
"POST:/api/v1/signs/inspector": "sys.inspect:sign",
|
||||
// 已判不合格回看(巡检终端「待整改」只读表):与签字同档,防止无签字权限账号查看
|
||||
"GET:/api/v1/signs/rejected": "sys.inspect:sign",
|
||||
// 附件中心(sys.attachment 菜单下):删除属管理动作;
|
||||
// 列表/预览/下载不设按钮门槛(有菜单权限即可查阅)
|
||||
// 2026-10-28 生命周期重构:清理工作台(归档页)动作归 sys.attachment:manage;
|
||||
|
||||
@@ -237,6 +237,45 @@ func ReturnAdjustHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// StationReturnedAccumHandler POST /api/internal/call/station-return-accum
|
||||
// 巡检/工位退料收货确认 → 已退累计(2026-11-28 对账铁律,17.6 选项B)。
|
||||
func StationReturnedAccumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
StationNo int `json:"stationNo"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
Qty int `json:"qty"`
|
||||
ReturnNo string `json:"returnNo"`
|
||||
}
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).AccumulateStationReturned(r.Context(), req.StationNo, req.MaterialCode, req.Qty, req.ReturnNo); err != nil {
|
||||
httpx.Fail(w, 3211, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "已退累计已记", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// StationReturnedAdjustHandler POST /api/internal/call/station-return-adjust
|
||||
// 巡检/工位退料修正数量 → 按差额冲正已退(无 material_request 的独立通道)。
|
||||
func StationReturnedAdjustHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.StationReturnAdjustInput
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).AdjustStationReturned(r.Context(), req); err != nil {
|
||||
httpx.Fail(w, 3212, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "已退数量修正已记", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// AdjustPoolHandler POST /api/internal/call/pool-adjust 叫料池人工改量(同工艺多工位场景;留痕)。
|
||||
func AdjustPoolHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package production
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -112,6 +111,18 @@ func ListCallsInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
Source: q.Get("source"),
|
||||
RequestNo: q.Get("requestNo"),
|
||||
}
|
||||
// 2026-11-29:工位端流水按包真分页(pkgpaged=1)——数据库层按 package_no 分组 + Count + Limit/Offset。
|
||||
// 与 paged=1(按单分页,WMS 队列用)并存,互不影响。
|
||||
if strings.EqualFold(strings.TrimSpace(q.Get("pkgpaged")), "1") {
|
||||
page, _ := strconv.Atoi(strings.TrimSpace(q.Get("page")))
|
||||
pres, err := svc.ListCallPackages(r.Context(), callQ, page)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3105, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, pres)
|
||||
return
|
||||
}
|
||||
// 2026-11-28:WMS 叫料队列改数据库分页。paged=1 才返回分页信封;
|
||||
// 其他既有调用方(终端/WMS 配送等)仍拿数组,响应结构不变。
|
||||
if strings.EqualFold(strings.TrimSpace(q.Get("paged")), "1") {
|
||||
@@ -138,34 +149,7 @@ func ListCallsInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// materialRequestMaps 补 PREPARED 行的已送达量后转 map(分页/全量两条出口共用)。
|
||||
// 实际转换在 logic 包,与按包分页共用同一口径。
|
||||
func materialRequestMaps(ctx context.Context, svcCtx *svc.ServiceContext, rows []*ent.MaterialRequest) []map[string]any {
|
||||
// PREPARED 行收集单号 → 批量查 WMS 送达量(一次往返)
|
||||
nos := make([]string, 0, len(rows))
|
||||
for _, mr := range rows {
|
||||
if mr.Status == "PREPARED" {
|
||||
nos = append(nos, mr.RequestNo)
|
||||
}
|
||||
}
|
||||
arrived := map[string]float64{}
|
||||
if len(nos) > 0 && svcCtx.Wms != nil {
|
||||
arrived = svcCtx.Wms.CallArrivedQty(ctx, nos)
|
||||
}
|
||||
out := make([]map[string]any, 0, len(rows))
|
||||
for _, mr := range rows {
|
||||
b, jerr := json.Marshal(mr)
|
||||
if jerr != nil {
|
||||
continue
|
||||
}
|
||||
var m map[string]any
|
||||
if json.Unmarshal(b, &m) != nil {
|
||||
continue
|
||||
}
|
||||
if mr.Status == "PREPARED" {
|
||||
if a, has := arrived[mr.RequestNo]; has {
|
||||
m["arrivedQty"] = a
|
||||
}
|
||||
}
|
||||
out = append(out, m)
|
||||
}
|
||||
return out
|
||||
return logic.MaterialRequestMaps(ctx, svcCtx, rows)
|
||||
}
|
||||
|
||||
@@ -10,14 +10,12 @@ import (
|
||||
token "bj_power_mes/common/token"
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/inspectionrecord"
|
||||
"bj_power_mes/ent/linepoint"
|
||||
"bj_power_mes/ent/material"
|
||||
"bj_power_mes/ent/workorder"
|
||||
"bj_power_mes/ent/workpiece"
|
||||
"bj_power_mes/ent/predicate"
|
||||
"bj_power_mes/internal/logic"
|
||||
"bj_power_mes/internal/svc"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// atoiDefault 解析整型字符串,非法返回默认值
|
||||
@@ -318,9 +316,8 @@ func WorkpieceLookupInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
|
||||
}
|
||||
ctx := r.Context()
|
||||
// 2026-11-27 用户拍板:SN 存储原样(扫什么/填什么就是什么),查询匹配大小写脱敏。
|
||||
// 用 LOWER(sn)=LOWER(?) 谓词,后台前缀填小写 abc、终端扫 ABC 也能查到同一件。
|
||||
foldSn := func(s string) predicate.Workpiece { return func(sel *sql.Selector) { sel.Where(sql.ExprP("LOWER(sn) = LOWER(?)", s)) } }
|
||||
wp, err := svcCtx.EntClient.Workpiece.Query().Where(foldSn(sn)).First(ctx)
|
||||
// 2026-11-30 修:统一用 logic.SnFold(b.Arg 绑定参数),原 sql.ExprP("...?") 在 Postgres 下语法报错。
|
||||
wp, err := svcCtx.EntClient.Workpiece.Query().Where(logic.SnFold(sn)).First(ctx)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2003, "该 SN 未在建工单时生成,请确认 SN 是否正确,或先在 MES 建单")
|
||||
return
|
||||
@@ -336,13 +333,20 @@ func WorkpieceLookupInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
|
||||
snMode = m.SnMode
|
||||
}
|
||||
}
|
||||
// 上线页按 SN 自动分模式:在制件是否已有产线点位台账占用,决定走「已在制」还是「送入产线」。
|
||||
hasLinePoint := false
|
||||
linePointNo := ""
|
||||
if pt, e := svcCtx.EntClient.LinePoint.Query().
|
||||
Where(linepoint.Occupied(true), linepoint.CurrentSnEQ(wp.Sn)).First(ctx); e == nil && pt != nil {
|
||||
hasLinePoint, linePointNo = true, pt.PointNo
|
||||
}
|
||||
httpx.Ok(w, map[string]any{
|
||||
"sn": sn, "orderNo": wo.WorkOrderNo, "workOrderId": wo.ID,
|
||||
"productCode": wo.ProductCode, "productName": wo.ProductName,
|
||||
"productSnMode": snMode, "workOrderStatus": wo.Status,
|
||||
"ownershipType": wo.OwnershipType, "ownershipNo": wo.ContractNo,
|
||||
"quantity": wo.Quantity, "flowCombination": wo.FlowCombination,
|
||||
"pieceStatus": wp.Status,
|
||||
"pieceStatus": wp.Status, "hasLinePoint": hasLinePoint, "linePointNo": linePointNo,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,79 @@ func SignPendingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
Page: atoiDefault(q.Get("page"), 1),
|
||||
PageSize: atoiDefault(q.Get("pageSize"), 50),
|
||||
}
|
||||
data, total, err := logic.New(svcCtx).PendingSigns(r.Context(), f)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3302, err.Error())
|
||||
return
|
||||
}
|
||||
data, total, err := logic.New(svcCtx).PendingSigns(r.Context(), f)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3302, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": data, "total": total})
|
||||
}
|
||||
}
|
||||
|
||||
// SignCallHandler POST /api/internal/sign/call 呼叫签字(工位终端)。
|
||||
// 操作工干完活主动呼叫检验员签字:落本工艺需签步骤的 OPERATOR 签字 + 内容指纹。
|
||||
// SignRejectedHandler GET /api/v1/signs/rejected 近 N 天已判 NG 记录(P2-3 检验员回看,只读)。
|
||||
func SignRejectedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
days := atoiDefault(r.URL.Query().Get("days"), 7)
|
||||
list, err := logic.New(svcCtx).SignRejected(r.Context(), logic.SignRejectedFilter{Days: days})
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3303, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": list, "total": len(list)})
|
||||
}
|
||||
}
|
||||
|
||||
func WorkSignCallHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.CallSignReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
result, err := logic.New(svcCtx).CallSign(r.Context(), req, operator(r, req.Operator))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3305, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, result)
|
||||
}
|
||||
}
|
||||
|
||||
// SignRevokeHandler POST /api/internal/sign/revoke 撤回呼叫(工位终端):本轮签字整轮作废。
|
||||
func WorkSignRevokeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.RevokeSignReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).RevokeSign(r.Context(), req, operator(r, req.Operator)); err != nil {
|
||||
httpx.Fail(w, 3306, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "已撤回签字,可整改后重新呼叫", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// SignStatusHandler GET /api/internal/sign/status 签字状态查询(工位终端):三档状态从签字记录推导。
|
||||
func WorkSignStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
sn, stationNo, orderNo := q.Get("sn"), q.Get("stationNo"), q.Get("orderNo")
|
||||
flowId := atoiDefault(q.Get("flowId"), 0)
|
||||
vo, err := logic.New(svcCtx).SignStatus(r.Context(), logic.SignStatusReq{
|
||||
Sn: sn, OrderNo: orderNo, FlowId: flowId, StationNo: stationNo,
|
||||
})
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3307, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, vo)
|
||||
}
|
||||
}
|
||||
|
||||
// AuditorSignHandler 审核人复核签字(工艺级审核 gate,工艺配置 needAudit 决定)。
|
||||
func AuditorSignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -79,4 +143,3 @@ func AuditPendingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.Ok(w, map[string]any{"list": data, "total": total})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ var stationEventTypes = map[string]bool{
|
||||
"station.workpiece": true, // 工件到位落实(2026-11-25)
|
||||
"station.points": true, // 点位台账占位/释放(2026-11-25)
|
||||
"station.state": true, // 停单/恢复接单(2026-11-25)
|
||||
"station.material": true, // 叫料/退料/AGV 流水刷新(2026-11-28 Q2/Q3)
|
||||
"station.sign": true, // 检验员签字 OK/NG(2026-11-30 P0-2:终端即时拉签字状态)
|
||||
}
|
||||
|
||||
func StationAlertsStreamHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
@@ -326,6 +326,27 @@ func UpdateWorkOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateWorkOrderFlowHandler PUT /api/v1/work-orders/flow
|
||||
// 2026-11-30:列表「工艺工位」独立入口专用——只保存这张工单的工艺工位(路线快照),
|
||||
// 不动归属/数量等字段,不走退料转产连锁;功能与原来建单弹窗里的「工艺工位」一致。
|
||||
func UpdateWorkOrderFlowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Id int `json:"id"`
|
||||
FlowCombination []map[string]int `json:"flowCombination"`
|
||||
}
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).UpdateWorkOrderFlow(r.Context(), req.Id, req.FlowCombination, operator(r, "")); err != nil {
|
||||
httpx.FailErr(w, err)
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "工艺工位已保存", nil)
|
||||
}
|
||||
}
|
||||
|
||||
func GetWorkOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
wo, err := logic.New(svcCtx).GetWorkOrder(r.Context(), pathID(r))
|
||||
|
||||
@@ -135,8 +135,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodGet, Path: "/api/internal/station/return-list", Handler: internal(production.StationSessionAuth(serverCtx)(StationReturnListInternalHandler(serverCtx))),
|
||||
})
|
||||
// 2026-11-28 Q10:退料派车权收归库管——WMS 库管确认接驳台有料后调本端点下发 AGV。
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/return-order/retry-dispatch", Handler: internal(production.StationSessionAuth(serverCtx)(RetryReturnDispatchInternalHandler(serverCtx))),
|
||||
Method: http.MethodPost, Path: "/api/internal/return-order/dispatch-by-warehouse", Handler: internal(DispatchReturnByWarehouseHandler(serverCtx)),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/station/return-cancel", Handler: internal(production.StationSessionAuth(serverCtx)(StationReturnCancelInternalHandler(serverCtx))),
|
||||
@@ -298,6 +299,16 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/call/return", Handler: internal(production.StationSessionAuth(serverCtx)(production.ReturnCallHandler(serverCtx))),
|
||||
})
|
||||
// 签字循环(2026-11-30 重构):呼叫签字/撤回/状态查询(工位终端,会话鉴权)
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/sign/call", Handler: internal(production.StationSessionAuth(serverCtx)(production.WorkSignCallHandler(serverCtx))),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/sign/revoke", Handler: internal(production.StationSessionAuth(serverCtx)(production.WorkSignRevokeHandler(serverCtx))),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodGet, Path: "/api/internal/sign/status", Handler: internal(production.StationSessionAuth(serverCtx)(production.WorkSignStatusHandler(serverCtx))),
|
||||
})
|
||||
// 仓库端点:完成备料/驳回/确认收回(WMS 后端以 X-API-TOKEN 调用)
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/call/complete", Handler: internal(production.CompleteCallHandler(serverCtx)),
|
||||
@@ -308,6 +319,12 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/call/return-confirm", Handler: internal(production.ConfirmReturnHandler(serverCtx)),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/call/station-return-accum", Handler: internal(production.StationReturnedAccumHandler(serverCtx)),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/call/station-return-adjust", Handler: internal(production.StationReturnedAdjustHandler(serverCtx)),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/call/return-adjust", Handler: internal(production.ReturnAdjustHandler(serverCtx)),
|
||||
})
|
||||
@@ -387,6 +404,8 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/work-orders", Handler: production.ListWorkOrdersHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/work-orders", Handler: production.CreateWorkOrderHandler(serverCtx)},
|
||||
{Method: http.MethodPut, Path: "/work-orders", Handler: production.UpdateWorkOrderHandler(serverCtx)},
|
||||
// 工艺工位独立入口(2026-11-30):只保存路线快照,不改其它字段
|
||||
{Method: http.MethodPut, Path: "/work-orders/flow", Handler: production.UpdateWorkOrderFlowHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/work-orders/status", Handler: production.SetWorkOrderStatusHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/work-orders/for-schedule", Handler: production.ForScheduleWorkOrdersHandler(serverCtx)},
|
||||
// 强制完工(方案 A,2026-10-20):核对单预览 + 执行(原因必填、在制>0 拒绝)
|
||||
@@ -517,6 +536,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
// ---------- 签字机制(需求B):操作工报工签字随 /workpiece/report 落库;检验员签字为独立动作 ----------
|
||||
{Method: http.MethodPost, Path: "/signs/inspector", Handler: production.InspectorSignHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/signs/pending", Handler: production.SignPendingHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/signs/rejected", Handler: production.SignRejectedHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/signs/auditor", Handler: production.AuditorSignHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/signs/audit-pending", Handler: production.AuditPendingHandler(serverCtx)},
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ package handler
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"strings"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
@@ -61,22 +61,23 @@ func StationQtyReportInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFun
|
||||
|
||||
// StationReturnMaterialInternalHandler POST /api/internal/station/return-material
|
||||
// 工位退料回库房:落事件日志 + 调 WMS 预建待确认退库单(WMS 确认收货后库存加回)。
|
||||
// Q10:工位只发起需求,AGV 由库管在 WMS 确认接驳台有料后派车。
|
||||
func StationReturnMaterialInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
OrderNo string `json:"orderNo"`
|
||||
StationNo int `json:"stationNo"`
|
||||
Sn string `json:"sn"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
Spec string `json:"spec"`
|
||||
Qty int `json:"qty"`
|
||||
Unit string `json:"unit"`
|
||||
ReturnDock string `json:"returnDock"`
|
||||
Reason string `json:"reason"`
|
||||
LossReason string `json:"lossReason"` // 2026-11-04 拍板:工位退料损耗原因(巡检退料一律必填,前端校验)
|
||||
TransportMode string `json:"transportMode"` // 2026-11-04 拍板:运输方式 agv/manual(必填;agv=传感器检测到托盘且库房有空位自动派车)
|
||||
ForceConfirm bool `json:"forceConfirm"` // 拍板2 2026-11-04:PLC 离线时前端弹风险提示后人工强行确认
|
||||
OrderNo string `json:"orderNo"`
|
||||
StationNo int `json:"stationNo"`
|
||||
Sn string `json:"sn"`
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
Spec string `json:"spec"`
|
||||
Qty int `json:"qty"`
|
||||
Unit string `json:"unit"`
|
||||
ReturnDock string `json:"returnDock"`
|
||||
PackageNo string `json:"packageNo"`
|
||||
Reason string `json:"reason"`
|
||||
LossReason string `json:"lossReason"` // 2026-11-04 拍板:工位退料损耗原因(巡检退料一律必填,前端校验)
|
||||
TransportMode string `json:"transportMode"` // 必填:agv=库管确认接驳台有料后派车;manual=人工搬运
|
||||
Operator string `json:"operator"`
|
||||
SNList []string `json:"snList"` // 2026-11-28 坑2:序列号件的可退 SN 清单(工位自动推导),WMS 收货逐颗扫码核对
|
||||
}
|
||||
@@ -86,7 +87,7 @@ func StationReturnMaterialInternalHandler(svcCtx *svc.ServiceContext) http.Handl
|
||||
}
|
||||
production.LogImpersonation(svcCtx, r, req.Operator, "/api/internal/station/return-material")
|
||||
result, err := logic.New(svcCtx).StationReturnMaterial(r.Context(), req.OrderNo, req.StationNo, req.Sn,
|
||||
req.MaterialCode, req.MaterialName, req.Spec, req.Reason, production.StationOp(r, req.Operator), req.Unit, req.Qty, req.ReturnDock, req.LossReason, req.TransportMode, req.ForceConfirm, req.SNList)
|
||||
req.MaterialCode, req.MaterialName, req.Spec, req.Reason, production.StationOp(r, req.Operator), req.Unit, req.Qty, req.ReturnDock, req.PackageNo, req.LossReason, req.TransportMode, req.SNList)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2403, err.Error())
|
||||
return
|
||||
@@ -114,9 +115,9 @@ func ReturnableSNsInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// RetryReturnDispatchInternalHandler POST /api/internal/return-order/retry-dispatch
|
||||
// 2026-11-28:退料单派车失败后人工重试——重做接驳台/JBT21 校验并派车,成功后回写派车时间。
|
||||
func RetryReturnDispatchInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
// DispatchReturnByWarehouseHandler POST /api/internal/return-order/dispatch-by-warehouse
|
||||
// 2026-11-28 Q10:库管派车退料单——WMS 确认工位接驳台有料 + JBT21 有空位后调用。
|
||||
func DispatchReturnByWarehouseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ReturnNo string `json:"returnNo"`
|
||||
@@ -127,16 +128,16 @@ func RetryReturnDispatchInternalHandler(svcCtx *svc.ServiceContext) http.Handler
|
||||
httpx.Fail(w, 2403, "退库单号必填")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).RetryReturnDispatch(r.Context(), req.ReturnNo, req.ReturnDock, req.Operator); err != nil {
|
||||
if err := logic.New(svcCtx).DispatchReturnByWarehouse(r.Context(), req.ReturnNo, req.ReturnDock, req.Operator); err != nil {
|
||||
httpx.Fail(w, 2403, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "已重试派车", nil)
|
||||
httpx.OkMessage(w, "退料派车已下发", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// StationReturnListInternalHandler GET /api/internal/station/return-list?stationNo=
|
||||
// 工位终端「我的退料单」列表(PENDING 可取消 / 全部可查),WMS 数据经 MES 转发。
|
||||
// StationReturnListInternalHandler GET /api/internal/station/return-list?stationNo=&page=&pageSize=
|
||||
// 工位终端「我的退料单」列表(WMS SQL 分页转发;PENDING 可取消 / 全部可查)。
|
||||
func StationReturnListInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
stationNo, _ := strconv.Atoi(r.URL.Query().Get("stationNo"))
|
||||
@@ -144,12 +145,24 @@ func StationReturnListInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFu
|
||||
httpx.Fail(w, 2407, "stationNo 必填")
|
||||
return
|
||||
}
|
||||
list, err := logic.New(svcCtx).ListStationReturnOrders(r.Context(), stationNo)
|
||||
page, _ := strconv.Atoi(r.URL.Query().Get("page"))
|
||||
pageSize, _ := strconv.Atoi(r.URL.Query().Get("pageSize"))
|
||||
// 2026-11-29:工位流水按包真分页(pkgMode=1),WMS 数据库层分组+分页。
|
||||
if strings.EqualFold(strings.TrimSpace(r.URL.Query().Get("pkgMode")), "1") {
|
||||
pkgPage, perr := logic.New(svcCtx).ListStationReturnPackages(r.Context(), stationNo, page)
|
||||
if perr != nil {
|
||||
httpx.Fail(w, 2407, perr.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, pkgPage)
|
||||
return
|
||||
}
|
||||
paged, err := logic.New(svcCtx).ListStationReturnOrders(r.Context(), stationNo, page, pageSize)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2407, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": list})
|
||||
httpx.Ok(w, paged)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user