From 0eac8cd498471e510c1887a914e6e28d1dfb4b19 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 31 十月 2023 11:54:49 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- controllers/report_forms_controller.go | 44 +++++++++++++++----------------------------- 1 files changed, 15 insertions(+), 29 deletions(-) diff --git a/controllers/report_forms_controller.go b/controllers/report_forms_controller.go index 79ee050..afffdb5 100644 --- a/controllers/report_forms_controller.go +++ b/controllers/report_forms_controller.go @@ -152,8 +152,8 @@ for _, detail := range details { var resp response.InventoryHistory resp.Amount = detail.Amount - resp.Unit = params.Unit - resp.ProductName = params.ProductName + resp.Unit = detail.Product.Unit + resp.ProductName = detail.Product.Name for _, operation := range operations { if detail.OperationID == operation.Id { resp.Number = operation.Number @@ -162,6 +162,7 @@ resp.ContactedName = operation.ContacterName resp.FromLocation = operation.FromLocation.Name resp.ToLocation = operation.ToLocation.Name + resp.BaseOperationType = operation.BaseOperationType result = append(result, resp) break } @@ -183,10 +184,7 @@ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") return } - search := models.NewLocationProductSearch() - if params.PageInfo.Check() { - search.SetPage(params.Page, params.PageSize) - } + //鏌ヨ浣嶇疆 locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).FindAll() if err != nil { @@ -198,36 +196,24 @@ ids = append(ids, location.Id) } - find, total, err := search.SetKeyword(params.KeyWord).SetProductId(params.ProductId).SetLocationIds(ids).FindByPage() - if err != nil { - util.ResponseFormat(c, code.RequestParamError, "鏌ヨ涓婃灦瑙勫垯澶辫触") - return - } - ruleIds := make([]int, 0) - for _, product := range find { - ruleIds = append(ruleIds, product.Id) - } - amounts, err := models.NewLocationProductAmountSearch().SetLocationProductIds(ruleIds).Find() + amounts, total, err := models.NewLocationProductAmountSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetKeyword(params.KeyWord).SetProductId(params.ProductId).SetLocationIds(ids).FindByPage() if err != nil { util.ResponseFormat(c, code.RequestParamError, "鏌ヨ鏁伴噺澶辫触") return } + var result []response.LocationForms - for _, product := range find { + for _, amount := range amounts { var resp response.LocationForms - for _, amount := range amounts { - if product.Id == amount.LocationProductId { - resp.Amount = amount.Amount - break - } - } - resp.LocationName = product.Location.Name - resp.ProduceId = product.Product.ID - resp.ProductName = product.Product.Name - resp.ProductTypeName = product.ProductCategory.Name - resp.Unit = product.Product.Unit - resp.Value = resp.Amount.Mul(product.Product.Cost) + resp.Amount = amount.Amount + resp.LocationName = amount.Location.Name + resp.ProduceId = amount.Product.ID + resp.ProductName = amount.Product.Name + resp.ProductTypeName = amount.ProductCategory.Name + resp.Unit = amount.Product.Unit + resp.Value = resp.Amount.Mul(amount.Product.Cost) result = append(result, resp) } + util.ResponseFormatList(c, code.Success, result, int(total)) } -- Gitblit v1.8.0