瀏覽代碼

指标库的时间入参修改

xyxie 1 年之前
父節點
當前提交
2f82746216
共有 1 個文件被更改,包括 13 次插入15 次删除
  1. 13 15
      controllers/data_manage/edb_info.go

+ 13 - 15
controllers/data_manage/edb_info.go

@@ -3712,7 +3712,8 @@ func (this *ChartInfoController) EdbInfoDataSeasonal() {
 	}
 	startDate := this.GetString("StartDate")
 	endDate := this.GetString("EndDate")
-
+	startYear, _ := this.GetInt("StartYear")
+	dateType, _ := this.GetInt("DateType")
 	edbInfoIdStr := this.GetString("EdbInfoId")
 	edbInfoId, err := strconv.Atoi(edbInfoIdStr)
 	if err != nil {
@@ -3728,28 +3729,25 @@ func (this *ChartInfoController) EdbInfoDataSeasonal() {
 	if calendar == "" {
 		calendar = "公历"
 	}
-	if startDate != `` {
-		startDate = startDate + "-01"
-	} else {
-		fivePre := time.Now().AddDate(-4, 0, 0).Year()
-		startDate = strconv.Itoa(fivePre) + "-01-01"
-	}
-	if endDate != `` {
-		seasonEndDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, endDate+"-01", time.Local)
-		if tmpErr != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取图表,指标信息失败,Err:" + tmpErr.Error()
-			return
+	if dateType == 0 {
+		if startDate == "" {
+			dateType = utils.DateTypeNYears
+		} else {
+			dateType = 5 //自定义时间
 		}
-		endDate = seasonEndDateTime.AddDate(0, 1, -1).Format(utils.FormatDate)
 	}
-
 	edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.Msg = "获取失败,Err:" + err.Error()
 		return
 	}
+	maxYear := 0
+	if edbInfo.LatestDate != "" {
+		latestDateT, _ := time.Parse(utils.FormatDate, edbInfo.LatestDate)
+		maxYear = latestDateT.Year()
+	}
+	startDate, endDate = utils.GetDateByDateTypeV2(dateType, startDate, endDate, startYear, maxYear)
 
 	dataList, err := data.GetChartEdbSeasonalData(calendar, startDate, endDate, edbInfo)
 	if err != nil {