docs: 统一修正全项目“SN管理”相关术语为“序列号”

本次 commit 统一修正了全项目范围内关于 SN 管理的术语表述,将原“SN管理”、“序列号件”、“批次件”等表述调整为“序列号”、“序列号=是”、“序列号=否”,同时同步更新了相关文档、代码注释、前端提示文本、数据库 schema 注释、API 文档等,确保全链路术语统一,消除理解歧义。
This commit is contained in:
SunYF
2026-10-10 15:58:59 +08:00
parent b032f47fc7
commit 8be6e03a15
335 changed files with 5742 additions and 1616 deletions
@@ -434,7 +434,7 @@ func buildWorkOrderCard(ctx context.Context, svcCtx *svc.ServiceContext, workOrd
}
}
// 用料实绩:工单全部 SN 的 workpiece_bind,按 序列号件 / 批次件 分组
// 用料实绩:工单全部 SN 的 workpiece_bind,按 序列号=是 / 序列号=否 分组
wps, _ := client.Workpiece.Query().Where(workpiece.OrderNo(wo.WorkOrderNo)).All(ctx)
sns := make([]string, 0, len(wps))
for _, w := range wps {
@@ -530,7 +530,7 @@ func buildModelWorkOrders(ctx context.Context, svcCtx *svc.ServiceContext, code
}
// ============================================================================
// 物料分组(实绩):序列号件 / 批次件 分离,类型经 WMS manage_mode 补全
// 物料分组(实绩):序列号=是 / 序列号=否 分离,类型经 WMS manage_mode 补全
// ============================================================================
func buildMaterialGroups(ctx context.Context, svcCtx *svc.ServiceContext, binds []*ent.WorkpieceBind) ([]woMaterialSerial, []woMaterialBatch) {
@@ -703,13 +703,13 @@ func manageModeCN(v int) string {
return "-"
}
// snModeCN 物料「序列号」(sn_mode):1序列号件/2批次件(仅作模板函数注册,避免未注册 panic)。
// snModeCN 物料「序列号」(sn_mode):1序列号=是/2序列号=否(仅作模板函数注册,避免未注册 panic)。
func snModeCN(v int) string {
switch v {
case 1:
return "序列号件"
return "序列号=是"
case 2:
return "批次件"
return "序列号=否"
}
return "-"
}
@@ -794,7 +794,7 @@ func renderWorkOrderCard(c *workOrderCard) (string, error) {
<p class="off">暂无工序实绩。</p>
{{end}}
<h2>二、用料清单 · 序列号件(逐件追溯)</h2>
<h2>二、用料清单 · 序列号=是(逐件追溯)</h2>
{{if .SerialMaterials}}
<table>
<thead><tr><th>图号</th><th>名称</th><th>类型</th><th>规格</th><th>单位</th><th>物料SN</th><th>数量</th><th>装配工位</th><th>装配人</th></tr></thead>
@@ -808,10 +808,10 @@ func renderWorkOrderCard(c *workOrderCard) (string, error) {
</tbody>
</table>
{{else}}
<p class="off">暂无序列号件实绩。</p>
<p class="off">暂无序列号=是实绩。</p>
{{end}}
<h2>三、用料清单 · 批次件(按批追溯)</h2>
<h2>三、用料清单 · 序列号=否(按批追溯)</h2>
{{if .BatchMaterials}}
<table>
<thead><tr><th>图号</th><th>名称</th><th>类型</th><th>规格</th><th>单位</th><th>批次号</th><th>数量</th><th>供应商</th><th>装配工位</th><th>装配人</th></tr></thead>
@@ -825,7 +825,7 @@ func renderWorkOrderCard(c *workOrderCard) (string, error) {
</tbody>
</table>
{{else}}
<p class="off">暂无批次件实绩。</p>
<p class="off">暂无序列号=否实绩。</p>
{{end}}
<h2>四、成品明细</h2>
@@ -927,7 +927,7 @@ func renderSnTraceCard(c *snTraceCard) (string, error) {
<p class="off">暂无工序实绩。</p>
{{end}}
<h2>二、用料清单 · 序列号件</h2>
<h2>二、用料清单 · 序列号=是</h2>
{{if .SerialMaterials}}
<table>
<thead><tr><th>图号</th><th>名称</th><th>类型</th><th>规格</th><th>单位</th><th>物料SN</th><th>数量</th><th>装配工位</th><th>装配人</th></tr></thead>
@@ -941,10 +941,10 @@ func renderSnTraceCard(c *snTraceCard) (string, error) {
</tbody>
</table>
{{else}}
<p class="off">暂无序列号件实绩。</p>
<p class="off">暂无序列号=是实绩。</p>
{{end}}
<h2>三、用料清单 · 批次件</h2>
<h2>三、用料清单 · 序列号=否</h2>
{{if .BatchMaterials}}
<table>
<thead><tr><th>图号</th><th>名称</th><th>类型</th><th>规格</th><th>单位</th><th>批次号</th><th>数量</th><th>装配工位</th><th>装配人</th></tr></thead>
@@ -958,7 +958,7 @@ func renderSnTraceCard(c *snTraceCard) (string, error) {
</tbody>
</table>
{{else}}
<p class="off">暂无批次件实绩。</p>
<p class="off">暂无序列号=否实绩。</p>
{{end}}
{{if .TorqueRows}}
@@ -152,3 +152,22 @@ func SetFlowStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
httpx.OkMessage(w, "操作成功", nil)
}
}
// SetStationStatusHandler POST /stations/status(工位启用/停用,对齐 /process-flows/status 模式)
func SetStationStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
Id int `json:"id"`
Status string `json:"status"`
}
if err := httpx.ParseJSON(r, &req); err != nil {
httpx.BadRequest(w, "请求体解析失败")
return
}
if err := logic.New(svcCtx).SetStationStatus(r.Context(), req.Id, req.Status, operator(r, "")); err != nil {
httpx.Fail(w, 2209, err.Error())
return
}
httpx.OkMessage(w, "操作成功", nil)
}
}
@@ -15,14 +15,14 @@ func CreateAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
Name string `json:"name"`
Type string `json:"type"`
Threshold float64 `json:"threshold"`
Receiver string `json:"receiver"`
NotifyChannels string `json:"notifyChannels"`
Enabled bool `json:"enabled"`
}
if err := httpx.ParseJSON(r, &req); err != nil {
httpx.BadRequest(w, "请求体解析失败")
return
}
if err := logic.New(svcCtx).CreateAlertRule(r.Context(), req.Name, req.Type, req.Threshold, req.Receiver, req.Enabled, operator(r, "")); err != nil {
if err := logic.New(svcCtx).CreateAlertRule(r.Context(), req.Name, req.Type, req.NotifyChannels, req.Threshold, req.Enabled, operator(r, "")); err != nil {
httpx.Fail(w, 3301, err.Error())
return
}
@@ -38,14 +38,14 @@ func UpdateAlertRuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
Name string `json:"name"`
Type string `json:"type"`
Threshold float64 `json:"threshold"`
Receiver string `json:"receiver"`
NotifyChannels string `json:"notifyChannels"`
Enabled bool `json:"enabled"`
}
if err := httpx.ParseJSON(r, &req); err != nil {
httpx.BadRequest(w, "请求体解析失败")
return
}
if err := logic.New(svcCtx).UpdateAlertRule(r.Context(), req.Id, req.Name, req.Type, req.Threshold, req.Receiver, req.Enabled); err != nil {
if err := logic.New(svcCtx).UpdateAlertRule(r.Context(), req.Id, req.Name, req.Type, req.NotifyChannels, req.Threshold, req.Enabled); err != nil {
httpx.Fail(w, 3302, err.Error())
return
}
@@ -81,14 +81,15 @@ func ListAlertRulesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
}
// ListAlertsHandler GET /alerts?status=&type=&orderNo=&from=&to=&page=&pageSize=
// 预警消息收件箱:支持 状态/类型/工单号/时间范围(YYYY-MM-DD) 筛选;带 page 返回分页对象,否则返回全量数组(顶部铃铛未读数复用)。
// ListAlertsHandler GET /alerts?status=&type=&level=&orderNo=&from=&to=&page=&pageSize=
// 预警消息收件箱:支持 级别/状态/类型/工单号/时间范围(YYYY-MM-DD) 筛选;带 page 返回分页对象,否则返回全量数组(顶部铃铛未读数复用)。
func ListAlertsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
query := logic.AlertQuery{
Status: q.Get("status"),
Type: q.Get("type"),
Level: q.Get("level"),
OrderNo: q.Get("orderNo"),
From: q.Get("from"),
To: q.Get("to"),
@@ -125,3 +126,48 @@ func MarkAlertReadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
httpx.OkMessage(w, "已标记已读", nil)
}
}
// ResolveAlertHandler POST /alerts/:id/resolve 处置预警(遗留5 告警框架第一阶段):
// 置 READ 并记录处置人(JWT 登录账号)与处置时间,形成处置闭环;重复处置幂等。
func ResolveAlertHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
id := pathID(r)
if id <= 0 {
httpx.Fail(w, 3307, "缺少 id")
return
}
if err := logic.New(svcCtx).ResolveAlert(r.Context(), id, operator(r, "")); err != nil {
httpx.Fail(w, 3307, err.Error())
return
}
httpx.OkMessage(w, "已处置", nil)
}
}
// ListAlertRulesAliasHandler GET /alert-rules 规则列表(GET /alert/rules 的规范别名)
func ListAlertRulesAliasHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return ListAlertRulesHandler(svcCtx)
}
// UpdateAlertRulePathHandler PUT /alert-rules/:id 修改预警规则(PUT /alert/rule 的规范别名,
// body 不含 id、以路径参数为准,其余字段同 PUT /alert/rule)
func UpdateAlertRulePathHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
Name string `json:"name"`
Type string `json:"type"`
Threshold float64 `json:"threshold"`
NotifyChannels string `json:"notifyChannels"`
Enabled bool `json:"enabled"`
}
if err := httpx.ParseJSON(r, &req); err != nil {
httpx.BadRequest(w, "请求体解析失败")
return
}
if err := logic.New(svcCtx).UpdateAlertRule(r.Context(), pathID(r), req.Name, req.Type, req.NotifyChannels, req.Threshold, req.Enabled); err != nil {
httpx.Fail(w, 3302, err.Error())
return
}
httpx.OkMessage(w, "保存成功", nil)
}
}
@@ -2,7 +2,6 @@ package production
import (
"net/http"
"strconv"
"strings"
"bj_power_mes/common/httpx"
@@ -57,8 +56,8 @@ func ListDocksHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
}
// ListDocksMaintHandler GET /docks/maint 接驳台维护页只读分页查询。
// 编码精确 / 名称模糊 / 类型精确 / 状态精确各自独立筛选(真分页在 SQL 层)。
// ListDocksMaintHandler GET /docks/maint 接驳台维护页只读查询(无分页,返回全部点位,按 dockCode 升序)。
// 编码精确 / 名称模糊 / 类型精确 / 状态精确各自独立筛选。
func ListDocksMaintHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
@@ -75,22 +74,7 @@ func ListDocksMaintHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
if status := strings.TrimSpace(q.Get("status")); status != "" {
query = query.Where(dock.StatusEQ(status))
}
total, err := query.Count(r.Context())
if err != nil {
httpx.Fail(w, 3113, "查询接驳台失败:"+err.Error())
return
}
page, _ := strconv.Atoi(q.Get("page"))
if page < 1 {
page = 1
}
size, _ := strconv.Atoi(q.Get("pageSize"))
if size < 1 || size > 200 {
size = 20
}
list, err := query.
Order(ent.Desc(dock.FieldCreatedAt), ent.Desc(dock.FieldID)).
Offset((page - 1) * size).Limit(size).All(r.Context())
list, err := query.Order(dock.ByDockCode()).All(r.Context())
if err != nil {
httpx.Fail(w, 3113, "查询接驳台失败:"+err.Error())
return
@@ -99,7 +83,7 @@ func ListDocksMaintHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
for _, d := range list {
rows = append(rows, dockRowOf(d))
}
httpx.Ok(w, map[string]any{"list": rows, "total": total, "page": page, "pageSize": size})
httpx.Ok(w, rows)
}
}
@@ -15,7 +15,7 @@ import (
// ListMaterialsHandler GET /api/v1/materials 物料下拉(读 MES 本地 materials 副本,需求一 M3/M6)。
// 两库对等的核心收益:WMS 宕机时本接口照常可用。
// 响应 [{code,name,spec,unit,manageMode,snMode}]:manageMode=类型 1结构件/2电气件/3其他(仅分类);
// snMode=是否逐件SN管理 0未选择/1序列号件(录SN)/2批次件(不录SN),行为唯一依据。
// snMode=是否逐件SN管理 0未选择/1序列号=是(录SN)/2序列号=否(不录SN),行为唯一依据。
// 大数据量治理:支持 keyword(图号/名称 模糊,ILIKE)过滤 + limit(默认100、封顶200),
// 避免一次性全量返回造成数据炸弹;下拉框按需远程搜索。
// 本地为空(冷启动)时异步自 WMS 全量拉取补齐(M7),并顺带异步重推 sync_pending 行(M3);
@@ -59,7 +59,7 @@ func ListMaterialsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
// ---------- 备料单 ----------
// GenerateMaterialHandler 按日排产生成备料单(生成前校验 BOM 物料在 WMS 档案存在)
// GenerateMaterialHandler 按日排产生成备料单(生成前校验物料清单物料在 WMS 档案存在)
func GenerateMaterialHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
@@ -10,7 +10,7 @@ import (
)
// MaterialDemandInternalHandler 内部接口:WMS「缺料补货」视图实时拉取排产物料需求量。
// 数据链路:daily_plan → work_order → BOM,按物料汇总未来 N 天需求量。WMS 拿到后自己比本地可用量。
// 数据链路:daily_plan → work_order → 物料清单,按物料汇总未来 N 天需求量。WMS 拿到后自己比本地可用量。
func MaterialDemandInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
days := 0
@@ -209,10 +209,10 @@ func WorkpieceTraceInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
}
}
// orderRow 工单行 + 产品序列号件口径(工位终端上线建档面板分流用)
// orderRow 工单行 + 产品序列号=是口径(工位终端上线建档面板分流用)
type orderRow struct {
*ent.WorkOrder
ProductSnMode int `json:"productSnMode"` // 产品型号/物料档案 sn_mode:0未选择/1序列号件/2批次件
ProductSnMode int `json:"productSnMode"` // 产品型号/物料档案 sn_mode:0未选择/1序列号=是/2序列号=否
}
// OrderQueryInternalHandler GET /api/internal/order/query?orderNo=
@@ -225,7 +225,7 @@ func OrderQueryInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
httpx.Fail(w, 2004, err.Error())
return
}
// 批量取产品编码 → sn_mode,供工位终端上线建档 SN 分流(序列号件扫来料SN/批次件自动发号)
// 批量取产品编码 → sn_mode,供工位终端上线建档 SN 分流(序列号=是扫来料SN/序列号=否自动发号)
codes := make([]string, 0, len(list))
for _, wo := range list {
if wo.ProductCode != "" {
@@ -303,7 +303,7 @@ func DoneWorkpieceInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
// OrderUsageInternalHandler 工单单台用料(工位终端上线位「领料确认」按工单工艺组合的物料清单展示应领料)。
// GET ?orderNo=,返回 []logic.UsageRow。BOM 已删除:用料唯一来源 = 工单工艺组合×工艺物料清单。
// GET ?orderNo=,返回 []logic.UsageRow。物料清单已删除:用料唯一来源 = 工单工艺组合×工艺物料清单。
func OrderUsageInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
data, err := logic.New(svcCtx).GetOrderUsage(r.Context(), r.URL.Query().Get("orderNo"))
@@ -34,14 +34,17 @@ func ListProductTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
// ListProductTypesPageHandler GET /product-types/page 产品型号管理页真分页+搜索
// 响应 {total,list,page,pageSize,wmsOnline}
// 筛选:code/name/spec 独立模糊;manageMode(1结构件/2电气件/3其他)、snMode(1序列号=是/2序列号=否)
// 与 isActive 各自精确。响应 {total,list,page,pageSize,wmsOnline}
func ListProductTypesPageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
page := atoiDefault(q.Get("page"), 1)
pageSize := atoiDefault(q.Get("pageSize"), 20)
total, list, wmsOnline, err := logic.New(svcCtx).ListProductTypesPage(r.Context(),
q.Get("code"), q.Get("name"), q.Get("isActive"), page, pageSize)
q.Get("code"), q.Get("name"), q.Get("spec"),
atoiDefault(q.Get("manageMode"), 0), atoiDefault(q.Get("snMode"), 0),
q.Get("isActive"), page, pageSize)
if err != nil {
httpx.Fail(w, 3001, err.Error())
return
@@ -92,12 +95,35 @@ func DeleteProductTypeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
}
// SetProductTypeStatusHandler POST /product-types/status 物料档案启用/停用专用通道(body {id,isActive})
func SetProductTypeStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
Id int `json:"id"`
IsActive bool `json:"isActive"`
}
if err := httpx.ParseJSON(r, &req); err != nil {
httpx.BadRequest(w, "请求体解析失败")
return
}
if req.Id <= 0 {
httpx.Fail(w, 3014, "缺少 id")
return
}
if err := logic.New(svcCtx).SetProductTypeStatus(r.Context(), req.Id, req.IsActive); err != nil {
httpx.Fail(w, 3014, err.Error())
return
}
httpx.OkMessage(w, "操作成功", nil)
}
}
// ExportProductTypesHandler GET /product-types/export 转发 WMS xlsx 导出
func ExportProductTypesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
b, err := svcCtx.Wms.ExportProductTypes(r.Context(),
q.Get("code"), q.Get("name"), q.Get("isActive"), q.Get("startDate"), q.Get("endDate"))
q.Get("code"), q.Get("name"), q.Get("spec"), q.Get("isActive"), q.Get("startDate"), q.Get("endDate"))
if err != nil {
httpx.Fail(w, 3002, "导出失败(WMS 不可达):"+err.Error())
return
@@ -22,7 +22,7 @@ import (
// ============================================================================
// 工艺路线卡(产品级定义层卡片,2026-10-09 客户裁定恢复)
//
// 定位:回答「这个产品应该怎么做」——产品工艺的路线 + 每道工艺的步骤配置 + BOM + 检验卡项。
// 定位:回答「这个产品应该怎么做」——产品工艺的路线 + 每道工艺的步骤配置 + 物料清单 + 检验卡项。
// 与「生产流程卡」(工单实绩层)分离:本卡只读定义、不复制不落表;工单页不嵌入本卡,
// 工单想看定义层时跳转到「产品工艺」页查看/打印(客户裁定)。
// 端点:GET /api/v1/product-processes/card?id=N 默认可打印 HTML;?format=json 返回结构化数据。
@@ -33,7 +33,6 @@ type ppCardData struct {
ProductCode string `json:"productCode"`
ProductName string `json:"productName"`
StatusCN string `json:"statusCN"`
IsDefault bool `json:"isDefault"`
Remark string `json:"remark"`
GeneratedAt string `json:"generatedAt"`
Items []ppCardItem `json:"items"`
@@ -99,7 +98,7 @@ func buildProductProcessCard(ctx context.Context, svcCtx *svc.ServiceContext, id
card := &ppCardData{
Name: pp.Name, ProductCode: pp.ProductCode, ProductName: pp.ProductName,
StatusCN: map[bool]string{true: "启用", false: "停用"}[pp.Status == "ACTIVE"],
IsDefault: pp.IsDefault, Remark: pp.Remark, GeneratedAt: nowText(),
Remark: pp.Remark, GeneratedAt: nowText(),
Items: []ppCardItem{}, Checks: []ppCardCheck{},
}
items, err := client.ProductProcessItem.Query().
@@ -166,7 +165,7 @@ func buildProductProcessCard(ctx context.Context, svcCtx *svc.ServiceContext, id
})
}
}
// 物料清单(BOM 定义挂在工艺上)
// 物料清单(定义挂在工艺上)
fms, _ := client.FlowMaterial.Query().
Where(flowmaterial.FlowId(it.FlowId)).All(ctx)
for _, m := range fms {
@@ -242,14 +241,13 @@ func renderProductProcessCard(c *ppCardData) (string, error) {
<span>产品编码:<b>{{.ProductCode}}</b></span>
<span>产品名称:<b>{{.ProductName}}</b></span>
<span>状态:<b>{{.StatusCN}}</b></span>
<span>{{if .IsDefault}}<b class="flag">默认路线</b>{{end}}</span>
<span>生成时间:<b>{{.GeneratedAt}}</b></span>
</div>
{{if .Remark}}<div class="meta"><span>备注:<b>{{.Remark}}</b></span></div>{{end}}
<h2>一、工艺路线(按顺序执行)</h2>
<table>
<thead><tr><th>道次</th><th>工艺</th><th>绑定工位</th><th>步骤数</th><th>检验点数</th><th>BOM 条目</th></tr></thead>
<thead><tr><th>道次</th><th>工艺</th><th>绑定工位</th><th>步骤数</th><th>检验点数</th><th>物料清单条目</th></tr></thead>
<tbody>
{{range .Items}}
<tr>
@@ -283,7 +281,7 @@ func renderProductProcessCard(c *ppCardData) (string, error) {
{{else}}<p class="off">该工艺暂无步骤配置。</p>{{end}}
{{end}}
<h2>三、物料清单(BOM 定义)</h2>
<h2>三、物料清单</h2>
{{$hasBom := false}}{{range .Items}}{{if .Bom}}{{$hasBom = true}}{{end}}{{end}}
{{if $hasBom}}
<table>
@@ -298,7 +296,7 @@ func renderProductProcessCard(c *ppCardData) (string, error) {
</tbody>
</table>
{{else}}
<p class="off">各工艺暂无物料清单(BOM 定义在「工艺」页维护)。</p>
<p class="off">各工艺暂无物料清单(在「工艺」页维护)。</p>
{{end}}
<h2>四、检验卡项(需检测确认的步骤汇总)</h2>
@@ -162,6 +162,8 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
{Method: http.MethodGet, Path: "/product-types/export", Handler: production.ExportProductTypesHandler(serverCtx)},
{Method: http.MethodPost, Path: "/product-types", Handler: production.CreateProductTypeHandler(serverCtx)},
{Method: http.MethodPut, Path: "/product-types", Handler: production.UpdateProductTypeHandler(serverCtx)},
// 物料档案启用/停用专用通道(body {id,isActive}):本地置 isActive 并同步 WMS,停用=退出新建下拉
{Method: http.MethodPost, Path: "/product-types/status", Handler: production.SetProductTypeStatusHandler(serverCtx)},
{Method: http.MethodDelete, Path: "/product-types/:id", Handler: production.DeleteProductTypeHandler(serverCtx)},
{Method: http.MethodGet, Path: "/work-orders", Handler: production.ListWorkOrdersHandler(serverCtx)},
@@ -187,7 +189,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
{Method: http.MethodGet, Path: "/material-requests", Handler: production.ListMaterialRequestsHandler(serverCtx)},
// 物料档案(代理 WMS /api/internal/materials,WMS 是物料主数据源;WMS 不可达返回空列表)
{Method: http.MethodGet, Path: "/materials", Handler: production.ListMaterialsHandler(serverCtx)},
// 工单单台用料(BOM 已删除:工单详情页只读汇总 = 工单工艺组合×工艺物料清单)
// 工单单台用料(物料清单已删除:工单详情页只读汇总 = 工单工艺组合×工艺物料清单)
{Method: http.MethodGet, Path: "/order-usage", Handler: production.OrderUsageHandler(serverCtx)},
{Method: http.MethodPost, Path: "/material-requests/receive", Handler: production.ReceiveMaterialRequestHandler(serverCtx)},
{Method: http.MethodPost, Path: "/material-requests/auto-outbound", Handler: production.AutoOutboundHandler(serverCtx)},
@@ -225,12 +227,17 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
{Method: http.MethodGet, Path: "/event-logs", Handler: production.ListEventLogsHandler(serverCtx)},
// ---------- 预警规则 + 预警中心(M10) ----------
// ---------- 预警规则 + 预警中心(M10 / 遗留5 告警框架第一阶段) ----------
{Method: http.MethodPost, Path: "/alert/rule", Handler: production.CreateAlertRuleHandler(serverCtx)},
{Method: http.MethodPut, Path: "/alert/rule", Handler: production.UpdateAlertRuleHandler(serverCtx)},
{Method: http.MethodDelete, Path: "/alert/rule", Handler: production.DeleteAlertRuleHandler(serverCtx)},
{Method: http.MethodGet, Path: "/alert/rules", Handler: production.ListAlertRulesHandler(serverCtx)},
// 规范别名(遗留5):GET /alert-rules、PUT /alert-rules/:id(路径参数携带 id)
{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):置已读并记录处置人/处置时间
{Method: http.MethodPost, Path: "/alerts/:id/resolve", Handler: production.ResolveAlertHandler(serverCtx)},
{Method: http.MethodPost, Path: "/alert/read", Handler: production.MarkAlertReadHandler(serverCtx)},
// ---------- 附件中心(统一存储方案 2026-09-19) ----------
@@ -253,6 +260,7 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
{Method: http.MethodGet, Path: "/files/:y/:m/:d/:t/:f", Handler: FileDeepPathHandler(serverCtx)},
{Method: http.MethodGet, Path: "/stations", Handler: ListStationsHandler(serverCtx)},
{Method: http.MethodPost, Path: "/stations", Handler: SaveStationHandler(serverCtx)},
{Method: http.MethodPost, Path: "/stations/status", Handler: SetStationStatusHandler(serverCtx)},
{Method: http.MethodDelete, Path: "/stations/:id", Handler: DeleteStationHandler(serverCtx)},
// ---------- 产品工艺(2026-10-09 定稿:产品级工艺定义,有序工艺集合不绑工位;建单时推导工位) ----------