|
@@ -5,7 +5,10 @@ import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
+import com.phm.manage.enums.DataTypeEnum;
|
|
|
+import com.phm.manage.service.IFaultCaseService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -45,12 +48,16 @@ public class ModelServiceImpl implements IModelService {
|
|
|
|
|
|
@Autowired
|
|
|
ModelInfoMapper modelInfoMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private SnowFlakeIdGenerator snowFlakeIdGenerator;
|
|
|
|
|
|
@Autowired
|
|
|
private ISortieParameterService sortieParameterService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFaultCaseService faultCaseService;
|
|
|
+
|
|
|
@Override
|
|
|
public ModelInfo selectModelById(Long id) {
|
|
|
return modelInfoMapper.selectModelById(id);
|
|
@@ -92,6 +99,7 @@ public class ModelServiceImpl implements IModelService {
|
|
|
}
|
|
|
// TODO 模型参数
|
|
|
Map<String, String> parmsMap = getParmsMap(modelInfo);
|
|
|
+ // 数据
|
|
|
SortieParameter sortieParameter = sortieParameterService.selectSortieParameterById(modelRequest.getDataId());
|
|
|
if (ObjectUtil.isEmpty(sortieParameter)) {
|
|
|
throw new GlobalException("选择的架次数据为空,请检查!");
|
|
@@ -108,16 +116,20 @@ public class ModelServiceImpl implements IModelService {
|
|
|
String result = HttpClientUtils.postJson(modelInfo.getUrl(), parms);
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(result);
|
|
|
String jsonString = jsonObject.getStr("data");
|
|
|
+ // 故障深度隔离无结果。需要匹配故障案例
|
|
|
+ if (Objects.equals(modelInfo.getType(), DataTypeEnum.DEEP_ISOLATION.getType())) {
|
|
|
+ // TODO 故障案例 传入故障要素
|
|
|
+ faultCaseService.findFaultCaseList(jsonString);
|
|
|
+ }
|
|
|
// CSV文件路径
|
|
|
- String csvFilePath = PHMConfig.getCsvFilePath() + CsvUtils.RESULT_DATA_PATH + "model_result"
|
|
|
- + Seq.getId(Seq.uploadSeqType) + ".csv";
|
|
|
+ String csvFilePath =
|
|
|
+ PHMConfig.getCsvFilePath() + CsvUtils.RESULT_DATA_PATH + CsvUtils.extractFilename("model_result");
|
|
|
CsvUtils.jsonToFileCsv(jsonString, csvFilePath);
|
|
|
SortieParameter parameter = new SortieParameter();
|
|
|
parameter.setDataPath(csvFilePath).setSortieNo(sortieParameter.getSortieNo())
|
|
|
- .setBatchNo(IdUtil.getSnowflakeNextIdStr());
|
|
|
+ .setBatchNo(IdUtil.getSnowflakeNextIdStr()).setType(modelInfo.getType());
|
|
|
sortieParameterService.insertSortieParameter(parameter);
|
|
|
return jsonString;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private static Map<String, String> getParmsMap(ModelInfo modelInfo) {
|
|
@@ -130,7 +142,7 @@ public class ModelServiceImpl implements IModelService {
|
|
|
for (Object obj : modelParamsArray) {
|
|
|
if (obj instanceof JSONObject) {
|
|
|
JSONObject jsonObj = (JSONObject)obj;
|
|
|
- String name = jsonObj.getStr("name");
|
|
|
+ String name = jsonObj.getStr("key");
|
|
|
String value = jsonObj.getStr("value");
|
|
|
if (ObjectUtil.isNotEmpty(name) && ObjectUtil.isNotEmpty(value)) {
|
|
|
parmsMap.put(name, value);
|
|
@@ -145,7 +157,8 @@ public class ModelServiceImpl implements IModelService {
|
|
|
// 查询数据源
|
|
|
JSONArray dataJson = CsvUtils.getCsvDataByHeaders(dataPath, jsonArray.toList(String.class));
|
|
|
// 生成新的csv文件
|
|
|
- String filePath = PHMConfig.getCsvFilePath() + CsvUtils.TEMP + "parameter_result.csv";
|
|
|
+ String filePath =
|
|
|
+ PHMConfig.getCsvFilePath() + CsvUtils.MODEL_DATA_PATH + CsvUtils.extractFilename("parameter_result");
|
|
|
File file = CsvUtils.jsonToFileCsvByJsonArray(dataJson, filePath);
|
|
|
// 上传并返回新文件名称以及路径
|
|
|
String fileName = FileUploadUtils.upload(PHMConfig.getUploadPath(), FileUtil.fileToMultipartFile(file));
|