|
@@ -5,6 +5,7 @@ import (
|
|
|
"eta/eta_mini_bridge/models/response"
|
|
|
"eta/eta_mini_bridge/services"
|
|
|
"eta/eta_mini_bridge/utils"
|
|
|
+ "fmt"
|
|
|
"html"
|
|
|
"strconv"
|
|
|
"time"
|
|
@@ -763,6 +764,7 @@ func (this *ReportController) Search() {
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param RangeType query string true "范围类型,1-一天内,2-一周内,3-半年内"
|
|
|
// @Param ClassifyId query int true "分类id"
|
|
|
+// @Param ReportType query int true "报告类型:1-eta报告,2-pdf报告"
|
|
|
// @Success 200 {object} response.ReportListResp
|
|
|
// @router /list [get]
|
|
|
func (this *ReportNoAuthController) List() {
|
|
@@ -778,19 +780,32 @@ func (this *ReportNoAuthController) List() {
|
|
|
level, _ := this.GetInt("Level")
|
|
|
rangeType, _ := this.GetInt("RangeType")
|
|
|
classifyId, _ := this.GetInt("ClassifyId")
|
|
|
+ reportType, _ := this.GetInt("ReportType")
|
|
|
|
|
|
- if chartPermissionId < 0 {
|
|
|
- br.Msg = "品种参数错误"
|
|
|
- return
|
|
|
- }
|
|
|
+ now := time.Now()
|
|
|
+ todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
|
|
|
var condition string
|
|
|
switch rangeType {
|
|
|
case 1:
|
|
|
- condition += ` AND DATE(modify_time)=DATE(NOW()) `
|
|
|
+ condition += fmt.Sprintf(` AND modify_time >= '%s' `, todayStart.Format(utils.FormatDateTime))
|
|
|
case 2:
|
|
|
- condition += ` AND DATE(modify_time) BETWEEN DATE_SUB(NOW(),INTERVAL 1 WEEK) AND NOW() `
|
|
|
+ oneWeekAgo := now.AddDate(0, 0, -7)
|
|
|
+ condition += fmt.Sprintf(` AND modify_time >= '%s' `, oneWeekAgo.Format(utils.FormatDateTime))
|
|
|
case 3:
|
|
|
- condition += ` AND DATE(modify_time) BETWEEN DATE_SUB(NOW(),INTERVAL 6 MONTH) AND NOW() `
|
|
|
+ sixMonthAgo := now.AddDate(0, -6, 0)
|
|
|
+ condition += fmt.Sprintf(` AND modify_time >= '%s' `, sixMonthAgo.Format(utils.FormatDateTime))
|
|
|
+ }
|
|
|
+
|
|
|
+ switch reportType {
|
|
|
+ case utils.ReportTypeEta:
|
|
|
+ if chartPermissionId < 0 {
|
|
|
+ br.Msg = "品种参数错误"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ case utils.ReportTypePdf:
|
|
|
+ default:
|
|
|
+ br.Msg = "报告类型参数错误"
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
var startSize int
|
|
@@ -877,14 +892,14 @@ func (this *ReportNoAuthController) List() {
|
|
|
classifyThirdIds = append(classifyThirdIds, v.Id)
|
|
|
}
|
|
|
}
|
|
|
- tmptotal, err := models.GetPushReportCountByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds, condition)
|
|
|
+ tmptotal, err := models.GetPushReportCountByClassifyIds(reportType, classifyFirstIds, classifySecondIds, classifyThirdIds, condition)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据失败"
|
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
total = tmptotal
|
|
|
- tmpReportList, err := models.GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds, condition, startSize, pageSize)
|
|
|
+ tmpReportList, err := models.GetPushReportListByClassifyIds(reportType, classifyFirstIds, classifySecondIds, classifyThirdIds, condition, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取报告列表失败"
|
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
@@ -945,14 +960,14 @@ func (this *ReportNoAuthController) List() {
|
|
|
classifyThirdIds = append(classifyThirdIds, v.Id)
|
|
|
}
|
|
|
}
|
|
|
- tmptotal, err := models.GetPushReportCountByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds, condition)
|
|
|
+ tmptotal, err := models.GetPushReportCountByClassifyIds(reportType, classifyFirstIds, classifySecondIds, classifyThirdIds, condition)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据失败"
|
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
total = tmptotal
|
|
|
- tmpReportList, err := models.GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds, condition, startSize, pageSize)
|
|
|
+ tmpReportList, err := models.GetPushReportListByClassifyIds(reportType, classifyFirstIds, classifySecondIds, classifyThirdIds, condition, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取报告列表失败"
|
|
|
br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
|
|
@@ -964,14 +979,14 @@ func (this *ReportNoAuthController) List() {
|
|
|
for k := range classifyIdMap {
|
|
|
selectedClassifyIds = append(selectedClassifyIds, k)
|
|
|
}
|
|
|
- tmptotal, err := models.GetPushReportCount(selectedClassifyIds, condition)
|
|
|
+ tmptotal, err := models.GetPushReportCount(reportType, selectedClassifyIds, condition)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取数据失败"
|
|
|
br.ErrMsg = "获取数据失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
total = tmptotal
|
|
|
- tmpReportList, err := models.GetPushReportListByPage(selectedClassifyIds, condition, startSize, pageSize)
|
|
|
+ tmpReportList, err := models.GetPushReportListByPage(reportType, selectedClassifyIds, condition, startSize, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取报告列表失败"
|
|
|
br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
|