feat: 两库对等物料管理及产品工号贯通全流程
- 新增 MES 本地物料表及双向同步接口,WMS 物料变更自动同步 - 全流程新增产品工号字段,贯通入库/库存/出库/检验环节 - 工单管理支持多工单混产,移除单工单互斥限制 - 新增批次号/SN 字段支持质量检验联动 WMS 库存处置 - 修复权限规则,仅内置管理员账号不允许修改删除 - 工位终端新增 SN 扫码自动切换所属工单功能
This commit is contained in:
@@ -41,6 +41,7 @@ func semiInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
CompletedText string `json:"completedText"` // 已完成至工位(展示快照,空=未报工)
|
||||
ZoneCode string `json:"zoneCode"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
ProductWorkNo string `json:"productWorkNo"` // 产品工号(A1 五页带出;MES 回流可顺带传)
|
||||
Operator string `json:"operator"`
|
||||
Category int `json:"category"` // 2=半成品 3=成品(默认 2)
|
||||
OwnershipType string `json:"ownershipType"`
|
||||
@@ -93,6 +94,14 @@ func semiInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// A2 半成品入库归属继承产线工单:填了工单号则按工单带出合同号作为归属,覆盖前端/调用方传入
|
||||
if req.OrderNo != "" && ctx.Mes != nil {
|
||||
if wo, e := ctx.Mes.GetWorkOrder(ctx0(), req.OrderNo); e == nil && wo != nil && wo.ContractNo != "" {
|
||||
req.OwnershipType = "workorder"
|
||||
req.OwnershipNo = wo.ContractNo
|
||||
}
|
||||
}
|
||||
|
||||
rec, err := ctx.EntClient.Inventory.Create().
|
||||
SetManageMode(2).
|
||||
SetCategory(category).
|
||||
@@ -105,6 +114,7 @@ func semiInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetStatus("在库").
|
||||
SetNillableInboundNo(strPtr(req.OrderNo)).
|
||||
SetOrderNo(req.OrderNo).
|
||||
SetNillableProductWorkNo(strPtr(req.ProductWorkNo)).
|
||||
SetCompletedProcess(completed).
|
||||
SetNillableOwnershipType(strPtr(ownershipTypeOrNone(req.OwnershipType))).
|
||||
SetNillableOwnershipNo(strPtr(req.OwnershipNo)).
|
||||
@@ -126,6 +136,36 @@ func semiInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// workOrderContractHandler GET /api/workorder/contract?orderNo=
|
||||
// 供前端半成品入库表单只读带出归属(A2 半成品入库继承产线工单):凭工单号解析合同号/工程编号。
|
||||
func workOrderContractHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
orderNo := r.URL.Query().Get("orderNo")
|
||||
if orderNo == "" {
|
||||
fail(w, http.StatusBadRequest, "工单号必填")
|
||||
return
|
||||
}
|
||||
if ctx.Mes == nil {
|
||||
fail(w, http.StatusInternalServerError, "MES 客户端未配置")
|
||||
return
|
||||
}
|
||||
wo, err := ctx.Mes.GetWorkOrder(ctx0(), orderNo)
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "解析工单归属失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
if wo == nil {
|
||||
fail(w, http.StatusNotFound, "工单不存在或无合同号")
|
||||
return
|
||||
}
|
||||
ok(w, map[string]any{
|
||||
"workOrderNo": wo.WorkOrderNo,
|
||||
"contractNo": wo.ContractNo,
|
||||
"projectNo": wo.ProjectNo,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// semiOutboundHandler 半成品/成品出库(重上线/发货等):更新 inventories 状态
|
||||
// 客户诉求 L224:出库原因必选(包装/继续生产/检验试验/其他),写入 outbound_reason 留痕。
|
||||
func semiOutboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
@@ -200,6 +240,7 @@ type semiViewRow struct {
|
||||
Status string `json:"status"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
OwnershipNo string `json:"ownershipNo"`
|
||||
ProductWorkNo string `json:"productWorkNo"`
|
||||
ProductStatus string `json:"productStatus"`
|
||||
RelatedStandard string `json:"relatedStandard"`
|
||||
TestRecordNo string `json:"testRecordNo"`
|
||||
@@ -223,6 +264,7 @@ func semiView(inv *ent.Inventory) *semiViewRow {
|
||||
Status: inv.Status,
|
||||
OrderNo: inv.OrderNo,
|
||||
OwnershipNo: inv.OwnershipNo,
|
||||
ProductWorkNo: inv.ProductWorkNo,
|
||||
ProductStatus: inv.ProductStatus,
|
||||
RelatedStandard: inv.RelatedStandard,
|
||||
TestRecordNo: inv.TestRecordNo,
|
||||
@@ -244,6 +286,7 @@ func querySemiHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
status := r.URL.Query().Get("status")
|
||||
sn := r.URL.Query().Get("sn")
|
||||
ownershipNo := r.URL.Query().Get("ownershipNo")
|
||||
productWorkNo := r.URL.Query().Get("productWorkNo")
|
||||
|
||||
q := ctx.EntClient.Inventory.Query().Where(inventory.CategoryEQ(invCatSemi))
|
||||
if materialCode != "" {
|
||||
@@ -258,6 +301,9 @@ func querySemiHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if ownershipNo != "" {
|
||||
q = q.Where(inventory.OwnershipNoContainsFold(ownershipNo))
|
||||
}
|
||||
if productWorkNo != "" {
|
||||
q = q.Where(inventory.ProductWorkNoContainsFold(productWorkNo))
|
||||
}
|
||||
|
||||
total, err := q.Count(ctx0())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user