fix:指标归档修改&关键结果名称显示修改
This commit is contained in:
@@ -135,6 +135,8 @@ public class KeyResultReq extends BaseReq {
|
||||
// ------------------归档关键结果使用-----------------
|
||||
@Schema(description = "关键结果uuid列表")
|
||||
private List<String> keyResultIdList;
|
||||
@Schema(description = "数值指标id列表")
|
||||
private List<Integer> performanceIdList;
|
||||
|
||||
// -----------------归档输入输出文件使用---------------
|
||||
@Schema(description = "文件id列表")
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.entity.resp.capability.FlowTemplateResp;
|
||||
import com.sdm.common.entity.resp.capability.ReportTemplateResp;
|
||||
import com.sdm.common.entity.resp.data.BatchAddFileInfoResp;
|
||||
import com.sdm.common.entity.req.data.QueryFileReq;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.entity.resp.data.SimulationTaskResultCurveResp;
|
||||
import com.sdm.common.entity.resp.flowable.ProcessInstanceDetailResponse;
|
||||
@@ -1468,6 +1469,40 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
.orderByAsc(SimulationRunKeyResult::getFileId)
|
||||
.list();
|
||||
PageInfo<SimulationRunKeyResult> page = new PageInfo<>(runKeyResults);
|
||||
|
||||
// 批量查询文件信息并回设name
|
||||
if (CollectionUtils.isNotEmpty(runKeyResults)) {
|
||||
// 提取所有fileId
|
||||
List<Long> fileIdList = runKeyResults.stream()
|
||||
.map(SimulationRunKeyResult::getFileId)
|
||||
.filter(ObjectUtils::isNotEmpty)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(fileIdList)) {
|
||||
// 批量查询文件信息
|
||||
QueryFileReq queryFileReq = new QueryFileReq();
|
||||
queryFileReq.setFileIdList(fileIdList);
|
||||
SdmResponse<List<FileMetadataInfoResp>> fileResponse = dataFeignClient.queryFileListByIdList(queryFileReq);
|
||||
|
||||
if (fileResponse.isSuccess() && CollectionUtils.isNotEmpty(fileResponse.getData())) {
|
||||
// 构建fileId -> originalName的映射
|
||||
Map<Long, String> fileIdToNameMap = fileResponse.getData().stream()
|
||||
.collect(Collectors.toMap(FileMetadataInfoResp::getId, FileMetadataInfoResp::getOriginalName, (v1, v2) -> v1));
|
||||
|
||||
// 回设name
|
||||
for (SimulationRunKeyResult keyResult : runKeyResults) {
|
||||
if (keyResult.getFileId() != null) {
|
||||
String originalName = fileIdToNameMap.get(keyResult.getFileId());
|
||||
if (originalName != null) {
|
||||
keyResult.setName(originalName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PageUtils.getJsonObjectSdmResponse(runKeyResults, page);
|
||||
}
|
||||
|
||||
@@ -2899,27 +2934,22 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
}
|
||||
}
|
||||
simulationKeyResultService.saveBatch(taskKeyResultList);
|
||||
} else {
|
||||
// 将算例下的指标分析值同步到任务指标
|
||||
} else if (CollectionUtils.isNotEmpty(req.getPerformanceIdList())) {
|
||||
// 将算例下的指标同步到任务指标
|
||||
List<SimulationPerformance> runPerformanceList = simulationPerformanceService.lambdaQuery()
|
||||
.eq(SimulationPerformance::getRunId, req.getRunId())
|
||||
.in(SimulationPerformance::getId, req.getPerformanceIdList())
|
||||
.list();
|
||||
Map<String, String> resultValueMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(runPerformanceList)) {
|
||||
resultValueMap = runPerformanceList.stream()
|
||||
.filter(sp -> sp.getResultValue() != null)
|
||||
.collect(Collectors.toMap(SimulationPerformance::getNodeCode, SimulationPerformance::getResultValue));
|
||||
}
|
||||
List<SimulationPerformance> simulationTaskPerformances = simulationPerformanceService.lambdaQuery()
|
||||
List<String> performanceCodes = runPerformanceList.stream().map(SimulationPerformance::getNodeCode).collect(Collectors.toList());
|
||||
// 把对应的任务下的指标删除后新增
|
||||
simulationPerformanceService.lambdaUpdate()
|
||||
.eq(SimulationPerformance::getTaskId, simulationRun.getTaskId())
|
||||
.isNull(SimulationPerformance::getRunId)
|
||||
.list();
|
||||
if (CollectionUtils.isNotEmpty(simulationTaskPerformances)) {
|
||||
for (SimulationPerformance simulationTaskPerformance : simulationTaskPerformances) {
|
||||
simulationTaskPerformance.setResultValue(resultValueMap.get(simulationTaskPerformance.getNodeCode()));
|
||||
}
|
||||
simulationPerformanceService.updateBatchById(simulationTaskPerformances);
|
||||
}
|
||||
.in(SimulationPerformance::getNodeCode, performanceCodes).remove();
|
||||
runPerformanceList.forEach(simulationPerformance -> {
|
||||
simulationPerformance.setRunId(null);
|
||||
simulationPerformance.setId(null);
|
||||
});
|
||||
simulationPerformanceService.saveBatch(runPerformanceList);
|
||||
}
|
||||
}
|
||||
return SdmResponse.success();
|
||||
|
||||
Reference in New Issue
Block a user