Files
bj_power/bj_power_workstation/internal/handler/routes.go
T
SunYF 1d1dc1bdd8 按模块说明
一、MES — 叫料单扩展(schema + 逻辑)​

material_request 新增字段:packageNo(叫料包号,一次提交=一包)、callDate(叫料日,默认当天)、planBreakdown(jsonb,工单×排产日明细 []CallPlanBreakdown);targetDock 语义降级为"期望接驳台(可空,配送时 WMS 确定实际台)"。
新增 internal/logic/call_plan.go:实时计算「叫料需求明细(工单×排产日×物料)」,派生两类提示(当日剩余未叫 / 跨日量明细),不落库、不拦提交;接驳台空台校验 EnsureStationDocksEmpty、托盘回库 DispatchPalletReturnManual、人工清台 ClearDockLedger、配送单派车 DispatchDeliveryAgv、工位物料明细 StationMaterialDetail。
新增 internal/handler/production/call_pkg.go:8 个 MES 内部端点(X-API-TOKEN 网关),供 WMS 调用——叫料需求明细、按包查单、接驳台状态、托盘回库、人工清台、配送单派车、叫料池原始行、工位物料明细、WMS 代叫料。
internal/handler/production/call.go、internal/logic/call.go、agv.go、qty_report.go、routes_production.go、wmsclient/client.go、db.go 同步接入上述逻辑。
二、WMS — 配送单(新功能,叫料与送料彻底拆开)​

新增 schema/delivery_order.go + delivery_order_item.go 及 ent 生成代码:delivery_order(PENDING→DISPATCHED→DONE / CANCELLED,一单=一次托盘配送)、delivery_order_item(配送物料明细快照:工单/工艺/排产日)。
新增 internal/handler/delivery.go + 路由 + DeliveryOrders.vue 页面(仓储作业 → 配送单)。
mesclient/client.go 扩展:MES 叫料单结构补 packageNo/callDate/workOrderNo/planBreakdown,新增 PoolRow/DockPalletState/DeliveryAgvItem/getJSON 等。
CallQueue.vue:按叫料包展示,新增「代叫料」「建配送单」按钮与对话框;出库单回写所属配送单号(outbound_order 加字段);AGV 派送改由配送单驱动。
三、工位终端 — 叫料体验升级

MaterialPanel.vue:新增「本工位物料明细」卡(工艺物料全集×工位账四数,量为 0 也显示);叫料改为「叫料包」模式(默认当天、可勾选分批、可选其他排产日、期望接驳台可空),新增叫料日选择器、两条提示横幅(当日剩余未叫 / 跨日量明细)、托盘回库按钮。
InspectPanel.vue/Main.vue/OnlinePanel.vue/OfflinePanel.vue/WorkPanel.vue/SyncQueueDialog.vue/api/index.js/internal/handler/line.go/routes.go 同步接入接驳台状态、托盘回库、下班双台空台校验等。
web/static/index.html 构建刷新。
四、文档

案例.md:重写第 5/6/8/9 节与新「配送单」流程,补「模拟模式跳过接驳台校验」说明,库管员菜单加「配送单」;并修正"本单箱体"等措辞歧义。
客户问题.md:同步本轮拍板口径。
五、构建产物 / 同步

多个 MES 前端页面(.vue)随本次改动统一重新构建刷新;ent 生成代码(MES material_request、WMS delivery_order/outbound_order 相关)随 schema 更新重新生成。
2026-11-05 19:18:18 +08:00

112 lines
7.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package handler
import (
"net/http"
"bj_power_workstation/internal/auth"
"bj_power_workstation/internal/svc"
"github.com/zeromicro/go-zero/rest"
)
func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
// 免鉴权:健康检查 / 登录 / 工位配置
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/health", Handler: healthHandler(ctx)},
{Method: http.MethodPost, Path: "/api/auth/login", Handler: loginHandler(ctx)},
{Method: http.MethodGet, Path: "/api/config", Handler: configHandler(ctx)},
// 工艺文件免鉴权直链(query 传名,支持日期子目录;供 iframe/window.open)
{Method: http.MethodGet, Path: "/pdfview", Handler: pdfViewHandler(ctx)},
// 本机工位报警 SSE(免鉴权:EventSource 无法携带 JWT;数据已按本机工位过滤,LAN 内低敏感)
{Method: http.MethodGet, Path: "/api/alerts/stream", Handler: alertsStreamHandler(ctx)},
// 前端静态托管
{Method: http.MethodGet, Path: "/", Handler: indexHandler(ctx.WebFS)},
{Method: http.MethodGet, Path: "/assets/:file", Handler: assetHandler(ctx.WebFS)},
},
)
// 登录鉴权中间件:白名单 /api/health、/api/auth/login、/api/config、/pdfopen/*
server.Use(auth.Interceptor(ctx.Config.Auth.AccessSecret, ctx.Config.Auth.AccessExpire))
// 业务接口(均需登录 JWT;PDF 代理除外——原样转发文件流)
server.AddRoutes(
[]rest.Route{
// 滑动续签(修订需求):任何人工触屏触发;touch 刷本地空闲计时,
// refresh-token 节流 30 秒换新 MES Bearer,作业中令牌不因固定有效期过期
{Method: http.MethodPost, Path: "/api/auth/touch", Handler: touchHandler(ctx)},
{Method: http.MethodPost, Path: "/api/auth/refresh-token", Handler: refreshTokenHandler(ctx)},
{Method: http.MethodGet, Path: "/api/task/current", Handler: taskCurrentHandler(ctx)},
{Method: http.MethodGet, Path: "/api/bind/panel", Handler: bindPanelHandler(ctx)},
{Method: http.MethodPost, Path: "/api/bind/record", Handler: bindRecordHandler(ctx)},
{Method: http.MethodPost, Path: "/api/bind/remove", Handler: bindRemoveHandler(ctx)},
{Method: http.MethodGet, Path: "/api/workload", Handler: workloadHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stations", Handler: stationsHandler(ctx)},
{Method: http.MethodPost, Path: "/api/station/pause", Handler: stationPauseHandler(ctx)},
{Method: http.MethodGet, Path: "/api/station/state", Handler: stationStateHandler(ctx)},
{Method: http.MethodGet, Path: "/api/pdf", Handler: pdfQueryHandler(ctx)},
{Method: http.MethodGet, Path: "/pdfopen/:name", Handler: pdfOpenHandler(ctx)},
{Method: http.MethodGet, Path: "/api/tightening/list", Handler: tighteningListHandler(ctx)},
{Method: http.MethodPost, Path: "/api/tightening/record", Handler: tighteningRecordHandler(ctx)},
{Method: http.MethodGet, Path: "/api/tightening/live", Handler: tighteningLiveHandler(ctx)},
{Method: http.MethodPost, Path: "/api/tightening/consume", Handler: tighteningConsumeHandler(ctx)},
{Method: http.MethodPost, Path: "/api/report/process-done", Handler: processDoneHandler(ctx)},
{Method: http.MethodPost, Path: "/api/report/temp-store", Handler: tempStoreHandler(ctx)},
// 工件报废/人工取走(2026-11-03 补全):与暂存退库语义互斥,原因必填,不做离线排队
{Method: http.MethodPost, Path: "/api/report/scrap", Handler: scrapHandler(ctx)},
{Method: http.MethodPost, Path: "/api/station/logout", Handler: logoutHandler(ctx)},
{Method: http.MethodPost, Path: "/api/sync/flush", Handler: syncFlushHandler(ctx)},
{Method: http.MethodGet, Path: "/api/sync/stats", Handler: syncStatsHandler(ctx)},
{Method: http.MethodPost, Path: "/api/sync/retry-queue", Handler: syncRetryQueueHandler(ctx)},
// 产线点位 / 叫料(代理 MES 内部 API)
{Method: http.MethodGet, Path: "/api/line/points", Handler: linePointsHandler(ctx)},
{Method: http.MethodPost, Path: "/api/line/occupy", Handler: lineOccupyHandler(ctx)},
// B5 叫料六端点(代理 MES 内部 API):池子/发起/列表/签收/取消/退库申请
{Method: http.MethodGet, Path: "/api/call/pool", Handler: callPoolHandler(ctx)},
{Method: http.MethodGet, Path: "/api/docks", Handler: docksHandler(ctx)},
{Method: http.MethodPost, Path: "/api/call/create", Handler: callCreateHandler(ctx)},
{Method: http.MethodGet, Path: "/api/call/list", Handler: callListHandler(ctx)},
{Method: http.MethodPost, Path: "/api/call/sign", Handler: callSignHandler(ctx)},
{Method: http.MethodPost, Path: "/api/call/cancel", Handler: callCancelHandler(ctx)},
{Method: http.MethodPost, Path: "/api/call/return", Handler: callReturnHandler(ctx)},
// 2026-11-05 叫料包拍板:需求明细(两类提示)/ 左右接驳台实时传感器 / 托盘回库 / 工位物料明细
{Method: http.MethodGet, Path: "/api/call/plan-detail", Handler: callPlanDetailHandler(ctx)},
{Method: http.MethodGet, Path: "/api/dock/station-pallets", Handler: stationDockPalletsHandler(ctx)},
{Method: http.MethodPost, Path: "/api/dock/pallet-return", Handler: palletReturnHandler(ctx)},
{Method: http.MethodGet, Path: "/api/call/material-detail", Handler: materialDetailHandler(ctx)},
// 巡检 / 应急呼叫 / 数量不符 / 退料(代理 MES 内部 API)
{Method: http.MethodPost, Path: "/api/inspection/submit", Handler: inspectionSubmitHandler(ctx)},
{Method: http.MethodPost, Path: "/api/emergency/call", Handler: emergencyCallHandler(ctx)},
{Method: http.MethodPost, Path: "/api/qty-report", Handler: qtyReportHandler(ctx)},
{Method: http.MethodPost, Path: "/api/return-material", Handler: returnMaterialHandler(ctx)},
// 退料单列表/取消/余量参考值(2026-11-04 口径定稿:工位可取消自己 PENDING 退料单)
{Method: http.MethodGet, Path: "/api/return-list", Handler: stationReturnListHandler(ctx)},
{Method: http.MethodPost, Path: "/api/return-cancel", Handler: stationReturnCancelHandler(ctx)},
{Method: http.MethodGet, Path: "/api/return-reference", Handler: stationReturnReferenceHandler(ctx)},
// 下班/结束作业闭环(2026-11-03):查询班次(退出提示)+ 下班提交(自检接驳台剩余物料)
{Method: http.MethodGet, Path: "/api/shift", Handler: shiftGetHandler(ctx)},
{Method: http.MethodPost, Path: "/api/off-duty", Handler: offDutyHandler(ctx)},
{Method: http.MethodPost, Path: "/api/inspection/upload", Handler: inspectionUploadHandler(ctx)},
// 在制品 / 0-13 上下线建档完工 / 物料清单领料 / 追溯(代理 MES 内部 API)
{Method: http.MethodGet, Path: "/api/wip", Handler: wipHandler(ctx)},
{Method: http.MethodGet, Path: "/api/bom", Handler: bomHandler(ctx)},
{Method: http.MethodGet, Path: "/api/order/query", Handler: orderQueryHandler(ctx)},
{Method: http.MethodGet, Path: "/api/trace", Handler: traceHandler(ctx)},
{Method: http.MethodPost, Path: "/api/workpiece/online", Handler: onlineHandler(ctx)},
{Method: http.MethodPost, Path: "/api/workpiece/done", Handler: doneHandler(ctx)},
// 本工位相关报警(谁受影响谁播报,2026-10-20):终端前端轮询 + 语音播报
{Method: http.MethodGet, Path: "/api/alerts/station", Handler: stationAlertsHandler(ctx)},
// PLC↔MES 对账(#8 T2/T3 终端事件驱动检查,不轮询):代理 MES 内部接口,MES 不可达静默跳过
{Method: http.MethodPost, Path: "/api/plc/mismatch/check", Handler: plcMismatchCheckHandler(ctx)},
// 2026-11-03 拍板:MES 公开配置快照(拧紧手填开关/缓存策略/AGV 超时),终端按配置显隐交互
{Method: http.MethodGet, Path: "/api/mes-config", Handler: mesConfigHandler(ctx)},
},
)
}