From 8397fb4c46d08d0332300f9fde1e7b3eb04845fe Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 23 三月 2024 14:00:12 +0800 Subject: [PATCH] srm查询入库单 --- proto/purchase_wms/server.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 49 insertions(+), 3 deletions(-) diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go index bdae0cd..cbab86d 100644 --- a/proto/purchase_wms/server.go +++ b/proto/purchase_wms/server.go @@ -5,6 +5,7 @@ "github.com/shopspring/decimal" "gorm.io/gorm" "strconv" + "strings" "time" "wms/constvar" "wms/models" @@ -23,7 +24,9 @@ operation.Number = strconv.FormatInt(time.Now().Unix(), 10) operation.Status = constvar.OperationStatus_Ready operation.CompanyName = req.SupplierName - warehouse, err := models.NewWarehouseSearch().First() + operation.CompanyID = int(req.SupplierId) + operation.Source = req.Source + warehouse, err := models.NewWarehouseSearch().SetName(req.WarehouseName).First() if err != nil { return nil, err } @@ -37,17 +40,18 @@ if err != nil { return nil, err } - operation.ToLocationID = location.Id first, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeVendor)).First() if err != nil { return nil, err } - operation.FromLocationID = first.Id + operation.LocationID = location.Id operation.BaseOperationType = constvar.BaseOperationTypeIncoming for _, product := range req.Product { var detail models.OperationDetails detail.ProductId = product.Id detail.Amount = decimal.NewFromInt(product.Amount) + detail.FromLocationID = first.Id + detail.ToLocationID = location.Id details = append(details, &detail) } err = models.WithTransaction(func(db *gorm.DB) error { @@ -68,3 +72,45 @@ resp.Warehouse = warehouse.Name return resp, nil } + +func (s *Server) SrmGetWarehouseInfo(c context.Context, req *SrmGetWarehouseInfoRequest) (*SrmGetWarehouseInfoResponse, error) { + warehouses, err := models.NewWarehouseSearch().FindNotTotal() + resp := new(SrmGetWarehouseInfoResponse) + if err != nil { + return resp, err + } + for _, warehouse := range warehouses { + var info SrmWarehouseInfo + info.Name = warehouse.Name + info.Address = warehouse.Address + info.Principal = warehouse.Contacts + resp.Info = append(resp.Info, &info) + } + return resp, nil +} + +func (s *Server) SrmGetOperationInfo(c context.Context, req *SrmGetOperationInfoRequest) (*SrmGetOperationInfoResponse, error) { + operations, err := models.NewOperationSearch().SetSourceNumber(req.Number).SetPreload(true).FindNotTotal() + if err != nil { + return nil, err + } + srm := make([]*SrmOperation, 0) + for _, operation := range operations { + var so SrmOperation + so.Number = operation.Number + index := strings.LastIndex(operation.OperationTypeName, "-") + so.WarehouseName = operation.OperationTypeName[:index] + so.Status = int64(operation.Status) + so.OverTime = operation.CreateTime + for _, detail := range operation.Details { + s := so + s.ProductId = detail.ProductId + s.Amount = detail.Amount.IntPart() + s.ProductName = detail.Product.Name + srm = append(srm, &s) + } + } + var resp = new(SrmGetOperationInfoResponse) + resp.Operations = srm + return resp, nil +} -- Gitblit v1.8.0