feat(production): 新增排产支撑功能并移除手动报工页面
- 在main.go中更新排产物料需求注释说明,明确WMS与MES系统间交互方式 - 从前端help.js中移除手动报工(helpScan)相关帮助文档 - 更新工艺流程、绩效报表等页面帮助文档中的报工流程说明 - 在主布局中添加排产支撑菜单项并移除手动报工菜单项 - 新增ProducibleSupport.vue组件实现排产支撑页面功能 - 移除Scan.vue手动报工页面组件 - 更新相关帮助文档内容以匹配新的业务流程
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -79,32 +80,25 @@ 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 {
|
||||
// MaterialDemandRow MES 排产物料需求行(按物料汇总,未来 N 天)
|
||||
// WMS「缺料补货」视图拉此数据,对比本地可用库存得出排产缺料量。
|
||||
type MaterialDemandRow struct {
|
||||
MaterialCode string `json:"materialCode"`
|
||||
Future5Qty int `json:"future5Qty"`
|
||||
MaterialName string `json:"materialName"`
|
||||
Unit string `json:"unit"`
|
||||
DemandQty int `json:"demandQty"` // 未来 N 天排产总需求(台数×单台用量,向上取整)
|
||||
StartDate string `json:"startDate"` // 需求窗口起(YYYY-MM-DD)
|
||||
EndDate string `json:"endDate"` // 需求窗口止(YYYY-MM-DD)
|
||||
}
|
||||
|
||||
// ProducibleResult MES /api/internal/producible 返回体
|
||||
type ProducibleResult struct {
|
||||
Items []ProducibleItem `json:"items"`
|
||||
Demands []ProducibleDemand `json:"demands"`
|
||||
ComputedAt int64 `json:"computedAt"`
|
||||
}
|
||||
|
||||
// FetchProducible 实时向 MES 拉取「可生产数量 + 未来5天物料需求」。
|
||||
// FetchMaterialDemand 实时向 MES 拉取「排产物料需求量」(供 WMS 缺料补货视图)。
|
||||
// 两系统之间不做定时/批量同步:WMS 打开页面时按需拉一次,MES 现算现返。
|
||||
func (c *Client) FetchProducible(ctx context.Context) (*ProducibleResult, error) {
|
||||
u := c.baseURL + "/api/internal/producible"
|
||||
// days 不传默认 5(与历史未来5天口径一致);MES 内部 /api/internal/material-demand 支持 ?days 覆盖。
|
||||
func (c *Client) FetchMaterialDemand(ctx context.Context, days int) ([]MaterialDemandRow, error) {
|
||||
u := c.baseURL + "/api/internal/material-demand"
|
||||
if days > 0 {
|
||||
u += "?days=" + strconv.Itoa(days)
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -116,9 +110,9 @@ func (c *Client) FetchProducible(ctx context.Context) (*ProducibleResult, error)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var env struct {
|
||||
Code int `json:"code"`
|
||||
Data ProducibleResult `json:"data"`
|
||||
Msg string `json:"message"`
|
||||
Code int `json:"code"`
|
||||
Data []MaterialDemandRow `json:"data"`
|
||||
Msg string `json:"message"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&env); err != nil {
|
||||
return nil, err
|
||||
@@ -130,7 +124,10 @@ func (c *Client) FetchProducible(ctx context.Context) (*ProducibleResult, error)
|
||||
}
|
||||
return nil, errors.New(msg)
|
||||
}
|
||||
return &env.Data, nil
|
||||
if env.Data == nil {
|
||||
return []MaterialDemandRow{}, nil
|
||||
}
|
||||
return env.Data, nil
|
||||
}
|
||||
|
||||
// DockRow MES 接驳台主数据行(dock 真源已迁 MES,WMS 仅只读取用)。
|
||||
|
||||
Reference in New Issue
Block a user