【全系统 · 时间权威与鉴权(核心)】 - 新增 clock 包(三端各一份):谁签发 JWT 就以谁的时间验 exp——验签方向签发方取 /api/server-time(30s 缓存,取不到降级本机 + 10min 容差兜底),本端签发用本机时间 - 三端均注册 GET /api/server-time;MES/WMS/终端配同一份「签发方→取时间地址」映射 - 密钥 SHA256 前 8 位指纹日志([鉴权诊断]),现场比对两端指纹秒定位密钥不一致导致的 401「登录已失效」 - token 由 localStorage 改 sessionStorage;登录响应带服务器时间,偏差只提示「时间已自动校正」不拦截 - 现场人工 w32tm 对时操作卡作废(随文档留存,正常部署无需执行) 【WMS · 库存盘点重构】 - 快照粒度改「物料 × 库位」:同物料 A/B 区拆两条各盘各的;扫码命中多行弹库位清单逐库位录入、写回精确定位,行不存在报错不静默跳过 - GET /api/stocktake/active 返回全部进行中单(旧 .First() 只返一条导致历史多单看不见、库存长期冻结);前端加单号下拉切换,刷新保持当前单 - 历史卡死单只走「完成/取消」事务解冻,严禁删库;写回任何一行失败都强提示,不吞错 - 去「全库」,按区域筛选支持选到区/货架/层/号任意层级;「本次盘点范围」同步加筛选、物料按区域过滤;去多余「(可选)」字样 【WMS/MES · 档案删除与停用口径】 - 产品档案新建默认停用(product_process.status ACTIVE→INACTIVE),配齐工艺路线+总账+分账才允许启用 - 产品/物料档案删除按钮统一为一个(按 WMS 做法),仅「无任何引用」可物理删;引用检查覆盖两库、查库报错一律拒绝删除(fail-close,不再误删) - 产品编码自动生成,重复则自增保证唯一;权限对齐:停用走「编辑」、删除走独立「删除」码 - WMS 删物料同步核查 MES 引用,MES 不可达/删除失败则拒绝并落同步失败台账,无兼容补录行 【业务整改】 - MES 工单整体完工自动结算遗留 PENDING 叫料单(释放占用额度);已发货 SHIPPED 不动,仅落日志提示人工签收 - WMS 已收货退库单支持直接修正数量(问题14):原单不动、留痕(修正人/时间/原因/前后值),库存差额补扣,SN 件按最终 SN 集合增删行 - 日排产:「排产日期范围」→「排产日期」;平铺补产品编码/名称;「产品型号」→「产品」去产品编号/名称;平均分摊与每日固定互算;删除写操作日志 - 齐套测算:逐日消耗模拟按实际排产日期;工单详情增「总物料清单」(照搬产品档案总账,实时) - PLC 对账:虚拟/离线工位(OFFLINE,如 15)跳过 PLC 托盘位读取,不再为特例扔给 PLC - AGV 点位锁与回调细节按 11-20 现场整改继续修正(agv.go / agv_point_lock.go) 【文档】 - 新增《全系统业务深坑审计报告》《全系统串联审计报告》《现场对时操作卡》;更新产线API.md、案例.md、问题临时.md(记录甲方逐条原话与验收口径)
115 lines
8.0 KiB
Go
115 lines
8.0 KiB
Go
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.MethodGet, Path: "/api/server-time", Handler: serverTimeHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/auth/login", Handler: loginHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/config", Handler: configHandler(ctx)},
|
||
// 工位选项(免鉴权,登录前调用):未配置工位的终端登录页选择工位用(2026-11-09 拍板)
|
||
{Method: http.MethodGet, Path: "/api/station-options", Handler: stationOptionsHandler(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.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)},
|
||
|
||
// 产线点位 / 叫料(代理 MES 内部 API)
|
||
{Method: http.MethodGet, Path: "/api/line/points", Handler: linePointsHandler(ctx)},
|
||
// 建档前点位传感器实物核对(只读,不触发下流;PLC 读不到时前端降级人工确认)
|
||
{Method: http.MethodGet, Path: "/api/line/point-sensor", Handler: linePointSensorHandler(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-14 用户拍板:停机/不良原因改下拉,代理 MES 唯一真源)
|
||
{Method: http.MethodGet, Path: "/api/dict/reasons", Handler: reasonDictHandler(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)},
|
||
|
||
// 在制品 / 上下线建档 / 物料清单领料 / 追溯(代理 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/order/by-sn", Handler: snOrderLookupHandler(ctx)},
|
||
{Method: http.MethodGet, Path: "/api/trace", Handler: traceHandler(ctx)},
|
||
{Method: http.MethodPost, Path: "/api/workpiece/online", Handler: onlineHandler(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)},
|
||
},
|
||
)
|
||
}
|