feat: 新增工序签字功能,移除移料指令模块
新增操作工/检验员工序签字功能,支持工艺步骤配置签字要求;删除移料指令相关代码,将移料页签重命名为产线点位(上料/下料);新增成品入库功能及相关权限;优化备料单状态、质量状态逻辑,新增批次序号字段;修复AGV取消后备料单回退状态问题。
This commit is contained in:
@@ -167,13 +167,67 @@ func (c *Client) DisposeInventory(ctx context.Context, req DisposeInventoryReq)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FinishedInbound 成品完工回流入库:调 WMS /api/internal/finished/inbound。
|
||||
// 成品 SN 由 MES 系统生成(工件SN),统一库存主表 category=3;失败返回 err 由调用方降级。
|
||||
func (c *Client) FinishedInbound(ctx context.Context, productCode, productName, sn, orderNo, operator string) error {
|
||||
return c.post(ctx, "/api/internal/finished/inbound", map[string]any{
|
||||
"productCode": productCode, "productName": productName, "sn": sn,
|
||||
"orderNo": orderNo, "snSource": "AUTO", "operator": operator,
|
||||
// FinishedPayload MES→WMS 成品回流入库载荷(完工检合格触发,调 /api/internal/finished/inbound)。
|
||||
// 归属三字段照 semi.go 半成品归属继承模式取自工单:ownershipType/ownershipNo 取工单归属,
|
||||
// productWorkNo=产品工号(即工单号),由 MES 自动带出,不做人工手选。
|
||||
// productStatus=完工检结论(已通过/部分通过,WMS 侧映射 qualityStatus 合格);
|
||||
// relatedStandard=相关标准、testRecordNo=试验记录单号(MES 完工检记录暂无专用字段时传空)。
|
||||
type FinishedPayload struct {
|
||||
ProductCode string
|
||||
ProductName string
|
||||
Sn string
|
||||
OrderNo string
|
||||
Operator string
|
||||
ProductStatus string // 完工检结论:已通过 / 部分通过(不合格不触发本接口)
|
||||
QualityStatus string // 质量状态:合格(默认)/让步接收(CONCESSION,可发货但标记)
|
||||
RelatedStandard string // 相关标准(无则传空)
|
||||
TestRecordNo string // 试验记录单号(无则传空)
|
||||
OwnershipType string // 归属类型:workorder=合同号/project=科技项目号/other=其他
|
||||
OwnershipNo string // 归属编号(合同号或科技项目号)
|
||||
ProductWorkNo string // 产品工号(=所属工单号)
|
||||
}
|
||||
|
||||
// FinishedInbound 成品回流入库:调 WMS /api/internal/finished/inbound,统一库存主表 category=3。
|
||||
// WMS 对重复 SN 返回 HTTP 409 防重,此处转成 *RespError{Status:409} 供调用方
|
||||
// 提示「已入库勿重复」(返修后复检再录合格的重复入库场景)。
|
||||
func (c *Client) FinishedInbound(ctx context.Context, p FinishedPayload) error {
|
||||
b, err := json.Marshal(map[string]any{
|
||||
"productCode": p.ProductCode, "productName": p.ProductName, "sn": p.Sn,
|
||||
"orderNo": p.OrderNo, "snSource": "AUTO", "operator": p.Operator,
|
||||
"productStatus": p.ProductStatus, "qualityStatus": p.QualityStatus, "relatedStandard": p.RelatedStandard,
|
||||
"testRecordNo": p.TestRecordNo, "ownershipType": p.OwnershipType,
|
||||
"ownershipNo": p.OwnershipNo, "productWorkNo": p.ProductWorkNo,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.BaseURL()+"/api/internal/finished/inbound", 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()
|
||||
raw, _ := io.ReadAll(resp.Body)
|
||||
var br struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
_ = json.Unmarshal(raw, &br)
|
||||
if resp.StatusCode >= 300 || br.Code != 0 {
|
||||
if resp.StatusCode == http.StatusConflict {
|
||||
return &RespError{Status: resp.StatusCode, Message: br.Message}
|
||||
}
|
||||
if br.Message != "" {
|
||||
return errors.New(br.Message)
|
||||
}
|
||||
return &RespError{Status: resp.StatusCode}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MaterialExists 批量校验物料编码是否存在于 WMS 物料档案。
|
||||
@@ -678,10 +732,14 @@ func (c *Client) post(ctx context.Context, path string, body any) error {
|
||||
}
|
||||
|
||||
type RespError struct {
|
||||
Status int
|
||||
Status int
|
||||
Message string // WMS 业务错误原文(可选;409 防重等场景透出,空则仅报状态码)
|
||||
}
|
||||
|
||||
func (e *RespError) Error() string {
|
||||
if e.Message != "" {
|
||||
return "wms call failed with status " + strconv.Itoa(e.Status) + ": " + e.Message
|
||||
}
|
||||
return "wms call failed with status " + strconv.Itoa(e.Status)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user