| | |
| | | dbIn := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). |
| | | Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id"). |
| | | Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeIncoming). |
| | | Where("wms_operation.status in (?)", []int{3, 4}) |
| | | Where("wms_operation.status = ?", constvar.OperationStatus_Finish) |
| | | dbOut := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). |
| | | Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id"). |
| | | Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeOutgoing). |
| | | Where("wms_operation.status in (?)", []int{3, 4}) |
| | | Where("wms_operation.base_operation_type in (?)", []int{2, 4}). |
| | | Where("wms_operation.status = ?", constvar.OperationStatus_Finish) |
| | | if len(locationIds) > 0 { |
| | | dbIn.Where("wms_operation.to_location_id in (?)", locationIds) |
| | | dbOut.Where("wms_operation.from_location_id in (?)", locationIds) |
| | |
| | | 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).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) |
| | | } |
| | | find, total, err := search.SetKeyword(params.KeyWord).FindByPage() |
| | | |
| | | //查询位置 |
| | | locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).FindAll() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询上架规则失败") |
| | | util.ResponseFormat(c, code.RequestParamError, "查询位置失败") |
| | | return |
| | | } |
| | | ids := make([]int, 0) |
| | | for _, location := range locations { |
| | | ids = append(ids, location.Id) |
| | | } |
| | | |
| | | 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 |
| | | resp.LocationName = product.Location.Name |
| | | resp.ProduceId = product.Product.ID |
| | | resp.ProductName = product.Product.Name |
| | | resp.ProductTypeName = product.ProductCategory.Name |
| | | resp.Amount = product.Product.Amount |
| | | resp.Unit = product.Product.Unit |
| | | resp.Value = product.Product.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)) |
| | | } |