Pārlūkot izejas kodu

fix:stl预览时使用配置文件参数

zqbao 1 dienu atpakaļ
vecāks
revīzija
d33de8f35c
1 mainītis faili ar 7 papildinājumiem un 2 dzēšanām
  1. 7 2
      services/data/stl/stl.go

+ 7 - 2
services/data/stl/stl.go

@@ -67,7 +67,7 @@ func GenerateStlEdbData(req *request.StlConfigReq, adminId int) (resp *response.
 	case LAST_N_YEARS:
 	case LAST_N_YEARS:
 		condition += " AND data_time >=?"
 		condition += " AND data_time >=?"
 		year := time.Now().Year()
 		year := time.Now().Year()
-		lastNyear, er := strconv.Atoi(req.LastNYear)
+		lastNyear, er := strconv.Atoi(confReq.LastNYear)
 		if er != nil {
 		if er != nil {
 			msg = "最近N年输入不合法"
 			msg = "最近N年输入不合法"
 			err = er
 			err = er
@@ -513,7 +513,12 @@ print(output)
 
 
 	pythonCode = fmt.Sprintf(pythonCode, path, period, seasonal, trend, fraction, seasonalDeg, trendDeg, lowPassDeg, robustStr, toPath)
 	pythonCode = fmt.Sprintf(pythonCode, path, period, seasonal, trend, fraction, seasonalDeg, trendDeg, lowPassDeg, robustStr, toPath)
 	utils.FileLog.Info("stl exec python code:%s", pythonCode)
 	utils.FileLog.Info("stl exec python code:%s", pythonCode)
-	cmd := exec.Command(`python3`, "-c", pythonCode)
+	var cmd *exec.Cmd
+	if utils.RunMode == "debug" {
+		cmd = exec.Command(`D:\conda\envs\py36\python`, "-c", pythonCode)
+	} else {
+		cmd = exec.Command(`python3`, "-c", pythonCode)
+	}
 	output, err := cmd.CombinedOutput()
 	output, err := cmd.CombinedOutput()
 	if err != nil {
 	if err != nil {
 		utils.FileLog.Info(`execStlPythonCode error:%s, input: path:%s, toPath:%s, period:%d, seasonal:%d, trend:%d, trendDeg:%d, seasonalDeg:%d, lowPassDeg:%d, fraction:%g, robust:%s, output:%s`, err.Error(), path, toPath, period, seasonal, trend, trendDeg, seasonalDeg, lowPassDeg, fraction, robustStr, string(output))
 		utils.FileLog.Info(`execStlPythonCode error:%s, input: path:%s, toPath:%s, period:%d, seasonal:%d, trend:%d, trendDeg:%d, seasonalDeg:%d, lowPassDeg:%d, fraction:%g, robust:%s, output:%s`, err.Error(), path, toPath, period, seasonal, trend, trendDeg, seasonalDeg, lowPassDeg, fraction, robustStr, string(output))