Browse Source

fix:季节性图

Roc 1 year ago
parent
commit
4470efdfc0
1 changed files with 16 additions and 4 deletions
  1. 16 4
      controllers/data_manage/chart_info.go

+ 16 - 4
controllers/data_manage/chart_info.go

@@ -125,13 +125,19 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 	}
 	if chartType == 2 {
 		if seasonStartDate != "" {
-			startDate = seasonStartDate + "-01-01"
+			startDate = seasonStartDate + "-01"
 		} else {
 			fivePre := time.Now().AddDate(-4, 0, 0).Year()
 			startDate = strconv.Itoa(fivePre) + "-01-01"
 		}
 		if seasonEndDate != "" {
-			endDate = seasonEndDate + "-12-31"
+			seasonEndDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, seasonEndDate+"-01", time.Local)
+			if tmpErr != nil {
+				msg = "获取失败"
+				errMsg = "获取图表,指标信息失败,Err:" + tmpErr.Error()
+				return
+			}
+			endDate = seasonEndDateTime.AddDate(0, 1, -1).Format(utils.FormatDate)
 		} else {
 			//endDate = time.Now().Format(utils.FormatDate)
 		}
@@ -332,13 +338,19 @@ func (this *ChartInfoController) ChartInfoDetail() {
 
 	if chartType == 2 {
 		if seasonStartDate != "" {
-			startDate = seasonStartDate + "-01-01"
+			startDate = seasonStartDate + "-01"
 		} else {
 			fivePre := time.Now().AddDate(-4, 0, 0).Year()
 			startDate = strconv.Itoa(fivePre) + "-01-01"
 		}
 		if seasonEndDate != "" {
-			endDate = seasonEndDate + "-12-31"
+			seasonEndDateTime, tmpErr := time.ParseInLocation(utils.FormatDate, seasonEndDate+"-01", time.Local)
+			if tmpErr != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取图表,指标信息失败,Err:" + tmpErr.Error()
+				return
+			}
+			endDate = seasonEndDateTime.AddDate(0, 1, -1).Format(utils.FormatDate)
 		} else {
 			endDate = "" //time.Now().AddDate(2, 0, 0).Format(utils.FormatDate)
 		}