refactor: 重构工艺工序相关命名与数据模型

1.  全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2.  重构工单与工件工艺数据模型:
    - 新增工艺组合表flow_material作为备料/齐套唯一源头
    - 新增工位状态表station_state支持自主停单/恢复接单
    - 移除station_process派工表,改用工单工艺组合作为路线唯一源头
    - 替换processCode为flowId作为工艺关联标识
    - 重构工件当前进度字段为currentStationNo
3.  删除冗余的静态备份资源文件
4.  调整物料选择组件默认启用仅显示激活物料
5.  优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
SunYF
2026-09-22 11:32:29 +08:00
parent 932700ca65
commit d609ff8a9e
185 changed files with 8623 additions and 4501 deletions
+27 -27
View File
@@ -34,19 +34,19 @@ func mesRespCode(respBody []byte) string {
}
// processDoneHandler POST /api/report/process-done
// {sn, orderNo, processCode, stationNo, steps:[{stepId,name,value,text}], binds:[{materialCode,bindValue}], operator}
// {sn, orderNo, flowId, stationNo, steps:[{stepId,name,value,text}], binds:[{materialCode,bindValue}], operator}
// 流程:先冲刷一轮积压 → 实时报 MES /api/internal/station/report
// MES 不可达则写入 report_queue(kind=process_done) 并返回 data.queued=true(离线缓存稍后自动重传);
// MES 业务拒绝(HTTP200+code!=0,如装配物料未绑齐/电气件SN重复)直接失败回前端,绝不入离线队。
// binds 为本次工的装机绑定(结构件批次/电气件SN),MES 端落库 + 齐套强校验;离线重传时原样携带。
// binds 为本次工的装机绑定(结构件批次/电气件SN),MES 端落库 + 齐套强校验;离线重传时原样携带。
func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
Sn string `json:"sn"`
OrderNo string `json:"orderNo"`
ProcessCode int `json:"processCode"`
StationNo int `json:"stationNo"`
Steps []struct {
Sn string `json:"sn"`
OrderNo string `json:"orderNo"`
FlowId int `json:"flowId"`
StationNo int `json:"stationNo"`
Steps []struct {
StepId int `json:"stepId"`
Name string `json:"name"`
Value float64 `json:"value"`
@@ -67,8 +67,8 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, "参数错误")
return
}
if req.Sn == "" || req.ProcessCode <= 0 || req.StationNo <= 0 {
fail(w, http.StatusBadRequest, "sn/processCode/stationNo 必填")
if req.Sn == "" || req.FlowId <= 0 || req.StationNo <= 0 {
fail(w, http.StatusBadRequest, "sn/flowId/stationNo 必填")
return
}
@@ -76,12 +76,12 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
ctx.Syncer.RunOnce(r.Context())
body := map[string]any{
"sn": req.Sn,
"orderNo": req.OrderNo,
"processCode": req.ProcessCode,
"stationNo": req.StationNo,
"steps": req.Steps,
"operator": req.Operator,
"sn": req.Sn,
"orderNo": req.OrderNo,
"flowId": req.FlowId,
"stationNo": req.StationNo,
"steps": req.Steps,
"operator": req.Operator,
}
if len(req.Binds) > 0 {
body["binds"] = req.Binds
@@ -95,7 +95,7 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
payloadBytes, _ := json.Marshal(body)
ctx.Store.AddEventLog(req.OrderNo, req.Operator, "process_done",
"工完成上报 sn="+req.Sn+" stationNo="+itoa(req.StationNo)+" processCode="+itoa(req.ProcessCode)+" binds="+itoa(len(req.Binds)))
"工完成上报 sn="+req.Sn+" stationNo="+itoa(req.StationNo)+" flowId="+itoa(req.FlowId)+" binds="+itoa(len(req.Binds)))
respBody, _, err := ctx.Mes.Post("/api/internal/station/report", json.RawMessage(payloadBytes))
if err != nil {
@@ -119,16 +119,16 @@ func processDoneHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
// tempStoreHandler POST /api/report/temp-store
// {sn, orderNo, stationNo, processCode, operator} → 调 MES /api/internal/station/checkin(半成品入库)。
// {sn, orderNo, stationNo, flowId, 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 {
Sn string `json:"sn"`
OrderNo string `json:"orderNo"`
StationNo int `json:"stationNo"`
ProcessCode int `json:"processCode"`
Operator string `json:"operator"`
Sn string `json:"sn"`
OrderNo string `json:"orderNo"`
StationNo int `json:"stationNo"`
FlowId int `json:"flowId"`
Operator string `json:"operator"`
}
if err := parseJSON(r, &req); err != nil {
fail(w, http.StatusBadRequest, "参数错误")
@@ -143,11 +143,11 @@ func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
ctx.Syncer.RunOnce(r.Context())
body := map[string]any{
"sn": req.Sn,
"orderNo": req.OrderNo,
"stationNo": req.StationNo,
"processCode": req.ProcessCode,
"operator": req.Operator,
"sn": req.Sn,
"orderNo": req.OrderNo,
"stationNo": req.StationNo,
"flowId": req.FlowId,
"operator": req.Operator,
}
payloadBytes, _ := json.Marshal(body)