| | |
| | | if params.PageInfo.Check() { |
| | | detailsSearch.SetPage(params.Page, params.PageSize) |
| | | } |
| | | details, err := detailsSearch.SetProductId(params.ProduceId).FindNotTotal() |
| | | details, total, err := detailsSearch.SetProductId(params.ProduceId).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询操作详情失败") |
| | | return |
| | |
| | | operationIds = append(operationIds, detail.OperationID) |
| | | } |
| | | //获取已完成的操作记录 |
| | | operations, total, err := models.NewOperationSearch().SetIds(operationIds).SetBaseOperationType(params.BaseOperationType). |
| | | SetStatus(constvar.OperationStatus_Finish).Find() |
| | | operations, err := models.NewOperationSearch().SetIds(operationIds).SetBaseOperationType(params.BaseOperationType). |
| | | SetStatus(constvar.OperationStatus_Finish).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询操作记录失败") |
| | | return |
| | |
| | | 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 |
| | |
| | | resp.ContactedName = operation.ContacterName |
| | | resp.FromLocation = operation.FromLocation.Name |
| | | resp.ToLocation = operation.ToLocation.Name |
| | | resp.BaseOperationType = operation.BaseOperationType |
| | | result = append(result, resp) |
| | | break |
| | | } |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | 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 { |
| | |
| | | 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)) |
| | | } |