From 02a2176f7c5733a4e4c4429c2028bbb86a967ce7 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期二, 06 二月 2024 10:13:38 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/SRM --- proto/purchase_wms/server.go | 37 ++++++++++++++++++++++++++++++------- 1 files changed, 30 insertions(+), 7 deletions(-) diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go index 24fa4d3..10bf8a1 100644 --- a/proto/purchase_wms/server.go +++ b/proto/purchase_wms/server.go @@ -54,13 +54,8 @@ if req.ProductId == "" { return nil, errors.New("浜у搧id涓虹┖") } - var pt purchase.PurchaseType - err := global.GVA_DB.Model(&purchase.PurchaseType{}).First(&pt).Error - if err != nil { - return nil, err - } var product test.SupplierMaterial - err = global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number = ?", req.ProductId).First(&product).Error + err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number = ?", req.ProductId).First(&product).Error if err != nil { if err == gorm.ErrRecordNotFound { var material test.Material @@ -87,7 +82,7 @@ //閲囪喘鍗� var purchaseRecord purchase.Purchase - purchaseRecord.PurchaseTypeId = int(pt.ID) + //purchaseRecord.SupplierId = int(req.SupplierId) if req.Source == "WMS" { purchaseRecord.OrderSource = "WMS鎺ㄩ��" @@ -160,3 +155,31 @@ resp.Infos = infos return resp, nil } + +func (s *Server) ExistSupplier(ctx context.Context, req *ExistSupplierRequest) (*ExistSupplierResponse, error) { + resp := new(ExistSupplierResponse) + if len(req.ProductId) == 0 { + resp.Exist = false + return resp, nil + } + var products []test.SupplierMaterial + err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number in (?)", req.ProductId).Find(&products).Error + if err != nil { + return nil, err + } + for _, number := range req.ProductId { + exit := false + for _, product := range products { + if number == product.Number && product.SupplierId > 0 { + exit = true + break + } + } + if !exit { + resp.Exist = exit + return resp, nil + } + } + resp.Exist = true + return resp, nil +} -- Gitblit v1.8.0