|
@@ -17,11 +17,10 @@ import org.eco.als.domain.vo.ModelVo;
|
|
|
import org.eco.als.service.*;
|
|
|
import org.eco.als.utils.CsvUtils;
|
|
|
import org.eco.common.core.config.EcoConfig;
|
|
|
-import org.eco.common.core.constant.Constants;
|
|
|
import org.eco.common.core.exception.BusinessException;
|
|
|
import org.eco.common.core.utils.HttpUtils;
|
|
|
-import org.eco.common.core.utils.StringUtils;
|
|
|
import org.eco.common.core.utils.file.FileUtils;
|
|
|
+import org.eco.common.hadoop.hdfs.HadoopClient;
|
|
|
import org.eco.system.domain.vo.SysOssVo;
|
|
|
import org.eco.system.service.ISysOssService;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -72,10 +71,15 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
private ITaskService taskService;
|
|
|
@Resource
|
|
|
private IQaHistoryService qaHistoryService;
|
|
|
+ @Resource
|
|
|
+ private HadoopClient hadoopClient;
|
|
|
|
|
|
@Value("${kgqa.ask-url}")
|
|
|
private String askUrl;
|
|
|
|
|
|
+ @Value("${oss.download.url}")
|
|
|
+ private String url;
|
|
|
+
|
|
|
private static ModelHttpVo sendHttp(ModelVo modelVo, Map<String, Object> map) {
|
|
|
try {
|
|
|
String result = HttpUtils.postJson(modelVo.getUrl(), map);
|
|
@@ -122,12 +126,13 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
PreProcessing preProcessing = processingService.insert(processingBo);
|
|
|
// 参数
|
|
|
Map<String, Object> map = StrUtil.isBlank(algorithmBo.getParam()) ? new HashMap<>() : new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
- map.put("url", sysOssVo.getUrl());
|
|
|
+ map.put("url", url + sysOssVo.getOssId());
|
|
|
// 请求
|
|
|
ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
if (httpVo != null && httpVo.getStatus() == 200) {
|
|
|
File resultFile = CsvUtils.jsonToFileCsv(httpVo.getData(), CsvUtils.extractFilename("model_result"));
|
|
|
- SysOssVo sysOssVo2 = ossService.uploadHadoop(resultFile);
|
|
|
+ assert resultFile != null;
|
|
|
+ SysOssVo sysOssVo2 = ossService.uploadHadoop(resultFile, resultFile.getName());
|
|
|
processingBo.setOssId(sysOssVo2.getOssId());
|
|
|
processingBo.setStatus("1");
|
|
|
processingBo.setVersion(preProcessing.getVersion());
|
|
@@ -181,7 +186,7 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
});
|
|
|
// 参数
|
|
|
Map<String, Object> map = StrUtil.isBlank(algorithmBo.getParam()) ? new HashMap<>() : new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
- map.put("url", sysOssVo.getUrl());
|
|
|
+ map.put("url", url + sysOssVo.getOssId());
|
|
|
map.put("faultCode", warning.getCode());
|
|
|
// 请求
|
|
|
ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
@@ -239,7 +244,7 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
FaultDiagnosis faultDiagnosis = faultDiagnosisService.insert(diagnosisBo);
|
|
|
// 参数
|
|
|
Map<String, Object> map = StrUtil.isBlank(algorithmBo.getParam()) ? new HashMap<>() : new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
- map.put("url", sysOssVo.getUrl());
|
|
|
+ map.put("url", url + sysOssVo.getOssId());
|
|
|
// 请求
|
|
|
ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
if (httpVo != null && httpVo.getStatus() == 200) {
|
|
@@ -280,12 +285,12 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
throw new BusinessException("参数列不能为空,请检查!");
|
|
|
}
|
|
|
algorithmBo.setColumnData(modelVo.getColumnData().split(","));
|
|
|
- List<String> urls = new ArrayList<>();
|
|
|
+ List<Long> ossIds = new ArrayList<>();
|
|
|
dataImportVos.forEach(el -> {
|
|
|
algorithmBo.setOssId(el.getOssId());
|
|
|
SysOssVo sysOssVo = getSysOssVo(algorithmBo);
|
|
|
if (ObjectUtil.isNotNull(sysOssVo)) {
|
|
|
- urls.add(sysOssVo.getUrl());
|
|
|
+ ossIds.add(sysOssVo.getOssId());
|
|
|
}
|
|
|
});
|
|
|
// 插入退化评估记录
|
|
@@ -301,7 +306,7 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
|
|
|
// 参数
|
|
|
Map<String, Object> map = StrUtil.isBlank(algorithmBo.getParam()) ? new HashMap<>() : new HashMap<>(JSONUtil.parseObj(algorithmBo.getParam()));
|
|
|
- map.put("url", urls.getFirst());
|
|
|
+ map.put("url", url + ossIds.getFirst());
|
|
|
// 请求
|
|
|
ModelHttpVo httpVo = sendHttp(modelVo, map);
|
|
|
if (httpVo != null && httpVo.getStatus() == 200) {
|
|
@@ -320,14 +325,11 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
if (ObjectUtil.isNull(sysOss)) {
|
|
|
throw new BusinessException("文件数据不存在!");
|
|
|
}
|
|
|
- String path = StringUtils.substringAfter(sysOss.getFileName(), Constants.RESOURCE_PREFIX);
|
|
|
String tempPathCsv = EcoConfig.getTempPath() + "/" + CsvUtils.getName(FileUtils.getNameNotSuffix(sysOss.getOriginalName()));
|
|
|
-
|
|
|
- JSONArray jsonArray = CsvUtils.getCsvDataByHeaders(path, Arrays.asList(algorithmBo.getColumnData()), null);
|
|
|
+ JSONArray jsonArray = CsvUtils.getCsvDataByHeaders(hadoopClient.readFileContent(sysOss.getUrl()), Arrays.asList(algorithmBo.getColumnData()), null);
|
|
|
File file = CsvUtils.jsonToFileCsvByJsonArray(jsonArray, tempPathCsv);
|
|
|
-
|
|
|
if (ObjectUtil.isNotNull(file)) {
|
|
|
- sysOss = ossService.uploadHadoop(file);
|
|
|
+ sysOss = ossService.uploadHadoop(file, file.getName());
|
|
|
}
|
|
|
FileUtil.del(tempPathCsv);
|
|
|
return sysOss;
|
|
@@ -359,17 +361,13 @@ public class AlgorithmService implements IAlgorithmService {
|
|
|
@Override
|
|
|
public List<String> getDataHeader(Long ossId) {
|
|
|
SysOssVo ossVo = ossService.getById(ossId);
|
|
|
- // 数据库资源地址
|
|
|
- String path = StringUtils.substringAfter(ossVo.getFileName(), Constants.RESOURCE_PREFIX);
|
|
|
- return CsvUtils.getCsvHeaders(path);
|
|
|
+ return CsvUtils.getCsvHeaders(hadoopClient.readFileContent(ossVo.getUrl()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getDataByOssId(Long ossId) {
|
|
|
SysOssVo ossVo = ossService.getById(ossId);
|
|
|
- // 数据库资源地址
|
|
|
- String path = StringUtils.substringAfter(ossVo.getFileName(), Constants.RESOURCE_PREFIX);
|
|
|
- return CsvUtils.fileCsvToJson(path).toString();
|
|
|
+ return CsvUtils.fileCsvToJson(hadoopClient.readFileContent(ossVo.getUrl())).toString();
|
|
|
}
|
|
|
|
|
|
@Override
|