Эх сурвалжийг харах

fix:季节性图横坐标轴范围可调整

Roc 1 жил өмнө
parent
commit
b51f150f99

+ 15 - 4
controller/chart/chart_info.go

@@ -141,13 +141,18 @@ func GetChartInfoDetail(c *gin.Context) {
 			seasonEndDate = reqSeasonEndDate
 		}
 		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 {
+				response.FailMsg("获取失败", "获取图表,指标信息失败,Err:"+tmpErr.Error(), c)
+				return
+			}
+			endDate = seasonEndDateTime.AddDate(0, 1, -1).Format(utils.FormatDate)
 		} else {
 			endDate = time.Now().Format(utils.FormatDate)
 		}
@@ -321,13 +326,19 @@ func getChartInfoDetail(chartInfo *chartInfoModel.ChartInfoView, myChartClassify
 		seasonStartDate = chartInfo.SeasonStartDate
 		seasonEndDate = chartInfo.SeasonEndDate
 		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)
 		}