|
@@ -1,16 +1,15 @@
|
|
|
package com.gyee.impala.controller.diagnose;
|
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.gyee.impala.common.result.JsonResult;
|
|
|
import com.gyee.impala.common.result.ResultCode;
|
|
|
-import com.gyee.impala.model.custom.TokenUser;
|
|
|
import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
|
|
|
import com.gyee.impala.model.master.diagnose.TrainInfo;
|
|
|
-import com.gyee.impala.service.custom.SftpFileService;
|
|
|
import com.gyee.impala.service.custom.ShiroService;
|
|
|
import com.gyee.impala.service.master.diagnose.TrainFileModeService;
|
|
|
+import org.apache.ibatis.logging.Log;
|
|
|
+import org.apache.ibatis.logging.LogFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -29,10 +28,13 @@ import java.util.List;
|
|
|
@RequestMapping("/api/filemode")
|
|
|
public class TrainFileModeController {
|
|
|
|
|
|
+
|
|
|
+ protected Log log = LogFactory.getLog(getClass());
|
|
|
+
|
|
|
+
|
|
|
@Autowired
|
|
|
private ShiroService shiroService;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 线程池
|
|
|
*/
|
|
@@ -72,10 +74,10 @@ public class TrainFileModeController {
|
|
|
try {
|
|
|
synchronized (locker) {
|
|
|
name1 = name;
|
|
|
- forecastLabel1= forecastLabel;
|
|
|
- inputLabel1= inputLabel;
|
|
|
- host1= host;
|
|
|
- file1= file;
|
|
|
+ forecastLabel1 = forecastLabel;
|
|
|
+ inputLabel1 = inputLabel;
|
|
|
+ host1 = host;
|
|
|
+ file1 = file;
|
|
|
taskExecutor.submit(this::execute);
|
|
|
}
|
|
|
|
|
@@ -86,7 +88,6 @@ public class TrainFileModeController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private void execute() {
|
|
|
trainFileModeService.exec(name1, forecastLabel1, inputLabel1, host1, file1);
|
|
|
}
|
|
@@ -121,31 +122,30 @@ public class TrainFileModeController {
|
|
|
|
|
|
/**
|
|
|
* 训练结果
|
|
|
+ *
|
|
|
* @param history
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/putHistory")
|
|
|
- public JSONObject putDiagnosetrainhistory(@RequestBody String history){
|
|
|
+ public JSONObject putDiagnosetrainhistory(@RequestBody String history) {
|
|
|
try {
|
|
|
+ log.warn(history);
|
|
|
trainFileModeService.putDiagnosetrainhistory(history);
|
|
|
return JsonResult.success(ResultCode.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
+ log.error("请求错误", e);
|
|
|
return JsonResult.error(ResultCode.ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 获取最终结果
|
|
|
- * @param history
|
|
|
- * @return
|
|
|
- */
|
|
|
- @GetMapping("/getHistory")
|
|
|
- public JSONObject getDiagnosetrainhistory(String history){
|
|
|
+ @PostMapping("/getHistory")
|
|
|
+ public JSONObject getHistory() {
|
|
|
try {
|
|
|
- Diagnosetrainhistory d = trainFileModeService.getDiagnosetrainhistory(history);
|
|
|
+ Diagnosetrainhistory d = trainFileModeService.consumeHistory();
|
|
|
return JsonResult.successData(ResultCode.SUCCESS, d);
|
|
|
} catch (Exception e) {
|
|
|
+ log.error("请求错误", e);
|
|
|
return JsonResult.error(ResultCode.ERROR);
|
|
|
}
|
|
|
}
|
|
@@ -153,36 +153,46 @@ public class TrainFileModeController {
|
|
|
|
|
|
/**
|
|
|
* 编辑最终
|
|
|
+ *
|
|
|
* @param history
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/editHistory")
|
|
|
- public JSONObject editDiagnosetrainhistory(String history){
|
|
|
+ public JSONObject editDiagnosetrainhistory(@RequestBody String history) {
|
|
|
try {
|
|
|
|
|
|
- int code = trainFileModeService.editDiagnosetrainhistory(history);
|
|
|
- if(code >0){
|
|
|
- return JsonResult.success(ResultCode.SUCCESS);
|
|
|
- }else {
|
|
|
- return JsonResult.error(ResultCode.ERROR);
|
|
|
- }
|
|
|
+ trainFileModeService.editDiagnosetrainhistory(history);
|
|
|
+ return JsonResult.success(ResultCode.SUCCESS);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return JsonResult.error(ResultCode.ERROR_DATA);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/getHistoryList")
|
|
|
+ public JSONObject getDiagnosetrainhistoryList() {
|
|
|
+ try {
|
|
|
+ List<Diagnosetrainhistory> list = trainFileModeService.editDiagnosetrainhistoryList();
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, list);
|
|
|
} catch (Exception e) {
|
|
|
return JsonResult.error(ResultCode.ERROR);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 预测评估
|
|
|
+ *
|
|
|
* @param jsonObject
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/forecasts")
|
|
|
- public JSONObject forecasts(@RequestBody JSONObject jsonObject){
|
|
|
+ public JSONObject forecasts(@RequestBody JSONObject jsonObject) {
|
|
|
try {
|
|
|
- String resultvalue = trainFileModeService.forecasts(jsonObject);
|
|
|
- return JsonResult.successData(ResultCode.SUCCESS,resultvalue);
|
|
|
+ String resultvalue = trainFileModeService.forecasts(jsonObject);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, resultvalue);
|
|
|
} catch (Exception e) {
|
|
|
return JsonResult.error(ResultCode.ERROR);
|
|
|
}
|
|
@@ -190,5 +200,4 @@ public class TrainFileModeController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|