feat: 大屏多订单改为同屏并列展示,物料申请新增跨工位借料来源并移除工单完成日期

This commit is contained in:
SunYF
2026-11-02 19:17:05 +08:00
parent 0c03d32682
commit fd2f0e2767
77 changed files with 1773 additions and 664 deletions
+50 -5
View File
@@ -11,14 +11,19 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"sync"
"time"
)
// Client MES 内部接口客户端
type Client struct {
mu sync.RWMutex
baseURL string
token string
hc *http.Client
// initialBaseURL yaml 启动配置;页面把 MES 地址清空时回退到该值
initialBaseURL string
token string
hc *http.Client
}
func New(baseURL, token string) *Client {
@@ -26,12 +31,51 @@ func New(baseURL, token string) *Client {
baseURL = "http://127.0.0.1:8888"
}
return &Client{
baseURL: baseURL,
token: token,
hc: &http.Client{Timeout: 6 * time.Second},
baseURL: baseURL,
initialBaseURL: baseURL,
token: token,
hc: &http.Client{Timeout: 6 * time.Second},
}
}
// BaseURL 当前生效的 MES 地址(页面可热改,保存即生效)。
func (c *Client) BaseURL() string {
c.mu.RLock()
defer c.mu.RUnlock()
return c.baseURL
}
// SetBaseURL 热更新 MES 地址;传空串回退到 yaml 启动配置。
func (c *Client) SetBaseURL(u string) {
c.mu.Lock()
defer c.mu.Unlock()
u = strings.TrimRight(strings.TrimSpace(u), "/")
if u == "" {
u = c.initialBaseURL
}
c.baseURL = u
}
// Ping 连通性测试:调 MES 内部工单查询接口(轻量、无副作用),HTTP 200 即视为可达。
func (c *Client) Ping(ctx context.Context) error {
u := c.BaseURL() + "/api/internal/order/query?orderNo=__ping__"
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
if err != nil {
return err
}
req.Header.Set("X-API-TOKEN", c.token)
cli := &http.Client{Timeout: 4 * time.Second}
resp, err := cli.Do(req)
if err != nil {
return fmt.Errorf("无法连接 MES(%s):%v", c.BaseURL(), err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("MES 返回非 200(HTTP %d):请检查地址与 token", resp.StatusCode)
}
return nil
}
// MaterialRequest MES 叫料单行(B5:不绑工单/不绑排产;七态状态机)
type MaterialRequest struct {
ID int `json:"id"`
@@ -54,6 +98,7 @@ type MaterialRequest struct {
RejectReason string `json:"rejectReason"`
Operator string `json:"operator"`
CreatedAt string `json:"createdAt"` // RFC3339(MES ent 序列化),大屏叫料池显示 HH:MM 用
BorrowFrom map[string]int `json:"borrowFrom"` // 跨工位借料来源(MES 记账):stationNo→借用量;含本工位自取
}
// ListMaterialRequests 拉取备料单(含 target_dock)