docs(deployment): 更新部署手册和业务架构说明
- 更新MES和WMS服务端口配置说明 - 详细说明产线工位设备配置(扫码枪+拧紧枪) - 明确AGV配送和接驳台的模拟模式与真实对接方案 - 更新WMS中AGV配送默认模拟模式说明 - 完善厂内物流(AGV/接驳台)的业务架构约束 - 修订临时文档为详细的项目问题和解决方案规划
This commit is contained in:
@@ -572,6 +572,57 @@ func (c *Client) LedgerProgress(ctx context.Context, orderNo, materialCode strin
|
||||
return out.List, out.Total, nil
|
||||
}
|
||||
|
||||
// LedgerSyncItem 工单物料台账同步项(工单级需求量,一个物料一行)。
|
||||
type LedgerSyncItem struct {
|
||||
MaterialCode string `json:"materialCode"`
|
||||
MaterialName string `json:"materialName"`
|
||||
TotalQty int `json:"totalQty"`
|
||||
}
|
||||
|
||||
// LedgerSync 向 WMS 下发「该工单每种物料总共要多少料」(工单级需求量)。
|
||||
//
|
||||
// 需求10根因修复:MES 生成备料单后必须把工单级需求量同步给 WMS,
|
||||
// WMS 才知道 total_qty(台账需求量),否则出库/缺口/领料完结判定都无据可依。
|
||||
// WMS 侧按 orderNo+materialCode 幂等 upsert total_qty(详见 ledgerSyncHandler)。
|
||||
func (c *Client) LedgerSync(ctx context.Context, orderNo, productCode, operator string, items []LedgerSyncItem) error {
|
||||
if orderNo == "" || len(items) == 0 {
|
||||
return errors.New("orderNo 和 items 必填")
|
||||
}
|
||||
payload := map[string]any{
|
||||
"orderNo": orderNo,
|
||||
"productCode": productCode,
|
||||
"operator": operator,
|
||||
"items": items,
|
||||
}
|
||||
b, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.baseURL+"/api/internal/ledger/sync", bytes.NewReader(b))
|
||||
if err != nil {
|
||||
return 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 err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var body struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
_ = json.NewDecoder(resp.Body).Decode(&body)
|
||||
if resp.StatusCode >= 300 || body.Code != 0 {
|
||||
if body.Message != "" {
|
||||
return errors.New(body.Message)
|
||||
}
|
||||
return &RespError{Status: resp.StatusCode}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) post(ctx context.Context, path string, body any) error {
|
||||
b, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user