|
@@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Calendar;
|
|
@@ -35,7 +36,7 @@ public class TrainFaultPredictController {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- private CmdFaultPredictService trainFaultDiagnoseService;
|
|
|
+ private CmdFaultPredictService cmdFaultPredictService;
|
|
|
/**
|
|
|
* 参数
|
|
|
*/
|
|
@@ -63,6 +64,58 @@ public class TrainFaultPredictController {
|
|
|
|
|
|
|
|
|
|
|
|
+ private String name1;
|
|
|
+ private String forecastLabel1;
|
|
|
+ private String[] inputLabel1;
|
|
|
+ private String host1;
|
|
|
+ private MultipartFile file1;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 离线文件模式训练故障预测接口
|
|
|
+ * @param forecastLabel
|
|
|
+ * @param inputLabel
|
|
|
+ * @param host
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/trainfile")
|
|
|
+ @ResponseBody
|
|
|
+ public JSONObject getTrainfile(String forecastLabel, String[] inputLabel, String host, MultipartFile file) {
|
|
|
+
|
|
|
+ if (!cmdFaultPredictService.isComplete()) {
|
|
|
+ return JsonResult.error(4000, "命令正在执行...");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return JsonResult.error(ResultCode.ERROR_FILE_NO);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ synchronized (locker) {
|
|
|
+ forecastLabel1 = forecastLabel;
|
|
|
+ inputLabel1 = inputLabel;
|
|
|
+ host1 = host;
|
|
|
+ file1 = file;
|
|
|
+ taskExecutor.submit(this::executeFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ return JsonResult.success(ResultCode.SUCCESS);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return JsonResult.error(ResultCode.ERROR_DATA_FILE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 调用执行脚本
|
|
|
+ */
|
|
|
+ private void executeFile() {
|
|
|
+ cmdFaultPredictService.exec(forecastLabel1, inputLabel1, host1, file1);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/** 开始预测 查询 golden 所有原始数据
|
|
@@ -102,7 +155,7 @@ public class TrainFaultPredictController {
|
|
|
}
|
|
|
executeInfo.setDataInfos(dataInfos);
|
|
|
if (flag){
|
|
|
- if (!trainFaultDiagnoseService.isComplete()) {
|
|
|
+ if (!cmdFaultPredictService.isComplete()) {
|
|
|
return JsonResult.error(4000, "已有正在预测的故障模型...");
|
|
|
}
|
|
|
synchronized (locker) {
|
|
@@ -122,7 +175,7 @@ public class TrainFaultPredictController {
|
|
|
private void execute() {
|
|
|
|
|
|
fileName = dataDiagnoseService.getFormDataAll(executeInfo);
|
|
|
- trainFaultDiagnoseService.exec();
|
|
|
+ cmdFaultPredictService.exec();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -154,7 +207,7 @@ public class TrainFaultPredictController {
|
|
|
public JSONObject putDiagnosetrainhistory(@RequestBody String history) {
|
|
|
try {
|
|
|
log.info("训练模型结果:" + history);
|
|
|
- trainFaultDiagnoseService.putDiagnosetrainhistory(history);
|
|
|
+ cmdFaultPredictService.putDiagnosetrainhistory(history);
|
|
|
return JsonResult.success(ResultCode.SUCCESS);
|
|
|
} catch (Exception e) {
|
|
|
log.error("请求错误", e);
|
|
@@ -163,8 +216,6 @@ public class TrainFaultPredictController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 获取当前训练预测模型结果
|
|
|
* @return
|
|
@@ -172,7 +223,7 @@ public class TrainFaultPredictController {
|
|
|
@GetMapping("/getHistory")
|
|
|
public JSONObject getHistory() {
|
|
|
try {
|
|
|
- Diagnosetrainhistory d = trainFaultDiagnoseService.getHistoryQueue();
|
|
|
+ Diagnosetrainhistory d = cmdFaultPredictService.getHistoryQueue();
|
|
|
return JsonResult.successData(ResultCode.SUCCESS, d);
|
|
|
} catch (Exception e) {
|
|
|
log.error("请求错误", e);
|