Files
bj_power/bj_power_wms/internal/handler/routes.go
T
SunYF 0ab21b1234 feat&refactor: 完成多模块功能迭代与配置优化
本次提交覆盖多个业务模块的功能完善与体验优化:
1.  **鉴权与配置调整**:
    - 统一JWT滑动续签逻辑,简化Token存储,移除RefreshToken相关冗余代码
    - 调整多项目配置文件中JWT过期时间为3600秒,统一会话闲置窗口
    - 工位配置放开1~12限制,改为仅校验大于0
2.  **术语统一替换**:全链路将"精密件"替换为"电气件",修正物料管理描述
3.  **功能新增**:
    - 新增工位类型、工艺路线与产线点位台账模块
    - 添加工艺PDF预览面板、工位终端代理转发接口
    - 新增操作日志按操作人列表筛选、工位登出日志记录
    - 新增PLC移料指令与产线点位状态管理
4.  **业务流程优化**:
    - 调整BOM物料删除校验逻辑,优化工单备料计算
    - 补充物料图号、检测单号等追溯字段
    - 完善工艺流程图与工位绑定关系说明
    - 优化前端页面文案与交互细节
5.  **代码规范与维护**:
    - 新增通用工具函数与前端静态资源
    - 整理路由权限与中间件逻辑
    - 修复部分接口与配置的不兼容问题
2026-09-10 16:59:15 +08:00

186 lines
9.5 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_wms/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)},
},
)
server.Use(authInterceptor(ctx))
// 当前登录用户(JWT 鉴权)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/user/change-password", Handler: changePasswordHandler(ctx)},
{Method: http.MethodPost, Path: "/api/user/logout", Handler: logoutHandler(ctx)},
{Method: http.MethodGet, Path: "/api/user/info", Handler: userInfoHandler(ctx)},
{Method: http.MethodGet, Path: "/api/user/list", Handler: listUsersHandler(ctx)},
{Method: http.MethodPost, Path: "/api/user/create", Handler: createUserHandler(ctx)},
{Method: http.MethodPost, Path: "/api/user/update", Handler: updateUserHandler(ctx)},
{Method: http.MethodPost, Path: "/api/user/delete", Handler: deleteUserHandler(ctx)},
},
)
// 角色与权限(RBAC 数据化,取代 rbac.go 中的硬编码权限 map
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/rbac/seed", Handler: seedRbacHandler(ctx)},
{Method: http.MethodGet, Path: "/api/roles", Handler: listRolesHandler(ctx)},
{Method: http.MethodGet, Path: "/api/roles/options", Handler: roleOptionsHandler(ctx)},
{Method: http.MethodPost, Path: "/api/roles", Handler: createRoleHandler(ctx)},
{Method: http.MethodPost, Path: "/api/roles/update", Handler: updateRoleHandler(ctx)},
{Method: http.MethodPost, Path: "/api/roles/delete", Handler: deleteRoleHandler(ctx)},
{Method: http.MethodGet, Path: "/api/permissions", Handler: listPermissionsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/event/logs", Handler: eventLogListHandler(ctx)},
},
)
// 物料档案
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/material/create", Handler: createMaterialHandler(ctx)},
{Method: http.MethodPost, Path: "/api/material/update", Handler: updateMaterialHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/query", Handler: queryMaterialsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/list", Handler: listMaterialsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/detail", Handler: getMaterialHandler(ctx)},
{Method: http.MethodGet, Path: "/api/material/export", Handler: exportMaterialsHandler(ctx)},
{Method: http.MethodPost, Path: "/api/material/import", Handler: excelMaterialImportHandler(ctx)},
},
)
// 入库
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/inbound/create", Handler: createInboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inbound/query", Handler: queryInboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inbound/details", Handler: inboundDetailsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inbound/export", Handler: exportInboundHandler(ctx)},
{Method: http.MethodPost, Path: "/api/inbound/batch-excel", Handler: excelInboundHandler(ctx)},
},
)
// 出库(统一主表:备料出库 workorder / 通用出库 general,装箱信息落在同一张表)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/outbound/create", Handler: createOutboundHandler(ctx)},
{Method: http.MethodPost, Path: "/api/outbound/general", Handler: generalOutboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/outbound/query", Handler: queryOutboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/outbound/export", Handler: exportOutboundHandler(ctx)},
},
)
// AGV 配送(海康 RCS 对接:下发/任务列表/状态轮询/接驳台状态)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/agv/submit", Handler: requirePerm(ctx, "agv:manage", submitAgvHandler(ctx))},
{Method: http.MethodGet, Path: "/api/agv/tasks", Handler: requirePerm(ctx, "agv:manage", listAgvTasksHandler(ctx))},
{Method: http.MethodPost, Path: "/api/agv/refresh", Handler: requirePerm(ctx, "agv:manage", refreshAgvHandler(ctx))},
{Method: http.MethodGet, Path: "/api/agv/docks", Handler: requirePerm(ctx, "agv:manage", listDocksHandler(ctx))},
{Method: http.MethodGet, Path: "/api/agv/materials", Handler: requirePerm(ctx, "agv:manage", listAgvMaterialsHandler(ctx))},
},
)
// 库存
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/stock/query", Handler: queryStockHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stock/material-summary", Handler: materialSummaryHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stock/details", Handler: stockDetailsHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stock/export", Handler: exportStockHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stock/zone-summary", Handler: zoneSummaryHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/lock", Handler: lockStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/unlock", Handler: unlockStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/deduct", Handler: deductStockHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stock/check", Handler: checkStockHandler(ctx)},
},
)
// 检验
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/inspection/create", Handler: createInspectionHandler(ctx)},
{Method: http.MethodPost, Path: "/api/inspection/batch-flip", Handler: batchFlipInspectionHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inspection/query", Handler: queryInspectionHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inspection/export", Handler: exportInspectionHandler(ctx)},
{Method: http.MethodGet, Path: "/api/inspection/stats", Handler: statsInspectionHandler(ctx)},
},
)
// 区域
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/zone/create", Handler: createZoneHandler(ctx)},
{Method: http.MethodPost, Path: "/api/zone/update", Handler: updateZoneHandler(ctx)},
{Method: http.MethodGet, Path: "/api/zone/list", Handler: listZonesHandler(ctx)},
{Method: http.MethodGet, Path: "/api/zone/picker", Handler: listZonesForPicker(ctx)},
},
)
// 盘点
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/stocktake/start", Handler: startStocktakeHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stocktake/record", Handler: recordStocktakeHandler(ctx)},
{Method: http.MethodPost, Path: "/api/stocktake/finish", Handler: finishStocktakeHandler(ctx)},
{Method: http.MethodGet, Path: "/api/stocktake/query", Handler: queryStocktakeHandler(ctx)},
},
)
// 半成品
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/semi/inbound", Handler: semiInboundHandler(ctx)},
{Method: http.MethodPost, Path: "/api/semi/outbound", Handler: semiOutboundHandler(ctx)},
{Method: http.MethodGet, Path: "/api/semi/query", Handler: querySemiHandler(ctx)},
},
)
// 工单物料台账(WMS 侧)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/ledger/query", Handler: queryLedgerHandler(ctx)},
{Method: http.MethodGet, Path: "/api/orders", Handler: ordersHandler(ctx)},
},
)
// 大屏展示数据(免登录)
server.AddRoutes(
[]rest.Route{
{Method: http.MethodGet, Path: "/api/display/overview", Handler: internalDisplayHandler(ctx)},
},
)
// 项目间内部 APIX-API-TOKEN 写死 token 保护)
// 与 JWT 侧业务接口同实现,仅供 MES(B)/工位终端(D) 等服务间调用
server.AddRoutes(
[]rest.Route{
{Method: http.MethodPost, Path: "/api/internal/ledger/sync", Handler: wrapInternal(ctx)(ledgerSyncHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/check", Handler: wrapInternal(ctx)(checkStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/lock", Handler: wrapInternal(ctx)(lockStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/unlock", Handler: wrapInternal(ctx)(unlockStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/stock/deduct", Handler: wrapInternal(ctx)(deductStockHandler(ctx))},
{Method: http.MethodGet, Path: "/api/internal/stock/query", Handler: wrapInternal(ctx)(queryStockHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/semi/inbound", Handler: wrapInternal(ctx)(semiInboundHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/semi/outbound", Handler: wrapInternal(ctx)(semiOutboundHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/finished/inbound", Handler: wrapInternal(ctx)(finishedInboundHandler(ctx))},
{Method: http.MethodGet, Path: "/api/internal/product-types", Handler: wrapInternal(ctx)(listProductTypesInternalHandler(ctx))},
{Method: http.MethodGet, Path: "/api/internal/product-types/export", Handler: wrapInternal(ctx)(exportProductTypesInternalHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/product-types", Handler: wrapInternal(ctx)(createProductTypeInternalHandler(ctx))},
{Method: http.MethodPut, Path: "/api/internal/product-types", Handler: wrapInternal(ctx)(updateProductTypeInternalHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/product-types/delete", Handler: wrapInternal(ctx)(deleteProductTypeInternalHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/material/exists", Handler: wrapInternal(ctx)(materialExistsHandler(ctx))},
{Method: http.MethodPost, Path: "/api/internal/dock/pallet-sync", Handler: syncDockPalletHandler(ctx)},
},
)
}