feat: 完成MES工位终端系统全量功能迭代
本次提交包含以下核心变更: 1. 新增按钮级权限控制框架与前端权限校验 2. 新增工位管理、工艺流程、巡检终端等核心业务模块 3. 完善用户体系,支持工位终端专属登录权限 4. 新增文件上传下载、报表查询等配套功能 5. 修复多系统兼容性与交互体验问题 6. 完成所有文档与配置项的规范化更新
This commit is contained in:
@@ -10,24 +10,30 @@ import (
|
||||
)
|
||||
|
||||
// processDoneHandler POST /api/report/process-done
|
||||
// {dockCode, orderNo, sn, processCode, operator}
|
||||
// 流程:先冲刷一轮积压 → 实时报 MES /api/internal/station/done;
|
||||
// {sn, processCode, stationNo, steps:[{stepId,name,value,text}]}
|
||||
// 流程:先冲刷一轮积压 → 实时报 MES /api/internal/station/report;
|
||||
// MES 不可达则写入 report_queue(kind=process_done) 并返回 data.queued=true(离线缓存稍后自动重传)。
|
||||
func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
DockCode string `json:"dockCode"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
Sn string `json:"sn"`
|
||||
ProcessCode string `json:"processCode"`
|
||||
Operator string `json:"operator"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
ProcessCode int `json:"processCode"`
|
||||
StationNo int `json:"stationNo"`
|
||||
Steps []struct {
|
||||
StepId int `json:"stepId"`
|
||||
Name string `json:"name"`
|
||||
Value float64 `json:"value"`
|
||||
Text string `json:"text"`
|
||||
} `json:"steps"`
|
||||
Operator string `json:"operator"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
if req.DockCode == "" {
|
||||
fail(w, http.StatusBadRequest, "缺少 dockCode")
|
||||
if req.Sn == "" || req.ProcessCode <= 0 || req.StationNo <= 0 {
|
||||
fail(w, http.StatusBadRequest, "sn/processCode/stationNo 必填")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -35,18 +41,19 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
ctx.Syncer.RunOnce(r.Context())
|
||||
|
||||
body := map[string]any{
|
||||
"dockCode": req.DockCode,
|
||||
"orderNo": req.OrderNo,
|
||||
"sn": req.Sn,
|
||||
"orderNo": req.OrderNo,
|
||||
"processCode": req.ProcessCode,
|
||||
"stationNo": req.StationNo,
|
||||
"steps": req.Steps,
|
||||
"operator": req.Operator,
|
||||
}
|
||||
payloadBytes, _ := json.Marshal(body)
|
||||
|
||||
ctx.Store.AddEventLog(req.OrderNo, req.Operator, "process_done",
|
||||
"工序完成上报 dockCode="+req.DockCode+" sn="+req.Sn+" processCode="+req.ProcessCode)
|
||||
"工序完成上报 sn="+req.Sn+" stationNo="+itoa(req.StationNo)+" processCode="+itoa(req.ProcessCode))
|
||||
|
||||
if _, _, err := ctx.Mes.Post("/api/internal/station/done", json.RawMessage(payloadBytes)); err != nil {
|
||||
if _, _, err := ctx.Mes.Post("/api/internal/station/report", json.RawMessage(payloadBytes)); err != nil {
|
||||
if qerr := ctx.Store.InsertQueueItem("process_done", string(payloadBytes)); qerr != nil {
|
||||
fail(w, http.StatusInternalServerError, "上报失败且离线队列写入失败:"+qerr.Error())
|
||||
return
|
||||
@@ -61,22 +68,23 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// tempStoreHandler POST /api/report/temp-store
|
||||
// {dockCode, orderNo, sn, operator} → 调 MES /api/internal/station/checkin,
|
||||
// body 附带 type=temp_store;不可达时以同样 payload 写入 report_queue(kind=temp_store)。
|
||||
// {sn, orderNo, stationNo, processCode, operator} → 调 MES /api/internal/station/checkin(半成品入库)。
|
||||
// 不可达时以同样 payload 写入 report_queue(kind=temp_store)。
|
||||
func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
DockCode string `json:"dockCode"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
Sn string `json:"sn"`
|
||||
Operator string `json:"operator"`
|
||||
Sn string `json:"sn"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
StationNo int `json:"stationNo"`
|
||||
ProcessCode int `json:"processCode"`
|
||||
Operator string `json:"operator"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
if req.DockCode == "" {
|
||||
fail(w, http.StatusBadRequest, "缺少 dockCode")
|
||||
if req.Sn == "" {
|
||||
fail(w, http.StatusBadRequest, "缺少 sn")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -84,16 +92,16 @@ func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
ctx.Syncer.RunOnce(r.Context())
|
||||
|
||||
body := map[string]any{
|
||||
"type": "temp_store", // checkin 类型标识:暂存退库
|
||||
"dockCode": req.DockCode,
|
||||
"orderNo": req.OrderNo,
|
||||
"sn": req.Sn,
|
||||
"operator": req.Operator,
|
||||
"sn": req.Sn,
|
||||
"orderNo": req.OrderNo,
|
||||
"stationNo": req.StationNo,
|
||||
"processCode": req.ProcessCode,
|
||||
"operator": req.Operator,
|
||||
}
|
||||
payloadBytes, _ := json.Marshal(body)
|
||||
|
||||
ctx.Store.AddEventLog(req.OrderNo, req.Operator, "temp_store",
|
||||
"暂存/退回库房 dockCode="+req.DockCode+" sn="+req.Sn)
|
||||
"暂存/退回库房 sn="+req.Sn+" stationNo="+itoa(req.StationNo))
|
||||
|
||||
if _, _, err := ctx.Mes.Post("/api/internal/station/checkin", json.RawMessage(payloadBytes)); err != nil {
|
||||
if qerr := ctx.Store.InsertQueueItem("temp_store", string(payloadBytes)); qerr != nil {
|
||||
@@ -107,4 +115,4 @@ func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
ok(w, map[string]any{"queued": false})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user