refactor: 重构产线工位与备料流程,移除冗余字段
1. 移除工单、工件、日排产中的冗余工位组合/接驳台字段 2. 新增工位接驳台编码字段与唯一约束,关联WMS接驳台主数据 3. 重构日排产为工位产量分配模式,替代原接驳台列表 4. 新增备料单工位级字段与分批出库支持 5. 移除定时同步可生产数量,改为WMS实时拉取接口 6. 过滤操作日志,排除登录/退出相关日志 7. 调整仪表盘工序展示逻辑为今日派工路线 8. 新增接驳台维护菜单与基础数据
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -78,6 +79,60 @@ func (c *Client) ListMaterialRequests(ctx context.Context, status string) ([]Mat
|
||||
return env.Data, nil
|
||||
}
|
||||
|
||||
// ProducibleItem MES 实时计算的可生产数量行
|
||||
type ProducibleItem struct {
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductName string `json:"productName"`
|
||||
ProducibleQty int `json:"producibleQty"`
|
||||
ShortText string `json:"shortText"`
|
||||
ComputedAt int64 `json:"computedAt"`
|
||||
}
|
||||
|
||||
// ProducibleDemand MES 实时计算的未来5天物料需求行
|
||||
type ProducibleDemand struct {
|
||||
MaterialCode string `json:"materialCode"`
|
||||
Future5Qty int `json:"future5Qty"`
|
||||
}
|
||||
|
||||
// ProducibleResult MES /api/internal/producible 返回体
|
||||
type ProducibleResult struct {
|
||||
Items []ProducibleItem `json:"items"`
|
||||
Demands []ProducibleDemand `json:"demands"`
|
||||
ComputedAt int64 `json:"computedAt"`
|
||||
}
|
||||
|
||||
// FetchProducible 实时向 MES 拉取「可生产数量 + 未来5天物料需求」。
|
||||
// 两系统之间不做定时/批量同步:WMS 打开页面时按需拉一次,MES 现算现返。
|
||||
func (c *Client) FetchProducible(ctx context.Context) (*ProducibleResult, error) {
|
||||
u := c.baseURL + "/api/internal/producible"
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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 env struct {
|
||||
Code int `json:"code"`
|
||||
Data ProducibleResult `json:"data"`
|
||||
Msg string `json:"message"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&env); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if env.Code != 0 {
|
||||
msg := env.Msg
|
||||
if msg == "" {
|
||||
msg = "MES 返回失败"
|
||||
}
|
||||
return nil, errors.New(msg)
|
||||
}
|
||||
return &env.Data, nil
|
||||
}
|
||||
|
||||
// MarkStatus 回写备料单状态(DELIVERING / DONE)
|
||||
func (c *Client) MarkStatus(ctx context.Context, requestNo, status string) error {
|
||||
b, _ := json.Marshal(map[string]string{"requestNo": requestNo, "status": status})
|
||||
|
||||
Reference in New Issue
Block a user