feat(production): 新增排产支撑功能并移除手动报工页面
- 在main.go中更新排产物料需求注释说明,明确WMS与MES系统间交互方式 - 从前端help.js中移除手动报工(helpScan)相关帮助文档 - 更新工艺流程、绩效报表等页面帮助文档中的报工流程说明 - 在主布局中添加排产支撑菜单项并移除手动报工菜单项 - 新增ProducibleSupport.vue组件实现排产支撑页面功能 - 移除Scan.vue手动报工页面组件 - 更新相关帮助文档内容以匹配新的业务流程
This commit is contained in:
@@ -43,9 +43,6 @@ var pathPermMap = map[string]string{
|
||||
// 列表/预览/下载不设按钮门槛(有菜单权限即可查阅)
|
||||
"POST:/api/v1/attachment/delete": "sys.attachment:manage",
|
||||
"POST:/api/v1/attachment/archive": "sys.attachment:manage",
|
||||
// 装机绑定(报工前扫料/撤销,属报工操作域)
|
||||
"POST:/api/v1/binds": "produce.scan",
|
||||
"POST:/api/v1/binds/remove": "produce.scan",
|
||||
// 账号管理(拆分自原 sys.rbac:user;sys.account 菜单下增/改/删)
|
||||
"POST:/api/v1/users": "sys.account:add",
|
||||
"PUT:/api/v1/users": "sys.account:edit",
|
||||
|
||||
@@ -37,22 +37,6 @@ func doBind(svcCtx *svc.ServiceContext, r *http.Request) (any, error) {
|
||||
return logic.New(svcCtx).BindWorkpiece(r.Context(), req.Sn, req.OrderNo, req.ProcessCode, stationNo, op, req.Items)
|
||||
}
|
||||
|
||||
// BindHandler POST /api/v1/binds —— MES 手动报工页/巡检录绑
|
||||
func BindHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := doBind(svcCtx, r)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3309, err.Error())
|
||||
return
|
||||
}
|
||||
if data == nil {
|
||||
httpx.BadRequest(w, "sn / processCode 必填")
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// BindInternalHandler POST /api/internal/workpiece/binds —— 工位终端扫码绑料
|
||||
func BindInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -83,17 +67,6 @@ func doUnbind(svcCtx *svc.ServiceContext, r *http.Request) error {
|
||||
return logic.New(svcCtx).RemoveBind(r.Context(), req.Sn, req.ProcessCode, req.MaterialCode, req.BindValue, operator(r, req.Operator))
|
||||
}
|
||||
|
||||
// UnbindHandler POST /api/v1/binds/remove —— 撤销误绑(未报工前)
|
||||
func UnbindHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if err := doUnbind(svcCtx, r); err != nil {
|
||||
httpx.Fail(w, 3310, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "已撤销绑定", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// UnbindInternalHandler POST /api/internal/workpiece/binds/remove
|
||||
func UnbindInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -117,23 +90,6 @@ func bindPanelFromReq(svcCtx *svc.ServiceContext, r *http.Request) (any, error)
|
||||
return logic.New(svcCtx).StationBindPanelData(r.Context(), sn, processCode)
|
||||
}
|
||||
|
||||
// BindPanelHandler GET /api/v1/bind-panel?sn=&processCode=
|
||||
// 手动报工页在报工前拉取"本工件本工序应装什么料、已装什么",展示引导并做齐套校验。
|
||||
func BindPanelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := bindPanelFromReq(svcCtx, r)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3308, err.Error())
|
||||
return
|
||||
}
|
||||
if data == nil {
|
||||
httpx.BadRequest(w, "缺少 sn / processCode 参数")
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// BindPanelInternalHandler GET /api/internal/workpiece/bind-panel?sn=&processCode=
|
||||
// 工位终端(12 个触控一体机)扫码工件后拉取绑定面板,驱动工人扫码绑料。
|
||||
func BindPanelInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
@@ -126,24 +126,7 @@ func TorqueStatHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 报工记录 ----------
|
||||
|
||||
// ReportRecordsHandler GET /workpiece/process/records?sn=&orderNo=&stationNo=&page=&pageSize=
|
||||
// 报工记录列表:直查真实报工表 workpiece_process,手动报工与工位终端报工均在此可见(报工闭环)。
|
||||
func ReportRecordsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
data, total, err := logic.New(svcCtx).ListProcessRecords(r.Context(), q.Get("sn"), q.Get("orderNo"),
|
||||
atoiDefault(q.Get("stationNo"), 0), atoiDefault(q.Get("page"), 1), atoiDefault(q.Get("pageSize"), 20))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3206, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": data, "total": total})
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessStepsHandler 查询工位的工序步骤(参数采集模板),供手动报工页动态渲染。
|
||||
// ProcessStepsHandler 查询工位的工序步骤(参数采集模板),供巡检终端等按工位动态渲染。
|
||||
// 按 stationNo 加载该工位启用工艺流程的工序步骤。
|
||||
func ProcessStepsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -2,19 +2,39 @@ package production
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/internal/logic"
|
||||
"bj_power_mes/internal/svc"
|
||||
)
|
||||
|
||||
// ProducibleInternalHandler 内部接口:WMS 打开「可生产数量」时实时拉取。
|
||||
// 不做定时/批量同步——WMS 需要时来拉一次,MES 现算现返(BOM 单台用量在 MES、可用量在 WMS)。
|
||||
func ProducibleInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
// MaterialDemandInternalHandler 内部接口:WMS「缺料补货」视图实时拉取排产物料需求量。
|
||||
// 数据链路:daily_plan → work_order → BOM,按物料汇总未来 N 天需求量。WMS 拿到后自己比本地可用量。
|
||||
func MaterialDemandInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := logic.New(svcCtx).ComputeProducible(r.Context())
|
||||
days := 0
|
||||
if s := r.URL.Query().Get("days"); s != "" {
|
||||
if n, e := strconv.Atoi(s); e == nil {
|
||||
days = n
|
||||
}
|
||||
}
|
||||
res, err := logic.New(svcCtx).ComputeMaterialDemand(r.Context(), days)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3401, err.Error())
|
||||
httpx.Fail(w, 3402, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, res)
|
||||
}
|
||||
}
|
||||
|
||||
// ProducibleSupportHandler 用户态接口:MES「排产支撑」视图。
|
||||
// 返回逐成品可生产套数 + 整体还能满产多少天/支撑到哪天/最先告罄短板物料。
|
||||
func ProducibleSupportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := logic.New(svcCtx).ComputeProducibleSupport(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3403, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, res)
|
||||
|
||||
@@ -31,21 +31,6 @@ func OnlineWorkpieceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func ReportWorkpieceProcessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.ReportProcessReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).ReportProcess(r.Context(), req, operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 3302, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "报工成功", nil)
|
||||
}
|
||||
}
|
||||
|
||||
func DoneWorkpieceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.DoneReq
|
||||
|
||||
@@ -114,9 +114,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/dock/pallet/set", Handler: internal(production.SetDockPalletInternalHandler(serverCtx)),
|
||||
})
|
||||
// 可生产数量:WMS 打开页面时实时拉取(不做定时推送)
|
||||
// 排产物料需求量:WMS「缺料补货」视图实时拉取(?days=N 覆盖窗口,默认5天)
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodGet, Path: "/api/internal/producible", Handler: internal(production.ProducibleInternalHandler(serverCtx)),
|
||||
Method: http.MethodGet, Path: "/api/internal/material-demand", Handler: internal(production.MaterialDemandInternalHandler(serverCtx)),
|
||||
})
|
||||
|
||||
// ---------- 产线点位/移料(供工位终端调用,X-API-TOKEN 保护)----------
|
||||
@@ -196,18 +196,13 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodPost, Path: "/torque/audit", Handler: production.TorqueAuditHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/torque/audit-log", Handler: production.TorqueAuditLogHandler(serverCtx)},
|
||||
|
||||
{Method: http.MethodGet, Path: "/workpiece/process/records", Handler: production.ReportRecordsHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/process-steps", Handler: production.ProcessStepsHandler(serverCtx)},
|
||||
|
||||
{Method: http.MethodPost, Path: "/workpiece/online", Handler: production.OnlineWorkpieceHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/workpiece/process/report", Handler: production.ReportWorkpieceProcessHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/workpiece/done", Handler: production.DoneWorkpieceHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/workpieces", Handler: production.ListWorkpiecesHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/workpieces/in-process", Handler: production.InProcessHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/trace", Handler: production.TraceHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/bind-panel", Handler: production.BindPanelHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/binds", Handler: production.BindHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/binds/remove", Handler: production.UnbindHandler(serverCtx)},
|
||||
|
||||
{Method: http.MethodPost, Path: "/semi/flow", Handler: production.SemiFlowHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/semi/flows", Handler: production.ListSemiFlowsHandler(serverCtx)},
|
||||
@@ -274,6 +269,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/station-process", Handler: production.ListStationProcessHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/station-process/save", Handler: production.SaveStationProcessHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/station-process/route", Handler: production.RouteStationProcessHandler(serverCtx)},
|
||||
|
||||
// ---------- 排产支撑视图(§A2 / §D1):可生产套数 + 支撑天数 + 最先告罄短板物料 ----------
|
||||
{Method: http.MethodGet, Path: "/production/producible-support", Handler: production.ProducibleSupportHandler(serverCtx)},
|
||||
}
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares([]rest.Middleware{permissionGuard(serverCtx)}, jwtRoutes...),
|
||||
|
||||
Reference in New Issue
Block a user