controllers/report_forms_controller.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
docs/docs.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
docs/swagger.json | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
docs/swagger.yaml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/location.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/location_product.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
models/location_product_amount.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
request/report_forms_request.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
controllers/report_forms_controller.go
@@ -186,21 +186,46 @@ 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, "查询位置失败") return } ids := make([]int, 0) for _, location := range locations { 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() if err != nil { util.ResponseFormat(c, code.RequestParamError, "查询数量失败") return } var result []response.LocationForms for _, product := range find { 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.Amount = product.Product.Amount resp.Unit = product.Product.Unit resp.Value = product.Product.Amount.Mul(product.Product.Cost) resp.Value = resp.Amount.Mul(product.Product.Cost) result = append(result, resp) } util.ResponseFormatList(c, code.Success, result, int(total)) docs/docs.go
@@ -3122,6 +3122,12 @@ "pageSize": { "description": "每页大小", "type": "integer" }, "productId": { "type": "string" }, "wareHouseCode": { "type": "string" } } }, docs/swagger.json
@@ -3110,6 +3110,12 @@ "pageSize": { "description": "每页大小", "type": "integer" }, "productId": { "type": "string" }, "wareHouseCode": { "type": "string" } } }, docs/swagger.yaml
@@ -865,6 +865,10 @@ pageSize: description: 每页大小 type: integer productId: type: string wareHouseCode: type: string type: object request.GetProductList: properties: models/location.go
@@ -310,7 +310,7 @@ records = make([]*Location, 0) db = slf.build() ) err := db.Find(&records) err := db.Find(&records).Error if err != nil { fmt.Println(err) return records, fmt.Errorf("func FindAll err: %v", err) models/location_product.go
@@ -22,12 +22,13 @@ LocationProductSearch struct { LocationProduct Order string PageNum int PageSize int Keyword string Orm *gorm.DB Preload bool Order string PageNum int PageSize int Keyword string Orm *gorm.DB Preload bool LocationIds []int } ) @@ -79,6 +80,11 @@ return slf } func (slf *LocationProductSearch) SetLocationIds(locationIds []int) *LocationProductSearch { slf.LocationIds = locationIds return slf } func (slf *LocationProductSearch) build() *gorm.DB { var db = slf.Orm.Model(&LocationProduct{}) @@ -111,6 +117,10 @@ db = db.Where("product_id=?", slf.ProductId) } if len(slf.LocationIds) > 0 { db = db.Where("location_id in (?)", slf.LocationIds) } return db } models/location_product_amount.go
@@ -20,12 +20,13 @@ LocationProductAmountSearch struct { LocationProductAmount Order string PageNum int PageSize int Keyword string Orm *gorm.DB Preload bool Order string PageNum int PageSize int Keyword string Orm *gorm.DB Preload bool LocationProductIds []int } LocationProductAmountWithOperation struct { @@ -88,6 +89,11 @@ return slf } func (slf *LocationProductAmountSearch) SetLocationProductIds(ids []int) *LocationProductAmountSearch { slf.LocationProductIds = ids return slf } func (slf *LocationProductAmountSearch) build() *gorm.DB { var db = slf.Orm.Model(&LocationProductAmount{}) @@ -108,6 +114,9 @@ if slf.LocationProductId != 0 { db = db.Where("location_product_id=?", slf.LocationProductId) } if len(slf.LocationProductIds) > 0 { db = db.Where("location_product_id in (?)", slf.LocationProductIds) } return db } request/report_forms_request.go
@@ -17,5 +17,7 @@ type GetLocationForms struct { PageInfo KeyWord string `json:"keyWord"` KeyWord string `json:"keyWord"` WareHouseCode string `json:"wareHouseCode"` ProductId string `json:"productId"` }