|
@@ -15,17 +15,16 @@ import (
|
|
|
// 统计报表
|
|
|
func Report(r *GinRouter) {
|
|
|
// 加工列表
|
|
|
- r.POST("/report/produce/list", ReportProduceList)
|
|
|
+ r.GET("/report/produce/list", ReportProduceList)
|
|
|
// 采购列表
|
|
|
- r.POST("/report/purchase/list", ReportPurchaseList)
|
|
|
- r.POST("/report/produce/download", ReportProduceDownload)
|
|
|
- r.POST("/report/purchase/download", ReportPurchaseDownload)
|
|
|
+ r.GET("/report/purchase/list", ReportPurchaseList)
|
|
|
+ r.GET("/report/produce/download", ReportProduceDownload)
|
|
|
+ r.GET("/report/purchase/download", ReportPurchaseDownload)
|
|
|
}
|
|
|
|
|
|
type ReportListReq struct {
|
|
|
SupplierId primitive.ObjectID
|
|
|
TimeRange []string
|
|
|
- PackIds []primitive.ObjectID
|
|
|
PlanIds []primitive.ObjectID
|
|
|
Page int64
|
|
|
Size int64
|
|
@@ -34,55 +33,44 @@ type ReportListReq struct {
|
|
|
// 加工单
|
|
|
func ReportProduceList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
// 财务管理】 添加统计报表功能。按 时间范围, 供应商(单选) 包装(多选) 计划(多选) 四个维度进行过滤,形成报表。可以下载
|
|
|
- var form ReportListReq
|
|
|
- err := c.ShouldBindJSON(&form)
|
|
|
- if err != nil {
|
|
|
- return nil, errors.New("参数错误")
|
|
|
- }
|
|
|
-
|
|
|
- var page int64 = 1
|
|
|
- var size int64 = 10
|
|
|
- if form.Page > 0 {
|
|
|
- page = form.Page
|
|
|
- }
|
|
|
- if form.Size > 0 {
|
|
|
- size = form.Size
|
|
|
- }
|
|
|
-
|
|
|
+ page, size, query := UtilQueryPageSize(c)
|
|
|
// 条件处理
|
|
|
- query := make(map[string]interface{}, 0)
|
|
|
query["status"] = "complete"
|
|
|
- if !form.SupplierId.IsZero() {
|
|
|
- query["supplierId"] = form.SupplierId
|
|
|
- }
|
|
|
|
|
|
- // 时间范围
|
|
|
- if len(form.TimeRange) == 2 {
|
|
|
- start, end := getTimeRange(form.TimeRange[0], form.TimeRange[1])
|
|
|
- query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
+ if _supplierId, ok := query["supplierId"]; ok {
|
|
|
+ supplierId, _ := primitive.ObjectIDFromHex(_supplierId.(string))
|
|
|
+ if !supplierId.IsZero() {
|
|
|
+ query["supplierId"] = supplierId
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 包装
|
|
|
- if len(form.PackIds) > 0 {
|
|
|
- packQuery := []bson.M{}
|
|
|
- for _, packId := range form.PackIds {
|
|
|
- packQuery = append(packQuery, bson.M{"packId": packId})
|
|
|
+ if _timeRange, ok := query["timeRange"]; ok {
|
|
|
+ timeRange, _ := _timeRange.([]interface{})
|
|
|
+
|
|
|
+ if len(timeRange) == 2 {
|
|
|
+ start, end := getTimeRange(timeRange[0].(string), timeRange[1].(string))
|
|
|
+ query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
}
|
|
|
- query["$or"] = packQuery
|
|
|
+ delete(query, "timeRange")
|
|
|
}
|
|
|
|
|
|
- // 计划
|
|
|
- if len(form.PlanIds) > 0 {
|
|
|
- planQuery := bson.A{}
|
|
|
- for _, planId := range form.PlanIds {
|
|
|
- planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ if _planIds, ok := query["planIds"]; ok {
|
|
|
+ if len(_planIds.([]interface{})) > 0 {
|
|
|
+ planQuery := bson.A{}
|
|
|
+ for _, _planId := range _planIds.([]interface{}) {
|
|
|
+ planId, _ := primitive.ObjectIDFromHex(_planId.(string))
|
|
|
+ planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ }
|
|
|
+ query["$or"] = planQuery
|
|
|
}
|
|
|
- query["$or"] = planQuery
|
|
|
+ delete(query, "planIds")
|
|
|
}
|
|
|
+ fmt.Println(query)
|
|
|
|
|
|
// 获取采购单符合条件的信息
|
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
- CollectName: repo.CollectionBillPurchase,
|
|
|
+ CollectName: repo.CollectionBillProduce,
|
|
|
Query: query,
|
|
|
Page: page,
|
|
|
Size: size,
|
|
@@ -93,52 +81,39 @@ func ReportProduceList(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
// 采购单
|
|
|
func ReportPurchaseList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
// 财务管理】 添加统计报表功能。按 时间范围, 供应商(单选) 包装(多选) 计划(多选) 四个维度进行过滤,形成报表。可以下载
|
|
|
- var form ReportListReq
|
|
|
- err := c.ShouldBindJSON(&form)
|
|
|
- if err != nil {
|
|
|
- return nil, errors.New("参数错误")
|
|
|
- }
|
|
|
-
|
|
|
- var page int64 = 1
|
|
|
- var size int64 = 10
|
|
|
- if form.Page > 0 {
|
|
|
- page = form.Page
|
|
|
- }
|
|
|
- if form.Size > 0 {
|
|
|
- size = form.Size
|
|
|
- }
|
|
|
-
|
|
|
+ page, size, query := UtilQueryPageSize(c)
|
|
|
// 条件处理
|
|
|
- query := make(map[string]interface{}, 0)
|
|
|
query["status"] = "complete"
|
|
|
- if !form.SupplierId.IsZero() {
|
|
|
- query["supplierId"] = form.SupplierId
|
|
|
- }
|
|
|
|
|
|
- // 时间范围
|
|
|
- if len(form.TimeRange) == 2 {
|
|
|
- start, end := getTimeRange(form.TimeRange[0], form.TimeRange[1])
|
|
|
- query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
- }
|
|
|
+ if _supplierId, ok := query["supplierId"]; ok {
|
|
|
+ supplierId, _ := primitive.ObjectIDFromHex(_supplierId.(string))
|
|
|
+ if !supplierId.IsZero() {
|
|
|
+ query["supplierId"] = supplierId
|
|
|
|
|
|
- // 包装
|
|
|
- if len(form.PackIds) > 0 {
|
|
|
- packQuery := []bson.M{}
|
|
|
- for _, packId := range form.PackIds {
|
|
|
- packQuery = append(packQuery, bson.M{"packId": packId})
|
|
|
}
|
|
|
- query["$or"] = packQuery
|
|
|
}
|
|
|
|
|
|
- // 计划
|
|
|
- if len(form.PlanIds) > 0 {
|
|
|
- planQuery := bson.A{}
|
|
|
- for _, planId := range form.PlanIds {
|
|
|
- planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ if _timeRange, ok := query["timeRange"]; ok {
|
|
|
+ timeRange, _ := _timeRange.([]interface{})
|
|
|
+
|
|
|
+ if len(timeRange) == 2 {
|
|
|
+ start, end := getTimeRange(timeRange[0].(string), timeRange[1].(string))
|
|
|
+ query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
}
|
|
|
- query["$or"] = planQuery
|
|
|
+ delete(query, "timeRange")
|
|
|
}
|
|
|
|
|
|
+ if _planIds, ok := query["planIds"]; ok {
|
|
|
+ if len(_planIds.([]interface{})) > 0 {
|
|
|
+ planQuery := bson.A{}
|
|
|
+ for _, _planId := range _planIds.([]interface{}) {
|
|
|
+ planId, _ := primitive.ObjectIDFromHex(_planId.(string))
|
|
|
+ planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ }
|
|
|
+ query["$or"] = planQuery
|
|
|
+ }
|
|
|
+ delete(query, "planIds")
|
|
|
+ }
|
|
|
// 获取采购单符合条件的信息
|
|
|
return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionBillPurchase,
|
|
@@ -149,205 +124,44 @@ func ReportPurchaseList(c *gin.Context, apictx *ApiSession) (interface{}, error)
|
|
|
|
|
|
}
|
|
|
|
|
|
-// func ReportProduceList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
-// // 财务管理】 添加统计报表功能。按 时间范围, 供应商(单选) 包装(多选) 计划(多选) 四个维度进行过滤,形成报表。可以下载
|
|
|
-// var form ReportListReq
|
|
|
-// err := c.ShouldBindJSON(&form)
|
|
|
-// if err != nil {
|
|
|
-// return nil, errors.New("参数错误")
|
|
|
-// }
|
|
|
-
|
|
|
-// var page int64 = 1
|
|
|
-// var size int64 = 10
|
|
|
-// if form.Page > 0 {
|
|
|
-// page = form.Page
|
|
|
-// } else {
|
|
|
-// page = 1
|
|
|
-// }
|
|
|
-// if form.Size > 0 {
|
|
|
-// size = form.Size
|
|
|
-// } else {
|
|
|
-// size = 10
|
|
|
-// }
|
|
|
-// start := (page - 1) * size
|
|
|
-// end := page*size - 1
|
|
|
-
|
|
|
-// // 条件处理
|
|
|
-// query := make(map[string]interface{}, 0)
|
|
|
-// query["status"] = "complete"
|
|
|
-// if !form.SupplierId.IsZero() {
|
|
|
-// query["supplierId"] = form.SupplierId
|
|
|
-// }
|
|
|
-
|
|
|
-// // 时间范围
|
|
|
-// if len(form.TimeRange) == 2 {
|
|
|
-// start, end := getTimeRange(form.TimeRange[0], form.TimeRange[1])
|
|
|
-// query["createTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
-// }
|
|
|
-
|
|
|
-// // 包装
|
|
|
-// if len(form.PackIds) > 0 {
|
|
|
-// packQuery := []bson.M{}
|
|
|
-// for _, packId := range form.PackIds {
|
|
|
-// packQuery = append(packQuery, bson.M{"packId": packId})
|
|
|
-// }
|
|
|
-// query["$or"] = packQuery
|
|
|
-// }
|
|
|
-
|
|
|
-// // 计划
|
|
|
-// if len(form.PlanIds) > 0 {
|
|
|
-// planQuery := bson.A{}
|
|
|
-// for _, planId := range form.PlanIds {
|
|
|
-// planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
-// }
|
|
|
-// query["$or"] = planQuery
|
|
|
-// }
|
|
|
-
|
|
|
-// // 获取采购单符合条件的信息
|
|
|
-// purchases := []model.PurchaseBill{}
|
|
|
-// repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
-// CollectName: repo.CollectionBillPurchase,
|
|
|
-// Query: query,
|
|
|
-// }, &purchases)
|
|
|
-
|
|
|
-// // 获取加工单符合条件的信息
|
|
|
-// produces := []model.ProduceBill{}
|
|
|
-// repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
-// CollectName: repo.CollectionBillProduce,
|
|
|
-// Query: query,
|
|
|
-// }, &produces)
|
|
|
-// // 组装数据
|
|
|
-// cacheKey := "report:list"
|
|
|
-// apictx.Svc.Redis.Del(apictx.CreateRepoCtx().Ctx, cacheKey)
|
|
|
-// // key存在时
|
|
|
-// // if apictx.Svc.Redis.Exists(apictx.CreateRepoCtx().Ctx, cacheKey).Val() == 1 {
|
|
|
-// // ret := apictx.Svc.Redis.ZRange(apictx.CreateRepoCtx().Ctx, cacheKey, start, end)
|
|
|
-// // retList = ret.Val()
|
|
|
-// // } else {
|
|
|
-
|
|
|
-// // }
|
|
|
-
|
|
|
-// mlen := len(purchases) + len(produces)
|
|
|
-// type MapList map[string]interface{}
|
|
|
-// lists := make([]MapList, mlen)
|
|
|
-// if len(purchases) > 0 {
|
|
|
-// for _, purchase := range purchases {
|
|
|
-// apictx.Svc.Redis.ZAdd(apictx.CreateRepoCtx().Ctx, cacheKey, &redis.Z{
|
|
|
-// Score: float64(purchase.CreateTime.Unix()),
|
|
|
-// Member: purchase.Id.Hex(),
|
|
|
-// })
|
|
|
-// list := MapList{purchase.Id.Hex(): purchase, "type": "purchase"}
|
|
|
-// lists = append(lists, list)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if len(produces) > 0 {
|
|
|
-// for _, produce := range produces {
|
|
|
-// apictx.Svc.Redis.ZAdd(apictx.CreateRepoCtx().Ctx, cacheKey, &redis.Z{
|
|
|
-// Score: float64(produce.CreateTime.Unix()),
|
|
|
-// Member: produce.Id.Hex(),
|
|
|
-// })
|
|
|
-// list := MapList{produce.Id.Hex(): produce, "type": "produce"}
|
|
|
-// lists = append(lists, list)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// // 当前key存在时
|
|
|
-// retList := make([]map[string]interface{}, 0)
|
|
|
-// // 所有id
|
|
|
-// ids := make([]map[string]string, 0)
|
|
|
-// if apictx.Svc.Redis.Exists(apictx.CreateRepoCtx().Ctx, cacheKey).Val() == 1 {
|
|
|
-// // ret := apictx.Svc.Redis.ExpireLT(apictx.CreateRepoCtx().Ctx, cacheKey, 20*time.Second)
|
|
|
-// // 按创建时间升序排
|
|
|
-// result := apictx.Svc.Redis.ZRange(apictx.CreateRepoCtx().Ctx, cacheKey, start, end)
|
|
|
-// if result.Err() != nil {
|
|
|
-// log.Error(err)
|
|
|
-// return nil, errors.New("缓存数据内部错误")
|
|
|
-// }
|
|
|
-// retids := apictx.Svc.Redis.ZRange(apictx.CreateRepoCtx().Ctx, cacheKey, 0, -1)
|
|
|
-
|
|
|
-// // 所有id
|
|
|
-// if len(retids.Val()) > 0 {
|
|
|
-// for _, id := range retids.Val() {
|
|
|
-// for _, item := range lists {
|
|
|
-// if _, ok := item[id]; ok {
|
|
|
-// ids = append(ids, map[string]string{"id": id, "type": item["type"].(string)})
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
-// // 返回的列表
|
|
|
-// if len(result.Val()) > 0 {
|
|
|
-// for _, id := range result.Val() {
|
|
|
-// for _, item := range lists {
|
|
|
-// if _, ok := item[id]; ok {
|
|
|
-// retList = append(retList, item)
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// }
|
|
|
-// type PageResult struct {
|
|
|
-// List []map[string]interface{} `json:"list"`
|
|
|
-// Total int64 `json:"total"`
|
|
|
-// Page int64 `json:"page"`
|
|
|
-// Size int64 `json:"size"`
|
|
|
-// Ids []map[string]string `json:"ids"`
|
|
|
-// }
|
|
|
-
|
|
|
-// out := &PageResult{
|
|
|
-// List: retList,
|
|
|
-// Total: int64(mlen),
|
|
|
-// Page: page,
|
|
|
-// Size: size,
|
|
|
-// Ids: ids,
|
|
|
-// }
|
|
|
-
|
|
|
-// return out, nil
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
func ReportProduceDownload(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- var form ReportListReq
|
|
|
- err := c.ShouldBindJSON(&form)
|
|
|
- if err != nil {
|
|
|
- return nil, errors.New("参数错误")
|
|
|
- }
|
|
|
+ _, _, query := UtilQueryPageSize(c)
|
|
|
// 条件处理
|
|
|
- query := make(map[string]interface{}, 0)
|
|
|
query["status"] = "complete"
|
|
|
- if !form.SupplierId.IsZero() {
|
|
|
- query["supplierId"] = form.SupplierId
|
|
|
- }
|
|
|
|
|
|
- // 时间范围
|
|
|
- if len(form.TimeRange) == 2 {
|
|
|
- start, end := getTimeRange(form.TimeRange[0], form.TimeRange[1])
|
|
|
- query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
+ if _supplierId, ok := query["supplierId"]; ok {
|
|
|
+ supplierId, _ := primitive.ObjectIDFromHex(_supplierId.(string))
|
|
|
+ if !supplierId.IsZero() {
|
|
|
+ query["supplierId"] = supplierId
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 包装
|
|
|
- if len(form.PackIds) > 0 {
|
|
|
- packQuery := []bson.M{}
|
|
|
- for _, packId := range form.PackIds {
|
|
|
- packQuery = append(packQuery, bson.M{"packId": packId})
|
|
|
+ if _timeRange, ok := query["timeRange"]; ok {
|
|
|
+ timeRange, _ := _timeRange.([]interface{})
|
|
|
+
|
|
|
+ if len(timeRange) == 2 {
|
|
|
+ start, end := getTimeRange(timeRange[0].(string), timeRange[1].(string))
|
|
|
+ query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
}
|
|
|
- query["$or"] = packQuery
|
|
|
+ delete(query, "timeRange")
|
|
|
}
|
|
|
|
|
|
- // 计划
|
|
|
- if len(form.PlanIds) > 0 {
|
|
|
- planQuery := bson.A{}
|
|
|
- for _, planId := range form.PlanIds {
|
|
|
- planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ if _planIds, ok := query["planIds"]; ok {
|
|
|
+ if len(_planIds.([]interface{})) > 0 {
|
|
|
+ planQuery := bson.A{}
|
|
|
+ for _, _planId := range _planIds.([]interface{}) {
|
|
|
+ planId, _ := primitive.ObjectIDFromHex(_planId.(string))
|
|
|
+ planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ }
|
|
|
+ query["$or"] = planQuery
|
|
|
}
|
|
|
- query["$or"] = planQuery
|
|
|
+ delete(query, "planIds")
|
|
|
}
|
|
|
|
|
|
// 获取采符合条件的信息
|
|
|
produces := []model.ProduceBill{}
|
|
|
- err = repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionBillProduce,
|
|
|
Query: query,
|
|
|
}, &produces)
|
|
@@ -378,19 +192,23 @@ func ReportProduceDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
|
|
|
|
|
|
var budgetCount float64 = 0
|
|
|
var realCount float64 = 0
|
|
|
+ var row int = 0
|
|
|
|
|
|
for _, produce := range produces {
|
|
|
produceExcel := NewReportProduceExcel(f)
|
|
|
produceExcel.Content = &produce
|
|
|
- budgetCount += produceExcel.BudgetCount
|
|
|
- realCount += produceExcel.RealCount
|
|
|
- produceExcel.Title = fmt.Sprintf("%ss加工单", info.CompanyName)
|
|
|
+
|
|
|
+ produceExcel.Title = fmt.Sprintf("%s加工单", info.CompanyName)
|
|
|
//设置对应的数据
|
|
|
produceExcel.Offset = offset
|
|
|
produceExcel.Draws()
|
|
|
+ budgetCount += produceExcel.BudgetCount
|
|
|
+ realCount += produceExcel.RealCount
|
|
|
offset += 15
|
|
|
+ row = produceExcel.Row
|
|
|
+
|
|
|
}
|
|
|
- row := offset + 1
|
|
|
+ row++
|
|
|
startCell := fmt.Sprintf("%s%d", "A", row)
|
|
|
endCell := fmt.Sprintf("%s%d", "H", row)
|
|
|
f.MergeCell(sheetName, startCell, endCell)
|
|
@@ -429,45 +247,42 @@ func ReportProduceDownload(c *gin.Context, apictx *ApiSession) (interface{}, err
|
|
|
}
|
|
|
|
|
|
func ReportPurchaseDownload(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
- var form ReportListReq
|
|
|
- err := c.ShouldBindJSON(&form)
|
|
|
- if err != nil {
|
|
|
- return nil, errors.New("参数错误")
|
|
|
- }
|
|
|
+ _, _, query := UtilQueryPageSize(c)
|
|
|
// 条件处理
|
|
|
- query := make(map[string]interface{}, 0)
|
|
|
query["status"] = "complete"
|
|
|
- if !form.SupplierId.IsZero() {
|
|
|
- query["supplierId"] = form.SupplierId
|
|
|
- }
|
|
|
|
|
|
- // 时间范围
|
|
|
- if len(form.TimeRange) == 2 {
|
|
|
- start, end := getTimeRange(form.TimeRange[0], form.TimeRange[1])
|
|
|
- query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
- }
|
|
|
+ if _supplierId, ok := query["supplierId"]; ok {
|
|
|
+ supplierId, _ := primitive.ObjectIDFromHex(_supplierId.(string))
|
|
|
+ if !supplierId.IsZero() {
|
|
|
+ query["supplierId"] = supplierId
|
|
|
|
|
|
- // 包装
|
|
|
- if len(form.PackIds) > 0 {
|
|
|
- packQuery := []bson.M{}
|
|
|
- for _, packId := range form.PackIds {
|
|
|
- packQuery = append(packQuery, bson.M{"packId": packId})
|
|
|
}
|
|
|
- query["$or"] = packQuery
|
|
|
}
|
|
|
|
|
|
- // 计划
|
|
|
- if len(form.PlanIds) > 0 {
|
|
|
- planQuery := bson.A{}
|
|
|
- for _, planId := range form.PlanIds {
|
|
|
- planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ if _timeRange, ok := query["timeRange"]; ok {
|
|
|
+ timeRange, _ := _timeRange.([]interface{})
|
|
|
+
|
|
|
+ if len(timeRange) == 2 {
|
|
|
+ start, end := getTimeRange(timeRange[0].(string), timeRange[1].(string))
|
|
|
+ query["updateTime"] = bson.M{"$gte": start, "$lte": end}
|
|
|
}
|
|
|
- query["$or"] = planQuery
|
|
|
+ delete(query, "timeRange")
|
|
|
}
|
|
|
|
|
|
+ if _planIds, ok := query["planIds"]; ok {
|
|
|
+ if len(_planIds.([]interface{})) > 0 {
|
|
|
+ planQuery := bson.A{}
|
|
|
+ for _, _planId := range _planIds.([]interface{}) {
|
|
|
+ planId, _ := primitive.ObjectIDFromHex(_planId.(string))
|
|
|
+ planQuery = append(planQuery, bson.M{"planId": planId})
|
|
|
+ }
|
|
|
+ query["$or"] = planQuery
|
|
|
+ }
|
|
|
+ delete(query, "planIds")
|
|
|
+ }
|
|
|
// 获取符合条件的信息
|
|
|
purchases := []model.PurchaseBill{}
|
|
|
- err = repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
+ err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
|
|
|
CollectName: repo.CollectionBillPurchase,
|
|
|
Query: query,
|
|
|
}, &purchases)
|
|
@@ -498,19 +313,21 @@ func ReportPurchaseDownload(c *gin.Context, apictx *ApiSession) (interface{}, er
|
|
|
|
|
|
var budgetCount float64 = 0
|
|
|
var realCount float64 = 0
|
|
|
+ var row int = 0
|
|
|
|
|
|
for _, purchase := range purchases {
|
|
|
purchaseExcel := NewReportPurchaseExcel(f)
|
|
|
purchaseExcel.Content = &purchase
|
|
|
- budgetCount += purchaseExcel.BudgetCount
|
|
|
- realCount += purchaseExcel.RealCount
|
|
|
purchaseExcel.Title = fmt.Sprintf("%s原材料采购单", info.CompanyName)
|
|
|
//设置对应的数据
|
|
|
purchaseExcel.Offset = offset
|
|
|
purchaseExcel.Draws()
|
|
|
+ budgetCount += purchaseExcel.BudgetCount
|
|
|
+ realCount += purchaseExcel.RealCount
|
|
|
offset += 15
|
|
|
+ row = purchaseExcel.Row
|
|
|
}
|
|
|
- row := offset + 1
|
|
|
+ row++
|
|
|
startCell := fmt.Sprintf("%s%d", "A", row)
|
|
|
endCell := fmt.Sprintf("%s%d", "H", row)
|
|
|
f.MergeCell(sheetName, startCell, endCell)
|