| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param id path int true "采购单ID" |
| | | // @Param data body purchaserequest.SubmitPurchase true "参数" |
| | | // @Success 200 {object} response.Response{msg=string} "提交采购单" |
| | | // @Router /purchase/submit [post] |
| | | func (e *PurchaseApi) Submit(c *gin.Context) { |
| | |
| | | } |
| | | client := purchase_wms.NewPurchaseServiceClient(purchase_wms.PurchaseConn) |
| | | resp, err := client.PurchaseToWms(context.Background(), &purchase_wms.PurchaseToWmsRequest{ |
| | | Number: data.Number, |
| | | SupplierName: data.Supplier.Name, |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | Number: data.Number, |
| | | SupplierName: data.Supplier.Name, |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | OperationSource: purchase_wms.OperationSource_OperationSourcePurchase, |
| | | }) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("grpc调用失败!", zap.Error(err)) |
| | |
| | | response.FailWithMessage("参数缺失", c) |
| | | return |
| | | } |
| | | data, err := service.NewPurchaseService().GetPurchase(uint(id)) |
| | | server := service.NewPurchaseService() |
| | | data, err := server.GetPurchase(uint(id)) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | return |
| | | } |
| | | productList, err := service.NewPurchaseService().GetPurchaseProductList(uint(id)) |
| | | productList, err := server.GetPurchaseProductList(uint(id)) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | | return |
| | | } |
| | | confirmInfo, err := server.GetPurchaseProductConfirmInfo(data.Number) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("获取失败!", zap.Error(err)) |
| | | response.FailWithMessage("获取失败", c) |
| | |
| | | if operation.OverTime != "" { |
| | | oi.OverTime = operation.OverTime |
| | | oi.OverAmount = operation.Amount |
| | | } else { |
| | | oi.SendAmount = operation.Amount |
| | | } |
| | | for _, products := range productList { |
| | | if products.Product.Number == operation.ProductId { |
| | |
| | | oi.Unit = products.Product.Unit |
| | | oi.Specifications = products.Product.Specifications |
| | | oi.ModelNumber = products.Product.ModelNumber |
| | | break |
| | | } |
| | | } |
| | | for _, confirm := range confirmInfo { |
| | | if operation.ProductId == confirm.ProductId { |
| | | oi.SendAmount = confirm.OverReceiveAmount.IntPart() |
| | | break |
| | | } |
| | | } |
| | |
| | | oi.Unit = products.Product.Unit |
| | | oi.Specifications = products.Product.Specifications |
| | | oi.ModelNumber = products.Product.ModelNumber |
| | | for _, confirm := range confirmInfo { |
| | | if products.Product.Number == confirm.ProductId { |
| | | oi.SendAmount = confirm.OverReceiveAmount.IntPart() |
| | | break |
| | | } |
| | | } |
| | | operationInfos = append(operationInfos, oi) |
| | | } |
| | | } |
| | |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param id path int true "采购单ID" true "采购单ID" |
| | | // @Param data body purchaserequest.SubmitPurchase true "参数" |
| | | // @Success 200 {object} response.Response{msg=string} "新版提交" |
| | | // @Router /purchase/newSubmit [post] |
| | | func (e *PurchaseApi) NewSubmit(c *gin.Context) { |
| | |
| | | } |
| | | client := purchase_wms.NewPurchaseServiceClient(purchase_wms.PurchaseConn) |
| | | _, err = client.PurchaseToWms(context.Background(), &purchase_wms.PurchaseToWmsRequest{ |
| | | Number: purchaseData.Number, |
| | | SupplierName: purchaseData.Supplier.Name, |
| | | SupplierId: int64(purchaseData.SupplierId), |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | WarehouseName: purchaseData.Warehouse, |
| | | Number: purchaseData.Number, |
| | | SupplierName: purchaseData.Supplier.Name, |
| | | SupplierId: int64(purchaseData.SupplierId), |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | WarehouseName: purchaseData.Warehouse, |
| | | OperationSource: purchase_wms.OperationSource_OperationSourcePurchase, |
| | | }) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("grpc调用失败!", zap.Error(err)) |
| | |
| | | } |
| | | client := purchase_wms.NewPurchaseServiceClient(purchase_wms.PurchaseConn) |
| | | _, err = client.PurchaseToWms(context.Background(), &purchase_wms.PurchaseToWmsRequest{ |
| | | Number: purchaseData.Number, |
| | | SupplierName: purchaseData.Supplier.Name, |
| | | SupplierId: int64(purchaseData.SupplierId), |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | WarehouseName: purchaseData.Warehouse, |
| | | Number: purchaseData.Number, |
| | | SupplierName: purchaseData.Supplier.Name, |
| | | SupplierId: int64(purchaseData.SupplierId), |
| | | Product: product, |
| | | Source: "SRM_PURCHASE", |
| | | WarehouseName: purchaseData.Warehouse, |
| | | OperationSource: purchase_wms.OperationSource_OperationSourcePurchase, |
| | | }) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("grpc调用失败!", zap.Error(err)) |
| | |
| | | response.FailWithMessage("质检失败", c) |
| | | return |
| | | } |
| | | err = server.UpdatePurchaseStatus(purchaseData.Number, purchase.WaitInspection) |
| | | if err != nil { |
| | | global.GVA_LOG.Error("质检失败!", zap.Error(err)) |
| | | response.FailWithMessage("质检失败", c) |
| | | return |
| | | } |
| | | response.OkWithMessage("质检成功", c) |
| | | } |