浏览代码

Merge branch 'bzq1/stl' of eta_server/eta_index_lib into debug

baoziqiang 5 月之前
父节点
当前提交
3dd2b1a87a
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      services/edb_data_calculate_stl.go

+ 8 - 2
services/edb_data_calculate_stl.go

@@ -27,7 +27,7 @@ type EdbStlConfig struct {
 	DataRangeType        int     `description:"数据时间类型:1-全部时间,2-最近N年,3-区间设置,4-区间设置(至今)"`
 	StartDate            string  `description:"开始日期"`
 	EndDate              string  `description:"结束日期"`
-	LastNYear            int     `description:"最近N年"`
+	LastNYear            string  `description:"最近N年"`
 	Period               int     `description:"数据的周期,根据频率设置"`
 	Seasonal             int     `description:"季节性成分窗口大小,一般为period+1,可以设置为大于period的正奇数"`
 	Trend                int     `description:"趋势成分窗口大小,一般为period+1,可以设置为大于period的正奇数"`
@@ -77,7 +77,13 @@ func RefreshStlData(edbInfoId int) (msg string, err error) {
 	case LAST_N_YEARS:
 		condition += " AND data_time >=?"
 		year := time.Now().Year()
-		lastDate := time.Date(year-stlConfig.LastNYear, 1, 1, 0, 0, 0, 0, time.Local)
+		lastNyear, er := strconv.Atoi(stlConfig.LastNYear)
+		if er != nil {
+			msg = "最近N年输入不合法"
+			err = er
+			return
+		}
+		lastDate := time.Date(year-lastNyear, 1, 1, 0, 0, 0, 0, time.Local)
 		pars = append(pars, lastDate)
 	case RANGE_DATE:
 		condition = " AND data_time >=? AND data_time <=?"