|
@@ -1,19 +1,17 @@
|
|
|
package com.gyee.impala.controller.diagnose;
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.gyee.impala.common.result.JsonResult;
|
|
|
import com.gyee.impala.common.result.ResultCode;
|
|
|
-import com.gyee.impala.model.master.diagnose.TrainParam;
|
|
|
+import com.gyee.impala.model.master.diagnose.TrainInfo;
|
|
|
import com.gyee.impala.service.custom.SftpFileService;
|
|
|
import com.gyee.impala.service.master.diagnose.TrainFileModeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -31,25 +29,50 @@ public class TrainFileModeController {
|
|
|
private TrainFileModeService trainFileModeService;
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
@PostMapping("/trainfile")
|
|
|
@ResponseBody
|
|
|
- public JSONObject getTrainfile(@RequestPart("trainParam") TrainParam trainParam, @RequestParam("file") MultipartFile file) {
|
|
|
+ public JSONObject getTrainfile(String name, String forecastLabel, String[] inputLabel, String host, MultipartFile file) {
|
|
|
if (file.isEmpty()) {
|
|
|
return JsonResult.error(ResultCode.ERROR_FILE_NO);
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- trainFileModeService.exec(trainParam, file);
|
|
|
+ trainFileModeService.exec(name, forecastLabel, inputLabel, host, file);
|
|
|
return JsonResult.success(ResultCode.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
return JsonResult.error(ResultCode.ERROR_DATA_FILE);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/addtrainInfo")
|
|
|
+ public JSONObject addProducer(@RequestBody String trainInfo) {
|
|
|
|
|
|
+ try {
|
|
|
+ TrainInfo t = JSONObject.parseObject(trainInfo, TrainInfo.class);
|
|
|
+ trainFileModeService.produce(t);
|
|
|
+ return JsonResult.success(ResultCode.SUCCESS);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return JsonResult.error(ResultCode.ERROR);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @PostMapping("/gettrainInfo")
|
|
|
+ @ResponseBody
|
|
|
+ public JSONObject getConsume() {
|
|
|
+ try {
|
|
|
+ List<TrainInfo> list = trainFileModeService.consume();
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return JsonResult.error(ResultCode.ERROR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|