Merge branch 'main' of http://carsafe.uicp.cn/toolchaintechnologycenter/spdm-backend
This commit is contained in:
@@ -67,4 +67,7 @@ public class GetSimulationTaskFileReq extends BaseReq {
|
||||
|
||||
@Schema(description = "排序类型:Asc/Desc")
|
||||
private String orderType;
|
||||
|
||||
@Schema(description = "所属学科名称")
|
||||
private String ownDisciplineName;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.sdm.common.entity.req.project;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GetTaskDetailReq {
|
||||
|
||||
@NotNull(message = "relatedResourceUuid不能为空")
|
||||
private String relatedResourceUuid;
|
||||
|
||||
private List<String> relatedResourceUuidList;
|
||||
}
|
||||
|
||||
@@ -14,15 +14,6 @@ public class BaseResp {
|
||||
@Schema(description = "所属学科")
|
||||
String ownDisciplineName;
|
||||
|
||||
@Schema(description = "所属学科id")
|
||||
private String ownDisciplineId;
|
||||
|
||||
@Schema(description = "所属工况任务")
|
||||
String owntaskName;
|
||||
|
||||
@Schema(description = "所属工况任务id")
|
||||
private String owntaskId;
|
||||
|
||||
@Schema(description= "文件业务类型(1:模型文件 2:仿真报告、3:计算文件、4:曲线文件、5:云图文件,6:网格文件,7:计算过程文件)")
|
||||
@TableField("fileType")
|
||||
private Integer fileType;
|
||||
|
||||
@@ -57,6 +57,20 @@ public class SimulationTaskFeignClientImpl implements ISimulationTaskFeignClient
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Map<String, SpdmTaskVo>> batchGetTaskDetailByUuids(GetTaskDetailReq req) {
|
||||
try {
|
||||
SdmResponse<Map<String, SpdmTaskVo>> response = simulationTaskFeignClient.batchGetTaskDetailByUuids(req);
|
||||
if(!response.isSuccess() || ObjectUtils.isEmpty(response.getData())){
|
||||
return SdmResponse.failed("内部调用获取任务详情失败");
|
||||
}
|
||||
return response;
|
||||
}catch (Exception e){
|
||||
log.error("内部调用获取任务详情失败", e);
|
||||
return SdmResponse.failed("内部调用获取任务详情失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Map<String, List<String>>> getAllTasksByDiscipline(GetAllTasksByDisciplineReq req) {
|
||||
try {
|
||||
|
||||
@@ -38,6 +38,10 @@ public interface ISimulationTaskFeignClient {
|
||||
@PostMapping("/task/getTaskDetail")
|
||||
SdmResponse<SpdmTaskVo> getTaskDetail(@RequestBody GetTaskDetailReq req);
|
||||
|
||||
@PostMapping("/task/batchGetTaskDetailByUuids")
|
||||
SdmResponse<Map<String,SpdmTaskVo>> batchGetTaskDetailByUuids(@RequestBody GetTaskDetailReq req);
|
||||
|
||||
|
||||
/**
|
||||
* 根据学科获取所有的任务
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.sdm.common.service;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.bo.DataDictionary;
|
||||
import com.sdm.common.entity.enums.FileDictTagEnum;
|
||||
import com.sdm.common.feign.impl.system.SysConfigFeignClientImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
* @Description: 文件业务类型服务
|
||||
* @Date: 2021/12/27 16:07
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class FileBizTypeService {
|
||||
@Autowired
|
||||
private SysConfigFeignClientImpl sysConfigFeignClient;
|
||||
|
||||
/**
|
||||
* 获取文件类型字典映射(value -> name)
|
||||
* @return 映射表,key 为 dictValue=6,value 为 dictName=流程脚本
|
||||
*/
|
||||
public Map<String, String> getFileTypeMapName() {
|
||||
return getDictMap(FileDictTagEnum.FILE_TYPE.getDictClass(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型字典映射(name -> value)
|
||||
* @return 映射表,key 为 dictName=流程脚本,value 为 dictValue=6
|
||||
*/
|
||||
public Map<String, String> getFileNameMapValue() {
|
||||
return getDictMap(FileDictTagEnum.FILE_TYPE.getDictClass(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用方法:根据 dictClass 获取字典映射
|
||||
* @param dictClass 字典分类
|
||||
* @param reverse 是否反转映射(true: name->value, false: value->name)
|
||||
* @return 映射表
|
||||
*/
|
||||
private Map<String, String> getDictMap(String dictClass, boolean reverse) {
|
||||
SdmResponse<List<DataDictionary>> dictList = sysConfigFeignClient.getDictionaryData(dictClass);
|
||||
if (!dictList.isSuccess() || ObjectUtils.isEmpty(dictList.getData())) {
|
||||
log.error("字典信息查询失败,dictClass: {}", dictClass);
|
||||
return emptyMap();
|
||||
}
|
||||
|
||||
if (reverse) {
|
||||
// name -> value
|
||||
return dictList.getData().stream()
|
||||
.collect(Collectors.toMap(DataDictionary::getDictName, DataDictionary::getDictValue));
|
||||
} else {
|
||||
// value -> name
|
||||
return dictList.getData().stream()
|
||||
.collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为文件类型节点
|
||||
* @param fileType 文件类型值
|
||||
* @return 是否为配置的类型
|
||||
*/
|
||||
public boolean isFileType(String fileType) {
|
||||
Map<String, String> typeMap = getFileTypeMapName();
|
||||
return typeMap.containsKey(fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型名称
|
||||
* @param fileType 文件字典表的dictValue: 1,2,3
|
||||
* @return 文件类型名称:脚本,流程,图片
|
||||
*/
|
||||
public String getFileName(String fileType) {
|
||||
Map<String, String> typeMap = getFileTypeMapName();
|
||||
return typeMap.get(fileType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型值
|
||||
* @param fileName 文件类型名称
|
||||
* @return 文件类型值
|
||||
*/
|
||||
public String getFileType(String fileName) {
|
||||
Map<String, String> fileNameMapValue = getFileNameMapValue();
|
||||
return fileNameMapValue.get(fileName);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class TagMapService {
|
||||
log.error("字典信息查询失败");
|
||||
return emptyMap();
|
||||
}
|
||||
// project-->tag1 phase-->tag2
|
||||
// tag1 --> project tag2 --> phase
|
||||
return tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictName, DataDictionary::getDictValue));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.sdm.data.model.req;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SimulationParameterItem {
|
||||
@Schema(description = "参数名")
|
||||
private String parameterName;
|
||||
|
||||
@@ -14,8 +14,11 @@ import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||
import com.sdm.common.entity.req.data.TagReq;
|
||||
import com.sdm.common.entity.req.export.FileAnalysisExportExcelFormat;
|
||||
import com.sdm.common.entity.req.export.FileAnalysisExportExcelParam;
|
||||
import com.sdm.common.entity.req.project.GetAllTasksByDisciplineReq;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.feign.inter.project.ISimulationTaskFeignClient;
|
||||
import com.sdm.common.service.FileBizTypeService;
|
||||
import com.sdm.common.utils.*;
|
||||
import com.sdm.data.bo.ExportOperate;
|
||||
import com.sdm.data.model.entity.FileMetadataInfo;
|
||||
@@ -70,9 +73,32 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
@Resource
|
||||
private DictTagHelper dictTagHelper;
|
||||
|
||||
@Autowired
|
||||
ISimulationTaskFeignClient simulationTaskFeignClient;
|
||||
|
||||
@Autowired
|
||||
FileBizTypeService fileBizTypeService;
|
||||
|
||||
|
||||
@Override
|
||||
public SdmResponse<PageDataResp<List<SimulationTaskResultCurveResp>>> getSimulationTaskFile(GetSimulationTaskFileReq req) {
|
||||
// 传了学科字段,需要根据学科获取对应的任务uuid
|
||||
List<String> discipoTaskUUids = new ArrayList<>();
|
||||
Set<Long> discipoTaskDirIds = new HashSet<>();
|
||||
if(ObjectUtils.isNotEmpty(req.getOwnDisciplineName())) {
|
||||
discipoTaskUUids = getDisciplineToTaskUUID(List.of(req.getOwnDisciplineName()));
|
||||
if (CollectionUtils.isNotEmpty(discipoTaskUUids)) {
|
||||
List<FileMetadataInfo> discipoTaskDirFileMetaInfo = fileMetadataInfoService.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.in(FileMetadataInfo::getRelatedResourceUuid, discipoTaskUUids)
|
||||
.isNull(FileMetadataInfo::getDeletedAt)
|
||||
.list();
|
||||
if (CollectionUtils.isNotEmpty(discipoTaskDirFileMetaInfo)) {
|
||||
discipoTaskDirIds = discipoTaskDirFileMetaInfo.stream().map(FileMetadataInfo::getId).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// level=task,或者tagReq不为空且tagReq.taskId不为空且tagReq.runId为空,查询工况下的文件
|
||||
if (NodeTypeEnum.TASK.getValue().equals(req.getLevel()) ||
|
||||
@@ -81,13 +107,11 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
&& ObjectUtils.isNotEmpty(req.getTagReq().getTaskId())
|
||||
&& ObjectUtils.isEmpty(req.getTagReq().getRunId())
|
||||
)) {
|
||||
Long taskDirId = resolveTaskDirId(req);
|
||||
if (ObjectUtils.isEmpty(taskDirId)) {
|
||||
Set<Long> taskDirIds = resolveTaskDirId(req);
|
||||
if (ObjectUtils.isEmpty(taskDirIds)) {
|
||||
return PageUtils.getJsonObjectSdmResponse(new ArrayList<>(), new PageInfo<>());
|
||||
}
|
||||
QueryBigFileReq queryBigFileReq = new QueryBigFileReq();
|
||||
queryBigFileReq.setDirId(taskDirId);
|
||||
return getTaskLevelFile(req, queryBigFileReq);
|
||||
return getTaskLevelFile(req, taskDirIds,discipoTaskDirIds);
|
||||
}
|
||||
|
||||
List<Long> fileIdsByDictTags = null;
|
||||
@@ -122,7 +146,7 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
}
|
||||
|
||||
// 所属项目、阶段、机台、工位、任务、算列
|
||||
applyTagFilters(wrapper, req.getTagReq());
|
||||
applyTagFilters(wrapper, req.getTagReq(),discipoTaskUUids);
|
||||
|
||||
if (ObjectUtils.isEmpty(req.getOrderBy())) {
|
||||
wrapper.orderByDesc(FileMetadataInfo::getCreateTime);
|
||||
@@ -148,6 +172,21 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
return PageUtils.getJsonObjectSdmResponse(finalResultList, pageInfo);
|
||||
}
|
||||
|
||||
private List<String> getDisciplineToTaskUUID(List<String> disciplines){
|
||||
// 调用feign获取每个学科对应的任务UUID列表
|
||||
GetAllTasksByDisciplineReq req = new GetAllTasksByDisciplineReq();
|
||||
req.setDisciplines(disciplines);
|
||||
SdmResponse<Map<String, List<String>>> disciplineTasksResponse = simulationTaskFeignClient.getAllTasksByDiscipline(req);
|
||||
|
||||
if (!disciplineTasksResponse.isSuccess() || com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isEmpty(disciplineTasksResponse.getData())) {
|
||||
log.warn("获取学科对应的任务列表失败");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 获取所有学科对应的任务UUID列表
|
||||
return disciplineTasksResponse.getData().values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 复用listBigFile的逻辑:在目录范围内根据dictTags筛出文件ID
|
||||
@@ -182,7 +221,7 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
private void applyTagFilters(LambdaQueryChainWrapper<FileMetadataInfo> wrapper, TagReq tagReq) {
|
||||
private void applyTagFilters(LambdaQueryChainWrapper<FileMetadataInfo> wrapper, TagReq tagReq, List<String> discipoTaskDirIds) {
|
||||
if (ObjectUtils.isEmpty(tagReq)) {
|
||||
return;
|
||||
}
|
||||
@@ -201,6 +240,9 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
// task/run 按普通IN过滤
|
||||
inByCsv(wrapper, FileMetadataInfo::getTaskId, tagReq.getTaskId());
|
||||
inByCsv(wrapper, FileMetadataInfo::getRunId, tagReq.getRunId());
|
||||
|
||||
// 根据所属学科查询所属任务
|
||||
wrapper.in(FileMetadataInfo::getTaskId,discipoTaskDirIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,26 +291,25 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
private Long resolveTaskDirId(GetSimulationTaskFileReq req) {
|
||||
private Set<Long> resolveTaskDirId(GetSimulationTaskFileReq req) {
|
||||
if (ObjectUtils.isNotEmpty(req.getDirId())) {
|
||||
return req.getDirId();
|
||||
return Set.of(req.getDirId());
|
||||
}
|
||||
TagReq tagReq = req.getTagReq();
|
||||
if (ObjectUtils.isNotEmpty(tagReq) && StringUtils.isNotBlank(tagReq.getTaskId())) {
|
||||
List<String> taskIds = parseCsv(tagReq.getTaskId());
|
||||
String targetTaskId = CollectionUtils.isNotEmpty(taskIds) ? taskIds.get(taskIds.size() - 1) : null;
|
||||
if (StringUtils.isNotBlank(targetTaskId)) {
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery()
|
||||
if (CollectionUtils.isNotEmpty(taskIds)) {
|
||||
List<FileMetadataInfo> taskDirs = fileMetadataInfoService.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.eq(FileMetadataInfo::getRelatedResourceUuid, targetTaskId)
|
||||
.in(FileMetadataInfo::getRelatedResourceUuid, taskIds)
|
||||
.isNull(FileMetadataInfo::getDeletedAt)
|
||||
.one();
|
||||
if (ObjectUtils.isNotEmpty(fileMetadataInfo)) {
|
||||
return fileMetadataInfo.getId();
|
||||
.list();
|
||||
if (CollectionUtils.isNotEmpty(taskDirs)) {
|
||||
return taskDirs.stream().map(FileMetadataInfo::getId).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
@@ -327,33 +368,34 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
};
|
||||
}
|
||||
|
||||
private SdmResponse<PageDataResp<List<SimulationTaskResultCurveResp>>> getTaskLevelFile(GetSimulationTaskFileReq req, QueryBigFileReq queryBigFileReq) {
|
||||
private SdmResponse<PageDataResp<List<SimulationTaskResultCurveResp>>> getTaskLevelFile(GetSimulationTaskFileReq req, Set<Long> dirIds, Set<Long> discipoTaskDirIds) {
|
||||
// level=task,查task下的交付物文件夹 再根据fileType查具体的云图文件、曲线文件夹下的文件
|
||||
List<FileMetadataInfo> deliverableFileInfoList = fileMetadataInfoService.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getParentId, queryBigFileReq.getDirId())
|
||||
.in(CollectionUtils.isNotEmpty(dirIds),FileMetadataInfo::getParentId, dirIds)
|
||||
.in(CollectionUtils.isNotEmpty(discipoTaskDirIds),FileMetadataInfo::getParentId, discipoTaskDirIds)
|
||||
.eq(FileMetadataInfo::getOriginalName, CommonConstants.DELIVERABLE_DIR_NAME)
|
||||
.isNull(FileMetadataInfo::getDeletedAt)
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.list();
|
||||
if (CollectionUtils.isNotEmpty(deliverableFileInfoList)) {
|
||||
// 交付物文件夹id
|
||||
Long deliverableDirId = deliverableFileInfoList.get(0).getId();
|
||||
Set<Long> deliverableDirIds = deliverableFileInfoList.stream().map(FileMetadataInfo::getId).collect(Collectors.toSet());
|
||||
// 云图/曲线/文件夹名称
|
||||
String secondDirName = FileBizTypeEnum.getDirNameByValue(req.getFileBizType());
|
||||
List<String> fileNames = Arrays.stream(req.getFileTypeDictValue().split(",")).map(fileType -> fileBizTypeService.getFileName(fileType)).toList();
|
||||
List<FileMetadataInfo> secondDirFileMetadataInfoList = fileMetadataInfoService.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getParentId, deliverableDirId)
|
||||
.eq(FileMetadataInfo::getOriginalName, secondDirName)
|
||||
.in(FileMetadataInfo::getParentId, deliverableDirIds)
|
||||
.in(FileMetadataInfo::getOriginalName, fileNames)
|
||||
.isNull(FileMetadataInfo::getDeletedAt)
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.list();
|
||||
if (CollectionUtils.isNotEmpty(secondDirFileMetadataInfoList)) {
|
||||
// 云图/曲线/文件夹id
|
||||
Long secondDirId = secondDirFileMetadataInfoList.get(0).getId();
|
||||
Set<Long> secondDirIds = secondDirFileMetadataInfoList.stream().map(FileMetadataInfo::getId).collect(Collectors.toSet());
|
||||
|
||||
// 最后查云图/曲线/文件夹底下的文件
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
List<FileMetadataInfo> fileMetadataInfoList = fileMetadataInfoService.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getParentId, secondDirId)
|
||||
.in(FileMetadataInfo::getParentId, secondDirIds)
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.isNull(FileMetadataInfo::getDeletedAt)
|
||||
.eq(FileMetadataInfo::getIsLatest, true)
|
||||
@@ -383,25 +425,6 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
}
|
||||
}
|
||||
return PageUtils.getJsonObjectSdmResponse(new ArrayList<>(), new PageInfo<>());
|
||||
|
||||
// PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
// List<FileMetadataInfo> fileMetadataInfoList = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getParentId, queryBigFileReq.getDirId())
|
||||
// .eq(FileMetadataInfo::getFileType, req.getFileBizType())
|
||||
// .eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
// .list();
|
||||
// PageInfo<FileMetadataInfo> page = new PageInfo<>(fileMetadataInfoList);
|
||||
// long total = page.getTotal();
|
||||
//
|
||||
// List<Long> fileIdList = fileMetadataInfoList.stream().map(FileMetadataInfo::getId).toList();
|
||||
// List<SimulationTaskResultCurveResp> finalResultList = hierarchyHelper.processFileHierarchy(
|
||||
// fileIdList,
|
||||
// SimulationTaskResultCurveResp.class,
|
||||
// FileMetadataHierarchyHelper::setFileHierarchy
|
||||
// );
|
||||
//
|
||||
// PageInfo<SimulationTaskResultCurveResp> page1 = new PageInfo<>(finalResultList);
|
||||
// page1.setTotal(total);
|
||||
// return PageUtils.getJsonObjectSdmResponse(finalResultList, page1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -390,17 +390,6 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
childDto.setTotalName(totalName);
|
||||
}
|
||||
|
||||
// 目前已经移除了学科节点,学科信息作为task节点的字段附属信息
|
||||
if (ObjectUtils.isNotEmpty(childDto.getOwntaskId()) ||
|
||||
(NodeTypeEnum.TASK.getValue().equalsIgnoreCase(childDto.getRelatedResourceUuidOwnType()) && ObjectUtils.isNotEmpty(childDto.getRelatedResourceUuid()))) {
|
||||
GetTaskDetailReq getTaskDetailReq = new GetTaskDetailReq();
|
||||
getTaskDetailReq.setRelatedResourceUuid(ObjectUtils.isNotEmpty(childDto.getOwntaskId()) ? childDto.getOwntaskId() : childDto.getRelatedResourceUuid());
|
||||
SdmResponse<SpdmTaskVo> taskDetail = simulationTaskFeignClient.getTaskDetail(getTaskDetailReq);
|
||||
if (taskDetail.isSuccess()) {
|
||||
childDto.setOwnDisciplineName(taskDetail.getData().getDiscipline());
|
||||
}
|
||||
}
|
||||
|
||||
allChildren.add(childDto);
|
||||
groupedChildren.computeIfAbsent(fileInfo.getOriginalName(), key -> new ArrayList<>()).add(childDto);
|
||||
}
|
||||
@@ -421,7 +410,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
}
|
||||
long start4= System.currentTimeMillis();
|
||||
|
||||
// 批量设置文件的节点信息tag1-tag10
|
||||
// 批量设置文件的节点信息tag1-tag10,学科信息
|
||||
hierarchyHelper.setTagReqFromFileMetadataBatch(allChildren, FileMetadataInfoResp::getId);
|
||||
long start5 = System.currentTimeMillis();
|
||||
// 批量填充文件类型标签信息
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.sdm.data.service.impl;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||
import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.entity.req.project.GetTaskDetailReq;
|
||||
import com.sdm.common.entity.resp.project.SpdmTaskVo;
|
||||
import com.sdm.common.feign.inter.project.ISimulationTaskFeignClient;
|
||||
import com.sdm.common.service.TagMapService;
|
||||
import com.sdm.common.utils.FileSizeUtils;
|
||||
import com.sdm.data.model.entity.FileMetadataInfo;
|
||||
import com.sdm.data.service.IFileMetadataInfoService;
|
||||
@@ -29,6 +33,12 @@ public class FileMetadataHierarchyHelper {
|
||||
@Autowired
|
||||
private IFileMetadataInfoService fileMetadataInfoService;
|
||||
|
||||
@Autowired
|
||||
private ISimulationTaskFeignClient simulationTaskFeignClient;
|
||||
|
||||
@Autowired
|
||||
private TagMapService tagMapService;
|
||||
|
||||
/**
|
||||
* 默认递归深度限制
|
||||
*/
|
||||
@@ -236,13 +246,25 @@ public class FileMetadataHierarchyHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量为响应对象设置tagReq(合并单条逻辑,避免重复查询)
|
||||
* 批量为响应对象设置 tagReq(合并单条逻辑,避免重复查询)
|
||||
*
|
||||
* @param respList 响应对象列表
|
||||
* @param idGetter 获取文件ID的函数
|
||||
* @param idGetter 获取文件 ID 的函数
|
||||
* @param <T> 响应对象类型
|
||||
*/
|
||||
public <T> void setTagReqFromFileMetadataBatch(List<T> respList, Function<T, Long> idGetter) {
|
||||
setTagReqFromFileMetadataBatch(respList, idGetter, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量为响应对象设置 tagReq 和学科属性(可控制是否设置学科信息)
|
||||
*
|
||||
* @param respList 响应对象列表
|
||||
* @param idGetter 获取文件 ID 的函数
|
||||
* @param enableDiscipline 是否设置学科信息
|
||||
* @param <T> 响应对象类型
|
||||
*/
|
||||
public <T> void setTagReqFromFileMetadataBatch(List<T> respList, Function<T, Long> idGetter, boolean enableDiscipline) {
|
||||
if (CollectionUtils.isEmpty(respList) || idGetter == null) {
|
||||
return;
|
||||
}
|
||||
@@ -265,6 +287,25 @@ public class FileMetadataHierarchyHelper {
|
||||
Map<Long, FileMetadataInfo> fileMap = files.stream()
|
||||
.collect(Collectors.toMap(FileMetadataInfo::getId, item -> item, (left, right) -> left));
|
||||
|
||||
// 如果需要设置学科信息,先收集所有 taskId 并获取任务数据
|
||||
Map<String, SpdmTaskVo> taskMap = null;
|
||||
if (enableDiscipline) {
|
||||
Set<String> taskUuidSet = files.stream()
|
||||
.map(FileMetadataInfo::getTaskId)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (CollectionUtils.isNotEmpty(taskUuidSet)) {
|
||||
GetTaskDetailReq req = new GetTaskDetailReq();
|
||||
req.setRelatedResourceUuidList(new ArrayList<>(taskUuidSet));
|
||||
SdmResponse<Map<String, SpdmTaskVo>> mapSdmResponse = simulationTaskFeignClient.batchGetTaskDetailByUuids(req);
|
||||
taskMap = mapSdmResponse.getData();
|
||||
if (taskMap == null) {
|
||||
taskMap = new HashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> uuidNameMap = buildUuidNameMap(files);
|
||||
|
||||
for (T resp : respList) {
|
||||
@@ -274,23 +315,101 @@ public class FileMetadataHierarchyHelper {
|
||||
}
|
||||
FileMetadataInfo file = fileMap.get(fileId);
|
||||
if (file != null) {
|
||||
setTagReqFromFileMetadataInternal(file, resp, uuidNameMap);
|
||||
setTagReqFromFileMetadataInternal(file, resp, uuidNameMap, taskMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接使用FileMetadataInfo中已存储的tag1~tag10、taskId、runId构建并设置tagReq
|
||||
* 并基于relatedResourceUuid查询对应originalName填充tagName/taskName/runName
|
||||
* 直接使用 FileMetadataInfo 中已存储的 tag1~tag10、taskId、runId 构建并设置 tagReq
|
||||
* 并基于 relatedResourceUuid 查询对应 originalName 填充 tagName/taskName/runName
|
||||
*/
|
||||
public <T> void setTagReqFromFileMetadata(FileMetadataInfo file, T resp) {
|
||||
setTagReqFromFileMetadata(file, resp, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接使用 FileMetadataInfo 中已存储的 tag1~tag10、taskId、runId 构建并设置 tagReq 和学科属性
|
||||
* 并基于 relatedResourceUuid 查询对应 originalName 填充 tagName/taskName/runName
|
||||
*
|
||||
* @param file 文件元数据
|
||||
* @param resp 响应对象
|
||||
* @param enableDiscipline 是否设置学科信息
|
||||
*/
|
||||
public <T> void setTagReqFromFileMetadata(FileMetadataInfo file, T resp, boolean enableDiscipline) {
|
||||
if (Objects.isNull(file) || Objects.isNull(resp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> uuidNameMap = buildUuidNameMap(Collections.singletonList(file));
|
||||
setTagReqFromFileMetadataInternal(file, resp, uuidNameMap);
|
||||
|
||||
// 如果需要设置学科信息,获取任务数据
|
||||
Map<String, SpdmTaskVo> taskMap = null;
|
||||
if (enableDiscipline && StringUtils.isNotBlank(file.getTaskId())) {
|
||||
GetTaskDetailReq req = new GetTaskDetailReq();
|
||||
req.setRelatedResourceUuidList(Collections.singletonList(file.getTaskId()));
|
||||
SdmResponse<Map<String, SpdmTaskVo>> mapSdmResponse = simulationTaskFeignClient.batchGetTaskDetailByUuids(req);
|
||||
taskMap = mapSdmResponse.getData();
|
||||
if (taskMap == null) {
|
||||
taskMap = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
setTagReqFromFileMetadataInternal(file, resp, uuidNameMap, taskMap);
|
||||
}
|
||||
|
||||
private <T> void setTagReqFromFileMetadataInternal(FileMetadataInfo file, T resp, Map<String, String> uuidNameMap, Map<String, SpdmTaskVo> taskMap) {
|
||||
try {
|
||||
Class<?> tagReqClass = Class.forName("com.sdm.common.entity.req.data.TagReq");
|
||||
Object tagReq = tagReqClass.getDeclaredConstructor().newInstance();
|
||||
|
||||
List<String> tagValues = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
Object tagValue = FileMetadataInfo.class.getMethod("getTag" + i).invoke(file);
|
||||
String value = Objects.toString(tagValue, null);
|
||||
tagValues.add(value);
|
||||
tagReqClass.getMethod("setTag" + i, String.class).invoke(tagReq, value);
|
||||
}
|
||||
|
||||
String taskId = file.getTaskId();
|
||||
String runId = file.getRunId();
|
||||
tagReqClass.getMethod("setTaskId", String.class).invoke(tagReq, taskId);
|
||||
tagReqClass.getMethod("setRunId", String.class).invoke(tagReq, runId);
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
String tagValue = tagValues.get(i - 1);
|
||||
List<String> uuidChain = parseUuidChain(tagValue);
|
||||
String tagName = uuidChain.stream()
|
||||
.map(uuidNameMap::get)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.joining("/"));
|
||||
tagReqClass.getMethod("setTag" + i + "Name", String.class).invoke(tagReq, tagName);
|
||||
}
|
||||
tagReqClass.getMethod("setTaskName", String.class).invoke(tagReq, uuidNameMap.get(taskId));
|
||||
tagReqClass.getMethod("setRunName", String.class).invoke(tagReq, uuidNameMap.get(runId));
|
||||
|
||||
resp.getClass().getMethod("setTagReq", tagReqClass).invoke(resp, tagReq);
|
||||
|
||||
// 设置学科信息
|
||||
if (taskMap != null && StringUtils.isNotBlank(taskId)) {
|
||||
SpdmTaskVo taskVo = taskMap.get(taskId);
|
||||
if (taskVo != null) {
|
||||
String disciplineName = taskVo.getDiscipline();
|
||||
if (StringUtils.isNotBlank(disciplineName)) {
|
||||
resp.getClass().getMethod("setOwnDisciplineName", String.class).invoke(resp, disciplineName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("设置 tagReq 失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 uuidNameMap: key=tag1UUid ,value=项目名称
|
||||
* @param files
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> buildUuidNameMap(List<FileMetadataInfo> files) {
|
||||
Set<String> relatedUuids = new HashSet<>();
|
||||
for (FileMetadataInfo file : files) {
|
||||
@@ -334,42 +453,6 @@ public class FileMetadataHierarchyHelper {
|
||||
));
|
||||
}
|
||||
|
||||
private <T> void setTagReqFromFileMetadataInternal(FileMetadataInfo file, T resp, Map<String, String> uuidNameMap) {
|
||||
try {
|
||||
Class<?> tagReqClass = Class.forName("com.sdm.common.entity.req.data.TagReq");
|
||||
Object tagReq = tagReqClass.getDeclaredConstructor().newInstance();
|
||||
|
||||
List<String> tagValues = new ArrayList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
Object tagValue = FileMetadataInfo.class.getMethod("getTag" + i).invoke(file);
|
||||
String value = Objects.toString(tagValue, null);
|
||||
tagValues.add(value);
|
||||
tagReqClass.getMethod("setTag" + i, String.class).invoke(tagReq, value);
|
||||
}
|
||||
|
||||
String taskId = file.getTaskId();
|
||||
String runId = file.getRunId();
|
||||
tagReqClass.getMethod("setTaskId", String.class).invoke(tagReq, taskId);
|
||||
tagReqClass.getMethod("setRunId", String.class).invoke(tagReq, runId);
|
||||
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
String tagValue = tagValues.get(i - 1);
|
||||
List<String> uuidChain = parseUuidChain(tagValue);
|
||||
String tagName = uuidChain.stream()
|
||||
.map(uuidNameMap::get)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.joining("/"));
|
||||
tagReqClass.getMethod("setTag" + i + "Name", String.class).invoke(tagReq, tagName);
|
||||
}
|
||||
tagReqClass.getMethod("setTaskName", String.class).invoke(tagReq, uuidNameMap.get(taskId));
|
||||
tagReqClass.getMethod("setRunName", String.class).invoke(tagReq, uuidNameMap.get(runId));
|
||||
|
||||
resp.getClass().getMethod("setTagReq", tagReqClass).invoke(resp, tagReq);
|
||||
} catch (Exception e) {
|
||||
log.warn("设置tagReq失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析逗号拼接的uuid链
|
||||
*/
|
||||
|
||||
@@ -150,6 +150,16 @@ public class SimulationTaskController implements ISimulationTaskFeignClient {
|
||||
return taskService.getTaskDetail(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务uuid 批量获取任务详情
|
||||
*/
|
||||
@PostMapping("/batchGetTaskDetailByUuids")
|
||||
@Operation(summary = "批量获取任务详情", description = "批量获取任务详情")
|
||||
public SdmResponse<Map<String,SpdmTaskVo>> batchGetTaskDetailByUuids(@RequestBody GetTaskDetailReq req) {
|
||||
return taskService.batchGetTaskDetailByUuids(req);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据学科获取所有的任务
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp;
|
||||
import com.sdm.common.entity.resp.project.SpdmTaskVo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
@@ -65,6 +66,8 @@ public interface ITaskService {
|
||||
|
||||
SdmResponse<SpdmTaskVo> getTaskDetail(GetTaskDetailReq req);
|
||||
|
||||
SdmResponse<Map<String,SpdmTaskVo>> batchGetTaskDetailByUuids(@RequestBody GetTaskDetailReq req);
|
||||
|
||||
SdmResponse<Map<String, List<String>>> getAllTasksByDiscipline(GetAllTasksByDisciplineReq req);
|
||||
|
||||
BosimSaveProjectTaskRsp syncCidTask(SyncCidTaskReq req);
|
||||
|
||||
@@ -3159,6 +3159,17 @@ public class TaskServiceImpl implements ITaskService {
|
||||
return SdmResponse.success(taskVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Map<String,SpdmTaskVo>> batchGetTaskDetailByUuids(GetTaskDetailReq req) {
|
||||
return SdmResponse.success(
|
||||
simulationTaskService.lambdaQuery().in(SimulationTask::getUuid, req.getRelatedResourceUuidList()).list().stream().map(task -> {
|
||||
SpdmTaskVo taskVo = new SpdmTaskVo();
|
||||
BeanUtils.copyProperties(task, taskVo);
|
||||
return taskVo;
|
||||
}).collect(Collectors.toMap(SpdmTaskVo::getUuid, taskVo -> taskVo))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<Map<String, List<String>>> getAllTasksByDiscipline(GetAllTasksByDisciplineReq req) {
|
||||
Map<String, List<String>> discipline2TaskUUIDMap = simulationTaskService.lambdaQuery()
|
||||
|
||||
Reference in New Issue
Block a user