feat: 移除工艺物料与混产模板实体、新增产线清线与 PLC 监控实时推送、看板双屏增强
- 移除实体:MES 删除 FlowMaterial(工艺物料)与 MixProductionTemplate(混产模板)全套(schema/ent 生成码/handler/logic),清理关联路由与种子 - 新增功能:产线清线(line_clearance handler + logic)、PLC 监控 WebSocket 实时推送(ws/plc_monitor_hub + handler) - 看板增强:新增管理屏与 KPI 组件(BoardManage/BoardKpi),调整演示屏 Mock 与各看板面板 - MES 完善:PLC 匹配/扭矩扫描/签收、工艺卡 PDF 与工单、AGV 链路、叫料/备料/在制品/短料预测等逻辑与前端调整 - 工位终端:删除离线面板 OfflinePanel,调整主界面/物料面板与 api/store/handler/路由 - WMS:AGV 托盘、物料与 MES 客户端调整及前端帮助/基础数据/叫料/托盘页 - 文档:更新产线API/客户问题/案例/部署手册/问题记录
This commit is contained in:
@@ -51,7 +51,7 @@ var pathPermMap = map[string]string{
|
||||
// 同步失败台账(2026-11-08):人工重试/标记已处理
|
||||
"POST:/api/v1/sync-failures/retry": "sys.syncfailure:retry",
|
||||
"POST:/api/v1/sync-failures/ignore": "sys.syncfailure:retry",
|
||||
// 过程巡检汇总生成《工序间检验记录》(巡检终端操作域)
|
||||
// 过程巡检汇总生成《工艺间检验记录》(巡检终端操作域)
|
||||
"POST:/api/v1/inspections/generate-inter-process": "sys.inspect:process",
|
||||
// 质量检验处置(过程检/完工检不合格处置 退货/返修/退换):按记录类型在 handler 内做权限粒度校验
|
||||
//(produce.quality:process / produce.quality:final),此处不映射单一码,避免误拦/误放。
|
||||
|
||||
@@ -272,7 +272,7 @@ func renderWorkOrderCardPdf(pdf *gofpdf.Fpdf, c *workOrderCard) {
|
||||
{"实际完成", c.CompletedAt}, {"实际结束", c.ActualFinish}, {"生成时间", c.GeneratedAt},
|
||||
}, 3)
|
||||
|
||||
y = pdfHeading(pdf, y, "一、工序实绩")
|
||||
y = pdfHeading(pdf, y, "一、工艺实绩")
|
||||
widths := []float64{12, 34, 14, 16, 28, 28, 24, 16, 18}
|
||||
rows := [][]string{}
|
||||
for _, s := range c.ProcessSteps {
|
||||
@@ -281,7 +281,7 @@ func renderWorkOrderCardPdf(pdf *gofpdf.Fpdf, c *workOrderCard) {
|
||||
s.ActualStart, s.ActualEnd, s.Operators, s.Status, s.Auditor,
|
||||
})
|
||||
}
|
||||
y = drawTable(pdf, y, widths, []string{"序号", "工序", "工位", "采集", "实绩开始", "实绩结束", "操作人", "状态", "审核人"}, rows)
|
||||
y = drawTable(pdf, y, widths, []string{"序号", "工艺", "工位", "采集", "实绩开始", "实绩结束", "操作人", "状态", "审核人"}, rows)
|
||||
|
||||
y = pdfHeading(pdf, y, "二、用料清单 · 序列号=是(逐件追溯)")
|
||||
swidths := []float64{28, 38, 16, 28, 12, 28, 10, 14, 16}
|
||||
@@ -344,7 +344,7 @@ func renderSnTraceCardPdf(pdf *gofpdf.Fpdf, c *snTraceCard) {
|
||||
{"状态", c.Status}, {"完工时间", c.DoneAt}, {"生成时间", c.GeneratedAt},
|
||||
}, 3)
|
||||
|
||||
y = pdfHeading(pdf, y, "一、工序实绩")
|
||||
y = pdfHeading(pdf, y, "一、工艺实绩")
|
||||
widths := []float64{14, 14, 38, 28, 28, 22, 16, 16}
|
||||
rows := [][]string{}
|
||||
for _, s := range c.Processes {
|
||||
@@ -353,7 +353,7 @@ func renderSnTraceCardPdf(pdf *gofpdf.Fpdf, c *snTraceCard) {
|
||||
s.Operator, s.Status, s.Result,
|
||||
})
|
||||
}
|
||||
y = drawTable(pdf, y, widths, []string{"产线", "工位", "工序", "开始", "结束", "操作人", "状态", "结果"}, rows)
|
||||
y = drawTable(pdf, y, widths, []string{"产线", "工位", "工艺", "开始", "结束", "操作人", "状态", "结果"}, rows)
|
||||
|
||||
y = pdfHeading(pdf, y, "二、用料清单 · 序列号=是")
|
||||
swidths := []float64{28, 38, 16, 28, 12, 28, 10, 14, 16}
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
// 业务定位(客户裁定):
|
||||
// - 客户要的是「生产实绩 / 追溯卡」,工单维度为主卡,成品 SN 维度为追溯子视图,两者都保留。
|
||||
// - 产品型号只是筛选入口(/process-card/by-model 返回该型号下的工单列表),不是独立卡片。
|
||||
// - 定义层(工艺怎么规定)仅用于给出工序清单;实绩层(谁在何时做了什么、用了什么料)才是主内容。
|
||||
// - 定义层(工艺怎么规定)仅用于给出工艺清单;实绩层(谁在何时做了什么、用了什么料)才是主内容。
|
||||
//
|
||||
// 三端点:
|
||||
// GET /api/v1/process-card/workorder?no=WO-xxx 工单生产流程卡(主卡)
|
||||
@@ -380,7 +380,7 @@ func buildWorkOrderCard(ctx context.Context, svcCtx *svc.ServiceContext, workOrd
|
||||
}
|
||||
}
|
||||
|
||||
// 实绩:该工单全部 SN 的 workpiece_process,按 (flow_id, 工序名) 聚合
|
||||
// 实绩:该工单全部 SN 的 workpiece_process,按 (flow_id, 工艺名) 聚合
|
||||
procs, _ := client.WorkpieceProcess.Query().Where(workpieceprocess.OrderNo(wo.WorkOrderNo)).All(ctx)
|
||||
type agg struct {
|
||||
started *time.Time
|
||||
@@ -423,7 +423,7 @@ func buildWorkOrderCard(ctx context.Context, svcCtx *svc.ServiceContext, workOrd
|
||||
card.ActualFinish = lastEnd.Format("2006-01-02 15:04")
|
||||
}
|
||||
|
||||
// 工序签字(工序级):一次加载工单全部签字,按 step_id / role 索引
|
||||
// 工艺签字(工艺级):一次加载工单全部签字,按 step_id / role 索引
|
||||
signs, _ := client.StepSignRecord.Query().Where(stepsignrecord.OrderNo(wo.WorkOrderNo)).All(ctx)
|
||||
signByStep := map[int]map[string][]*ent.StepSignRecord{}
|
||||
for _, s := range signs {
|
||||
@@ -436,7 +436,7 @@ func buildWorkOrderCard(ctx context.Context, svcCtx *svc.ServiceContext, workOrd
|
||||
signByStep[s.StepId][s.SignRole] = append(signByStep[s.StepId][s.SignRole], s)
|
||||
}
|
||||
|
||||
// 组装工序实绩行(并行候选工位模型:按工序聚合,工位列展示该工序的全部候选工位,避免重复渲染)
|
||||
// 组装工艺实绩行(并行候选工位模型:按工艺聚合,工位列展示该工艺的全部候选工位,避免重复渲染)
|
||||
route := logic.GroupFlowRoute(items)
|
||||
for _, fr := range route {
|
||||
for _, s := range stepsByFlow[fr.FlowId] {
|
||||
@@ -466,7 +466,7 @@ func buildWorkOrderCard(ctx context.Context, svcCtx *svc.ServiceContext, workOrd
|
||||
} else {
|
||||
ps.Status = "待开工"
|
||||
}
|
||||
// 该工序的审核人(AUDITOR 最新一条)
|
||||
// 该工艺的审核人(AUDITOR 最新一条)
|
||||
if recs := signByStep[s.ID]["AUDITOR"]; len(recs) > 0 {
|
||||
latest := recs[0]
|
||||
for _, r := range recs {
|
||||
@@ -520,7 +520,7 @@ func buildSnTraceCard(ctx context.Context, svcCtx *svc.ServiceContext, sn string
|
||||
}
|
||||
}
|
||||
|
||||
// 工序实绩(逐条)
|
||||
// 工艺实绩(逐条)
|
||||
procs, _ := client.WorkpieceProcess.Query().
|
||||
Where(workpieceprocess.Sn(sn)).Order(ent.Asc(workpieceprocess.FieldFlowId), ent.Asc(workpieceprocess.FieldID)).All(ctx)
|
||||
for _, p := range procs {
|
||||
@@ -637,7 +637,7 @@ func buildMaterialGroups(ctx context.Context, svcCtx *svc.ServiceContext, binds
|
||||
return serials, batches
|
||||
}
|
||||
|
||||
// summarizeSigns 工序级签字汇总(操作工/检验员/审核人);单据级审核/批准留手签空位。
|
||||
// summarizeSigns 工艺级签字汇总(操作工/检验员/审核人);单据级审核/批准留手签空位。
|
||||
func summarizeSigns(signs []*ent.StepSignRecord) woSignSummary {
|
||||
sum := woSignSummary{}
|
||||
roles := map[string]*woSignRole{}
|
||||
@@ -822,10 +822,10 @@ func renderWorkOrderCard(c *workOrderCard) (string, error) {
|
||||
<span>生成时间:<b>{{.GeneratedAt}}</b></span>
|
||||
</div>
|
||||
|
||||
<h2>一、工序实绩</h2>
|
||||
<h2>一、工艺实绩</h2>
|
||||
{{if .ProcessSteps}}
|
||||
<table>
|
||||
<thead><tr><th>序号</th><th>工序</th><th>采集方式</th><th>工位</th><th>计划工时</th><th>实绩开始</th><th>实绩结束</th><th>操作人</th><th>状态</th><th>审核人</th><th>审核时间</th></tr></thead>
|
||||
<thead><tr><th>序号</th><th>工艺</th><th>采集方式</th><th>工位</th><th>计划工时</th><th>实绩开始</th><th>实绩结束</th><th>操作人</th><th>状态</th><th>审核人</th><th>审核时间</th></tr></thead>
|
||||
<tbody>
|
||||
{{range .ProcessSteps}}
|
||||
<tr>
|
||||
@@ -839,7 +839,7 @@ func renderWorkOrderCard(c *workOrderCard) (string, error) {
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="off">暂无工序实绩。</p>
|
||||
<p class="off">暂无工艺实绩。</p>
|
||||
{{end}}
|
||||
|
||||
<h2>二、用料清单 · 序列号=是(逐件追溯)</h2>
|
||||
@@ -957,10 +957,10 @@ func renderSnTraceCard(c *snTraceCard) (string, error) {
|
||||
<span>生成时间:<b>{{.GeneratedAt}}</b></span>
|
||||
</div>
|
||||
|
||||
<h2>一、工序实绩</h2>
|
||||
<h2>一、工艺实绩</h2>
|
||||
{{if .Processes}}
|
||||
<table>
|
||||
<thead><tr><th>工位</th><th>工序</th><th>开始</th><th>结束</th><th>操作人</th><th>状态</th><th>结果</th></tr></thead>
|
||||
<thead><tr><th>工位</th><th>工艺</th><th>开始</th><th>结束</th><th>操作人</th><th>状态</th><th>结果</th></tr></thead>
|
||||
<tbody>
|
||||
{{range .Processes}}
|
||||
<tr>
|
||||
@@ -972,7 +972,7 @@ func renderSnTraceCard(c *snTraceCard) (string, error) {
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="off">暂无工序实绩。</p>
|
||||
<p class="off">暂无工艺实绩。</p>
|
||||
{{end}}
|
||||
|
||||
<h2>二、用料清单 · 序列号=是</h2>
|
||||
|
||||
@@ -27,7 +27,7 @@ func ListProcessFlowsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// SaveProcessFlowHandler POST /process-flows(新建或更新工艺流程,含工序步骤)
|
||||
// SaveProcessFlowHandler POST /process-flows(新建或更新工艺流程,含工艺步骤)
|
||||
func SaveProcessFlowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.FlowReq
|
||||
|
||||
@@ -165,10 +165,19 @@ func DockListInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
if d.Side == "left" {
|
||||
side = "左"
|
||||
}
|
||||
// 实时传感器状态(2026-11-18 定稿):WMS 托盘工作台选择接驳台时据此提示"传感器未检测到托盘"。
|
||||
// PLC 离线时 sensorOk=false,前端回退看台账 hasPallet 并提示"PLC 离线无法核实"。
|
||||
sensorHas, sensorOk := d.HasPallet, false
|
||||
if svcCtx.PLC != nil && !svcCtx.PLC.IsMock() {
|
||||
if has, e := svcCtx.PLC.Get().QueryDockPallet(r.Context(), d.DockCode); e == nil {
|
||||
sensorHas, sensorOk = has, true
|
||||
}
|
||||
}
|
||||
out = append(out, map[string]any{
|
||||
"dockCode": d.DockCode, "name": d.Name, "dockType": d.DockType,
|
||||
"stationNo": d.StationNo, "side": d.Side, "sideCn": side,
|
||||
"hasPallet": d.HasPallet, "palletRef": d.PalletRef, "status": d.Status,
|
||||
"sensorHasPallet": sensorHas, "sensorOk": sensorOk,
|
||||
})
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": out})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -165,6 +166,18 @@ func ResolveAlertHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ResolveAllAlertsHandler POST /alerts/resolve-all 全部标记为已读(批量处置,记录处置人/时间)。
|
||||
func ResolveAllAlertsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
n, err := logic.New(svcCtx).ResolveAllAlerts(r.Context(), operator(r, ""))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3308, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, fmt.Sprintf("已将 %d 条告警标记为已读", n), map[string]any{"count": n})
|
||||
}
|
||||
}
|
||||
|
||||
// ListAlertRulesAliasHandler GET /alert-rules 规则列表(GET /alert/rules 的规范别名)
|
||||
func ListAlertRulesAliasHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return ListAlertRulesHandler(svcCtx)
|
||||
|
||||
@@ -239,7 +239,7 @@ func syncAgvPointForDock(ctx context.Context, client *ent.Client, d *ent.Dock, n
|
||||
SetEnabled(true).Save(ctx)
|
||||
}
|
||||
|
||||
// SaveDockHandler POST /docks 新增或修改接驳台(id=0 为新增)。
|
||||
// SaveDockHandler POST /docks 修改接驳台(2026-11-18 用户拍板:接驳台与现场实物一一对应,禁止新增)。
|
||||
func SaveDockHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req dockEditReq
|
||||
@@ -247,6 +247,10 @@ func SaveDockHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if req.ID <= 0 {
|
||||
httpx.Fail(w, 3117, "接驳台与现场实物一一对应,不允许新增;现场新增实物后由管理员在数据库登记")
|
||||
return
|
||||
}
|
||||
code, stationNo, ok := validateDock(w, svcCtx, r, req)
|
||||
if !ok {
|
||||
return
|
||||
@@ -257,25 +261,14 @@ func SaveDockHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
if status == "" {
|
||||
status = "ENABLED"
|
||||
}
|
||||
var d *ent.Dock
|
||||
if req.ID > 0 {
|
||||
updated, err := svcCtx.EntClient.Dock.UpdateOneID(req.ID).
|
||||
SetDockCode(code).SetName(name).SetDockType(typ).SetStationNo(stationNo).SetStatus(status).Save(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3115, "修改接驳台失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
d = updated
|
||||
} else {
|
||||
created, err := svcCtx.EntClient.Dock.Create().
|
||||
SetDockCode(code).SetName(name).SetDockType(typ).SetStationNo(stationNo).SetStatus(status).Save(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3115, "新增接驳台失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
d = created
|
||||
updated, err := svcCtx.EntClient.Dock.UpdateOneID(req.ID).
|
||||
SetDockCode(code).SetName(name).SetDockType(typ).SetStationNo(stationNo).SetStatus(status).Save(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3115, "修改接驳台失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
// 新增/修改接驳台 → 强制同步一条强绑定的 AGV 点位(硬件级一一对应闭环)
|
||||
d := updated
|
||||
// 修改接驳台 → 强制同步一条强绑定的 AGV 点位(硬件级一一对应闭环)
|
||||
syncAgvPointForDock(r.Context(), svcCtx.EntClient, d, name)
|
||||
httpx.Ok(w, dockRowOf(d))
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/internal/logic"
|
||||
"bj_power_mes/internal/svc"
|
||||
)
|
||||
|
||||
// ListFlowMaterialsHandler GET /api/v1/process-flows/:id/materials —— 查某工艺的物料清单(flow_material)
|
||||
func ListFlowMaterialsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
flowId := pathID(r)
|
||||
data, err := logic.New(svcCtx).ListFlowMaterials(r.Context(), flowId)
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2113, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, data)
|
||||
}
|
||||
}
|
||||
|
||||
// SaveFlowMaterialsHandler POST /api/v1/process-flows/:id/materials —— 整表覆盖保存工艺物料清单
|
||||
// body: {items: [{materialCode, materialName, spec, unit, snMode, unitQty, lossRate}]}
|
||||
func SaveFlowMaterialsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
flowId := pathID(r)
|
||||
var req struct {
|
||||
Items []logic.FlowMaterialReq `json:"items"`
|
||||
}
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).SaveFlowMaterials(r.Context(), flowId, req.Items, operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 2114, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "工艺物料清单已保存", nil)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/internal/logic"
|
||||
"bj_power_mes/internal/svc"
|
||||
)
|
||||
|
||||
// CheckLineClearanceHandler POST /line/clearance-check
|
||||
// 换绑前的产线五项台账检查(在制工件 / 余料 / 带工件托盘 / PLC 未完成任务 / AGV 在途):
|
||||
// passed=true 表示全清;否则逐项给数量与处理办法,confirmed 为人工逐项确认放行的 key,
|
||||
// 确认放行在 logic 层写 event_log 留痕。空托盘不算占位、不触发提示(2026-11-18 定稿)。
|
||||
func CheckLineClearanceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Confirmed []string `json:"confirmed"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
httpx.BadRequest(w, "参数错误: "+err.Error())
|
||||
return
|
||||
}
|
||||
res, err := logic.New(svcCtx).CheckLineClearance(r.Context(), req.Confirmed, r.Header.Get("X-Username"))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 500, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, res)
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/internal/logic"
|
||||
"bj_power_mes/internal/svc"
|
||||
)
|
||||
|
||||
// ListMixTemplatesHandler GET /mix-templates 混产模板列表(圈定哪几个产品可混线生产,带 isActive)。
|
||||
func ListMixTemplatesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
rows, err := logic.New(svcCtx).ListMixTemplates(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 500, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": rows})
|
||||
}
|
||||
}
|
||||
|
||||
// SaveMixTemplateHandler POST /mix-templates/save 新增/编辑混产模板(圈定哪几个产品可混线生产)。
|
||||
func SaveMixTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Id int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ProductCodes string `json:"productCodes"`
|
||||
Remark string `json:"remark"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
httpx.BadRequest(w, "参数错误: "+err.Error())
|
||||
return
|
||||
}
|
||||
op := r.Header.Get("X-Username")
|
||||
if err := logic.New(svcCtx).SaveMixTemplate(r.Context(), req.Id, req.Name, req.ProductCodes, req.Remark, req.Status, op); err != nil {
|
||||
httpx.Fail(w, 400, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"ok": true})
|
||||
}
|
||||
}
|
||||
|
||||
// SetActiveMixTemplateHandler POST /mix-templates/active 切换「当前产线在用的混产模板」。
|
||||
// 排产/建工单按当前模板校验产品范围,同模板内混产切换才免清线。
|
||||
func SetActiveMixTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
httpx.BadRequest(w, "参数错误: "+err.Error())
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).SetActiveMixTemplate(r.Context(), req.Name, r.Header.Get("X-Username")); err != nil {
|
||||
httpx.Fail(w, 400, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"ok": true})
|
||||
}
|
||||
}
|
||||
|
||||
// CheckLineClearanceHandler POST /mix-templates/clearance-check
|
||||
// 返回结构化「清线确认单」:needClearance=false 表示同模板混产免清线;
|
||||
// 否则给出五项(在制品/余料/托盘/PLC 未完成任务/AGV 在途)实测数量与 passed 结论。
|
||||
// confirmed 为人工逐项确认放行的 key;确认结果在 logic 层写 event_log 留痕。
|
||||
func CheckLineClearanceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
ProductCode string `json:"productCode"`
|
||||
Confirmed []string `json:"confirmed"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
httpx.BadRequest(w, "参数错误: "+err.Error())
|
||||
return
|
||||
}
|
||||
res, err := logic.New(svcCtx).CheckLineClearance(r.Context(),
|
||||
strings.TrimSpace(req.ProductCode), req.Confirmed, r.Header.Get("X-Username"))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 500, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, res)
|
||||
}
|
||||
}
|
||||
@@ -136,36 +136,8 @@ func PlcPositionCorrectHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// PlcEndPointOccupiedHandler GET /plc/monitor/end-points 列出末端下料检测位(G11/G12)占用记录(取件释放用)。
|
||||
func PlcEndPointOccupiedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := logic.New(svcCtx).ListEndPointOccupied(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3310, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.Ok(w, map[string]any{"list": data})
|
||||
}
|
||||
}
|
||||
|
||||
// PlcReleaseEndPointHandler POST /plc/monitor/release-end-point 人工确认末端取件,释放 G11/G12 点位占用。
|
||||
func PlcReleaseEndPointHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.ReleaseEndPointReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).ReleaseEndPoint(r.Context(), req, operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 3311, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "已释放", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// ScanFlowChainHandler POST /plc/flow-scan 手动全线流转扫描:
|
||||
// 与报工后自动连锁(triggerFlowChain)同一套逻辑(送下一工序候选工位 / 缓存策略 / 层层拉入)。
|
||||
// 与报工后自动连锁(triggerFlowChain)同一套逻辑(送下一工艺候选工位 / 缓存策略 / 层层拉入)。
|
||||
func ScanFlowChainHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := logic.New(svcCtx).ScanFlowChain(r.Context(), operator(r, ""))
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package production
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
tokenx "bj_power_mes/common/token"
|
||||
"bj_power_mes/internal/svc"
|
||||
"bj_power_mes/internal/ws"
|
||||
)
|
||||
|
||||
var (
|
||||
plcMonitorHubOnce sync.Once
|
||||
plcMonitorHub *ws.PlcMonitorHub
|
||||
)
|
||||
|
||||
func globalPlcMonitorHub(svcCtx *svc.ServiceContext) *ws.PlcMonitorHub {
|
||||
plcMonitorHubOnce.Do(func() {
|
||||
plcMonitorHub = ws.NewPlcMonitorHub(svcCtx)
|
||||
})
|
||||
return plcMonitorHub
|
||||
}
|
||||
|
||||
// PlcMonitorWsHandler GET /api/v1/plc/monitor/ws?token=<JWT> PLC 点位长连接推送。
|
||||
// 浏览器 WebSocket 无法带 Authorization 头,token 走 query,校验复用 tokenx.Parse(签名+过期),
|
||||
// 与 TodoWsHandler / AgvWsHandler 同模式。本接口只推只读点位快照,不含任何写 PLC 操作。
|
||||
func PlcMonitorWsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tok := strings.TrimSpace(r.URL.Query().Get("token"))
|
||||
if tok == "" {
|
||||
httpx.Unauthorized(w, "缺少登录凭证,请重新登录")
|
||||
return
|
||||
}
|
||||
claims, err := tokenx.Parse(svcCtx.Config.Auth.AccessSecret, tok)
|
||||
if err != nil || claims == nil || claims.ExpiresAt == nil || time.Until(claims.ExpiresAt.Time) <= 0 {
|
||||
httpx.Unauthorized(w, "登录凭证无效或已过期,请重新登录")
|
||||
return
|
||||
}
|
||||
globalPlcMonitorHub(svcCtx).Handle(w, r)
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
// ---------- PLC 工序下发 ----------
|
||||
// ---------- PLC 工艺下发 ----------
|
||||
|
||||
func PlcSendProcessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -188,8 +188,8 @@ func TorqueDispositionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessStepsHandler 查询工位的工序步骤(参数采集模板),供巡检终端等按工位动态渲染。
|
||||
// 按 stationNo 加载该工位启用工艺流程的工序步骤。
|
||||
// ProcessStepsHandler 查询工位的工艺步骤(参数采集模板),供巡检终端等按工位动态渲染。
|
||||
// 按 stationNo 加载该工位启用工艺流程的工艺步骤。
|
||||
func ProcessStepsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
stationNo := atoiDefault(r.URL.Query().Get("stationNo"), 0)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
// ============ 产品 BOM 总账 / 分账(2026-11-13 拍板「总分制」) ============
|
||||
// 总账挂在产品下、分账挂在产品工艺下;P10:物料清单与工艺配置分离、各自独立保存。
|
||||
// 硬校验:Σ分账 = 总账、分账物料是总账子集、分账工序在工艺路线内;改总账会回校已有分账。
|
||||
// 硬校验:Σ分账 = 总账、分账物料是总账子集、分账工艺在工艺路线内;改总账会回校已有分账。
|
||||
|
||||
// ListProductBOMHandler GET /product-boms?productCode= 读取某产品的总账。
|
||||
func ListProductBOMHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
@@ -225,7 +225,7 @@ func OrderQueryInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
orderNo := r.URL.Query().Get("orderNo")
|
||||
keyword := r.URL.Query().Get("keyword")
|
||||
status := r.URL.Query().Get("status")
|
||||
// firstStation(2026-11-16 上线建档下拉专用):>0 时只返回第1道工序候选工位含该工位的工单
|
||||
// firstStation(2026-11-16 上线建档下拉专用):>0 时只返回第1道工艺候选工位含该工位的工单
|
||||
firstStation := 0
|
||||
if n, e := strconv.Atoi(r.URL.Query().Get("stationNo")); e == nil && n > 0 {
|
||||
firstStation = n
|
||||
@@ -266,11 +266,11 @@ func OrderQueryInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
// ---------- 工位终端内部接口(上下线面板 / 在制品展示) ----------
|
||||
|
||||
// InProcessInternalHandler 在制品列表(工位终端「在制品默认展示」/上下线面板)。
|
||||
// GET ?stationNo=(>0=停在该工位)/ ?scope=(pending=待流转 / end-pending=末端待取件)/ ?orderNo=(模糊),返回 {list}。
|
||||
// GET ?stationNo=(>0=停在该工位)/ ?scope=(pending=待流转)/ ?status=SEMI_STORED(半成品)/ ?orderNo=(模糊),返回 {list}。
|
||||
func InProcessInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
stationNo := atoiDefault(r.URL.Query().Get("stationNo"), 0)
|
||||
data, err := logic.New(svcCtx).WorkpiecesInProcess(r.Context(), stationNo, r.URL.Query().Get("orderNo"), r.URL.Query().Get("scope"))
|
||||
data, err := logic.New(svcCtx).WorkpiecesInProcess(r.Context(), stationNo, r.URL.Query().Get("orderNo"), r.URL.Query().Get("scope"), r.URL.Query().Get("status"))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 2006, err.Error())
|
||||
return
|
||||
@@ -301,24 +301,6 @@ func OnlineWorkpieceInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
|
||||
}
|
||||
}
|
||||
|
||||
// DoneWorkpieceInternalHandler 工件完工入库(工位终端下线面板提交)。
|
||||
// POST DoneReq{sn,batchItems,serialItems};完工内部自动回流 WMS 成品库存。
|
||||
func DoneWorkpieceInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.DoneReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
LogImpersonation(svcCtx, r, r.URL.Query().Get("operator"), "/api/internal/workpiece/done")
|
||||
if err := logic.New(svcCtx).DoneWorkpiece(r.Context(), req, StationOp(r, r.URL.Query().Get("operator"))); err != nil {
|
||||
httpx.Fail(w, 2008, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "完工成功", nil)
|
||||
}
|
||||
}
|
||||
|
||||
// WorkpieceLookupInternalHandler GET /api/internal/workpiece/lookup?sn=
|
||||
// 2026-11-16 拍板:建工单时已按数量预生成全部 SN(workpiece.status=NEW,带 order_no/work_order_id),
|
||||
// 工位终端上线建档只需扫 SN 即可秒认工单,不再让工人手选工单。查不到 SN 明确提示,不静默放行。
|
||||
|
||||
@@ -44,7 +44,7 @@ func SignPendingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// AuditorSignHandler 审核人复核签字(工序级审核 gate,工艺配置 needAudit 决定)。
|
||||
// AuditorSignHandler 审核人复核签字(工艺级审核 gate,工艺配置 needAudit 决定)。
|
||||
func AuditorSignHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.AuditorSignReq
|
||||
|
||||
@@ -535,12 +535,12 @@ func SuggestedDockCodesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// InProcessHandler GET /workpieces/in-process 跨天在制品视图(停在各工位未完工工件)
|
||||
// stationNo 可选:>0=停在该工位;scope 可选:pending=待流转 / end-pending=末端待取件;皆不传返回全部。
|
||||
// stationNo 可选:>0=停在该工位;scope 可选:pending=待流转;status 可选:SEMI_STORED=半成品视图;皆不传返回全部在制。
|
||||
// orderNo 可选:按工单号模糊过滤(客户第12条「记录查看加一项看工单号查询」)。
|
||||
func InProcessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
stationNo, _ := strconv.Atoi(r.URL.Query().Get("stationNo"))
|
||||
data, err := logic.New(svcCtx).WorkpiecesInProcess(r.Context(), stationNo, r.URL.Query().Get("orderNo"), r.URL.Query().Get("scope"))
|
||||
data, err := logic.New(svcCtx).WorkpiecesInProcess(r.Context(), stationNo, r.URL.Query().Get("orderNo"), r.URL.Query().Get("scope"), r.URL.Query().Get("status"))
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3001, err.Error())
|
||||
return
|
||||
|
||||
@@ -32,18 +32,20 @@ func OnlineWorkpieceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func DoneWorkpieceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
// ForceCompleteWorkpieceHandler POST /workpieces/force-complete 半成品强行完工(2026-11-18 定稿):
|
||||
// 异常件唯一出路=先「暂存退库」半成品入库,再在「在制品追踪」页半成品处强行完工(管理员显式动作,留痕)。
|
||||
func ForceCompleteWorkpieceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req logic.DoneReq
|
||||
var req logic.ForceCompleteReq
|
||||
if err := httpx.ParseJSON(r, &req); err != nil {
|
||||
httpx.BadRequest(w, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
if err := logic.New(svcCtx).DoneWorkpiece(r.Context(), req, operator(r, "")); err != nil {
|
||||
if err := logic.New(svcCtx).ForceCompleteWorkpiece(r.Context(), req, operator(r, "")); err != nil {
|
||||
httpx.Fail(w, 3303, err.Error())
|
||||
return
|
||||
}
|
||||
httpx.OkMessage(w, "完工成功", nil)
|
||||
httpx.OkMessage(w, "已强行完工", nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ import (
|
||||
|
||||
"bj_power_mes/common/httpx"
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/flowmaterial"
|
||||
"bj_power_mes/ent/material"
|
||||
"bj_power_mes/ent/productbom"
|
||||
"bj_power_mes/ent/productprocessmaterial"
|
||||
"bj_power_mes/ent/processstep"
|
||||
"bj_power_mes/ent/productprocess"
|
||||
"bj_power_mes/ent/productprocessitem"
|
||||
@@ -24,7 +26,7 @@ import (
|
||||
//
|
||||
// 定位:回答「这个产品应该怎么做」——产品工艺的路线 + 每道工艺的步骤配置 + 物料清单 + 检验卡项。
|
||||
// 业务口径(2026-11-06 拍板):工艺路线显示工位号——路线卡表格含「绑定工位」列、
|
||||
// 产品工艺页工序行展示「工位N,N」;注意工单详情抽屉按 2026-10-19 裁定不显示工位列(工位号仅作排序)。
|
||||
// 产品工艺页工艺行展示「工位N,N」;注意工单详情抽屉按 2026-10-19 裁定不显示工位列(工位号仅作排序)。
|
||||
// 与「生产流程卡」(工单实绩层)分离:本卡只读定义、不复制不落表;工单页不嵌入本卡,
|
||||
// 工单想看定义层时跳转到「产品工艺」页查看/打印(客户裁定)。
|
||||
// 端点:GET /api/v1/product-processes/card?id=N 默认可打印 HTML;?format=json 返回结构化数据。
|
||||
@@ -104,6 +106,36 @@ func buildProductProcessCard(ctx context.Context, svcCtx *svc.ServiceContext, id
|
||||
Remark: pp.Remark, GeneratedAt: nowText(),
|
||||
Items: []ppCardItem{}, Checks: []ppCardCheck{},
|
||||
}
|
||||
// 分账 + 物料档案 + 产品总账(2026-11-18 纯分账口径:工艺卡物料列 = 该产品工艺的分账行)
|
||||
allocByFlow := map[int][]*ent.ProductProcessMaterial{}
|
||||
if rows, aerr := client.ProductProcessMaterial.Query().
|
||||
Where(productprocessmaterial.ProductProcessId(id)).All(ctx); aerr == nil {
|
||||
for _, r := range rows {
|
||||
allocByFlow[r.FlowId] = append(allocByFlow[r.FlowId], r)
|
||||
}
|
||||
}
|
||||
codes := []string{}
|
||||
for _, rows := range allocByFlow {
|
||||
for _, r := range rows {
|
||||
codes = append(codes, r.MaterialCode)
|
||||
}
|
||||
}
|
||||
snByCode := map[string]int{}
|
||||
specByCode := map[string]string{}
|
||||
if len(codes) > 0 {
|
||||
if mats, merr := client.Material.Query().Where(material.CodeIn(codes...)).All(ctx); merr == nil {
|
||||
for _, m := range mats {
|
||||
snByCode[m.Code] = m.SnMode
|
||||
specByCode[m.Code] = m.Spec
|
||||
}
|
||||
}
|
||||
}
|
||||
lossByCode := map[string]float64{}
|
||||
if boms, berr := client.ProductBOM.Query().Where(productbom.ProductCode(pp.ProductCode)).All(ctx); berr == nil {
|
||||
for _, b := range boms {
|
||||
lossByCode[b.MaterialCode] = b.LossRate
|
||||
}
|
||||
}
|
||||
items, err := client.ProductProcessItem.Query().
|
||||
Where(productprocessitem.ProductProcessId(id)).
|
||||
Order(ent.Asc(productprocessitem.FieldSeq)).All(ctx)
|
||||
@@ -171,14 +203,12 @@ func buildProductProcessCard(ctx context.Context, svcCtx *svc.ServiceContext, id
|
||||
})
|
||||
}
|
||||
}
|
||||
// 物料清单(定义挂在工艺上)
|
||||
fms, _ := client.FlowMaterial.Query().
|
||||
Where(flowmaterial.FlowId(it.FlowId)).All(ctx)
|
||||
for _, m := range fms {
|
||||
// 物料清单(2026-11-18 纯分账口径:该产品工艺的分账行)
|
||||
for _, m := range allocByFlow[it.FlowId] {
|
||||
row.Bom = append(row.Bom, ppCardBom{
|
||||
MaterialCode: m.MaterialCode, MaterialName: m.MaterialName,
|
||||
Spec: m.Spec, Unit: m.Unit, SnModeCN: snModeCN(m.SnMode),
|
||||
UnitQty: m.UnitQty, LossRate: m.LossRate,
|
||||
Spec: specByCode[m.MaterialCode], Unit: m.Unit, SnModeCN: snModeCN(snByCode[m.MaterialCode]),
|
||||
UnitQty: m.UnitQty, LossRate: lossByCode[m.MaterialCode],
|
||||
})
|
||||
}
|
||||
card.Items = append(card.Items, row)
|
||||
|
||||
@@ -166,9 +166,6 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/workpiece/online", Handler: internal(production.StationSessionAuth(serverCtx)(production.OnlineWorkpieceInternalHandler(serverCtx))),
|
||||
})
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/workpiece/done", Handler: internal(production.StationSessionAuth(serverCtx)(production.DoneWorkpieceInternalHandler(serverCtx))),
|
||||
})
|
||||
// 工件报废/人工取走(工位终端代理,2026-11-03 补全):原因必填、留痕。
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodPost, Path: "/api/internal/workpiece/scrap", Handler: internal(production.StationSessionAuth(serverCtx)(production.ScrapWorkpieceInternalHandler(serverCtx))),
|
||||
@@ -440,10 +437,8 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
// 工件位置核对/纠正(块 E:产线管理页 tab4;MES 记录有、PLC 实际无 → 清为不在工位)
|
||||
{Method: http.MethodGet, Path: "/plc/monitor/position-check", Handler: production.PlcPositionCheckHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/plc/monitor/position-correct", Handler: production.PlcPositionCorrectHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/plc/monitor/end-points", Handler: production.PlcEndPointOccupiedHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/plc/monitor/release-end-point", Handler: production.PlcReleaseEndPointHandler(serverCtx)},
|
||||
// 报工后自动流转连锁(triggerFlowChain,2026-11-11 拍板):手动全线扫描走同一套逻辑
|
||||
// (送下一工序候选工位 / 缓存策略 strict 进缓存位、满仓报警 / 模拟模式闭环)。
|
||||
// (送下一工艺候选工位 / 缓存策略 strict 进缓存位、满仓报警 / 模拟模式闭环)。
|
||||
{Method: http.MethodPost, Path: "/plc/flow-scan", Handler: production.ScanFlowChainHandler(serverCtx)},
|
||||
|
||||
// PLC↔MES 对账检查(#8):终端 T2/T3 单工位(弹终端)、系统 T6/T7 全量 11 位(落预警中心)。事件驱动,禁止定时轮询。
|
||||
@@ -494,7 +489,6 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{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/done", Handler: production.DoneWorkpieceHandler(serverCtx)},
|
||||
// 工件报废/人工取走(2026-11-03 断头路补全):SCRAPPED 唯一写入者,原因必填、留痕;
|
||||
// 与「暂存退库(在制品回库)」语义互斥——报废=永久退出,退库=合法暂停可重上线。
|
||||
{Method: http.MethodPost, Path: "/workpiece/scrap", Handler: production.ScrapWorkpieceHandler(serverCtx)},
|
||||
@@ -504,6 +498,8 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
|
||||
{Method: http.MethodPost, Path: "/semi/flow", Handler: production.SemiFlowHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/semi/flows", Handler: production.ListSemiFlowsHandler(serverCtx)},
|
||||
// 半成品强行完工(2026-11-18 定稿):SEMI_STORED 唯一收口入口,Wip 页行内按钮
|
||||
{Method: http.MethodPost, Path: "/workpieces/force-complete", Handler: production.ForceCompleteWorkpieceHandler(serverCtx)},
|
||||
|
||||
{Method: http.MethodGet, Path: "/event-logs", Handler: production.ListEventLogsHandler(serverCtx)},
|
||||
|
||||
@@ -516,7 +512,8 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/alert-rules", Handler: production.ListAlertRulesAliasHandler(serverCtx)},
|
||||
{Method: http.MethodPut, Path: "/alert-rules/:id", Handler: production.UpdateAlertRulePathHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/alerts", Handler: production.ListAlertsHandler(serverCtx)},
|
||||
// 处置预警(遗留5):置已读并记录处置人/处置时间
|
||||
// 处置预警(遗留5):置已读并记录处置人/处置时间;批量端点放参数路由前,避免被 :id 吞掉
|
||||
{Method: http.MethodPost, Path: "/alerts/resolve-all", Handler: production.ResolveAllAlertsHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/alerts/:id/resolve", Handler: production.ResolveAlertHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/alert/read", Handler: production.MarkAlertReadHandler(serverCtx)},
|
||||
|
||||
@@ -570,7 +567,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodPost, Path: "/product-processes/status", Handler: SetProductProcessStatusHandler(serverCtx)},
|
||||
{Method: http.MethodDelete, Path: "/product-processes/:id", Handler: DeleteProductProcessHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/product-processes/copy", Handler: CopyProductProcessHandler(serverCtx)},
|
||||
// 2026-11-13 拍板「总分制」:产品BOM总账 + 产品工艺把总账物料分配到各工序(分账)
|
||||
// 2026-11-13 拍板「总分制」:产品BOM总账 + 产品工艺把总账物料分配到各工艺(分账)
|
||||
{Method: http.MethodGet, Path: "/product-boms", Handler: production.ListProductBOMHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/product-boms/save", Handler: production.SaveProductBOMHandler(serverCtx)},
|
||||
// 2026-11-17 透明化:一键按新总账重新分配分账(预览可改 + 人工确认,杜绝黑盒)
|
||||
@@ -578,11 +575,8 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodPost, Path: "/product-boms/reallocate", Handler: production.ApplyReallocateHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/product-process-materials", Handler: production.ListProcessAllocationsHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/product-process-materials/save", Handler: production.SaveProcessAllocationsHandler(serverCtx)},
|
||||
// 2026-11-13 拍板:混产模板(多工单多产品混线)+ 模板外新产品的清线门禁
|
||||
{Method: http.MethodGet, Path: "/mix-templates", Handler: production.ListMixTemplatesHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/mix-templates/save", Handler: production.SaveMixTemplateHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/mix-templates/active", Handler: production.SetActiveMixTemplateHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/mix-templates/clearance-check", Handler: production.CheckLineClearanceHandler(serverCtx)},
|
||||
// 2026-11-18 定稿:换绑前清线确认单(产线五项台账检查,空托盘不算占位)
|
||||
{Method: http.MethodPost, Path: "/line/clearance-check", Handler: production.CheckLineClearanceHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/line/points", Handler: ListPointsHandler(serverCtx)},
|
||||
|
||||
// ---------- PAD 巡检终端(块8) ----------
|
||||
@@ -590,7 +584,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/inspections", Handler: ListInspectionsHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/inspections/binds", Handler: InspectionBindsHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/inspections/upload", Handler: UploadPhotoHandler(serverCtx)},
|
||||
// P0-4:一键生成《工序间检验记录》(汇总该工单 PROCESS 类巡检,按步骤维度,附装配物料绑定明细)
|
||||
// P0-4:一键生成《工艺间检验记录》(汇总该工单 PROCESS 类巡检,按步骤维度,附装配物料绑定明细)
|
||||
// ---------- MES 质量检验(过程检/完工检,来料检在 WMS 已做仍落本表) ----------
|
||||
|
||||
{Method: http.MethodGet, Path: "/quality/finished-pending", Handler: FinishedPendingHandler(serverCtx)},
|
||||
@@ -598,9 +592,6 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/quality/unqualified-report", Handler: UnqualifiedReportHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/inspections/generate-inter-process", Handler: GenerateInterProcessInspectionHandler(serverCtx)},
|
||||
|
||||
// ---------- 虚拟工位作业(管理后台,与终端同逻辑;虚拟工位无实体屏,手机/电脑登录操作) ----------
|
||||
{Method: http.MethodGet, Path: "/station/task", Handler: StationTaskAdminHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/station/report", Handler: StationReportAdminHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/workpiece/bind-panel", Handler: production.BindPanelAdminHandler(serverCtx)},
|
||||
|
||||
// ---------- 系统基础设置(系统管理员;保存即生效无需重启) ----------
|
||||
@@ -626,10 +617,6 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
{Method: http.MethodGet, Path: "/process-card/list", Handler: ProcessCardListHandler(serverCtx)},
|
||||
{Method: http.MethodGet, Path: "/process-card/pdf", Handler: WorkOrderCardPdfHandler(serverCtx)},
|
||||
|
||||
// ---------- 工艺物料清单(flow_material,一份工艺定义一份清单) ----------
|
||||
{Method: http.MethodGet, Path: "/process-flows/:id/materials", Handler: production.ListFlowMaterialsHandler(serverCtx)},
|
||||
{Method: http.MethodPost, Path: "/process-flows/:id/materials", Handler: production.SaveFlowMaterialsHandler(serverCtx)},
|
||||
|
||||
// ---------- 排产支撑视图(§A2 / §D1):可生产套数 + 支撑天数 + 最先告罄短板物料 ----------
|
||||
{Method: http.MethodGet, Path: "/production/producible-support", Handler: production.ProducibleSupportHandler(serverCtx)},
|
||||
|
||||
@@ -671,6 +658,12 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
|
||||
Method: http.MethodGet, Path: "/api/v1/agv/ws", Handler: production.AgvWsHandler(serverCtx),
|
||||
}, rest.WithTimeout(3600_000_000_000))
|
||||
|
||||
// ---------- PLC 点位 WebSocket:长连接推送 48 位信号 + MW 在途,免手动刷新 ----------
|
||||
// token 走 query 由 PlcMonitorWsHandler 自校验(同 AgvWs),不挂 WithJwt;放宽超时避免 5s 断连。
|
||||
server.AddRoute(rest.Route{
|
||||
Method: http.MethodGet, Path: "/api/v1/plc/monitor/ws", Handler: production.PlcMonitorWsHandler(serverCtx),
|
||||
}, rest.WithTimeout(3600_000_000_000))
|
||||
|
||||
// ---------- 海康 RCS-Lite SPI 主动回调(文档 2.2.1 任务执行通知 agvCallback) ----------
|
||||
// 注意:RCS 回调不携带我方鉴权头;生产环境必须以防火墙 / IP 白名单隔离该端点(待与 RCS 方确认鉴权方式)。
|
||||
// RCS-Lite 后台需将上层回调地址配置为本端点(路径遵循文档 /xxx/agv/agvCallbackService/agvCallback)。
|
||||
|
||||
@@ -157,16 +157,6 @@ func StationTaskInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// StationTaskAdminHandler GET /station/task?stationNo= 管理后台「虚拟工位作业」页拉取任务(与终端同逻辑)
|
||||
func StationTaskAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return StationTaskInternalHandler(svcCtx)
|
||||
}
|
||||
|
||||
// StationReportAdminHandler POST /station/report 管理后台「虚拟工位作业」报工(与终端同逻辑,operator=登录账号)
|
||||
func StationReportAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return StationReportInternalHandler(svcCtx)
|
||||
}
|
||||
|
||||
// StationReportInternalHandler 工位终端工艺报工(写工位实绩 + 步骤考核)
|
||||
func StationReportInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -251,7 +251,7 @@ func EmergencyCallHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
// GenerateInterProcessInspectionHandler POST /api/v1/inspections/generate-inter-process
|
||||
// 一键生成《工序间检验记录》:汇总该工单 PROCESS 类巡检记录(按步骤维度)。
|
||||
// 一键生成《工艺间检验记录》:汇总该工单 PROCESS 类巡检记录(按步骤维度)。
|
||||
func GenerateInterProcessInspectionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
|
||||
Reference in New Issue
Block a user