refactor: 重构产线工位与备料流程,移除冗余字段

1. 移除工单、工件、日排产中的冗余工位组合/接驳台字段
2. 新增工位接驳台编码字段与唯一约束,关联WMS接驳台主数据
3. 重构日排产为工位产量分配模式,替代原接驳台列表
4. 新增备料单工位级字段与分批出库支持
5. 移除定时同步可生产数量,改为WMS实时拉取接口
6. 过滤操作日志,排除登录/退出相关日志
7. 调整仪表盘工序展示逻辑为今日派工路线
8. 新增接驳台维护菜单与基础数据
This commit is contained in:
SunYF
2026-09-19 07:50:21 +08:00
parent 543655d441
commit 37f10d3a13
156 changed files with 4489 additions and 1285 deletions
+80 -4
View File
@@ -5,6 +5,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"net/http"
"net/url"
"time"
@@ -343,10 +344,85 @@ type ProducibleDemand struct {
Future5Qty int `json:"future5Qty"`
}
// SyncProducible 推送可生产数量快照 + 未来5天需求到 WMS /api/internal/producible/sync(全量覆盖)。
func (c *Client) SyncProducible(ctx context.Context, items []ProducibleItem, demands []ProducibleDemand) error {
return c.post(ctx, "/api/internal/producible/sync", map[string]any{
"items": items, "demands": demands,
// MaterialTypes 批量查询物料在 WMS 的品类(1原材料/2半成品/3成品/4其他)。
// 供产品物料清单递归展开使用:成品子项需继续向下展开到原材料/外购件。
// WMS 不可达返回 err,由调用方按"全部视为叶子物料"降级(不阻塞产线)。
func (c *Client) MaterialTypes(ctx context.Context, codes []string) (map[string]int, error) {
b, err := json.Marshal(map[string]any{"codes": codes})
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/internal/material/types", bytes.NewReader(b))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-TOKEN", c.token)
resp, err := c.hc.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var body struct {
Code int `json:"code"`
Data struct {
Types map[string]int `json:"types"`
} `json:"data"`
Msg string `json:"message"`
}
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
return nil, err
}
if body.Code != 0 {
if body.Msg != "" {
return nil, errors.New(body.Msg)
}
return nil, errors.New("WMS 查询物料品类失败")
}
if body.Data.Types == nil {
return map[string]int{}, nil
}
return body.Data.Types, nil
}
// DockRow 接驳台主数据行(WMS dock 真源)
type DockRow struct {
DockCode string `json:"dockCode"`
Name string `json:"name"`
DockType string `json:"dockType"`
StationNo int `json:"stationNo"`
HasPallet bool `json:"hasPallet"`
Status string `json:"status"`
}
// ListDocks 拉取 WMS 接驳台主数据列表(MES 工位维护页「送达接驳台」下拉真源)。
// WMS 不可达返回 err,由调用方降级为写死兜底。
func (c *Client) ListDocks(ctx context.Context) ([]DockRow, error) {
var data struct {
List []DockRow `json:"list"`
}
if err := c.get(ctx, "/api/internal/docks", &data); err != nil {
return nil, err
}
return data.List, nil
}
// BackflushItem 反冲单条物料(已含损耗的单件消耗 * 完成件数)
type BackflushItem struct {
MaterialCode string `json:"materialCode"`
Qty int `json:"qty"`
}
// Backflush 调 WMS /api/internal/material/backflush 反冲扣账。
// 物料在该道工序被消耗:报工完成时 MES 算好「工单产品BOM + 当前工序」消耗明细,
// WMS 负责 FIFO 扣库存 + 生成 backflush 出库单。失败返回 err,由调用方降级(仅记日志不阻塞产线)。
func (c *Client) Backflush(ctx context.Context, orderNo string, stationNo, processCode int, operator string, items []BackflushItem) error {
return c.post(ctx, "/api/internal/material/backflush", map[string]any{
"orderNo": orderNo,
"stationNo": stationNo,
"processCode": processCode,
"operator": operator,
"items": items,
})
}