|
@@ -66,7 +66,13 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
case LAST_N_YEARS:
|
|
|
condition += " AND data_time >=?"
|
|
|
year := time.Now().Year()
|
|
|
- lastDate := time.Date(year-confReq.LastNYear, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ lastNyear, er := strconv.Atoi(req.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 <=?"
|
|
@@ -211,10 +217,20 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
bTrend, _ := json.Marshal(trendChart.DataList)
|
|
|
bSeasonal, _ := json.Marshal(seasonalChart.DataList)
|
|
|
bResidual, _ := json.Marshal(residualChart.DataList)
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_TREND_CACHE+strconv.Itoa(config.CalculateStlConfigId), bTrend, time.Hour*2)
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_SEASONAL_CACHE+strconv.Itoa(config.CalculateStlConfigId), bSeasonal, time.Hour*2)
|
|
|
+ err = utils.Rc.Put(EDB_DATA_CALCULATE_STL_TREND_CACHE+strconv.Itoa(config.CalculateStlConfigId), bTrend, time.Hour*2)
|
|
|
+ if err != nil {
|
|
|
+ msg = "计算失败,请重新计算"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = utils.Rc.Put(EDB_DATA_CALCULATE_STL_SEASONAL_CACHE+strconv.Itoa(config.CalculateStlConfigId), bSeasonal, time.Hour*2)
|
|
|
+ if err != nil {
|
|
|
+ msg = "计算失败,请重新计算"
|
|
|
+ return
|
|
|
+ }
|
|
|
utils.Rc.Put(EDB_DATA_CALCULATE_STL_RESIDUAL_CACHE+strconv.Itoa(config.CalculateStlConfigId), bResidual, time.Hour*2)
|
|
|
-
|
|
|
+ if err != nil {
|
|
|
+ msg = "计算失败,请重新计算"
|
|
|
+ }
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -455,7 +471,8 @@ print(output)
|
|
|
}
|
|
|
|
|
|
pythonCode = fmt.Sprintf(pythonCode, path, period, seasonal, trend, fraction, seasonalDeg, trendDeg, lowPassDeg, robustStr, toPath)
|
|
|
- cmd := exec.Command(`python3`, "-c", pythonCode)
|
|
|
+ // cmd := exec.Command(`python3`, "-c", pythonCode)
|
|
|
+ cmd := exec.Command(`D:\conda\envs\py311\python`, "-c", pythonCode)
|
|
|
output, err := cmd.CombinedOutput()
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -484,7 +501,13 @@ func SaveStlConfig(req *request.StlConfigReq, adminId int) (configId int64, msg
|
|
|
case LAST_N_YEARS:
|
|
|
condition += " AND data_time >=?"
|
|
|
year := time.Now().Year()
|
|
|
- lastDate := time.Date(year-req.LastNYear, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
+ lastNyear, er := strconv.Atoi(req.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 <=?"
|