|
@@ -7,7 +7,8 @@ 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.FalseAlarmBo;
|
|
|
+import org.eco.als.domain.bo.FalseAlarmResultBo;
|
|
|
import org.eco.als.domain.bo.PreProcessingBo;
|
|
|
import org.eco.als.domain.bo.TaskBo;
|
|
|
import org.eco.als.domain.vo.DataImportVo;
|
|
@@ -15,6 +16,7 @@ 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.IFalseAlarmResultService;
|
|
|
import org.eco.als.service.IFalseAlarmService;
|
|
|
import org.eco.als.service.IFaultDiagnosisService;
|
|
|
import org.eco.als.service.IModelService;
|
|
@@ -61,12 +63,29 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
@Resource
|
|
|
private IFalseAlarmService falseAlarmService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IFalseAlarmResultService falseAlarmResultService;
|
|
|
+
|
|
|
@Resource
|
|
|
private IFaultDiagnosisService faultDiagnosisService;
|
|
|
|
|
|
@Resource
|
|
|
private ITaskService taskService;
|
|
|
|
|
|
+ private static ModelHttpVo sendHttp(ModelVo modelVo, Map<String, Object> map) {
|
|
|
+ try {
|
|
|
+ String result = HttpUtils.postJson(modelVo.getUrl(), map);
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
+ String data = jsonObject.getStr("data");
|
|
|
+ String status = jsonObject.getStr("status");
|
|
|
+ String msg = jsonObject.getStr("msg");
|
|
|
+ return ModelHttpVo.builder().data(data).status(Integer.valueOf(status)).msg(msg).build();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new BusinessException("算法服务连接异常,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* executePro 预处理
|
|
|
*
|
|
@@ -75,23 +94,14 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
**/
|
|
|
@Override
|
|
|
public String executePro(AlgorithmBo algorithmBo) {
|
|
|
-
|
|
|
// 模型相关信息
|
|
|
ModelVo modelVo = modelService.selectById(algorithmBo.getModelId());
|
|
|
if (ObjectUtil.isNull(modelVo)) {
|
|
|
throw new BusinessException("模型信息为空,请检查!");
|
|
|
}
|
|
|
|
|
|
- // 数据相关信息
|
|
|
- DataImportVo dataVo = dataImportService.selectById(algorithmBo.getDataId());
|
|
|
- if (ObjectUtil.isNull(dataVo)) {
|
|
|
- throw new BusinessException("数据为空,请检查!");
|
|
|
- }
|
|
|
-
|
|
|
- // 参数
|
|
|
- Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
File file = null;
|
|
|
- try (InputStream inputStream = ossService.getFileStream(dataVo.getOssId())) {
|
|
|
+ try (InputStream inputStream = ossService.getFileStream(algorithmBo.getOssId())) {
|
|
|
file = CsvUtils.excelToFileCsvByColumns(inputStream, algorithmBo.getColumnData());
|
|
|
} catch (Exception e) {
|
|
|
log.error("文件转换异常:{}", e.getMessage());
|
|
@@ -100,13 +110,28 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
return null;
|
|
|
}
|
|
|
SysOssVo sysOssVo = ossService.upload(file);
|
|
|
- processingService.insert(PreProcessingBo.builder().ossId(sysOssVo.getOssId()).aircraftId(dataVo.getAircraftId()).sortieNo(dataVo.getSortieNo()).build());
|
|
|
- // 请求
|
|
|
+ PreProcessingBo processingBo =
|
|
|
+ PreProcessingBo.builder()
|
|
|
+ .ossId(sysOssVo.getOssId())
|
|
|
+ .aircraftId(algorithmBo.getAircraftId())
|
|
|
+ .modelType(modelVo.getType())
|
|
|
+ .sortieNo(algorithmBo.getSortieNo())
|
|
|
+ .param(algorithmBo.getParam())
|
|
|
+ .status("0")
|
|
|
+ .columnData(Arrays.toString(algorithmBo.getColumnData()))
|
|
|
+ .build();
|
|
|
+ processingService.insert(processingBo);
|
|
|
+ // 参数
|
|
|
+ Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
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);
|
|
|
+ processingBo.setOssId(sysOssVo2.getOssId());
|
|
|
+ processingBo.setStatus("1");
|
|
|
+ processingService.update(processingBo);
|
|
|
}
|
|
|
return httpVo != null ? httpVo.getData() : null;
|
|
|
}
|
|
@@ -119,45 +144,60 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
**/
|
|
|
@Override
|
|
|
public String executeFalseAlarm(AlgorithmBo algorithmBo) {
|
|
|
+ // 虚警抑制校验警告列表
|
|
|
+ if (ObjectUtil.isNull(algorithmBo.getWarningIds())) {
|
|
|
+ throw new BusinessException("警告信息不能为空,请检查!");
|
|
|
+ }
|
|
|
// 模型相关信息
|
|
|
ModelVo modelVo = modelService.selectById(algorithmBo.getModelId());
|
|
|
if (ObjectUtil.isNull(modelVo)) {
|
|
|
throw new BusinessException("模型信息为空,请检查!");
|
|
|
}
|
|
|
-
|
|
|
- // 虚警抑制校验警告列表
|
|
|
- if (ObjectUtil.isNull(algorithmBo.getWarningIds())) {
|
|
|
- throw new BusinessException("警告信息不能为空,请检查!");
|
|
|
+ File file = null;
|
|
|
+ try (InputStream inputStream = ossService.getFileStream(algorithmBo.getOssId())) {
|
|
|
+ file = CsvUtils.excelToFileCsvByColumns(inputStream, algorithmBo.getColumnData());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("文件转换异常:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNull(file)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
+ SysOssVo sysOssVo = ossService.upload(file);
|
|
|
+ FalseAlarmBo falseAlarmBo = FalseAlarmBo.builder()
|
|
|
+ .ossId(sysOssVo.getOssId())
|
|
|
+ .aircraftId(algorithmBo.getAircraftId())
|
|
|
+ .modelType(modelVo.getType())
|
|
|
+ .sortieNo(algorithmBo.getSortieNo())
|
|
|
+ .param(algorithmBo.getParam())
|
|
|
+ .status("0")
|
|
|
+ .columnData(Arrays.toString(algorithmBo.getColumnData()))
|
|
|
+ .build();
|
|
|
+ falseAlarmService.insert(falseAlarmBo);
|
|
|
+
|
|
|
// 警告列表
|
|
|
List<Warning> warnings = warningService.listByIds(Arrays.asList(algorithmBo.getWarningIds()));
|
|
|
+ Warning warning = warnings.getFirst();
|
|
|
warnings.forEach(el -> {
|
|
|
-
|
|
|
});
|
|
|
-
|
|
|
- // 数据相关信息
|
|
|
- DataImportVo dataVo = dataImportService.selectById(algorithmBo.getDataId());
|
|
|
- if (ObjectUtil.isNull(dataVo)) {
|
|
|
- throw new BusinessException("数据为空,请检查!");
|
|
|
- }
|
|
|
// 参数
|
|
|
- String param = algorithmBo.getParam();
|
|
|
- Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(param));
|
|
|
- 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);
|
|
|
- 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;
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage());
|
|
|
+ Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
+ map.put("url", sysOssVo.getUrl());
|
|
|
+ // 请求
|
|
|
+ ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
+ if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
+ falseAlarmBo.setStatus("1");
|
|
|
+ falseAlarmService.update(falseAlarmBo);
|
|
|
+ FalseAlarmResultBo falseAlarmResultBo = FalseAlarmResultBo.builder()
|
|
|
+ .falseAlarmId(falseAlarmBo.getId())
|
|
|
+ .code(warning.getCode())
|
|
|
+ .name(warning.getName())
|
|
|
+ .aircraftId(warning.getAircraftId())
|
|
|
+ .sortieNo(warning.getSortieNo())
|
|
|
+ .status(httpVo.getData())
|
|
|
+ .build();
|
|
|
+ falseAlarmResultService.insert(falseAlarmResultBo);
|
|
|
}
|
|
|
- return null;
|
|
|
+ return httpVo != null ? httpVo.getData() : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -174,30 +214,30 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
if (ObjectUtil.isNull(modelVo)) {
|
|
|
throw new BusinessException("模型信息为空,请检查!");
|
|
|
}
|
|
|
-
|
|
|
- // 数据相关信息
|
|
|
- DataImportVo dataVo = dataImportService.selectById(algorithmBo.getDataId());
|
|
|
- if (ObjectUtil.isNull(dataVo)) {
|
|
|
- throw new BusinessException("数据为空,请检查!");
|
|
|
+ File file = null;
|
|
|
+ try (InputStream inputStream = ossService.getFileStream(algorithmBo.getOssId())) {
|
|
|
+ file = CsvUtils.excelToFileCsvByColumns(inputStream, algorithmBo.getColumnData());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("文件转换异常:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNull(file)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
+ SysOssVo sysOssVo = ossService.upload(file);
|
|
|
+
|
|
|
+ // 警告列表
|
|
|
+ List<Warning> warnings = warningService.listByIds(Arrays.asList(algorithmBo.getWarningIds()));
|
|
|
+ Warning warning = warnings.getFirst();
|
|
|
+ warnings.forEach(el -> {
|
|
|
+ });
|
|
|
// 参数
|
|
|
- String param = algorithmBo.getParam();
|
|
|
- Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(param));
|
|
|
- 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);
|
|
|
- if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
- faultDiagnosisService.insert(FaultDiagnosisBo.builder().aircraftId(dataVo.getAircraftId()).build());
|
|
|
- } else {
|
|
|
- }
|
|
|
- return httpVo != null ? httpVo.getData() : null;
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage());
|
|
|
+ Map<String, Object> map = new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
+ map.put("url", sysOssVo.getUrl());
|
|
|
+ // 请求
|
|
|
+ ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
+ if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
}
|
|
|
- return null;
|
|
|
+ return httpVo != null ? httpVo.getData() : null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -228,7 +268,8 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
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"));
|
|
|
+ File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"
|
|
|
+ ));
|
|
|
SysOssVo sysOssVo2 = ossService.upload(resultFile);
|
|
|
}
|
|
|
if (taskBo.getStepNumber() == 1) {
|
|
@@ -241,18 +282,4 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
taskService.insert(taskBo);
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
- private static ModelHttpVo sendHttp(ModelVo modelVo, Map<String, Object> map) {
|
|
|
- try {
|
|
|
- String result = HttpUtils.postJson(modelVo.getUrl(), map);
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
- String data = jsonObject.getStr("data");
|
|
|
- String status = jsonObject.getStr("status");
|
|
|
- String msg = jsonObject.getStr("msg");
|
|
|
- return ModelHttpVo.builder().data(data).status(Integer.valueOf(status)).msg(msg).build();
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- throw new BusinessException("算法服务连接异常,请联系管理员!");
|
|
|
- }
|
|
|
- }
|
|
|
}
|