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