瀏覽代碼

故障预测

wangchangsheng 2 年之前
父節點
當前提交
c46e49962e

+ 34 - 8
gyee-sample-impala/src/main/java/com/gyee/impala/controller/diagnose/TrainFaultDiagnoseController.java

@@ -18,12 +18,13 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Calendar;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
- * 故障诊断
+ * 故障预测
  */
 @Slf4j
 @CrossOrigin
@@ -34,11 +35,14 @@ public class TrainFaultDiagnoseController {
 
     @Autowired
     private TrainFaultDiagnoseService trainFaultDiagnoseService;
-
-
+    /**
+     * 参数
+     */
     private ExecuteInfo executeInfo;
 
-
+    /**
+     * 数据服务
+     */
     @Autowired
     private DataPointService dataService;
 
@@ -48,6 +52,11 @@ public class TrainFaultDiagnoseController {
     @Resource
     private ThreadPoolTaskExecutor taskExecutor;
 
+    /**
+     * 预测生成文件名
+     */
+    private String fileName;
+
 
     private static final Object locker = new Object();
 
@@ -55,16 +64,16 @@ public class TrainFaultDiagnoseController {
 
 
 
-    /** 开始诊断 查询 golden 所有原始数据
+    /** 开始预测 查询 golden 所有原始数据
      *  flag  ture: 所有数据 ;false: 前10条数据
      * **/
-    @PostMapping("/pointdata")
+    @PostMapping("/pointfaultdata")
     public JSONObject getPointData(@RequestBody JSONObject json){
         if (json == null)
             return JsonResult.error(ResultCode.PARAM_IS_BLANK);
 
 
-        log.info("进入诊断程序");
+        log.info("进入预测程序");
         boolean flag = json.getBooleanValue("flag");
         List<Diagnosepoint> points = JSONObject.parseArray(json.getJSONArray("points").toString(), Diagnosepoint.class);
         List<Casefault> faults = JSONObject.parseArray(json.getJSONArray("faults").toString(), Casefault.class);
@@ -93,7 +102,7 @@ public class TrainFaultDiagnoseController {
         executeInfo.setDataInfos(dataInfos);
         if (flag){
             if (!trainFaultDiagnoseService.isComplete()) {
-                return JsonResult.error(4000, "已有正在诊断的故障模型...");
+                return JsonResult.error(4000, "已有正在预测的故障模型...");
             }
             synchronized (locker) {
                 taskExecutor.submit(this::execute);
@@ -111,11 +120,28 @@ public class TrainFaultDiagnoseController {
      */
     private void execute() {
 
+        fileName = dataService.getFormDataAll(executeInfo);
+        trainFaultDiagnoseService.exec();
+
     }
 
 
 
 
+    /**
+     * py 获取预测数据
+     *
+     * @return
+     */
+    @GetMapping("/trainfaultdata")
+    public JSONObject getData() {
+        Map<String, Object> map = new HashMap<>();
+        map.put("info", this.executeInfo);
+        map.put("filename", fileName);
+        return JsonResult.successData(ResultCode.SUCCESS, map);
+    }
+
+