|
@@ -7,6 +7,7 @@ import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eco.als.domain.Warning;
|
|
|
import org.eco.als.domain.bo.AlgorithmBo;
|
|
|
+import org.eco.als.domain.bo.FaultDiagnosisBo;
|
|
|
import org.eco.als.domain.bo.PreProcessingBo;
|
|
|
import org.eco.als.domain.bo.TaskBo;
|
|
|
import org.eco.als.domain.vo.DataImportVo;
|
|
@@ -14,8 +15,11 @@ import org.eco.als.domain.vo.ModelHttpVo;
|
|
|
import org.eco.als.domain.vo.ModelVo;
|
|
|
import org.eco.als.service.IAlgorithmService;
|
|
|
import org.eco.als.service.IDataImportService;
|
|
|
+import org.eco.als.service.IFalseAlarmService;
|
|
|
+import org.eco.als.service.IFaultDiagnosisService;
|
|
|
import org.eco.als.service.IModelService;
|
|
|
import org.eco.als.service.IPreProcessingService;
|
|
|
+import org.eco.als.service.ITaskService;
|
|
|
import org.eco.als.service.IWarningService;
|
|
|
import org.eco.als.utils.CsvUtils;
|
|
|
import org.eco.common.core.exception.BusinessException;
|
|
@@ -54,6 +58,15 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
@Resource
|
|
|
private IWarningService warningService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IFalseAlarmService falseAlarmService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IFaultDiagnosisService faultDiagnosisService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ITaskService taskService;
|
|
|
+
|
|
|
/**
|
|
|
* executePro 预处理
|
|
|
*
|
|
@@ -76,29 +89,26 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
}
|
|
|
|
|
|
// 参数
|
|
|
- String param = algorithmBo.getParam();
|
|
|
- Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(param));
|
|
|
+ Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
+ File file = null;
|
|
|
try (InputStream inputStream = ossService.getFileStream(dataVo.getOssId())) {
|
|
|
- File file = CsvUtils.excelToFileCsvByColumns(inputStream, algorithmBo.getColumnData());
|
|
|
- SysOssVo sysOssVo1 = ossService.upload(file);
|
|
|
- // 请求
|
|
|
- map.put("url", sysOssVo1.getUrl());
|
|
|
- ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
- PreProcessingBo bo = new PreProcessingBo();
|
|
|
- if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
- File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"));
|
|
|
- SysOssVo sysOssVo2 = ossService.upload(resultFile);
|
|
|
- bo.setOssId(sysOssVo2.getOssId());
|
|
|
- } else {
|
|
|
- bo.setStatus("0");
|
|
|
- }
|
|
|
- bo.setAircraftNo(dataVo.getAircraftNo()).setSortieNo(dataVo.getSortieNo());
|
|
|
- processingService.insert(bo);
|
|
|
- return httpVo != null ? httpVo.getData() : null;
|
|
|
+ file = CsvUtils.excelToFileCsvByColumns(inputStream, algorithmBo.getColumnData());
|
|
|
} catch (Exception e) {
|
|
|
- log.error(e.getMessage());
|
|
|
+ log.error("文件转换异常:{}", e.getMessage());
|
|
|
}
|
|
|
- return null;
|
|
|
+ if (ObjectUtil.isNull(file)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ SysOssVo sysOssVo = ossService.upload(file);
|
|
|
+ processingService.insert(PreProcessingBo.builder().ossId(sysOssVo.getOssId()).aircraftId(dataVo.getAircraftId()).sortieNo(dataVo.getSortieNo()).build());
|
|
|
+ // 请求
|
|
|
+ map.put("url", sysOssVo.getUrl());
|
|
|
+ ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
+ if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
+ File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"));
|
|
|
+ SysOssVo sysOssVo2 = ossService.upload(resultFile);
|
|
|
+ }
|
|
|
+ return httpVo != null ? httpVo.getData() : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -121,15 +131,10 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
}
|
|
|
// 警告列表
|
|
|
List<Warning> warnings = warningService.listByIds(Arrays.asList(algorithmBo.getWarningIds()));
|
|
|
-
|
|
|
warnings.forEach(el -> {
|
|
|
|
|
|
});
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// 数据相关信息
|
|
|
DataImportVo dataVo = dataImportService.selectById(algorithmBo.getDataId());
|
|
|
if (ObjectUtil.isNull(dataVo)) {
|
|
@@ -144,16 +149,10 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
// 请求
|
|
|
map.put("url", sysOssVo1.getUrl());
|
|
|
ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
- PreProcessingBo bo = new PreProcessingBo();
|
|
|
if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"));
|
|
|
SysOssVo sysOssVo2 = ossService.upload(resultFile);
|
|
|
- bo.setOssId(sysOssVo2.getOssId());
|
|
|
- } else {
|
|
|
- bo.setStatus("0");
|
|
|
}
|
|
|
- bo.setAircraftNo(dataVo.getAircraftNo()).setSortieNo(dataVo.getSortieNo());
|
|
|
- processingService.insert(bo);
|
|
|
return httpVo != null ? httpVo.getData() : null;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
@@ -190,16 +189,10 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
// 请求
|
|
|
map.put("url", sysOssVo1.getUrl());
|
|
|
ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
- PreProcessingBo bo = new PreProcessingBo();
|
|
|
if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
- File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"));
|
|
|
- SysOssVo sysOssVo2 = ossService.upload(resultFile);
|
|
|
- bo.setOssId(sysOssVo2.getOssId());
|
|
|
+ faultDiagnosisService.insert(FaultDiagnosisBo.builder().aircraftId(dataVo.getAircraftId()).build());
|
|
|
} else {
|
|
|
- bo.setStatus("0");
|
|
|
}
|
|
|
- bo.setAircraftNo(dataVo.getAircraftNo()).setSortieNo(dataVo.getSortieNo());
|
|
|
- processingService.insert(bo);
|
|
|
return httpVo != null ? httpVo.getData() : null;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
@@ -209,11 +202,43 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
|
|
|
@Override
|
|
|
public String batchExecute(TaskBo taskBo) {
|
|
|
+ // 数据编号
|
|
|
+ Long dataId;
|
|
|
+ // 预处理编号
|
|
|
+ Long preId;
|
|
|
+ // 虚警编号
|
|
|
+ Long falseAlarmId;
|
|
|
+ // 故障诊断编号
|
|
|
+ Long faultId;
|
|
|
+ // 决策编号
|
|
|
+ Long decisionId;
|
|
|
List<AlgorithmBo> algorithmList = taskBo.getAlgorithmList();
|
|
|
// 批量执行
|
|
|
algorithmList.forEach(el -> {
|
|
|
-
|
|
|
+ // 模型相关信息
|
|
|
+ ModelVo modelVo = modelService.selectById(el.getModelId());
|
|
|
+ // 数据相关信息
|
|
|
+ DataImportVo dataVo = dataImportService.selectById(el.getDataId());
|
|
|
+ // 参数
|
|
|
+ Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(el.getParam()));
|
|
|
+ try (InputStream inputStream = ossService.getFileStream(dataVo.getOssId())) {
|
|
|
+ File file = CsvUtils.excelToFileCsvByColumns(inputStream, el.getColumnData());
|
|
|
+ SysOssVo sysOssVo = ossService.upload(file);
|
|
|
+ // 请求
|
|
|
+ map.put("url", sysOssVo.getUrl());
|
|
|
+ ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
+ if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
+ File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"));
|
|
|
+ SysOssVo sysOssVo2 = ossService.upload(resultFile);
|
|
|
+ }
|
|
|
+ if (taskBo.getStepNumber() == 1) {
|
|
|
+ // TODO 对应结果
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
});
|
|
|
+ taskService.insert(taskBo);
|
|
|
return null;
|
|
|
}
|
|
|
|