refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -80,6 +81,49 @@ func stationsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 工位停单/恢复接单(透传 MES 内部 API) ----------
|
||||
|
||||
// stationPauseHandler POST /api/station/pause —— 工人停止接单/恢复接单。
|
||||
// 请求体按定稿契约:{stationNo:number, paused:bool, reason:string};
|
||||
// operator 由本服务补当前登录人(MES 记录操作人,body 多余字段 MES 忽略),响应原样透传。
|
||||
func stationPauseHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
payload, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体读取失败")
|
||||
return
|
||||
}
|
||||
var probe struct {
|
||||
StationNo int `json:"stationNo"`
|
||||
Paused bool `json:"paused"`
|
||||
}
|
||||
_ = json.Unmarshal(payload, &probe)
|
||||
if probe.StationNo <= 0 {
|
||||
fail(w, http.StatusBadRequest, "缺少 stationNo 参数")
|
||||
return
|
||||
}
|
||||
var req map[string]any
|
||||
_ = json.Unmarshal(payload, &req)
|
||||
injectOperator(req, r)
|
||||
body, _ := json.Marshal(req)
|
||||
resp, _, perr := ctx.Mes.Post("/api/internal/station/pause", json.RawMessage(body))
|
||||
mesJSON(w, resp, perr)
|
||||
}
|
||||
}
|
||||
|
||||
// stationStateHandler GET /api/station/state?date=yyyy-MM-dd —— 当天各工位停单状态。
|
||||
// MES 响应 [{stationNo,paused,reason,operator}],原样透传;date 缺省由 MES 取当天。
|
||||
func stationStateHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var params url.Values
|
||||
if d := strings.TrimSpace(r.URL.Query().Get("date")); d != "" {
|
||||
params = url.Values{"date": {d}}
|
||||
}
|
||||
body, _, err := ctx.Mes.Get("/api/internal/station/state", params)
|
||||
mesJSON(w, body, err)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 工艺 PDF 直通代理(含本地预缓存) ----------
|
||||
//
|
||||
// 前端 iframe/window.open 无法携带 Authorization,故提供免 JWT 前缀 /pdfopen/<name>,
|
||||
@@ -202,4 +246,4 @@ func streamBytes(body []byte, w http.ResponseWriter, name, contentType string) {
|
||||
w.Header().Set("X-PDF-Cache", "miss")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write(body)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user