|
@@ -61,19 +61,19 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
}
|
|
|
var condition string
|
|
|
var pars []interface{}
|
|
|
- switch req.DataRangeType {
|
|
|
+ switch confReq.DataRangeType {
|
|
|
case ALL_DATE:
|
|
|
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)
|
|
|
+ lastDate := time.Date(year-confReq.LastNYear, 1, 1, 0, 0, 0, 0, time.Local)
|
|
|
pars = append(pars, lastDate)
|
|
|
case RANGE_DATE:
|
|
|
condition = " AND data_time >=? AND data_time <=?"
|
|
|
- pars = append(pars, req.StartDate, req.EndDate)
|
|
|
+ pars = append(pars, confReq.StartDate, confReq.EndDate)
|
|
|
case RANGE_DATE_TO_NOW:
|
|
|
condition = " AND data_time >=?"
|
|
|
- pars = append(pars, req.StartDate)
|
|
|
+ pars = append(pars, confReq.StartDate)
|
|
|
}
|
|
|
condition += " AND edb_code =?"
|
|
|
pars = append(pars, edbInfo.EdbCode)
|
|
@@ -85,40 +85,40 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
}
|
|
|
|
|
|
var condMsg string
|
|
|
- if req.Period < 2 || req.Period > len(edbData) {
|
|
|
+ if confReq.Period < 2 || confReq.Period > len(edbData) {
|
|
|
condMsg += "period必须是一个大于等于2的正整数,且必须小于时间序列的长度"
|
|
|
}
|
|
|
- if req.Seasonal < 3 || req.Seasonal%2 == 0 || req.Seasonal <= req.Period {
|
|
|
+ if confReq.Seasonal < 3 || confReq.Seasonal%2 == 0 || confReq.Seasonal <= confReq.Period {
|
|
|
if condMsg != "" {
|
|
|
condMsg += "\n"
|
|
|
}
|
|
|
condMsg += "seasonal必须是一个大于等于3的奇整数,且必须大于period"
|
|
|
}
|
|
|
- if req.Trend < 3 || req.Trend%2 == 0 || req.Trend <= req.Period {
|
|
|
+ if confReq.Trend < 3 || confReq.Trend%2 == 0 || confReq.Trend <= confReq.Period {
|
|
|
if condMsg != "" {
|
|
|
condMsg += "\n"
|
|
|
}
|
|
|
condMsg += "trend必须是一个大于等于3的奇整数,且必须大于period"
|
|
|
}
|
|
|
- if req.Fraction < 0 || req.Fraction > 1 {
|
|
|
+ if confReq.Fraction < 0 || confReq.Fraction > 1 {
|
|
|
if condMsg != "" {
|
|
|
condMsg += "\n"
|
|
|
}
|
|
|
condMsg += "fraction必须是一个介于[0-1]之间"
|
|
|
}
|
|
|
- if 1 > req.TrendDeg || req.TrendDeg > 5 {
|
|
|
+ if 1 > confReq.TrendDeg || confReq.TrendDeg > 5 {
|
|
|
if condMsg != "" {
|
|
|
condMsg += "\n"
|
|
|
}
|
|
|
condMsg += "trend_deg请设置成1-5的整数"
|
|
|
}
|
|
|
- if 1 > req.SeasonalDeg || req.SeasonalDeg > 5 {
|
|
|
+ if 1 > confReq.SeasonalDeg || confReq.SeasonalDeg > 5 {
|
|
|
if condMsg != "" {
|
|
|
condMsg += "\n"
|
|
|
}
|
|
|
condMsg += "seasonal_deg请设置成1-5的整数"
|
|
|
}
|
|
|
- if 1 > req.LowPassDeg || req.LowPassDeg > 5 {
|
|
|
+ if 1 > confReq.LowPassDeg || confReq.LowPassDeg > 5 {
|
|
|
if condMsg != "" {
|
|
|
condMsg += "\n"
|
|
|
}
|
|
@@ -146,7 +146,7 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
|
|
|
defer os.Remove(loadFilePath)
|
|
|
|
|
|
saveFilePath := exPath + "/" + strconv.Itoa(adminId) + "_" + time.Now().Format(utils.FormatDateTimeUnSpace) + "_res" + ".xlsx"
|
|
|
- result, err := execStlPythonCode(loadFilePath, saveFilePath, req.Period, req.Seasonal, req.Trend, req.TrendDeg, req.SeasonalDeg, req.LowPassDeg, req.Fraction, req.Robust)
|
|
|
+ result, err := execStlPythonCode(loadFilePath, saveFilePath, confReq.Period, confReq.Seasonal, confReq.Trend, confReq.TrendDeg, confReq.SeasonalDeg, confReq.LowPassDeg, confReq.Fraction, confReq.Robust)
|
|
|
if err != nil {
|
|
|
msg = "计算失败,请重新选择指标和参数后计算"
|
|
|
}
|
|
@@ -181,9 +181,9 @@ 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(req.CalculateStlConfigId), bTrend, time.Hour*2)
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_SEASONAL_CACHE+strconv.Itoa(req.CalculateStlConfigId), bSeasonal, time.Hour*2)
|
|
|
- utils.Rc.Put(EDB_DATA_CALCULATE_STL_RESIDUAL_CACHE+strconv.Itoa(req.CalculateStlConfigId), bResidual, time.Hour*2)
|
|
|
+ utils.Rc.Put(EDB_DATA_CALCULATE_STL_TREND_CACHE+strconv.Itoa(confReq.CalculateStlConfigId), bTrend, time.Hour*2)
|
|
|
+ utils.Rc.Put(EDB_DATA_CALCULATE_STL_SEASONAL_CACHE+strconv.Itoa(confReq.CalculateStlConfigId), bSeasonal, time.Hour*2)
|
|
|
+ utils.Rc.Put(EDB_DATA_CALCULATE_STL_RESIDUAL_CACHE+strconv.Itoa(confReq.CalculateStlConfigId), bResidual, time.Hour*2)
|
|
|
|
|
|
return
|
|
|
}
|