From 3f15c3627b54a84617931e963fdb460f79fb5546 Mon Sep 17 00:00:00 2001 From: gulongcheng <474084054@qq.com> Date: Mon, 15 Dec 2025 09:50:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MinioFileIDataFileServiceImpl.java | 3 +- project/repomix-output.xml | 22163 ++++++++++++++++ 2 files changed, 22165 insertions(+), 1 deletion(-) create mode 100644 project/repomix-output.xml diff --git a/data/src/main/java/com/sdm/data/service/impl/MinioFileIDataFileServiceImpl.java b/data/src/main/java/com/sdm/data/service/impl/MinioFileIDataFileServiceImpl.java index fd8fb399..83555923 100644 --- a/data/src/main/java/com/sdm/data/service/impl/MinioFileIDataFileServiceImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/MinioFileIDataFileServiceImpl.java @@ -813,7 +813,8 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService { // 数据库批量删除文件信息 LambdaQueryWrapper fileMetaDataQuery = new LambdaQueryWrapper<>(); fileMetaDataQuery.select(FileStorage::getFileId).eq(FileStorage::getDirId, deleteDirId); - List deleteFileIdList = fileStorageService.listObjs(fileMetaDataQuery, id -> (Long) id); + List deleteFileIdList = fileStorageService.list(fileMetaDataQuery).stream().map(FileStorage::getFileId).collect(Collectors.toList()); + deleteFileIdList.add(deleteDirId); if(ObjectUtils.isNotEmpty(deleteFileIdList)){ diff --git a/project/repomix-output.xml b/project/repomix-output.xml new file mode 100644 index 00000000..11a97de2 --- /dev/null +++ b/project/repomix-output.xml @@ -0,0 +1,22163 @@ +This file is a merged representation of a subset of the codebase, containing specifically included files, combined into a single document by Repomix. + + +This section contains a summary of this file. + + +This file contains a packed representation of a subset of the repository's contents that is considered the most important context. +It is designed to be easily consumable by AI systems for analysis, code review, +or other automated processes. + + + +The content is organized as follows: +1. This summary section +2. Repository information +3. Directory structure +4. Repository files (if enabled) +5. Multiple file entries, each consisting of: + - File path as an attribute + - Full contents of the file + + + +- This file should be treated as read-only. Any changes should be made to the + original repository files, not this packed version. +- When processing this file, use the file path to distinguish + between different files in the repository. +- Be aware that this file may contain sensitive information. Handle it with + the same level of security as you would the original repository. + + + +- Some files may have been excluded based on .gitignore rules and Repomix's configuration +- Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files +- Only files matching these patterns are included: **/src/main/java/**/*.java, **/src/main/resources/**/*.yml, **/pom.xml +- Files matching patterns in .gitignore are excluded +- Files matching default ignore patterns are excluded +- Files are sorted by Git change count (files with more changes are at the bottom) + + + + + +pom.xml +src/main/java/com/sdm/project/common/ApprovalStatusEnum.java +src/main/java/com/sdm/project/common/DemandStatusTypeEnum.java +src/main/java/com/sdm/project/common/KeyResultTypeEnum.java +src/main/java/com/sdm/project/common/MemberTypeEnum.java +src/main/java/com/sdm/project/common/RunPerformanceStatusEnum.java +src/main/java/com/sdm/project/common/RunStatusEnum.java +src/main/java/com/sdm/project/common/TaskAchieveStatusEnum.java +src/main/java/com/sdm/project/common/TaskExeStatusEnum.java +src/main/java/com/sdm/project/common/TaskOperationTypeEnum.java +src/main/java/com/sdm/project/common/TaskQryTypeEnum.java +src/main/java/com/sdm/project/common/VersionEnum.java +src/main/java/com/sdm/project/config/DecryptEnvironmentPostProcessor.java +src/main/java/com/sdm/project/config/mybatis/DatabasePlugin.java +src/main/java/com/sdm/project/config/mybatis/DBContextHolder.java +src/main/java/com/sdm/project/config/mybatis/DBTypeEnum.java +src/main/java/com/sdm/project/config/mybatis/DynamicDataSource.java +src/main/java/com/sdm/project/config/mybatis/MybatisPlusConfig.java +src/main/java/com/sdm/project/config/OkHttpConfiguration.java +src/main/java/com/sdm/project/config/RedisConfig.java +src/main/java/com/sdm/project/config/RequestConfig.java +src/main/java/com/sdm/project/config/ScheduledTaskConfig.java +src/main/java/com/sdm/project/config/SwaggerConfig.java +src/main/java/com/sdm/project/controller/SimulationAnalysisController.java +src/main/java/com/sdm/project/controller/SimulationDemandController.java +src/main/java/com/sdm/project/controller/SimulationNodeController.java +src/main/java/com/sdm/project/controller/SimulationProjectController.java +src/main/java/com/sdm/project/controller/SimulationRunController.java +src/main/java/com/sdm/project/controller/SimulationTaskController.java +src/main/java/com/sdm/project/controller/YAModelController.java +src/main/java/com/sdm/project/dao/SimulationBaseQuantitiesMapper.java +src/main/java/com/sdm/project/dao/SimulationBaseUnitsMapper.java +src/main/java/com/sdm/project/dao/SimulationDemandMapper.java +src/main/java/com/sdm/project/dao/SimulationKeyResultMapper.java +src/main/java/com/sdm/project/dao/SimulationNodeMapper.java +src/main/java/com/sdm/project/dao/SimulationPerformanceMapper.java +src/main/java/com/sdm/project/dao/SimulationProjectMapper.java +src/main/java/com/sdm/project/dao/SimulationRunMapper.java +src/main/java/com/sdm/project/dao/SimulationTaskAttentionMapper.java +src/main/java/com/sdm/project/dao/SimulationTaskExtraMapper.java +src/main/java/com/sdm/project/dao/SimulationTaskMapper.java +src/main/java/com/sdm/project/dao/SimulationTaskMemberMapper.java +src/main/java/com/sdm/project/filter/AuthFilter.java +src/main/java/com/sdm/project/handler/ListStringTypeHandler.java +src/main/java/com/sdm/project/model/bo/ApprovalDeliverableContentsModel.java +src/main/java/com/sdm/project/model/bo/BaseBean.java +src/main/java/com/sdm/project/model/bo/CidTaskNode.java +src/main/java/com/sdm/project/model/bo/CurveParamDto.java +src/main/java/com/sdm/project/model/bo/ModifyProjectNode.java +src/main/java/com/sdm/project/model/bo/ModifyTaskNode.java +src/main/java/com/sdm/project/model/bo/PerformanceInfo.java +src/main/java/com/sdm/project/model/bo/ProjectExtraNode.java +src/main/java/com/sdm/project/model/bo/ProjectInfo.java +src/main/java/com/sdm/project/model/bo/ProjectMemberNode.java +src/main/java/com/sdm/project/model/bo/ProjectNode.java +src/main/java/com/sdm/project/model/bo/ProjectNodeInfo.java +src/main/java/com/sdm/project/model/bo/ProjectNodeTree.java +src/main/java/com/sdm/project/model/bo/TaskExtraNode.java +src/main/java/com/sdm/project/model/bo/TaskInfo.java +src/main/java/com/sdm/project/model/bo/TaskMemberNode.java +src/main/java/com/sdm/project/model/bo/TaskNode.java +src/main/java/com/sdm/project/model/bo/TaskNodeTag.java +src/main/java/com/sdm/project/model/bo/TaskNodeTree.java +src/main/java/com/sdm/project/model/entity/SimulationBaseQuantities.java +src/main/java/com/sdm/project/model/entity/SimulationBaseUnits.java +src/main/java/com/sdm/project/model/entity/SimulationDemand.java +src/main/java/com/sdm/project/model/entity/SimulationNode.java +src/main/java/com/sdm/project/model/entity/SimulationRun.java +src/main/java/com/sdm/project/model/entity/SimulationRunKeyResult.java +src/main/java/com/sdm/project/model/entity/SimulationTask.java +src/main/java/com/sdm/project/model/entity/SimulationTaskAttention.java +src/main/java/com/sdm/project/model/entity/SimulationTaskExtra.java +src/main/java/com/sdm/project/model/entity/SimulationTaskMember.java +src/main/java/com/sdm/project/model/po/NodeAllBase.java +src/main/java/com/sdm/project/model/po/PerformanceNodeExtraPo.java +src/main/java/com/sdm/project/model/po/PerformanceNodePo.java +src/main/java/com/sdm/project/model/po/ProjectNodeDetailPo.java +src/main/java/com/sdm/project/model/po/ProjectNodeExtraPo.java +src/main/java/com/sdm/project/model/po/ProjectNodeMemberPo.java +src/main/java/com/sdm/project/model/po/ProjectNodePo.java +src/main/java/com/sdm/project/model/po/RunNodePo.java +src/main/java/com/sdm/project/model/po/TaskNodeExtraPo.java +src/main/java/com/sdm/project/model/po/TaskNodeMemberPo.java +src/main/java/com/sdm/project/model/po/TaskNodePo.java +src/main/java/com/sdm/project/model/po/TaskRunPo.java +src/main/java/com/sdm/project/model/req/AddProjectNodeBatchReq.java +src/main/java/com/sdm/project/model/req/AddProjectReq.java +src/main/java/com/sdm/project/model/req/CommonGetCompleteStatisticsReq.java +src/main/java/com/sdm/project/model/req/DeliverableApproveReq.java +src/main/java/com/sdm/project/model/req/DelProjectNodeReq.java +src/main/java/com/sdm/project/model/req/DelProjectReq.java +src/main/java/com/sdm/project/model/req/GetNodeDetailReq.java +src/main/java/com/sdm/project/model/req/GetProjectDetailReq.java +src/main/java/com/sdm/project/model/req/GetProjectListReq.java +src/main/java/com/sdm/project/model/req/GetRunVersionReq.java +src/main/java/com/sdm/project/model/req/GetTaskDetailReq.java +src/main/java/com/sdm/project/model/req/GetUserGroupTaskCompleteStatisticsReq.java +src/main/java/com/sdm/project/model/req/GetWorkstationApproveStatusReq.java +src/main/java/com/sdm/project/model/req/KeyResultReq.java +src/main/java/com/sdm/project/model/req/PerformanceCompleteStatisticsReq.java +src/main/java/com/sdm/project/model/req/PerformanceInfoReq.java +src/main/java/com/sdm/project/model/req/ProjectNodeListReq.java +src/main/java/com/sdm/project/model/req/ProjectTreeReq.java +src/main/java/com/sdm/project/model/req/ProjectTreeTagReq.java +src/main/java/com/sdm/project/model/req/SpdmAddDemandReq.java +src/main/java/com/sdm/project/model/req/SpdmAddNodeReq.java +src/main/java/com/sdm/project/model/req/SpdmAddTaskRunReq.java +src/main/java/com/sdm/project/model/req/SpdmAnalysisPerformanceListReq.java +src/main/java/com/sdm/project/model/req/SpdmAnalysisRunListReq.java +src/main/java/com/sdm/project/model/req/SpdmAnalysisTaskListReq.java +src/main/java/com/sdm/project/model/req/SpdmDeleteDemandReq.java +src/main/java/com/sdm/project/model/req/SpdmDeleteNodeReq.java +src/main/java/com/sdm/project/model/req/SpdmDeleteProjectDetailReq.java +src/main/java/com/sdm/project/model/req/SpdmDeleteProjectReq.java +src/main/java/com/sdm/project/model/req/SpdmDemandExtraReq.java +src/main/java/com/sdm/project/model/req/SpdmDemandListReq.java +src/main/java/com/sdm/project/model/req/SpdmDemandRelateMemberReq.java +src/main/java/com/sdm/project/model/req/SpdmEditDemandReq.java +src/main/java/com/sdm/project/model/req/SpdmEditNodeForDataReq.java +src/main/java/com/sdm/project/model/req/SpdmEditNodeReq.java +src/main/java/com/sdm/project/model/req/SpdmEditTaskForDataReq.java +src/main/java/com/sdm/project/model/req/SpdmNodeDetailReq.java +src/main/java/com/sdm/project/model/req/SpdmNodeExtraReq.java +src/main/java/com/sdm/project/model/req/SpdmNodeParamReq.java +src/main/java/com/sdm/project/model/req/SpdmNodeRelateMemberReq.java +src/main/java/com/sdm/project/model/req/SpdmNodeReq.java +src/main/java/com/sdm/project/model/req/SpdmProjectNodeEditReq.java +src/main/java/com/sdm/project/model/req/SpdmSyncCidTaskReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskAttentionReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskCountReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskIssue.java +src/main/java/com/sdm/project/model/req/SpdmTaskIssueReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskListReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskOpr.java +src/main/java/com/sdm/project/model/req/SpdmTaskOprReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskReq.java +src/main/java/com/sdm/project/model/req/SpdmTaskRunReq.java +src/main/java/com/sdm/project/model/req/TaskCompleteStatisticsReq.java +src/main/java/com/sdm/project/model/req/TaskEditNodeReq.java +src/main/java/com/sdm/project/model/req/TaskHandleReq.java +src/main/java/com/sdm/project/model/req/UpdateProjectLeaderReq.java +src/main/java/com/sdm/project/model/req/UpdateProjectNodeBatchReq.java +src/main/java/com/sdm/project/model/req/UserDifficultCompleteStatisticsReq.java +src/main/java/com/sdm/project/model/req/UserTaskCompleteStatisticsReq.java +src/main/java/com/sdm/project/model/req/UserWorkloadReq.java +src/main/java/com/sdm/project/model/req/YA/DeleteModelNodeInfoReq.java +src/main/java/com/sdm/project/model/req/YA/GetModelNodeInfoReq.java +src/main/java/com/sdm/project/model/req/YA/GetTaskSimulatinFileReq.java +src/main/java/com/sdm/project/model/req/YA/ProjectTaskInfo.java +src/main/java/com/sdm/project/model/req/YA/SaveKeyResultNodeInfoReq.java +src/main/java/com/sdm/project/model/req/YA/SaveModelNodeInfoReq.java +src/main/java/com/sdm/project/model/req/YA/SaveReportNodeInfoReq.java +src/main/java/com/sdm/project/model/req/YA/SyncCidProjectReq.java +src/main/java/com/sdm/project/model/req/YA/SyncCidTaskReq.java +src/main/java/com/sdm/project/model/resp/FlowInfoDto.java +src/main/java/com/sdm/project/model/resp/GetAllRunResultByTaskIdResp.java +src/main/java/com/sdm/project/model/resp/KeyResultAndTaskInfoResp.java +src/main/java/com/sdm/project/model/resp/RunResultResp.java +src/main/java/com/sdm/project/model/resp/RunVersionInfoResp.java +src/main/java/com/sdm/project/model/resp/TaskCountResp.java +src/main/java/com/sdm/project/model/resp/TasKPerformanceResp.java +src/main/java/com/sdm/project/model/resp/TaskWorkDaysResp.java +src/main/java/com/sdm/project/model/resp/UserWorkloadResp.java +src/main/java/com/sdm/project/model/resp/YA/BosimErrorRespond.java +src/main/java/com/sdm/project/model/resp/YA/BosimKeyResultInfoRsp.java +src/main/java/com/sdm/project/model/resp/YA/BosimSaveNodeInfoRsp.java +src/main/java/com/sdm/project/model/resp/YA/BosimSaveProjectTaskRsp.java +src/main/java/com/sdm/project/model/resp/YA/KeyResultNodeInfo.java +src/main/java/com/sdm/project/model/vo/CommonGetCompleteFromPerformanceVo.java +src/main/java/com/sdm/project/model/vo/CommonGetCompleteFromTaskVo.java +src/main/java/com/sdm/project/model/vo/CommonStatisticsVo.java +src/main/java/com/sdm/project/model/vo/SpdmAnalysisTaskVo.java +src/main/java/com/sdm/project/model/vo/SpdmDemandExtraVo.java +src/main/java/com/sdm/project/model/vo/SpdmDemandMemberVo.java +src/main/java/com/sdm/project/model/vo/SpdmDemandVo.java +src/main/java/com/sdm/project/model/vo/SpdmExportDemandVo.java +src/main/java/com/sdm/project/model/vo/SpdmExportNewTaskVo.java +src/main/java/com/sdm/project/model/vo/SpdmExportNodeVo.java +src/main/java/com/sdm/project/model/vo/SpdmNewTaskVo.java +src/main/java/com/sdm/project/model/vo/SpdmNodeDetailForDataVo.java +src/main/java/com/sdm/project/model/vo/SpdmNodeDetailVo.java +src/main/java/com/sdm/project/model/vo/SpdmNodeExtraVo.java +src/main/java/com/sdm/project/model/vo/SpdmNodeMemberVo.java +src/main/java/com/sdm/project/model/vo/SpdmNodeVo.java +src/main/java/com/sdm/project/model/vo/SpdmTaskAttentionMemberVo.java +src/main/java/com/sdm/project/model/vo/SpdmTaskDetailVo.java +src/main/java/com/sdm/project/model/vo/SpdmTaskMemberVo.java +src/main/java/com/sdm/project/model/vo/SpdmTaskVo.java +src/main/java/com/sdm/project/model/vo/SpdmUserVo.java +src/main/java/com/sdm/project/model/vo/UserGroupDifficultyStatisticsVo.java +src/main/java/com/sdm/project/model/vo/UserGroupDifficultyVo.java +src/main/java/com/sdm/project/model/vo/UserGroupProjectVo.java +src/main/java/com/sdm/project/model/vo/UserGroupTaskCompleteStatisticsVo.java +src/main/java/com/sdm/project/model/vo/UserGroupTaskCompleteVo.java +src/main/java/com/sdm/project/model/vo/WorkstationApproveStatusVo.java +src/main/java/com/sdm/project/ProjectApplication.java +src/main/java/com/sdm/project/service/IDemandService.java +src/main/java/com/sdm/project/service/impl/DemandServiceImpl.java +src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java +src/main/java/com/sdm/project/service/impl/ProjectServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationBaseUnitsServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationKeyResultServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationPerformanceServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationRunServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationTaskAttentionServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationTaskExtraServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationTaskMemberServiceImpl.java +src/main/java/com/sdm/project/service/impl/SimulationTaskServiceImpl.java +src/main/java/com/sdm/project/service/impl/TaskServiceImpl.java +src/main/java/com/sdm/project/service/INodeService.java +src/main/java/com/sdm/project/service/IProjectService.java +src/main/java/com/sdm/project/service/ISimulationBaseQuantitiesService.java +src/main/java/com/sdm/project/service/ISimulationBaseUnitsService.java +src/main/java/com/sdm/project/service/ISimulationKeyResultService.java +src/main/java/com/sdm/project/service/ISimulationPerformanceService.java +src/main/java/com/sdm/project/service/ISimulationRunService.java +src/main/java/com/sdm/project/service/ISimulationTaskAttentionService.java +src/main/java/com/sdm/project/service/ISimulationTaskExtraService.java +src/main/java/com/sdm/project/service/ISimulationTaskMemberService.java +src/main/java/com/sdm/project/service/ISimulationTaskService.java +src/main/java/com/sdm/project/service/ITaskService.java +src/main/java/com/sdm/project/service/SimulationBaseQuantitiesServiceImpl.java +src/main/resources/application-dev.yml +src/main/resources/application-local.yml +src/main/resources/application-lyric.yml +src/main/resources/application-prod.yml +src/main/resources/application-test.yml +src/main/resources/application.yml + + + +This section contains the contents of the repository's files. + + + + + 4.0.0 + + com.sdm + SDM + 1.0-SNAPSHOT + + project + 0.0.1-SNAPSHOT + project + project + + 17 + UTF-8 + UTF-8 + 3.3.5 + + + + + com.sdm + common + 0.0.1-SNAPSHOT + + + * + * + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-web + + + + commons-net + commons-net + 3.11.1 + + + org.apache.commons + commons-lang3 + 3.14.0 + + + org.aspectj + aspectjweaver + + + javax.annotation + javax.annotation-api + 1.3.2 + + + com.squareup.okhttp3 + okhttp + 4.10.0 + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + true + + + + + + + + + + + + + + + + + + + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum ApprovalStatusEnum { + + ING("进行中", 1), + PASSED("评审通过", 2), + REJECTED("评审驳回", 3); + + private final String name; + + private final Integer code; + + ApprovalStatusEnum(String name, Integer code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum DemandStatusTypeEnum { + + UNASSIGNED("未分配", 0), + NOT_STARTED("未开始", 1), + IN_PROGRESS("进行中", 2), + PAUSE("暂停", 3), + CLOSED("已关闭", 4), + CLOSED_LOOP("已闭环", 5), + REJECTED("已驳回", 6); + + private final String name; + + private final Integer code; + + DemandStatusTypeEnum(String name, Integer code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import com.sdm.common.entity.enums.ApprovalFileDataStatusEnum; +import lombok.Getter; + +import java.util.Objects; + +@Getter +public enum KeyResultTypeEnum { + IMAGE("图片/动画", 1, "图片结果"), + CURVE("曲线", 2, "曲线结果"), + DOCUMENT("报告", 3, "报告结果"), + VALUE("数值", 4, "数值结果"); + + private final String name; + private final Integer keyResultType; + private final String dirName; + + KeyResultTypeEnum(String name, Integer keyResultType, String dirName) { + this.name = name; + this.keyResultType = keyResultType; + this.dirName = dirName; + } + + public static String getDirNameByType(Integer keyResultType) { + for (KeyResultTypeEnum status : values()) { + if (Objects.equals(status.getKeyResultType(), keyResultType)) { + return status.getDirName(); + } + } + return null; + } +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum MemberTypeEnum { + + PRINCIPAL("仿真负责人", 0), + EXECUTOR("仿真执行人", 1), + THREED("3D负责人", 2), + ATTENTION("关注人", 3); + + private final String name; + + private final Integer code; + + MemberTypeEnum(String name, Integer code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +/** + * 指标完成情况状态枚举 + */ +@Getter +public enum RunPerformanceStatusEnum { + + UNCOMPLETED("未完成", "0"), + NOT_STARTED("不合格", "1"), + RISK_CONTROL("风险可控", "2"), + UNANALYZED("未分析", "3"), + STARTED("合格", "4"); + + private final String name; + + private final String code; + + RunPerformanceStatusEnum(String name, String code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +/** + * 算例完成情况状态枚举 + */ +@Getter +public enum RunStatusEnum { + + UNCOMPLETED("未完成", 0), + RUNNING("执行中", 1), + COMPLETED("完成", 2), + FAILED("失败", 3); + + private final String name; + + private final Integer code; + + RunStatusEnum(String name, Integer code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum TaskAchieveStatusEnum { + + NO_CALCULATE ("未分析", "0"), + UNQUALIFIED ("不合格", "1"), + QUALIFIED ("合格", "2"); + + private final String name; + + private final String code; + + TaskAchieveStatusEnum(String name, String code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum TaskExeStatusEnum { + + NO_STARTED("未开始", "1"), + IN_PROGRESS("进行中", "2"), + REJECTED("已驳回", "3"), + COMPLETED("已完成", "4"), + PAUSED("已暂停", "5"), + CLOSED("已关闭","6"), + POSTPONED("已延期", "7"); + + private final String name; + + private final String code; + + TaskExeStatusEnum(String name, String code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum TaskOperationTypeEnum { + // 驳回 + REJECTED("已驳回", 0), + // 启动 + IN_PROGRESS("进行中", 1), + // 暂停 + PAUSE("暂停", 2), + // 工时 + DAYS("工时", 3), + //关闭 + CLOSED("已关闭", 4), + // 关注 + FOLLOW("关注", 5), + // 取消关注 + UN_FOLLOW("取消关注", 6); + + private final String name; + + private final Integer code; + + TaskOperationTypeEnum(String name, Integer code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.common; + +public enum TaskQryTypeEnum { + EXEC(0, "我执行的"), + ATTENTION(1, "我关注的"), + ALL(2, "所有"), + ISSUE(3, "我分发的"); + + private final Integer code; + private final String desc; + + TaskQryTypeEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + + public Integer getCode() { + return code; + } + + public static boolean isValid(Integer code) { + for (TaskQryTypeEnum type : values()) { + if (type.getCode() == code) { + return true; + } + } + return false; + } +} + + + +package com.sdm.project.common; + +import lombok.Getter; + +@Getter +public enum VersionEnum { + + INITIAL("初始版本", "V1.0"); + + private final String name; + + private final String code; + + VersionEnum(String name, String code) { + this.name = name; + this.code = code; + } + +} + + + +package com.sdm.project.config; + +import com.sdm.common.utils.AESUtil; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.core.env.*; +import org.springframework.stereotype.Component; + +import java.util.Properties; + +@Component +public class DecryptEnvironmentPostProcessor implements EnvironmentPostProcessor { + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { + Properties props = new Properties(); // 临时存储需要替换的配置 + // 假设加密密码前缀为 "ENC(",后缀为 ")" + MutablePropertySources propertySources = environment.getPropertySources(); + for (PropertySource propertySource : propertySources) { + if (propertySource instanceof EnumerablePropertySource) { + EnumerablePropertySource enumerablePropertySource = (EnumerablePropertySource) propertySource; + String[] propertyNames = enumerablePropertySource.getPropertyNames(); + // 遍历所有配置key:value + for (String propertyName : propertyNames) { + String propertyVal = environment.getProperty(propertyName); + // 根据自己写的规则来解析那些配置是需要解密的 + if (propertyVal != null && propertyVal.startsWith("ENC(") && propertyVal.endsWith(")")) { + // 解析得到加密的数据 + String encryptedValue = propertyVal.substring(4, propertyVal.length() - 1); + // 调用自定义工具类解密 + String decryptedValue = null; + try { + decryptedValue = AESUtil.decode(encryptedValue); + } catch (Exception e) { + throw new RuntimeException(e); + } + // 保存需要替换的配置 + props.put(propertyName, decryptedValue); + } + } + } + } + // 添加解密后的属性到环境中 + if (!props.isEmpty()) { + PropertiesPropertySource pps = new PropertiesPropertySource("decryptedProperties", props); + environment.getPropertySources().addFirst(pps); + } + } +} + + + +package com.sdm.project.config.mybatis; + +import lombok.extern.slf4j.Slf4j; +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.executor.keygen.SelectKeyGenerator; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; +import org.apache.ibatis.plugin.*; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; +import org.springframework.transaction.support.TransactionSynchronizationManager; + +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @Author xuyundi + * @Date 2023/7/21 + * @Note + */ +@Slf4j +@Intercepts({ + @Signature(type = Executor.class, method = "update", args = { + MappedStatement.class, Object.class}), + @Signature(type = Executor.class, method = "query", args = { + MappedStatement.class, Object.class, RowBounds.class, + ResultHandler.class})}) +public class DatabasePlugin implements Interceptor { + + private static final String REGEX = ".*insert\\u0020.*|.*delete\\u0020.*|.*update\\u0020.*"; + + private static final Map cacheMap = new ConcurrentHashMap<>(); + + @Override + public Object intercept(Invocation invocation) throws Throwable { + + boolean synchronizationActive = TransactionSynchronizationManager.isSynchronizationActive(); + if (!synchronizationActive) { + Object[] objects = invocation.getArgs(); + MappedStatement ms = (MappedStatement) objects[0]; + + DBTypeEnum databaseType = null; + + if ((databaseType = cacheMap.get(ms.getId())) == null) { + //读方法 + if (ms.getSqlCommandType().equals(SqlCommandType.SELECT)) { + //!selectKey 为自增id查询主键(SELECT LAST_INSERT_ID() )方法,使用主库 + if (ms.getId().contains(SelectKeyGenerator.SELECT_KEY_SUFFIX)) { + databaseType = DBTypeEnum.MASTER; + } else { + BoundSql boundSql = ms.getSqlSource().getBoundSql(objects[1]); + String sql = boundSql.getSql().toLowerCase(Locale.CHINA).replaceAll("[\\t\\n\\r]", " "); + if (sql.matches(REGEX)) { + databaseType = DBTypeEnum.MASTER; + } else { + databaseType = DBTypeEnum.SLAVE; + } + } + } else { + databaseType = DBTypeEnum.MASTER; + } +// log.warn("设置方法[{}] use [{}] Strategy, SqlCommandType [{}]..", ms.getId(), databaseType.name(), ms.getSqlCommandType().name()); + cacheMap.put(ms.getId(), databaseType); + } + DBContextHolder.set(databaseType); + } + + return invocation.proceed(); + } + + @Override + public Object plugin(Object target) { + if (target instanceof Executor) { + return Plugin.wrap(target, this); + } else { + return target; + } + } + + @Override + public void setProperties(Properties properties) { + + } + +} + + + +package com.sdm.project.config.mybatis; + +import lombok.extern.slf4j.Slf4j; + +import java.util.concurrent.atomic.AtomicInteger; + +/** + * @Author xuyundi + * @Date 2023/7/21 + * @Note + */ +@Slf4j +public class DBContextHolder { + private static final ThreadLocal contextHolder = new ThreadLocal<>(); + + private static final AtomicInteger counter = new AtomicInteger(-1); + + public static void set(DBTypeEnum dbType) { + contextHolder.set(dbType); + } + + public static DBTypeEnum get() { + return contextHolder.get(); + } + + public static void master() { + set(DBTypeEnum.MASTER); + log.info("切换到master"); + } + + public static void slave() { + set(DBTypeEnum.SLAVE); + log.info("切换到slave"); + + // 如果有多个从库,可通过轮询进行切换 +// int index = counter.getAndIncrement() % 2; +// if (counter.get() > 9999) { +// counter.set(-1); +// } +// if (index == 0) { +// set(DBTypeEnum.SLAVE1); +// log.info("切换到slave1"); +// }else { +// set(DBTypeEnum.SLAVE2); +// log.info("切换到slave2"); +// } + } +} + + + +package com.sdm.project.config.mybatis; + +/** + * @Author xuyundi + * @Date 2023/7/21 + * @Note + */ +public enum DBTypeEnum { + MASTER, SLAVE +} + + + +package com.sdm.project.config.mybatis; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; +import org.springframework.lang.Nullable; + +/** + * @Author xuyundi + * @Date 2023/7/21 + * @Note + */ +public class DynamicDataSource extends AbstractRoutingDataSource { + @Nullable + @Override + protected Object determineCurrentLookupKey() { + return DBContextHolder.get(); + } +} + + + +package com.sdm.project.config.mybatis; + +import com.baomidou.mybatisplus.core.MybatisConfiguration; +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; + +import javax.sql.DataSource; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * @Author xuyundi + * @Date 2023/7/21 + * @Note + */ +@Configuration +@MapperScan(basePackages = "com.sdm.project.dao", sqlSessionFactoryRef = "mybatisSqlSessionFactoryAdaptor") +public class MybatisPlusConfig { + + + @Value("${spring.datasource.slave.enable}") + private boolean slaveEnable; + +// /** +// * mybatis-plus分页插件 +// */ +// @Bean +// public PaginationInterceptor paginationInterceptor() { +// PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); +// paginationInterceptor.setDialectType(DBType.MYSQL.getDb()); +// return paginationInterceptor; +// } + + @Bean(name = "masterDataSource") + @Qualifier("masterDataSource") + @ConfigurationProperties(prefix = "spring.datasource.master") + public DataSource masterDataSource() { + return DataSourceBuilder.create().build(); + } + + @Bean(name = "slaveDataSource") + @Qualifier("slaveDataSource") + @ConfigurationProperties(prefix = "spring.datasource.slave") + public DataSource slaveDataSource() { + return DataSourceBuilder.create().build(); + } + + /** + * 构造多数据源连接池 + * Master 数据源连接池采用 HikariDataSource + * Slave 数据源连接池采用 DruidDataSource + * + * @param master + * @param slave + * @return + */ + @Bean + @Primary + public DynamicDataSource dataSource(@Qualifier("masterDataSource") DataSource master, + @Qualifier("slaveDataSource") DataSource slave) { + Map targetDataSources = new HashMap<>(); + targetDataSources.put(DBTypeEnum.MASTER, master); + targetDataSources.put(DBTypeEnum.SLAVE, slave); + + DynamicDataSource dataSource = new DynamicDataSource(); + dataSource.setTargetDataSources(targetDataSources);// 该方法是AbstractRoutingDataSource的方法 + dataSource.setDefaultTargetDataSource(slave);// 默认的datasource设置为myTestDbDataSourcereturn dataSource; + return dataSource; + } + + @Bean(name = "mybatisSqlSessionFactoryAdaptor") + public MybatisSqlSessionFactoryBean sqlSessionFactory(@Qualifier("masterDataSource") DataSource master, + @Qualifier("slaveDataSource") DataSource slave) throws IOException { + MybatisSqlSessionFactoryBean fb = new MybatisSqlSessionFactoryBean(); + fb.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/*.xml")); + fb.setDataSource(this.dataSource(master, slave)); + // 设置开启下划线转驼峰 + MybatisConfiguration configuration = new MybatisConfiguration(); + configuration.setMapUnderscoreToCamelCase(true); + fb.setConfiguration(configuration); + // 是否启动多数据源配置,目的是方便多环境下在本地环境调试,不影响其他环境 + if (slaveEnable) { + fb.setPlugins(new DatabasePlugin()); + } + return fb; + } + +} + + + +package com.sdm.project.config; + +import okhttp3.ConnectionPool; +import okhttp3.OkHttpClient; +import okhttp3.Protocol; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.Collections; +import java.util.concurrent.TimeUnit; + +@Configuration +public class OkHttpConfiguration { + + @Bean + public OkHttpClient okHttpClient() { + return new OkHttpClient.Builder() + .sslSocketFactory(sslSocketFactory(), x509TrustManager()) + //是否开启缓存 + .retryOnConnectionFailure(true) + .connectionPool(pool()) + .connectTimeout(60, TimeUnit.SECONDS) + .readTimeout(60, TimeUnit.SECONDS) + .writeTimeout(60, TimeUnit.SECONDS) + .hostnameVerifier((hostname, session) -> true) + .protocols(Collections.singletonList(Protocol.HTTP_1_1)) + .build(); + } + + @Bean + public X509TrustManager x509TrustManager() { + return new X509TrustManager() { + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { + + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + }; + } + + @Bean + public SSLSocketFactory sslSocketFactory() { + try { + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom()); + return sslContext.getSocketFactory(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Bean + public ConnectionPool pool() { + return new ConnectionPool(5000, 300, TimeUnit.SECONDS); + } +} + + + +package com.sdm.project.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig { + + @Bean(name = "redisTemplate") + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + RedisTemplate template = new RedisTemplate<>(); + RedisSerializer redisSerializer = new StringRedisSerializer(); + + template.setConnectionFactory(factory); + // key序列化方式 + template.setKeySerializer(redisSerializer); + // value序列化 + template.setValueSerializer(redisSerializer); + // value hashmap序列化 + template.setHashValueSerializer(redisSerializer); + // key haspmap序列化 + template.setHashKeySerializer(redisSerializer); + + return template; + } + + @Bean(name = "bytesRedisTemplate") + public RedisTemplate bytesRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(connectionFactory); + // 设置key和value的序列化规则 + redisTemplate.setValueSerializer(RedisSerializer.byteArray()); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.afterPropertiesSet(); + + return redisTemplate; + } +} + + + +package com.sdm.project.config; + +import com.sdm.project.filter.AuthFilter; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RequestConfig { + @Bean + public AuthFilter authFilter() { + return new AuthFilter(); + } + + @Bean + public FilterRegistrationBean registrationBean() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(); + registration.setFilter(authFilter()); + registration.setName("authFilter"); + registration.addUrlPatterns("/*"); + registration.setOrder(0); + return registration; + } +} + + + +package com.sdm.project.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; + +/** + * 解决多个定时任务单线程有任务不能执行的问题 + * + */ +@Configuration +public class ScheduledTaskConfig implements SchedulingConfigurer { + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); + taskScheduler.setPoolSize(5); + taskScheduler.initialize(); + taskRegistrar.setTaskScheduler(taskScheduler); + } +} + + + +package com.sdm.project.config; + +import io.swagger.v3.oas.models.ExternalDocumentation; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + @Bean + public OpenAPI openAPI() { + return new OpenAPI() + .info(new Info() + .title("SPDM系统-项目模块") + .description("SPDM系统-项目模块接口文档") + .version("V1")) + .externalDocs(new ExternalDocumentation() + .description("项目模块") + .url("/")); + } +} + + + +package com.sdm.project.controller; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.log.annotation.SysLog; +import com.sdm.project.model.req.SpdmAnalysisPerformanceListReq; +import com.sdm.project.model.req.SpdmAnalysisRunListReq; +import com.sdm.project.model.req.SpdmAnalysisTaskListReq; +import com.sdm.project.model.resp.GetAllRunResultByTaskIdResp; +import com.sdm.project.model.resp.RunResultResp; +import com.sdm.project.service.ITaskService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/analysis") +@Tag(name = "数据分析", description = "数据分析相关接口") +public class SimulationAnalysisController { + + @Resource + private ITaskService taskService; + + /** + * 数据分析(数据查询)-根据节点id获取仿真工况 + * + * @param req + * @return + */ + @SysLog("数据分析(数据查询)-根据节点id获取仿真工况") + @GetMapping("/taskList") + @Operation(summary = "仿真工况", description = "仿真工况") + public SdmResponse taskList(SpdmAnalysisTaskListReq req) { + return taskService.analysisTaskList(req); + } + + /** + * 数据分析(数据查询)-根据节点id获取指标 + * + * @param req + * @return + */ + @SysLog("数据分析(数据查询)-根据节点id获取指标") + @GetMapping("/performanceList") + @Operation(summary = "指标", description = "指标") + public SdmResponse performanceList(SpdmAnalysisPerformanceListReq req) { + return taskService.analysisPerformanceList(req); + } + + /** + * 数据分析(数据查询)-根据节点id获取算例 + * + * @param req + * @return + */ + @SysLog("数据分析(数据查询)-根据节点id获取算例") + @GetMapping("/runList") + @Operation(summary = "算例", description = "算例") + public SdmResponse runList(SpdmAnalysisRunListReq req) { + return taskService.analysisRunList(req); + } + + + /** + * 数据分析(数据查询)-根据任务id获取所有算列结果 + */ + @SysLog("数据分析(数据查询)-根据任务id获取所有算列结果") + @GetMapping("/getAllRunResultByTaskId") + public SdmResponse getAllRunResultByTaskId(String taskId) { + return taskService.getAllRunResultByTaskId(taskId); + } + + +} + + + +package com.sdm.project.controller; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.task.DemandExportExcelFormat; +import com.sdm.common.entity.req.task.TaskExportExcelFormat; +import com.sdm.common.feign.inter.data.IDataFeignClient; +import com.sdm.common.log.annotation.SysLog; +import com.sdm.project.model.bo.ModifyProjectNode; +import com.sdm.project.model.req.*; +import com.sdm.project.service.IDemandService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@RequestMapping("/demand") +@Tag(name = "仿真需求管理", description = "仿真需求管理") +public class SimulationDemandController { + + @Resource + private IDemandService demandService; + + /** + * 新增需求 + * + * @param req + * @return + */ + @SysLog("新增需求") + @PostMapping("/addDemand") + @Operation(summary = "新增需求", description = "新增需求") + public SdmResponse addDemand(@RequestBody @Validated SpdmAddDemandReq req) { + return demandService.addDemand(req); + } + + /** + * 修改需求 + * + * @param req + * @return + */ + @SysLog("修改需求") + @PostMapping("/editDemand") + @Operation(summary = "修改需求", description = "修改需求") + public SdmResponse editDemand(@RequestBody SpdmEditDemandReq req) { + return demandService.editDemand(req); + } + + /** + * 删除需求 + * + * @param req + * @return + */ + @SysLog("删除需求") + @PostMapping("/deleteDemand") + @Operation(summary = "删除需求", description = "删除需求") + public SdmResponse deleteDemand(@RequestBody @Validated SpdmDeleteDemandReq req) { + return demandService.deleteDemand(req); + } + + /** + * 需求列表(我发起的、我确认的) + * + * @param req + * @return + */ + @SysLog("查询需求列表") + @GetMapping("/list") + @Operation(summary = "需求列表(我发起的、我确认的)", description = "需求列表(我发起的、我确认的)") + public SdmResponse list(@Validated SpdmDemandListReq req) { + return demandService.list(req); + } + + /** + * 下发任务 + * + * @param req + * @return + */ + @SysLog("下发任务") + @PostMapping("/issueTask") + @Operation(summary = "下发任务(可批量)", description = "下发任务(可批量)") + public SdmResponse issueTask(@RequestBody SpdmTaskIssue req) { + return demandService.issueTask(req); + } + + @PostMapping(value = "/uploadDemandFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public SdmResponse uploadDemandFiles(UploadFilesReq req) { + return demandService.uploadDemandFiles(req); + } + + @PostMapping("/exportDemand") + @Operation(summary = "导出需求列表", description = "导出需求列表") + public SdmResponse exportDemand(@RequestBody DemandExportExcelFormat demandExportExcelFormat , HttpServletResponse httpservletResponse) { + return demandService.exportDemand(demandExportExcelFormat, httpservletResponse); + } + + /** + * 根据需求id,查询需求详情) + * + * @param demandId + * @return + */ + @GetMapping("/detail") + @Operation(summary = "根据需求id,查询需求详情", description = "根据需求id,查询需求详情") + public SdmResponse detail(@RequestParam @Validated String demandId) { + return demandService.detail(demandId); + } + +} + + + +package com.sdm.project.controller; + +import com.alibaba.excel.util.StringUtils; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.project.DelNodeReq; +import com.sdm.common.entity.req.project.ProjectExportExcelFormat; +import com.sdm.common.entity.req.project.RenameNodeReq; +import com.sdm.common.entity.req.project.SpdmNodeListReq; +import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; +import com.sdm.common.entity.resp.project.SimulationNodeResp; +import com.sdm.common.feign.inter.project.ISimulationNodeFeignClient; +import com.sdm.common.log.annotation.SysLog; +import com.sdm.project.model.req.*; +import com.sdm.project.service.INodeService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.constraints.NotNull; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@RestController +@RequestMapping("/node") +@Tag(name = "项目、阶段节点管理", description = "项目、阶段节点管理相关接口") +public class SimulationNodeController implements ISimulationNodeFeignClient { + + @Resource + private INodeService nodeService; + + /** + * 新增节点 + * + * @param req + * @return + */ + @SysLog("新增节点") + @PostMapping("/addNode") + @Operation(summary = "新增项目或阶段", description = "新增项目或阶段") + public SdmResponse addNode(@RequestBody @Validated SpdmAddNodeReq req) { + return nodeService.add(req); + } + + /** + * 修改节点 + * + * @param req + * @return + */ + @SysLog("修改节点") + @PostMapping("/editNode") + @Operation(summary = "修改项目或阶段", description = "修改项目或阶段") + public SdmResponse editNode(@RequestBody @Validated SpdmEditNodeReq req) { + return nodeService.edit(req); + } + + /** + * 删除节点 + * + * @param req + * @return + */ + @SysLog("删除节点") + @PostMapping("/deleteNode") + @Operation(summary = "删除项目或阶段", description = "删除项目或阶段") + public SdmResponse deleteNode(@RequestBody SpdmDeleteNodeReq req) { + return nodeService.delete(req); + } + + /** + * 节点列表 + * + * @param req + * @return + */ + @SysLog("查询项目列表") + @PostMapping("/list") + @Operation(summary = "项目列表", description = "项目列表") + public SdmResponse list(@RequestBody SpdmNodeListReq req) { + return nodeService.list(req); + } + + /** + * 获取节点详情(项目详情) + * + * @param req + * @return + */ + @SysLog("查询项目详情") + @GetMapping("/getNodeDetail") + @Operation(summary = "项目详情", description = "项目详情") + public SdmResponse getNodeDetail(GetProjectDetailReq req) { + return nodeService.getNodeDetail(req); + } + + /** + * 获取团队成员 + * + * @param req + * @return + */ + @SysLog("获取团队成员") + @GetMapping("/getProjectMemberList") + @Operation(summary = "获取团队成员", description = "获取团队成员") + public SdmResponse getProjectMemberList(@Validated GetProjectListReq req) { + return nodeService.getProjectMemberList(req); + } + + /** + * 根据项目查询子节点列表 + * + * @param nodeId + * @param nodeType + * @return + */ + @GetMapping("/getChildrenNodeList") + @Operation(summary = "根据项目查询子节点列表", description = "根据项目查询子节点列表") + public SdmResponse getChildrenNodeList(@RequestParam(value = "nodeId") String nodeId, @RequestParam(value = "nodeType") String nodeType) { + if (StringUtils.isBlank(nodeId) || StringUtils.isBlank(nodeType)) { + return SdmResponse.failed("节点id和类型都不能为空"); + } + return nodeService.getChildrenNodeList(Collections.singletonList(nodeId), nodeType); + } + + + /** + * 根据节点类型获取所有节点 + * + * @param nodeType 节点类型 + * @return SdmResponse> key 为节点id,value 为节点名称 + */ + @GetMapping("/getAllNodeByNodeType") + @Operation(summary = "根据节点类型获取所有节点", description = "根据节点类型获取所有节点") + public SdmResponse> getAllNodeByNodeType(@Parameter(description = "节点id") @RequestParam(value = "nodeId", required = false) Long nodeId, @RequestParam(value = "nodeType") String nodeType) { + return nodeService.getAllNodeByBodeType(nodeType, nodeId); + } + + /** + * 根据项目ID和节点类型获取所有节点信息 + * + * @param uuid 项目ID + * @param nextNodeType 下一级节点类型 + * @return SdmResponse> 节点信息 + */ + @GetMapping("/getAllNodeByProjectIdAndType") + @Operation(summary = "根据项目ID和节点类型获取所有节点信息", description = "根据项目ID和节点类型获取所有节点信息") + public SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeId") String uuid, @RequestParam(value = "nextNodeType") String nextNodeType) { + return nodeService.getAllNodeByProjectIdAndType(uuid, nextNodeType); + } + + /** + * 获取节点下的task列表 + */ + @GetMapping("/getNodeTaskList") + @Operation(summary = "获取节点下的task列表", description = "获取节点下的task列表") + public SdmResponse> getNodeTaskList(@RequestParam(value = "uuid") String uuid) { + return nodeService.getNodeTaskList(uuid); + } + + /** + * 获取task下的run + */ + @GetMapping("/getNodeTaskRunList") + @Operation(summary = "获取task下的run", description = "获取task下的run") + public SdmResponse> getTaskRunList(@RequestParam(value = "uuid") String uuid) { + return nodeService.getTaskRunList(uuid); + } + + + /** + * 用户组项目统计 + */ + @SysLog("用户组项目统计") + @GetMapping("/getUserGroupProjectStatistics") + @Operation(summary = "用户组项目统计", description = "用户组项目统计") + public SdmResponse getUserGroupProjectStatistics(@Parameter(description = "用户组ID")@RequestParam( value = "userGroupId" )@NotNull(message = "用户组ID(userGroupId)为必传参数,请补充后重试") Long userGroupId, @Parameter(description = "用户ID")@RequestParam( value = "userId", required = false) Long userId) { + return nodeService.getUserGroupProjectStatistics(userGroupId,userId); + } + + /** + * 用户组任务完成情况统计 + */ + @SysLog("用户组任务完成情况统计") + @PostMapping("/getUserGroupTaskCompleteStatistics") + @Operation(summary = "用户组任务完成情况统计", description = "用户组任务完成情况统计") + public SdmResponse getUserGroupTaskCompleteStatistics(@RequestBody @Validated GetUserGroupTaskCompleteStatisticsReq req) { + return nodeService.getUserGroupTaskCompleteStatistics(req); + } + + /** + * 用户组难度系数统计 + * + */ + @SysLog("用户组难度系数统计") + @PostMapping("/getUserGroupDifficultyStatistics") + @Operation(summary = "用户组难度系数统计", description = "用户组难度系数统计") + public SdmResponse getUserGroupDifficultyStatistics(@RequestBody @Validated GetUserGroupTaskCompleteStatisticsReq req) { + return nodeService.getUserGroupDifficultyStatistics(req); + } + + /** + * 通用完成统计查询 + */ + @SysLog("任务/指标 完成情况统计请求参数(工位、学科)") + @PostMapping("/getCommonCompleteStatistics") + @Operation(summary = "任务/指标 完成情况统计请求参数(工位、学科)", description = "任务/指标 完成情况统计请求参数(工位、学科)") + public SdmResponse getCommonCompleteStatistics(@RequestBody @Validated CommonGetCompleteStatisticsReq req) { + return nodeService.getCommonCompleteStatistics(req); + } + + /** + * 工位评审通过统计查询 + */ + @SysLog("工位评审通过统计查询") + @PostMapping("/getWorkstationReviewStatistics") + @Operation(summary = "工位评审通过统计查询", description = "工位评审通过统计查询") + public SdmResponse getWorkstationReviewStatistics(@RequestBody GetWorkstationApproveStatusReq req) { + return nodeService.getWorkstationReviewStatistics(req); + } + + @PostMapping("/renameNode") + @Operation(summary = "重命名node/task/run的名称", description = "重命名node/task/run的名称") + public SdmResponse renameNode(@RequestBody RenameNodeReq req) { + return nodeService.renameNode(req); + } + + @PostMapping("/delteNode") + @Operation(summary = "删除node/task/run", description = "删除node/task/run") + public SdmResponse delteNode(@RequestBody DelNodeReq req) { + return nodeService.delteNode(req); + } + + /** + * 上传项目文件 + * @param req + * @return + */ + @PostMapping(value = "/uploadProjectFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public SdmResponse uploadProjectFiles(UploadFilesReq req) { + return nodeService.uploadProjectFiles(req); + } + + /** + * 新增节点(数据总览使用) + * + * @param req + * @return + */ + @PostMapping("/addNodeForData") + @Operation(summary = "新增节点(数据总览使用)", description = "新增节点(数据总览使用)") + public SdmResponse addNodeForData(@RequestBody @Validated SpdmAddNodeReq req) { + return nodeService.addNodeForData(req); + } + + /** + * 新增任务(数据总览使用) + * + * @param req + * @return + */ + @PostMapping("/addTaskForData") + @Operation(summary = "新增任务(数据总览使用)", description = "新增任务(数据总览使用)") + public SdmResponse addTaskForData(@RequestBody @Validated SpdmTaskReq req) { + return nodeService.addTaskForData(req); + } + + /** + * 根据List 查询所有的 simulation_node 信息 + * @param + * @return SimulationNode集合 + */ + @PostMapping(value = "/querySimulationNodeByUuids") + @Operation(summary = "根据uuids查询所有的node列表", description = "根据uuids查询所有的node列表") + public SdmResponse> querySimulationNodeByUuids(@RequestBody Listuuids) { + return nodeService.querySimulationNodeByUuids(uuids); + } + + + @PostMapping("/exportProject") + @Operation(summary = "导出项目列表", description = "导出项目列表") + public SdmResponse exportProject(@RequestBody ProjectExportExcelFormat projectExportExcelFormat , HttpServletResponse httpservletResponse) { + return nodeService.exportProject(projectExportExcelFormat, httpservletResponse); + } + + /** + * 获取节点详情(数据总览编辑分类节点时使用) + * + * @param req + * @return + */ + @PostMapping("/getNodeDetailForData") + @Operation(summary = "获取节点详情(数据总览编辑分类节点时使用)", description = "获取节点详情(数据总览编辑分类节点时使用)") + public SdmResponse getNodeDetailForData(@RequestBody @Validated GetNodeDetailReq req) { + return nodeService.getNodeDetailForData(req); + } + + /** + * 修改节点(数据总览使用) + * + * @param req + * @return + */ + @PostMapping("/editNodeForData") + @Operation(summary = "修改节点(数据总览使用)", description = "修改节点(数据总览使用)") + public SdmResponse editNodeForData(@RequestBody @Validated SpdmEditNodeForDataReq req) { + return nodeService.editNodeForData(req); + } + + +} + + + +package com.sdm.project.controller; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.task.TaskExportExcelFormat; +import com.sdm.common.entity.req.task.TaskTreeExportExcelFormat; +import com.sdm.common.log.annotation.SysLog; +import com.sdm.project.model.bo.ModifyProjectNode; +import com.sdm.project.model.req.ProjectTreeTagReq; +import com.sdm.project.model.req.SpdmNodeReq; +import com.sdm.project.service.IProjectService; +import com.sdm.project.service.ITaskService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import org.apache.ibatis.annotations.Param; +import org.springframework.util.DigestUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +@RestController +@RequestMapping(value = "/project") +@Tag(name = "仿真任务策划管理", description = "仿真任务策划管理管理相关接口") +public class SimulationProjectController { + + @Resource + private IProjectService projectService; + + @Resource + private ITaskService taskService; + + + /** + * 操作节点(增、删、改) + * + * @param req + * @return + */ + @SysLog("新增修改删除任务、分析项") + @PostMapping("/modify") + @Operation(summary = "新增修改删除任务、分析项", description = "新增修改删除任务、分析项") + public SdmResponse modify(@RequestBody ModifyProjectNode req) { + return projectService.modify(req); + } + + /** + * 任务分析项树 + * + * @param req + * @return + */ + @SysLog("获取任务分析项树") + @PostMapping("/getTaskTree") + @Operation(summary = "任务分析项树", description = "任务分析项树") + public SdmResponse getTaskTree(@RequestBody ProjectTreeTagReq req) { + return projectService.getTaskTree(req); + } + +// @PostMapping("/exportTaskTree") +// @Operation(summary = "导出任务分析项树", description = "导出任务分析项树") +// public SdmResponse exportTaskTree(@RequestBody TaskTreeExportExcelFormat taskTreeExportExcelFormat , HttpServletResponse httpservletResponse) { +// return projectService.exportTaskTree(taskTreeExportExcelFormat, httpservletResponse); +// } + + @PostMapping("/exportTaskTree") + @Operation(summary = "导出任务分析项树", description = "导出任务分析项树") + public SdmResponse exportTaskTree(@RequestBody TaskTreeExportExcelFormat taskTreeExportExcelFormat , HttpServletResponse httpservletResponse) { + return taskService.newExportTaskTree(taskTreeExportExcelFormat, httpservletResponse); + } + + +} + + + +package com.sdm.project.controller; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.data.CreateDirReq; +import com.sdm.common.entity.req.data.QueryDirReq; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.project.SpdmReportReq; +import com.sdm.common.entity.req.system.LaunchApproveReq; +import com.sdm.common.entity.resp.PageDataResp; +import com.sdm.common.entity.resp.data.BatchAddFileInfoResp; +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import com.sdm.common.feign.inter.project.ISimulationRunFeignClient; +import com.sdm.common.log.annotation.SysLog; +import com.sdm.project.model.entity.SimulationBaseQuantities; +import com.sdm.project.model.entity.SimulationBaseUnits; +import com.sdm.project.model.entity.SimulationRun; +import com.sdm.project.model.entity.SimulationRunKeyResult; +import com.sdm.project.model.req.*; +import com.sdm.project.model.resp.FlowInfoDto; +import com.sdm.project.model.resp.KeyResultAndTaskInfoResp; +import com.sdm.project.model.resp.RunVersionInfoResp; +import com.sdm.project.service.ISimulationRunService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping(value = "/run") +@Tag(name = "仿真任务策划管理", description = "仿真任务策划管理管理相关接口") +public class SimulationRunController implements ISimulationRunFeignClient { + + @Resource + private ISimulationRunService runService; + + + /** + * 任务分析项算例树 + * + * @param req + * @return + */ + @SysLog("获取任务分析项算例树") + @PostMapping("/getTaskRunTree") + @Operation(summary = "任务分析项算例树", description = "任务分析项算例树") + public SdmResponse getTaskRunTree(@RequestBody ProjectTreeTagReq req) { + return runService.getTaskRunTree(req); + } + + /** + * 任务执行 创建算例 + */ + @SysLog("任务执行 创建算例") + @PostMapping("/addTaskRun") + public SdmResponse addTaskRun(@RequestBody @Validated SpdmAddTaskRunReq req) { + return runService.addTaskRun(req); + } + + /** + * 任务执行 删除算例 + */ + @SysLog("任务执行 删除算例") + @PostMapping("/deleteTaskRun") + public SdmResponse deleteTaskRun(@RequestBody SpdmTaskRunReq req) { + return runService.deleteTaskRun(req); + } + + /** + * 查询算例详情 + */ + @SysLog("查询算例详情") + @PostMapping("/queryTaskRun") + public SdmResponse> queryRunInfo(@RequestBody SpdmTaskRunReq req) { + return runService.queryTaskRun(req); + } + + /** + * 创建算例文件夹 + */ + @PostMapping(value = "/createRunDir") + public SdmResponse createRunDir(@RequestBody CreateDirReq req) { + return runService.createRunDir(req); + } + + /** + * 查询算例文件夹及文件 + */ + @PostMapping(value = "/queryRunDir") + public SdmResponse>> queryRunDir(@RequestBody QueryDirReq req) { + return runService.queryRunDir(req); + } + + /** + * 上传算例文件 + */ + @PostMapping(value = "/uploadRunFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public SdmResponse uploadRunFiles(UploadFilesReq req) { + return runService.uploadRunFiles(req); + } + + /** + * 获取task下所有算例版本 + * + * @return + */ + @SysLog("获取任务下所有算例版本") + @PostMapping("/getTaskRunVersion") + public SdmResponse> getTaskRunVersion(@RequestBody GetRunVersionReq req) { + return runService.getTaskRunVersion(req); + } + + /** + * 获取指定算例的版本结构 + * + * @return + */ + @SysLog("获取指定算例的版本结构") + @PostMapping("/getRunVersion") + public SdmResponse getRunVersion(@RequestBody GetRunVersionReq req) { + return runService.getRunVersion(req); + } + + /** + * 任务执行后 算例录入关键结果 + * + * @return + */ + @SysLog("任务执行后 算例录入关键结果") + @PostMapping(value = "/addSimulationKeyResult", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public SdmResponse addSimulationKeyResult(KeyResultReq req) { + return runService.addSimulationKeyResult(req); + } + + @SysLog("编辑算例关键结果属性") + @PostMapping(value = "/editSimulationKeyResult") + public SdmResponse editSimulationKeyResult(@RequestBody KeyResultReq req) { + return runService.editSimulationKeyResult(req); + } + + /** + * 上传交付物-第一步 文件信息和关键结果信息批量入库 + * + * @return + */ + @SysLog("上传交付物-文件信息和关键结果信息批量入库") + @PostMapping(value = "/batchAddSimulationKeyResult") + public SdmResponse> batchAddSimulationKeyResult(@RequestBody KeyResultReq req) { + return runService.batchAddSimulationKeyResult(req); + } + + /** + * 提交交付物审批 + * + * @return + */ + @SysLog("提交交付物审批") + @PostMapping(value = "/deliverableApprove") + public SdmResponse deliverableApprove(@RequestBody DeliverableApproveReq req) { + return runService.deliverableApprove(req); + } + + /** + * 交付物审批回调 + * + * @return + */ + @SysLog("交付物审批回调") + @PostMapping(value = "/deliverableApproveCallback") + public SdmResponse deliverableApproveCallback(@RequestBody LaunchApproveReq req) { + return runService.deliverableApproveCallback(req); + } + + /** + * 算例关键结果查询 + * + * @return + */ + @SysLog("算例关键结果查询") + @PostMapping(value = "/listSimulationKeyResult") + public SdmResponse>> listSimulationKeyResult(@RequestBody KeyResultReq req) { + return runService.listSimulationKeyResult(req); + } + + @GetMapping(value = "/getSimulationKeyResultFileIds") + public SdmResponse> getSimulationKeyResultFileIds(@RequestParam String runId) { + return runService.getSimulationKeyResultFileIds(runId); + } + + /** + * 根据交付物文件id查询相关属性和任务信息 + * + * @return + */ + @PostMapping(value = "/queryKeyResultAndTaskInfo") + public SdmResponse>> queryKeyResultAndTaskInfo(@RequestBody KeyResultReq req) { + return runService.queryKeyResultAndTaskInfo(req); + } + + /** + * 删除算例关键结果 + * + * @return + */ + @SysLog("删除算例关键结果") + @PostMapping(value = "/deleteSimulationKeyResult") + public SdmResponse deleteSimulationKeyResult(@RequestBody KeyResultReq req) { + return runService.deleteSimulationKeyResult(req); + } + + /** + * 生成自动化报告 + * + * @return + */ + @PostMapping("/generateReport") + @Operation(summary = "生成自动化报告", description = "生成自动化报告") + public void generateReport(@RequestBody SpdmReportReq req, HttpServletResponse response) { + runService.generateReport(req,response); + } + + /** + * 内部调用生成报告 + * + * @return + */ + @PostMapping("/generateReportInternal") + @Operation(summary = "内部调用生成报告", description = "内部调用生成报告") + public SdmResponse generateReportInternal(@RequestBody SpdmReportReq req) { + return runService.generateReportInternal(req); + } + + /** + * 任务执行 一键执行 启动流程 + */ + @SysLog("任务执行 一键执行 启动流程") + @PostMapping("/startProcessInstance") + public SdmResponse startProcessInstance(@RequestBody SpdmTaskRunReq req) { + return runService.startProcessInstance(req); + } + + /** + * 任务执行 设置节点输入参数和输出参数 + */ + @SysLog("设置节点输入参数和输出参数") + @PostMapping("/saveNodeParams") + public SdmResponse saveNodeParams(@RequestBody SpdmNodeParamReq req) { + return runService.saveNodeParams(req); + } + + /** + * 任务执行 查询流程节点列表 + */ + @SysLog("查询流程节点列表") + @PostMapping("/listFlowNodes") + public SdmResponse listFlowNodes(@RequestBody SpdmTaskRunReq req) { + return runService.listFlowNodes(req); + } + /** + * 流程关联报告 + * + * @return + */ + @PostMapping("/flowRelateReport") + @Operation(summary = "流程关联报告", description = "流程关联报告") + public SdmResponse flowRelateReport(@RequestBody SpdmReportReq req) { + return runService.flowRelateReport(req); + } + + /** + * 查询物理量基表 + * @return + */ + @GetMapping("/listQuantities") + @Operation(summary = "查询物理量基表", description = "查询物理量基表") + public SdmResponse> listQuantities() { + return runService.listQuantities(); + } + + /** + * 查询单位基表 + * @return + */ + @GetMapping("/listUnits") + @Operation(summary = "查询单位基表", description = "查询单位基表") + public SdmResponse> listUnits(@RequestParam(required = false) String quantityType) { + return runService.listUnits(quantityType); + } + +} + + + +package com.sdm.project.controller; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.task.TaskExportExcelFormat; +import com.sdm.common.log.annotation.SysLog; +import com.sdm.project.model.bo.ModifyTaskNode; +import com.sdm.project.model.req.*; +import com.sdm.project.model.resp.TaskCountResp; +import com.sdm.project.model.resp.TaskWorkDaysResp; +import com.sdm.project.model.resp.UserWorkloadResp; +import com.sdm.project.service.ISimulationTaskService; +import com.sdm.project.service.ITaskService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("/task") +@Tag(name = "仿真任务管理", description = "仿真任务管理") +public class SimulationTaskController { + + @Resource + private ITaskService taskService; + + @Autowired + private ISimulationTaskService simulationTaskService; + + /** + * 修改任务 + * + * @param req + * @return + */ + @SysLog("修改任务") + @PostMapping("/edit") + @Operation(summary = "修改任务", description = "修改任务") + public SdmResponse edit(@RequestBody ModifyTaskNode req) { + return taskService.edit(req); + } + + /** + * 驳回、启动、暂停、工时、关闭、关注、取消关注、编辑 + */ + @SysLog("操作任务") + @PostMapping("/operation") + @Operation(summary = "操作任务", description = "操作任务") + public SdmResponse operation(@RequestBody SpdmTaskOpr taskOpr) { + return taskService.operation(taskOpr); + } + + @SysLog("关注或取消关注任务") + @PostMapping("/attention") + @Operation(summary = "关注或取消关注任务", description = "关注或取消关注任务") + public SdmResponse attention(@RequestBody SpdmTaskAttentionReq req) { + return taskService.attention(req.getTaskId(), req.getAddUserIdList(),req.getCancelUserIdList()); + } + + + /** + * 任务列表(我执行的、我关注的、所有) + * + * @param req + * @return + */ + @SysLog("查询任务列表") + @PostMapping("/list") + @Operation(summary = "任务列表(我执行的、我关注的、所有)", description = "任务列表(我执行的、我关注的、所有)") + public SdmResponse list(@Validated @RequestBody SpdmTaskListReq req) { + return taskService.list(req); + } + + /** + * 任务列表根据不同执行状态计数(我执行的、我关注的、所有) + * @param req + * @return + */ + @PostMapping("/count") + @Operation(summary = "任务列表计数(我执行的、我关注的、所有)", description = "任务列表计数(我执行的、我关注的、所有)") + public SdmResponse countByStatus(@Validated @RequestBody SpdmTaskCountReq req) { + return taskService.countByStatus(req); + } + + @SysLog("批量删除任务") + @PostMapping("/batchDelete") + @Operation(summary = "批量删除任务", description = "批量删除任务") + public SdmResponse batchDeleteTask(@RequestBody SpdmTaskOpr taskOpr) { + return taskService.batchDeleteTask(taskOpr); + } + + /** + * 工作负载 查询执行时间在指定时间段内,指定用户执行的任务列表 + */ + @SysLog("查询用户工作负载") + @PostMapping("/listUserWorkloads") + @Operation(summary = "查询用户工作负载", description = "查询用户工作负载") + public SdmResponse> listUserWorkloadsWithinTimeFrame(@RequestBody UserWorkloadReq req) { + return taskService.listUserWorkloadsWithinTimeFrame(req); + } + + @PostMapping("/listTaskWorkDays") + @Operation(summary = "工作负载-任务工时统计图表", description = "工作负载-任务工时统计图表") + public SdmResponse> listTaskWorkDays(@RequestBody UserWorkloadReq req) { + return taskService.listTaskWorkDays(req); + } + + @PostMapping("/exportTask") + @Operation(summary = "导出任务列表", description = "导出任务列表") + public SdmResponse exportTask(@RequestBody TaskExportExcelFormat taskExportExcelFormat , HttpServletResponse httpservletResponse) { + return taskService.exportTask(taskExportExcelFormat, httpservletResponse); + } + +// /** +// * 同步CID创建的任务 +// * +// * @param req +// * @return +// */ +// @PostMapping("/synchronizeCidTask") +// @Operation(summary = "同步CID创建的任务", description = "同步CID创建的任务") +// public SdmResponse synchronizeCidTask(@RequestBody SpdmSyncCidTaskReq req) { +// return taskService.synchronizeCidTask(req); +// } + + /** + * 获取任务详情 + * + * @param req + * @return + */ + @PostMapping("/getTaskDetail") + @Operation(summary = "获取任务详情", description = "获取任务详情") + public SdmResponse getTaskDetail(@RequestBody @Validated GetTaskDetailReq req) { + return taskService.getTaskDetail(req); + } + + /** + * 修改任务(数据总览使用) + * + * @param req + * @return + */ + @PostMapping("/editTaskForData") + @Operation(summary = "修改任务(数据总览使用)", description = "修改任务(数据总览使用)") + public SdmResponse editTaskForData(@RequestBody @Validated SpdmEditTaskForDataReq req) { + return simulationTaskService.editTaskForData(req); + } + + /** + * 按工位、学科的仿真任务达成统计 + */ + @SysLog("按工位、学科的仿真任务达成统计") + @PostMapping("/getTaskCompleteStatistics") + @Operation(summary = "按工位、学科的仿真任务达成统计", description = "按工位、学科的仿真任务达成统计") + public SdmResponse getTaskCompleteStatistics(@RequestBody @Validated TaskCompleteStatisticsReq req) { + return taskService.getTaskCompleteStatistics(req); + } + + /** + * 按工位、学科的仿真指标达成统计 + */ + @SysLog("按工位、学科的仿真指标达成统计") + @PostMapping("/getPerformanceCompleteStatistics") + @Operation(summary = "按工位、学科的仿真指标达成统计", description = "按工位、学科的仿真指标达成统计") + public SdmResponse getPerformanceCompleteStatistics(@RequestBody @Validated PerformanceCompleteStatisticsReq req) { + return taskService.getPerformanceCompleteStatistics(req); + } + + /** + * 项目成员任务进度统计 + */ + @SysLog("项目成员任务进度统计") + @PostMapping("/getUserTaskCompleteStatistics") + @Operation(summary = "项目成员任务进度统计", description = "项目成员任务进度统计") + public SdmResponse getUserTaskCompleteStatistics(@RequestBody @Validated UserTaskCompleteStatisticsReq req) { + return taskService.getUserTaskCompleteStatistics(req); + } + + /** + * 项目成员难度系数统计 + * + */ + @SysLog("项目成员难度系数统计") + @PostMapping("/getUserDifficultyStatistics") + @Operation(summary = "项目成员难度系数统计", description = "项目成员难度系数统计") + public SdmResponse getUserDifficultyStatistics(@RequestBody @Validated UserDifficultCompleteStatisticsReq req) { + return taskService.getUserDifficultyStatistics(req); + } + + /** + * 根据需求id,查询任务列表 + * + * @param req + * @return + */ + @PostMapping("/getTaskListByDemandId") + @Operation(summary = "根据需求id,查询任务列表", description = "根据需求id,查询任务列表") + public SdmResponse getTaskListByDemandId(@RequestBody @Validated SpdmTaskListReq req) { + return taskService.getTaskListByDemandId(req); + } + +} + + + +package com.sdm.project.controller; + +import com.alibaba.fastjson2.JSONObject; +import com.github.pagehelper.PageInfo; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.enums.NodeTypeEnum; +import com.sdm.common.entity.req.data.GetSimulationTaskFileReq; +import com.sdm.common.entity.req.data.UploadFilesReq; + +import com.sdm.common.entity.resp.PageDataResp; +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import com.sdm.common.feign.impl.data.DataAnalysisFeignClientImpl; + +import com.sdm.common.feign.inter.data.IDataFeignClient; +import com.sdm.project.common.KeyResultTypeEnum; +import com.sdm.project.model.entity.SimulationRunKeyResult; +import com.sdm.project.model.req.KeyResultReq; +import com.sdm.project.model.req.YA.*; +import com.sdm.project.model.resp.YA.BosimKeyResultInfoRsp; +import com.sdm.project.model.resp.YA.BosimSaveNodeInfoRsp; +import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; +import com.sdm.project.model.resp.YA.KeyResultNodeInfo; +import com.sdm.project.service.INodeService; +import com.sdm.project.service.ITaskService; +import com.sdm.project.service.ISimulationRunService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +@RestController +@RequestMapping("/dataManager/tree/node") +@Tag(name = "宜安项目数据归档", description = "宜安项目模型数据关了") +public class YAModelController { + + @Autowired + private IDataFeignClient dataFeignClient; + + @Autowired + private DataAnalysisFeignClientImpl dataAnalysisFeignClient; + + @Resource + INodeService nodeService; + + @Resource + ITaskService taskService; + @Resource + ISimulationRunService runService; + + + /** + * 保存仿真模型数据 + * + * @param req + * @return + */ + @PostMapping(value = "/SaveModelNodeInfo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation( + summary = "上传模型", + description = "仿真模型归档,支持同时上传文件和附加参数", + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "模型文件上传请求", + required = true, + content = @Content( + mediaType = MediaType.MULTIPART_FORM_DATA_VALUE, + schema = @Schema(implementation = SaveModelNodeInfoReq.class) + ) + ) + ) + public BosimSaveNodeInfoRsp saveModelNodeInfo(SaveModelNodeInfoReq req) + { + UploadFilesReq fileReq = new UploadFilesReq(); + fileReq.setFileName(req.getName()); + fileReq.setProjectId(req.getProject()); + fileReq.setFileType(1); + fileReq.setFile(req.getFile()); + fileReq.setUuid(req.getScenario()); + fileReq.setAnalysisDirectionId(req.getScenario()); + SdmResponse uploadRespond = dataFeignClient.uploadFiles(fileReq); + BosimSaveNodeInfoRsp rsp = new BosimSaveNodeInfoRsp(); + if(uploadRespond.isSuccess()) + { + LinkedHashMap data = (LinkedHashMap) uploadRespond.getData(); + rsp.setCode("200"); + rsp.setMessage("success"); + int fileId = (int)data.get("fileId"); + rsp.getWorkRequest().add(String.valueOf(fileId)); + } + else + { + rsp.setCode("-200"); + rsp.setMessage(uploadRespond.getMessage()); + } + return rsp; + } + + /** + * 保存仿真报告 + * + * @param req + * @return + */ + @PostMapping(value = "/SaveReportNodeInfo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation( + summary = "上传仿真报告", + description = "仿真报告归档,支持同时上传文件和附加参数", + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "仿真报告上传请求", + required = true, + content = @Content( + mediaType = MediaType.MULTIPART_FORM_DATA_VALUE, + schema = @Schema(implementation = SaveReportNodeInfoReq.class) + ) + ) + ) + public BosimSaveNodeInfoRsp saveReportNodeInfo(SaveReportNodeInfoReq req) + { + UploadFilesReq fileReq = new UploadFilesReq(); + fileReq.setFileName(req.getName()); + fileReq.setProjectId(req.getProject()); + fileReq.setFileType(2); + fileReq.setFile(req.getFile()); + fileReq.setUuid(req.getScenario()); + fileReq.setAnalysisDirectionId(req.getScenario()); + SdmResponse uploadRespond = dataFeignClient.uploadFiles(fileReq); + BosimSaveNodeInfoRsp rsp = new BosimSaveNodeInfoRsp(); + if(uploadRespond.isSuccess()) + { + HashMap data = (HashMap) uploadRespond.getData(); + rsp.setCode("200"); + rsp.setMessage("success"); + int fileId = (int)data.get("fileId"); + rsp.getWorkRequest().add(String.valueOf(fileId)); + } + else + { + rsp.setCode("-200"); + rsp.setMessage(uploadRespond.getMessage()); + } + return rsp; + } + + /** + * 保存仿真关键结果 + * @param req + * @return + */ + @PostMapping(value = "/SaveKeyResultNodeInfo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation( + summary = "保存仿真关键结果", + description = "仿真关键结果归档,支持同时上传文件和附加参数", + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "仿真关键结果上传请求", + required = true, + content = @Content( + mediaType = MediaType.MULTIPART_FORM_DATA_VALUE, + schema = @Schema(implementation = SaveReportNodeInfoReq.class) + ) + ) + ) + public BosimSaveNodeInfoRsp saveKeyResultNodeInfo(SaveKeyResultNodeInfoReq req) + { + KeyResultReq addTaskRunReq = new KeyResultReq(); + addTaskRunReq.setFile(req.getFile()); + SdmResponse fileMetadataInfoResp = dataFeignClient.queryFileMetadataInfo(req.getScenario(), NodeTypeEnum.TASK.getValue(), 0L); + if (fileMetadataInfoResp.getData() != null) { + addTaskRunReq.setDirId(fileMetadataInfoResp.getData().getId()); + } + addTaskRunReq.setFileName(req.getFileName()); + addTaskRunReq.setFileType(req.getFileType()); + addTaskRunReq.setRunId(req.getScenario()); + addTaskRunReq.setKeyResultType(req.getCode()); + addTaskRunReq.setName(req.getName()); + addTaskRunReq.setQuantityType(req.getQuantityType()); + addTaskRunReq.setValue(req.getValue()); + addTaskRunReq.setUnits(req.getUnits()); + SdmResponse addTaskRunResp = runService.addSimulationKeyResult(addTaskRunReq); + + BosimSaveNodeInfoRsp rsp = new BosimSaveNodeInfoRsp(); + if(addTaskRunResp.isSuccess()) + { + rsp.setCode("200"); + rsp.setMessage("success"); + rsp.getWorkRequest().add(String.valueOf(addTaskRunResp.getData())); + } + return rsp; + } + + @PostMapping(value = "/listKeyResultNodeInfo") + public BosimKeyResultInfoRsp listKeyResultNodeInfo(@RequestBody SaveKeyResultNodeInfoReq req) { + KeyResultReq keyResultReq = new KeyResultReq(); + keyResultReq.setRunId(req.getScenario()); + keyResultReq.setKeyResultType(req.getCode()); + keyResultReq.setCurrent(req.getCurrent()); + keyResultReq.setSize(req.getSize()); + PageDataResp> response = runService.listSimulationKeyResult(keyResultReq).getData(); + List resultNodeInfoList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(response.getData())) { + List runKeyResults = response.getData(); + for (SimulationRunKeyResult runKeyResult : runKeyResults) { + KeyResultNodeInfo keyResultNodeInfo = new KeyResultNodeInfo(); + keyResultNodeInfo.setScenario(runKeyResult.getRunId()); + keyResultNodeInfo.setUuid(runKeyResult.getUuid()); + keyResultNodeInfo.setCode(runKeyResult.getKeyResultType()); + keyResultNodeInfo.setType(KeyResultTypeEnum.getDirNameByType(runKeyResult.getKeyResultType())); + keyResultNodeInfo.setName(runKeyResult.getName()); + keyResultNodeInfo.setFileId(runKeyResult.getFileId()); + keyResultNodeInfo.setQuantityType(runKeyResult.getQuantityType()); + keyResultNodeInfo.setUnits(runKeyResult.getUnits()); + keyResultNodeInfo.setValue(runKeyResult.getValue()); + resultNodeInfoList.add(keyResultNodeInfo); + } + } + PageInfo page = new PageInfo<>(resultNodeInfoList); + PageDataResp> pageDataResp = new PageDataResp<>(); + pageDataResp.setData(resultNodeInfoList); + pageDataResp.setTotal( page.getTotal()); + pageDataResp.setCurrentPage(page.getPageNum()); + pageDataResp.setPageSize(page.getPageSize()); + + BosimKeyResultInfoRsp rsp = new BosimKeyResultInfoRsp(); + rsp.setCode("200"); + rsp.setMessage("success"); + rsp.setData(pageDataResp); + return rsp; + } + + @PostMapping("") + public BosimSaveNodeInfoRsp deleteModelNodeInfo(DeleteModelNodeInfoReq req) + { + return null; + } + + + + + + + + @PostMapping("GetModelNodeInfoByIdAndType") + public void getModelNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req) + { + + } + + @PostMapping("DeleteModelNodeByObjectIds") + public void DeleteModelNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req) + { + + } + + @PostMapping("GetReportNodeInfoByIdAndType") + public void getReportNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req) + { + + } + + @PostMapping("DeleteReportNodeByObjectIds") + public void DeleteReportNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req) + { + + } + + @PostMapping("GetKeyResultNodeInfoByIdAndType") + public void getKeyResultNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req) + { + + } + + @PostMapping("DeleteKeyResultNodeByObjectIds") + public void DeleteKeyResultNodeInfo(@RequestBody @Validated GetModelNodeInfoReq req) + { + + } + + + /** + * 获取Task下模型文件信息 + * @param outsideReq + * @return + */ + @PostMapping("GetTaskModels") + public SdmResponse getTaskModels(@RequestBody @Validated GetTaskSimulatinFileReq outsideReq) + { + GetSimulationTaskFileReq req = new GetSimulationTaskFileReq(); + req.setUuid(outsideReq.getTaskId()); + req.setFileBizType(1); + req.setSize(outsideReq.getSize()); + req.setCurrent(outsideReq.getCurrent()); + return dataAnalysisFeignClient.getSimulationTaskFile(req); + } + + /** + * 获取Task下报告文件信息 + * @param outsideReq + * @return + */ + @PostMapping("GetTaskReports") + public SdmResponse getTaskReports(@RequestBody @Validated GetTaskSimulatinFileReq outsideReq) + { + GetSimulationTaskFileReq req = new GetSimulationTaskFileReq(); + req.setUuid(outsideReq.getTaskId()); + req.setFileBizType(2); + req.setSize(outsideReq.getSize()); + req.setCurrent(outsideReq.getCurrent()); + return dataAnalysisFeignClient.getSimulationTaskFile(req); + } + + + + public void downloadSimulationFile(long fileId) + { + + } + + @PostMapping("syncCidProject") + public BosimSaveProjectTaskRsp syncCidProject(@RequestBody @Validated SyncCidProjectReq req) + { + return nodeService.syncProject(req); + } + + @PostMapping("syncCidTask") + public BosimSaveProjectTaskRsp syncCidTask(@RequestBody @Validated SyncCidTaskReq req) + { + return taskService.syncCidTask(req); + } + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationBaseQuantities; +import com.sdm.project.model.entity.SimulationBaseUnits; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface SimulationBaseQuantitiesMapper extends BaseMapper { + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationBaseUnits; +import org.apache.ibatis.annotations.Mapper; + + +@Mapper +public interface SimulationBaseUnitsMapper extends BaseMapper { + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationDemand; +import com.sdm.project.model.req.*; +import com.sdm.project.model.vo.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface SimulationDemandMapper extends BaseMapper { + + int addDemand(@Param("req") SpdmAddDemandReq req,@Param("tenantId") Long tenantId,@Param("jobNumber") Long jobNumber); + + int addDemandMember(@Param("memberList") List memberList); + + int addDemandExtra(@Param("demandExtraList") List demandExtraList); + + int editDemand(@Param("req") SpdmEditDemandReq req, @Param("jobNumber") Long jobNumber); + + void deleteDemandMember(@Param("demandIdList") List demandIdList); + + void deleteDemandExtra(@Param("demandIdList") List demandIdList); + + void deleteDemand(@Param("deleteNodeIdList") List deleteNodeIdList); + + List getDemandList(@Param("tenantId") Long tenantId,@Param("req") SpdmDemandListReq req); + + List getMemberList(@Param("demandIdList") List demandIdList, @Param("memberType") Integer memberType); + + SpdmDemandVo getDemandByName(@Param("tenantId") Long tenantId,@Param("demandName") String demandName); + + List getDemandExtraList(@Param("demandIdList") List demandIdList); + + List getDemandListById(@Param("demandIdList") List demandIdList); + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationRunKeyResult; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SimulationKeyResultMapper extends BaseMapper { + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationNode; +import com.sdm.project.model.po.PerformanceNodePo; +import com.sdm.project.model.po.ProjectNodePo; +import com.sdm.project.model.po.TaskNodeMemberPo; +import com.sdm.project.model.po.TaskNodePo; +import com.sdm.project.model.req.*; +import com.sdm.project.model.vo.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Set; + +@Mapper +public interface SimulationNodeMapper extends BaseMapper { + + int addNodeBatch(@Param("addNodeList") List addNodeList); + + int editNode(@Param("editNode") SpdmNodeDetailReq editNode); + + int addNodeMemberBatch(@Param("addNodeMemberList") List addNodeMemberList); + + int editNodeMember(@Param("editNodeMember") SpdmNodeRelateMemberReq editNodeMember); + + int editNodeExtra(@Param("nodeExtra") SpdmNodeExtraReq nodeExtra); + + int deleteNodeBatch(@Param("deleteNodeIdList") List deleteNodeIdList); + + int deleteNodeMemberBatch(@Param("deleteNodeIdList") List deleteNodeIdList); + + int deleteNodeExtraBatch(@Param("deleteNodeIdList") List deleteNodeIdList); + + int addNodeExtraBatch(@Param("addNodeExtraList") List addNodeExtraList); + + + List getNodeList(@Param("nodeType") String nodeType, @Param("nodeSubType") String nodeSubType, @Param("exeStatus") String exeStatus, @Param("nodeCode") String nodeCode, + @Param("manager") String manager, @Param("nodeName") String nodeName, @Param("tenantId") Long tenantId, @Param("pos") int pos, @Param("limit") int limit); + + int getNodeListCount(@Param("nodeType") String nodeType, @Param("nodeSubType") String nodeSubType, @Param("progressStatus") Integer progressStatus, @Param("nodeCode") String nodeCode, + @Param("manager") String manager, @Param("nodeName") String nodeName, @Param("tenantId") Long tenantId); + + + List getNodeExtraListByNodeIdList(@Param("nodeIdList") List nodeIdList); + + List getNodeMemberListByNodeIdList(@Param("nodeIdList") List nodeIdList); + + SpdmNodeDetailVo getNodeDetail(@Param("projectNodeId") String projectNodeId,@Param("tenantId") String tenantId); + + List allList(@Param("nodeIdList") List deleteNodeList); + + void deleteTaskBatch(List deleteNodeIdList); + + void deleteTaskExtraBatch(@Param("taskIdList") List taskIdList); + + void deleteTaskMemberBatch(@Param("taskIdList") List taskIdList); + + void deletePerformanceBatch(@Param("performanceIdList") List performanceIdList); + + void deletePerformanceExtraBatch(@Param("performanceIdList") List performanceIdList); + + List getTaskListByNodeIdList(@Param("deleteNodeIdList") List deleteNodeIdList); + + List getTaskMemberListByNodeIdList(@Param("nodeIdList") List nodeIdList); + + List getPerformanceListByNodeIdList(@Param("taskIdList") List taskIdList); + + SpdmNodeVo getNodeById(@Param("projectNodeId") String projectNodeId); + + List getNodeListByNodeIdList(@Param("nodeIdList") List nodeIdList); + + + List getNodeListByIds(@Param("nodeIdList") List nodeIdList); + + List getUserGroupProjectStatistics(@Param("userIds")Set userIds ); + + List getUserGroupTaskCompleteStatistics(@Param("req") GetUserGroupTaskCompleteStatisticsReq req); + + List getUserGroupDifficultyStatistics(@Param("req") GetUserGroupTaskCompleteStatisticsReq req); + + List getCommonCompleteStatisticsFromTask(@Param("req") CommonGetCompleteStatisticsReq req); + + List getCommonCompleteStatisticsFromPerformance(@Param("req")CommonGetCompleteStatisticsReq req); + + List getWorkstationApproveStatus(@Param("req") GetWorkstationApproveStatusReq req); + + SpdmNodeVo getNodeByProjectIdAndName(@Param("projectId") String projectId, @Param("projectName") String projectName); + +} + + + +package com.sdm.project.dao; + +import com.sdm.common.entity.req.project.SimulationPerformance; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2025-11-03 + */ +public interface SimulationPerformanceMapper extends BaseMapper { + +} +
+ + +package com.sdm.project.dao; + + +import com.sdm.common.entity.resp.project.SimulationNodeResp; +import com.sdm.project.model.bo.*; +import com.sdm.project.model.po.*; +import com.sdm.project.model.req.ProjectTreeReq; +import com.sdm.project.model.req.TaskEditNodeReq; +import org.apache.ibatis.annotations.*; + +import java.util.List; + +@Mapper +public interface SimulationProjectMapper { + + +// int addProjectNodeVersion(@Param("version") ProjectNodeVersion version); + + int deleteProjectNodeVersion(@Param("projectNodeId")String projectNodeId); + +// List queryProjectNodeVersion(@Param("nodeName")String nodeName,@Param("nodeVersion")String nodeVersion); + + + ProjectNodePo queryProjectBrief(@Param("projectNodeId")String projectNodeId); + + + int batchAddSimulationNodes(@Param("list") List list); + + int batchAddSimulationNodeExtra(@Param("list") List list); + + int batchAddSimulationNodeMember(@Param("list") List list); + + int batchAddSimulationTask(@Param("list") List list); + + int batchAddSimulationCidTask(@Param("list") List list); + + int batchAddSimulationTaskExtra(@Param("list") List list); + + int batchAddSimulationTaskMember(@Param("list") List list); + + int batchAddSimulationPerformance(@Param("list") List list); + + int batchAddSimulationCidPerformance(@Param("list") List list); + + int batchAddSimulationPerformanceExtra(@Param("list")List list); + + + + + + + +// int batchUpdateSimulationNodes(@Param("list") List list); +// +// int batchUpdateSimulationNodeExtra(@Param("list") List list); +// +// int batchUpdateSimulationNodeMember(@Param("list") List list); +// +// int batchUpdateSimulationTask(@Param("list") List list); +// +// int batchUpdateSimulationTaskExtra(@Param("list") List list); +// +// int batchUpdateSimulationTaskMember(@Param("list") List list); +// +// int batchUpdateSimulationPerformance(@Param("list") List list); +// +// int batchUpdateSimulationPerformanceExtra(@Param("list")List list); + + + + int updateProjectNode(@Param("projectNode")ProjectNodePo projectNode); + + int updateProjectNodeItem(@Param("taskNode")TaskEditNodeReq taskNode); + + int updateProjectNodePerformance(@Param("performanceNode")TaskEditNodeReq performanceNode); + + int updateProjectNodeExtra(@Param("projectNodeExtra")ProjectNodeExtraPo projectNodeExtra); + + int updateProjectNodeItemExtra(@Param("taskNodeExtra")TaskExtraNode taskNodeExtra); + + int updateProjectNodeItemMember(@Param("taskNodeMember")TaskMemberNode taskNodeMember); + + int updateProjectNodePerformanceExtra(@Param("projectNodePerformanceExtra")TaskExtraNode projectNodePerformanceExtra); + + List queryProjectNodeList(@Param("projectName")String projectName); + + List queryNodeListByNodeId(@Param("nodeId")String nodeId); + + List queryNodeListByParentNodeId(@Param("nodeIdList")List nodeIdList); + + List queryProjectNodeItemList(@Param("projectNodeId")String projectNodeId); + + List queryProjectNodePerformanceList(@Param("projectNodeId")String projectNodeId); + + List queryProjectNodeExtras(@Param("projectNodeId")String projectNodeId); + + List queryProjectNodeExtrasByNodeIdList(@Param("nodeIdList")List nodeIdList); + + List queryProjectNodeMembersByNodeIdList(@Param("nodeIdList")List nodeIdList); + + List queryTaskNodeByNodeIdList(@Param("nodeIdList")List nodeIdList); + + List queryTaskNodeExtrasByNodeIdList(@Param("taskIdList")List taskIdList); + + List queryTaskNodeMembersByNodeIdList(@Param("taskIdList")List taskIdList); + + List queryProjectNodeItemExtraList(@Param("projectNodeId")String projectNodeId); + + List queryProjectNodePerformanceExtraList(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNode(@Param("nodeId")String nodeId); + + int deleteProjectNodeItem(@Param("taskId")String taskId); + + + int deleteProjectNodePerformance(@Param("performanceId")String performanceId); + + int deleteProjectNodeExtraInstance(@Param("extraId")String extraId); + + int deleteProjectNodeItemExtraInstance(@Param("extraId")String extraId); + + int deleteProjectNodePerformanceExtraInstance(@Param("extraId")String extraId); + + int deleteProjectNodeAllNodes(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllNodeExtras(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllNodeMembers(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllTasks(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllTaskExtras(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllTaskMembers(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllPerformances(@Param("projectNodeId")String projectNodeId); + + int deleteProjectNodeAllPerformanceExtra(@Param("projectNodeId")String projectNodeId); + + + List getNodeListByNodeIdList(@Param("nodeIdList") List nodeIdList); + + List getTaskListByNodeIdList(@Param("taskIdList") List taskIdList); + + List getPerformanceListByNodeIdList(@Param("taskIdList") List taskIdList); + + + void deleteNodeList(@Param("nodeIdList") List nodeIdList); + + void deleteNodeExtraList(@Param("nodeIdList") List nodeIdList); + + void deleteNodeMemberList(@Param("nodeIdList") List nodeIdList); + + void deletePerformanceList(@Param("performanceNodeIdList") List peformanceNodeIdList); + + void deletePerformanceExtraList(@Param("performanceNodeIdList") List performanceNodeIdList); + + void deleteTaskList(@Param("taskIdList") List taskIdList); + + void deleteTaskExtraList(@Param("taskIdList") List taskIdList); + + void deleteTaskMemberList(@Param("taskIdList") List taskIdList); + + + List queryPerformanceNodeByNodeIdList(@Param("taskIdList") List taskIdList,@Param("beginTime") String beginTime,@Param("endTime") String endTime,@Param("name") String name); + + List queryPerformanceNodeExtrasByNodeIdList(@Param("taskIdList") List taskIdList); + +// List getTaskList(@Param("tenantId") String tenantId,@Param("taskName") String taskName, @Param("taskStatus") Integer taskStatus, @Param("achieveStatus") Integer achieveStatus, @Param("nodeIdList") List nodeIdList); + + List queryRunListByNodeIdList(@Param("taskIdList") List taskIdList,@Param("beginTime") String beginTime,@Param("endTime") String endTime,@Param("name") String name); + + List getNodeListByTag(@Param("req") ProjectTreeReq projectTreeReq); + + List getTaskListByTag(@Param("req") ProjectTreeReq taskTreeReq); + + void getUserGroupProjectStatistics(); + + List getRunListByNodeIdList(@Param("taskIdList") List taskIdList); + + List querySimulationNodeByUuids(@Param("list")List uuids); + + List getNodeByIdList(@Param("nodeIdList") List nodeIdList); +} + + + +package com.sdm.project.dao; + +import com.sdm.project.model.entity.SimulationRun; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2025-11-03 + */ +public interface SimulationRunMapper extends BaseMapper { + + List findRunAndDescendantsIds(String runId); + +} +
+ + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationTaskAttention; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SimulationTaskAttentionMapper extends BaseMapper { + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationTaskExtra; + +/** + *

+ * Mapper 接口 + *

+ * + * @author author + * @since 2025-09-16 + */ +public interface SimulationTaskExtraMapper extends BaseMapper { + +} +
+ + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.common.common.SdmResponse; +import com.sdm.project.model.entity.SimulationTask; +import com.sdm.project.model.po.TaskNodeExtraPo; +import com.sdm.project.model.req.SpdmAnalysisTaskListReq; +import com.sdm.project.model.req.*; +import com.sdm.project.model.vo.*; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface SimulationTaskMapper extends BaseMapper { + + + SdmResponse list(SpdmTaskListReq req); + + List getTaskList(@Param("tenantId") Long tenantId, @Param("req") SpdmTaskListReq req); + + List getMemberList(@Param("taskIdList") List taskIdList, @Param("memberType") Integer memberType); + + List getAttentionMemberList(@Param("taskIdList") List taskIdList); + + List getTaskListByDemandIdList(@Param("demandIdList") List demandIdList); + + SpdmTaskVo getTask(@Param("taskId") String taskId); + + List taskList(@Param("req") SpdmAnalysisTaskListReq req, @Param("tenantId") Long tenantId, @Param("allNodeIdList") List allNodeIdList, @Param("pos") int pos, @Param("limit") int limit); + + void deleteAttentionByUserIdList(@Param("taskId") String taskId,@Param("userIdList") List userIdList); + + void saveAttentionList(@Param("attentionList") List attentionList); + + int updateTask(@Param("task") SpdmTaskVo task); + + List getUserExecTaskWithinTimeFrame(@Param("req") UserWorkloadReq req); + + SpdmTaskVo getTaskById(@Param("id") Long id); + + List getTaskCompleteStatistics(@Param("req") TaskCompleteStatisticsReq req); + + List getPerformanceCompleteStatistics(@Param("req") PerformanceCompleteStatisticsReq req); + + List getUserTaskCompleteStatistics(@Param("req") UserTaskCompleteStatisticsReq req); + + List getUserDifficultyStatistics(@Param("req") UserDifficultCompleteStatisticsReq req); + + List getTaskExtraList(@Param("taskIdList") List taskIdList); + + List getTaskListByTag(@Param("req") TaskCompleteStatisticsReq req); + + List getTaskListByName(@Param("taskNameList") List taskNameList); + + List getTaskListByDemandId(@Param("demandId") String demandId); + +} + + + +package com.sdm.project.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.sdm.project.model.entity.SimulationTaskMember; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SimulationTaskMemberMapper extends BaseMapper { + +} + + + +package com.sdm.project.filter; + +import com.sdm.common.filter.BaseAuthFilter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; + +@Slf4j +public class AuthFilter extends BaseAuthFilter { + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + super.doFilter(servletRequest, servletResponse, filterChain); + } +} + + + +package com.sdm.project.handler; + +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ListStringTypeHandler extends BaseTypeHandler> { + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, List parameter, JdbcType jdbcType) throws SQLException { + ps.setString(i, String.join(",", parameter)); + } + + @Override + public List getNullableResult(ResultSet rs, String columnName) throws SQLException { + if (rs.getString(columnName) == null) { + return new ArrayList<>(); + } + return Arrays.asList(rs.getString(columnName).split(",")); + } + + @Override + public List getNullableResult(ResultSet rs, int columnIndex) throws SQLException { + if (rs.getString(columnIndex) == null) { + return new ArrayList<>(); + } + return Arrays.asList(rs.getString(columnIndex).split(",")); + } + + @Override + public List getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { + if (cs.getString(columnIndex) == null) { + return new ArrayList<>(); + } + return Arrays.asList(cs.getString(columnIndex).split(",")); + } +} + + + +package com.sdm.project.model.bo; + +import lombok.Data; + +import java.util.List; + +/* 交付物审批流程,传递给电子流平台内容变化的数据 */ +@Data +public class ApprovalDeliverableContentsModel { + /** + * 任务uuid + */ + private String taskId; + /** + * 难度系数 + */ + private Float difficult; + +} + + + +package com.sdm.project.model.bo; + +import java.lang.reflect.Field; + +public class BaseBean { + protected void init() + { + Class cls = this.getClass(); + Field[] fields = cls.getDeclaredFields(); + try { + for (Field field : fields) { + Class typeClass = field.getType(); + if (typeClass == String.class) { + String empty = ""; + field.set(this, empty); + } + else if(typeClass == Byte.class) + { + field.setByte(this,(byte)0); + } + else if(typeClass == Integer.class) + { + field.setInt(this,0); + } + else if(typeClass == Long.class) + { + field.setLong(this,0); + } + else if(typeClass == Float.class) + { + field.setFloat(this,0); + } + else if(typeClass == Double.class) + { + field.setDouble(this,0); + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.po.ProjectNodeExtraPo; +import com.sdm.project.model.po.TaskNodeMemberPo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class CidTaskNode extends BaseEntity { + + /** + * 当前节点id + */ + private String uuid; + + private String ownRootNodeUuid; + + /** + * 父节点id + */ + private String parentId; + + private String nodeId; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String exeStatusValue; + + /** + * 项目进度状态 + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 仿真负责人 + */ + private String sManager; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + + /** + * 项目经理 + */ + private String managers; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + + /** + * 达标方式 + */ + private String method; + + private String taskId; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + private List children = new ArrayList<>(); //适配前端组件 + + + private String nodeVersion; + + private Long tenantId; + + private List taskExtraNodeList; + + private List memberList; + + private List extras; + + private List members; + + private String levelType; + + private String nodeLevel; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 任务名称 + */ + private String taskName; + + /** + * 任务编码 + */ + private String taskCode; + private String standard; + private String englishName; + private String performanceType; + private String lowValue; + private String highValue; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String analyseSoftwares; + private String department; + private String section; + private String group; + @JsonProperty(value = "bCapacity") + private String bCapacity; + @JsonProperty(value = "tag1") + private String tag1; + + + +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 从曲线结果提取的参数 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CurveParamDto { + @JsonProperty("max") + @Schema(description = "最大值") + private Double max; + + @JsonProperty("min") + @Schema(description = "最小值") + private Double min; + + @JsonProperty("unit") + @Schema(description = "单位") + private String unit; +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.po.ProjectNodeExtraPo; +import com.sdm.project.model.po.ProjectNodeMemberPo; +import com.sdm.project.model.req.SpdmDeleteProjectDetailReq; +import com.sdm.project.model.req.TaskEditNodeReq; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ModifyProjectNode extends BaseEntity { + String ownRootNodeUuid; + + List tagMap; + + List addNodeList; + + List editNodeList; + + List deleteNodeList; +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.req.TaskEditNodeReq; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ModifyTaskNode extends BaseEntity { + + List editNodeList; + + +} + + + +package com.sdm.project.model.bo; + +import com.sdm.common.entity.pojo.performance.PerformanceBase; +import com.sdm.common.entity.pojo.performance.PerformanceExpand; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +public class PerformanceInfo extends PerformanceBase { + private List expands; +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ProjectExtraNode extends BaseEntity { + + private String nodeId; + + private String performanceId; + + private String taskId; + + private String uuid; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + +} + + + +package com.sdm.project.model.bo; + +import com.sdm.common.entity.bo.UserInfo; +import com.sdm.common.entity.pojo.project.ProjectBase; +import com.sdm.common.entity.pojo.project.ProjectExpand; +import com.sdm.common.entity.pojo.project.ProjectNodeBase; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ProjectInfo extends ProjectBase { + private List expands; + + //状态灯颜色: 1:red 2:yellow 3:grey 4:green + private int projectStatus; + private String currentPhase; + + private List projectManagers; + + private List phases; +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ProjectMemberNode extends BaseEntity { + + /** + * 用户名 + */ + private String userName; + + /** + * 工号 + */ + private String jobNumber; + + /** + * 用户角色 + */ + private String userRole; + + /** + * 部门 + */ + private String department; + + /** + * 手机号 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + private String taskId; + + private String nodeId; + + private String uuid; + + private String identity; + + private String name; + + + + +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.po.ProjectNodeExtraPo; +import com.sdm.project.model.po.ProjectNodeMemberPo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ProjectNode extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 父节点id + */ + private String parentId; + + private String nodeId; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + /** + * 项目进度状态 + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 仿真负责人 + */ + private String sManager; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + + /** + * 项目经理 + */ + private String managers; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + + /** + * 达标方式 + */ + private String method; + + private String taskId; + + /** + * 目标值 + */ + private String targetValue; + + private String performanceType; + private String highValue; + private String lowValue; + + + + /** + * 单位 + */ + private String unit; + + private List children = new ArrayList<>(); //适配前端组件 + + + private String nodeVersion; + +// private String tenantId; + + + + /** + * 拓展属性集合 + */ + private List extras; + + private List memberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + private String levelType; + + private String nodeLevel; + + private String folderId; + + private String taskName; + + private String taskCode; + + private String performanceName; + + private String standard; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String department; + private String section; + private String group; + @JsonProperty(value = "bCapacity") + private String bCapacity; + private String flowTemplate; + private String englishName; + + private List analyseSoftwareList; + + @JsonProperty(value = "tag1") + private List tag1; + @JsonProperty(value = "tag2") + private List tag2; + @JsonProperty(value = "tag3") + private List tag3; + @JsonProperty(value = "tag4") + private List tag4; + @JsonProperty(value = "tag5") + private List tag5; + @JsonProperty(value = "tag6") + private List tag6; + @JsonProperty(value = "tag7") + private List tag7; + @JsonProperty(value = "tag8") + private List tag8; + @JsonProperty(value = "tag9") + private List tag9; + @JsonProperty(value = "tag10") + private List tag10; + + private Long imageFileId; +} + + + +package com.sdm.project.model.bo; + +import com.sdm.common.entity.bo.UserInfo; +import com.sdm.common.entity.pojo.project.ProjectNodeBase; +import com.sdm.common.entity.pojo.project.ProjectNodeExpand; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +public class ProjectNodeInfo extends ProjectNodeBase { + private List expands; + private List members; + private List children; + private List taskInfos; +} + + + +package com.sdm.project.model.bo; + +import java.util.ArrayList; +import java.util.List; + +public class ProjectNodeTree extends BaseBean { + + public List nodeList = new ArrayList<>(); +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class TaskExtraNode extends BaseEntity { + + private String nodeId; + + private String performanceId; + + private String taskId; + + private String uuid; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + + + +} + + + +package com.sdm.project.model.bo; + +import com.sdm.common.entity.bo.UserInfo; +import com.sdm.common.entity.pojo.task.TaskBase; +import com.sdm.common.entity.pojo.task.TaskExpand; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +public class TaskInfo extends TaskBase { + + private List expands; + + private List members; + + private List performanceInfos; +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class TaskMemberNode extends BaseEntity { + + /** + * 用户名 + */ + private String userName; + + /** + * 工号 + */ + private String jobNumber; + + /** + * 用户角色 + */ + private String userRole; + + /** + * 部门 + */ + private String department; + + /** + * 手机号 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + private String taskId; + + private String nodeId; + + private String uuid; + + private String identity; + + private String name; + + private String userId; + + private Integer type; + + +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.po.ProjectNodeExtraPo; +import com.sdm.project.model.po.TaskNodeExtraPo; +import com.sdm.project.model.po.TaskNodeMemberPo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class TaskNode extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + private String ownRootNodeUuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 父节点id + */ + private String parentId; + + private String nodeId; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String exeStatusValue; + + /** + * 项目进度状态 + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 仿真负责人 + */ + private String sManager; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + + /** + * 项目经理 + */ + private String managers; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + + /** + * 达标方式 + */ + private String method; + + private String taskId; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + private List children = new ArrayList<>(); //适配前端组件 + + + private String nodeVersion; + + private Long tenantId; + + private List taskExtraNodeList; + + private List memberList; + + private List extras; + + private List members; + + private String levelType; + + private String nodeLevel; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String standard; + + private String englishName; + + private String performanceType; + + private String lowValue; + private String highValue; + + + + /** + * 父主键id + */ + private Long ppId; + + + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String analyseSoftwares; + private String department; + private String section; + private String group; + @JsonProperty(value = "bCapacity") + private String bCapacity; + private String flowTemplate; + + @JsonProperty(value = "tag1") + private List tag1; + @JsonProperty(value = "tag2") + private List tag2; + @JsonProperty(value = "tag3") + private List tag3; + @JsonProperty(value = "tag4") + private List tag4; + @JsonProperty(value = "tag5") + private List tag5; + @JsonProperty(value = "tag6") + private List tag6; + @JsonProperty(value = "tag7") + private List tag7; + @JsonProperty(value = "tag8") + private List tag8; + @JsonProperty(value = "tag9") + private List tag9; + @JsonProperty(value = "tag10") + private List tag10; + +// private String tags1; +// private String tags2; +// private String tags3; +// private String tags4; +// private String tags5; +// private String tags6; +// private String tags7; +// private String tags8; +// private String tags9; +// private String tags10; + + private String demandId; + private Long imageFileId; + +} + + + +package com.sdm.project.model.bo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class TaskNodeTag { + String key; + String value; +} + + + +package com.sdm.project.model.bo; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.ArrayList; +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Data +public class TaskNodeTree extends BaseBean { + + public List nodeList = new ArrayList<>(); + +} + + + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_base_quantities") +@ApiModel(value="SimulationBaseQuantities对象", description="物理量基表") +public class SimulationBaseQuantities implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id") + private Integer id; + + @TableField("label") + private String label; + + @TableField("family") + private String family; + + @TableField("name") + private String name; + + @TableField("changeFlag") + private String changeFlag; + +} + + + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_base_units") +@ApiModel(value="SimulationBaseUnits对象", description="单位基表") +public class SimulationBaseUnits implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id") + private Integer id; + + @TableField("label") + private String label; + + @TableField("family") + private String family; + + @TableField("name") + private String name; + + @TableField("changeFlag") + private String changeFlag; + +} + + + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_demand") +@ApiModel(value="SimulationDemand对象", description="") +public class SimulationDemand implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("uuid") + private String uuid; + + @TableField("demand_name") + private String demandName; + + @TableField("demand_code") + private String demandCode; + + @TableField("demand_type") + private String demandType; + + @TableField("sim_type") + private String simType; + + @TableField("demand_status") + private String demandStatus; + + @TableField("achieve_status") + private String achieveStatus; + + @TableField("progress") + private Integer progress; + + @TableField("approval_status") + private String approvalStatus; + + @TableField("begin_time") + private String beginTime; + + @TableField("end_time") + private String endTime; + + @TableField("finish_time") + private String finishTime; + + @TableField("project_id") + private String projectId; + + @TableField("phase_id") + private String phaseId; + + @TableField("node_id") + private String nodeId; + + @TableField("tenant_id") + private Long tenantId; + + @TableField("creator") + private Long creator; + + @TableField("create_time") + private String createTime; + + @TableField("updater") + private Long updater; + + @TableField("update_time") + private String updateTime; + + @TableField("description") + private String description; +} + + + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author author + * @since 2025-11-17 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_node") +@ApiModel(value="SimulationNode对象", description="") +public class SimulationNode implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("uuid") + private String uuid; + + @ApiModelProperty(value = "所属根节点uuid") + @TableField("ownRootNodeUuid") + private String ownRootNodeUuid; + + @TableField("nodeName") + private String nodeName; + + @TableField("nodeCode") + private String nodeCode; + + @TableField("englishName") + private String englishName; + + @TableField("nodeType") + private String nodeType; + + @TableField("nodeSubType") + private String nodeSubType; + + @TableField("nodeStatus") + private String nodeStatus; + + @TableField("parentId") + private String parentId; + + @TableField("folderId") + private String folderId; + + @TableField("nodeLevel") + private Integer nodeLevel; + + @TableField("beginTime") + private String beginTime; + + @TableField("endTime") + private String endTime; + + @TableField("finishTime") + private String finishTime; + + @TableField("progress") + private Integer progress; + + @TableField("achieveStatus") + private Integer achieveStatus; + + @TableField("nodeVersion") + private String nodeVersion; + + @TableField("tenantId") + private Long tenantId; + + @TableField("description") + private String description; + + @TableField("detailImgUrl") + private String detailImgUrl; + + @TableField("creator") + private Long creator; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private String createTime; + + @TableField("updater") + private Long updater; + + @ApiModelProperty(value = "更新时间") + @TableField("update_time") + private String updateTime; + + @TableField("pid") + private Integer pid; + + @ApiModelProperty(value = "上汽大众:SVW 德国大众:VW") + @TableField("exe_status") + private String exeStatus; + + @TableField("tag1") + private String tag1; + + @TableField("tag2") + private String tag2; + + @TableField("tag3") + private String tag3; + + @TableField("tag4") + private String tag4; + + @TableField("tag5") + private String tag5; + + @TableField("tag6") + private String tag6; + + @TableField("tag7") + private String tag7; + + @TableField("tag8") + private String tag8; + + @TableField("tag9") + private String tag9; + + @TableField("tag10") + private String tag10; + + +} +
+ + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.*; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author author + * @since 2025-11-03 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_run") +@ApiModel(value="SimulationRun对象", description="") +public class SimulationRun implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("uuid") + private String uuid; + + @TableField("runName") + private String runName; + + @ApiModelProperty(value = "1:server 2:pbs 3:local only") + @TableField("type") + private Integer type; + + @TableField("taskId") + private String taskId; + + @ApiModelProperty(value = "流程模板id") + @TableField("flowTemplate") + private String flowTemplate; + + @ApiModelProperty(value = "Run状态 0:未执行 1:执行中 2:完成 3:失败") + @TableField("status") + private Integer status; + + @ApiModelProperty(value = "Run总共的流程步骤") + @TableField("totalStep") + private Integer totalStep; + + @ApiModelProperty(value = "当前的流程步骤") + @TableField("currentStep") + private Integer currentStep; + + @ApiModelProperty(value = "当前的流程步骤名称") + @TableField("currentStepName") + private String currentStepName; + + @ApiModelProperty(value = "Run执行结果 0:gray 1:red 2:yellow 3:green") + @TableField("achieveStatus") + private Integer achieveStatus; + + @ApiModelProperty(value = "run描述信息") + @TableField("description") + private String description; + + @ApiModelProperty(value = "Run对应在文件系统中的路径") + @TableField("folderId") + private Long folderId; + + @ApiModelProperty(value = "计算父版本Id") + @TableField("parentId") + private String parentId; + + @TableField("isPersonalTemplate") + private String isPersonalTemplate; + + @ApiModelProperty(value = "租户id") + @TableField("tenantId") + private Long tenantId; + + @ApiModelProperty(value = "英文名") + @TableField("englishName") + private Long englishName; + + @Schema(description= "创建者ID") + @TableField("creator") + private Long creator; + + @Schema(description= "创建时间") + @TableField("createTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + @Schema(description= "更新者ID") + @TableField("updater") + private Long updater; + + @Schema(description= "创建时间") + @TableField("updateTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + @Schema(description = "flowable流程完成部署后的流程定义id,根据这个发起流程实例") + @TableField("processDefinitionId") + public String processDefinitionId; + + @Schema(description= "流程实例id(流程引擎返回的)") + @TableField("flowInstanceId") + private String flowInstanceId; + +} +
+ + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_run_key_result") +@ApiModel(value="simulationRunKeyResult对象", description="任务执行-图片/动画/数值/文件关键性能结果实体") +public class SimulationRunKeyResult implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + @ApiModelProperty(value = "主键ID", example = "1") + private Long id; + + @TableField("uuid") + @ApiModelProperty(value = "关键结果唯一ID", required = true) + private String uuid; + + @TableField("runId") + @ApiModelProperty(value = "所属Run UUID", required = true) + private String runId; + + @TableField("keyResultType") + @ApiModelProperty(value = "关键性能结果类型 1-图片/动画 2-曲线 3-报告 4-数值") + private Integer keyResultType; + + @TableField("name") + @ApiModelProperty(value = "结果名称") + private String name; + + @TableField("fileId") + @ApiModelProperty(value = "关联文件id") + private Long fileId; + + @TableField("quantityType") + @ApiModelProperty(value = "物理量类型") + private String quantityType; + + @TableField("units") + @ApiModelProperty(value = "结果单位") + private String units; + + @TableField("max") + @ApiModelProperty(value = "最大数值") + private String max; + + @TableField("min") + @ApiModelProperty(value = "最小数值") + private String min; + + @TableField("value") + @ApiModelProperty(value = "数值") + private String value; + + @TableField("description") + @ApiModelProperty(value = "描述信息") + private String description; + + @TableField("xQuantityType") + @ApiModelProperty(value = "x轴物理量(曲线结果使用)") + private String xQuantityType; + + @TableField("xUnits") + @ApiModelProperty(value = "x轴结果单位(曲线结果使用)") + private String xUnits; + + @TableField("yQuantityType") + @ApiModelProperty(value = "y轴物理量(曲线结果使用)") + private String yQuantityType; + + @TableField("yUnits") + @ApiModelProperty(value = "y轴结果单位(曲线结果使用)") + private String yUnits; + + @TableField("creator") + @ApiModelProperty(value = "创建人ID") + private Long creator; + + @TableField("createTime") + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + @TableField("updater") + @ApiModelProperty(value = "更新人ID") + private Long updater; + + @TableField("updateTime") + @ApiModelProperty(value = "更新时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + @Schema(description= "创建者名称,列表展示使用") + @TableField(value = "creatorName", insertStrategy = FieldStrategy.NEVER,select = false,updateStrategy = FieldStrategy.NEVER) + private String creatorName; + + @Schema(description= "更新者名称,列表展示使用") + @TableField(value = "updaterName", insertStrategy = FieldStrategy.NEVER,select = false,updateStrategy = FieldStrategy.NEVER) + private String updaterName; + +} + + + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author author + * @since 2025-11-03 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_task") +@ApiModel(value="SimulationTask对象", description="") +public class SimulationTask implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "loadcase名称") + @TableField("uuid") + private String uuid; + + @ApiModelProperty(value = "loadcase所属学科名称") + @TableField("task_name") + private String taskName; + + @TableField("task_code") + private String taskCode; + + @ApiModelProperty(value = "loadcase 库名称") + @TableField("task_pool_name") + private String taskPoolName; + + @TableField("task_pool_version") + private String taskPoolVersion; + + @ApiModelProperty(value = "task所属节点Id,0表示不从属任何节点") + @TableField("node_id") + private String nodeId; + + @ApiModelProperty(value = "loadcase预估的工作周期") + @TableField("days") + private Integer days; + + @TableField("real_days") + private Integer realDays; + + @ApiModelProperty(value = "loadcase参照的标准") + @TableField("standard") + private String standard; + + @TableField("fold_id") + private String foldId; + + @ApiModelProperty(value = "loadcase当前状态 1:red 2:yellow 3:grey 4:green") + @TableField("status") + private Integer status; + + @TableField("achieve_status") + private String achieveStatus; + + @ApiModelProperty(value = "loadcase开始时间") + @TableField("begin_time") + private String beginTime; + + @ApiModelProperty(value = "loadcase执行结束时间") + @TableField("end_time") + private String endTime; + + @TableField("finish_time") + private String finishTime; + + @ApiModelProperty(value = "loadcase进度") + @TableField("progress") + private Integer progress; + + @ApiModelProperty(value = "上汽大众:SVW 德国大众:VW") + @TableField("exe_status") + private String exeStatus; + + @ApiModelProperty(value = "置信度") + @TableField("confidence") + private String confidence; + + @TableField("analyse_target") + private String analyseTarget; + + @ApiModelProperty(value = "分析软件") + @TableField("analyse_software") + private String analyseSoftware; + + @TableField("approval_status") + private Integer approvalStatus; + + @TableField("comfirm_status") + private String comfirmStatus; + + @TableField("description") + private String description; + + @TableField("difficult") + private Float difficult; + + @TableField("tenant_id") + private String tenantId; + + @TableField("pid") + private Integer pid; + + @ApiModelProperty(value = "创建人") + @TableField("creator") + private Long creator; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private String createTime; + + @ApiModelProperty(value = "更新人") + @TableField("updater") + private Long updater; + + @ApiModelProperty(value = "更新时间") + @TableField("update_time") + private String updateTime; + + @ApiModelProperty(value = "部门") + @TableField("department") + private String department; + + @ApiModelProperty(value = "科") + @TableField("sectionName") + private String sectionName; + + @ApiModelProperty(value = "组") + @TableField("groupName") + private String groupName; + + @ApiModelProperty(value = "仿真能力") + @TableField("bCapacity") + private String bCapacity; + + @ApiModelProperty(value = "任务流程模板") + @TableField("flowTemplate") + private String flowTemplate; + + @TableField("englishName") + private String englishName; + + @ApiModelProperty(value = "关联的需求id") + @TableField("demand_id") + private String demandId; + + @TableField("tag1") + private String tag1; + + @TableField("tag2") + private String tag2; + + @TableField("tag3") + private String tag3; + + @TableField("tag4") + private String tag4; + + @TableField("tag5") + private String tag5; + + @TableField("tag6") + private String tag6; + + @TableField("tag7") + private String tag7; + + @TableField("tag8") + private String tag8; + + @TableField("tag9") + private String tag9; + + @TableField("tag10") + private String tag10; + + @TableField("cidFlowId") + private String cidFlowId; + + +} +
+ + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_task_attention") +@ApiModel(value="SimulationTaskAttention", description="") +public class SimulationTaskAttention implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "任务ID") + @TableField("task_id") + private String taskId; + + @ApiModelProperty(value = "身份标识") + @TableField("identity") + private String identity; + + @ApiModelProperty(value = "名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "用户ID") + @TableField("user_id") + private Long userId; + + @ApiModelProperty(value = "创建人") + @TableField("creator") + private String creator; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private String createTime; + + @ApiModelProperty(value = "更新人") + @TableField("updater") + private String updater; + + @ApiModelProperty(value = "更新时间") + @TableField("update_time") + private String updateTime; + +} + + + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author author + * @since 2025-09-16 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_task_extra") +@ApiModel(value="SimulationTaskExtra对象", description="") +public class SimulationTaskExtra implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("task_id") + private String taskId; + + @TableField("property_name") + private String propertyName; + + @TableField("property_value") + private String propertyValue; + + @TableField("value_type") + private String valueType; + + @TableField("property_class") + private String propertyClass; + + +} +
+ + +package com.sdm.project.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("simulation_task_member") +@ApiModel(value="SimulationTaskMember", description="") +public class SimulationTaskMember implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键ID") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "任务ID") + @TableField("task_id") + private String taskId; + + @ApiModelProperty(value = "身份标识") + @TableField("identity") + private String identity; + + @ApiModelProperty(value = "名称") + @TableField("name") + private String name; + + @ApiModelProperty(value = "用户ID") + @TableField("user_id") + private Long userId; + + @ApiModelProperty(value = "创建人") + @TableField("creator") + private Long creator; + + @ApiModelProperty(value = "创建时间") + @TableField("create_time") + private String createTime; + + @ApiModelProperty(value = "更新人") + @TableField("updater") + private Long updater; + + @ApiModelProperty(value = "更新时间") + @TableField("update_time") + private String updateTime; + + @ApiModelProperty(value = "类型:0-仿真负责人 1-仿真执行人") + @TableField("type") + private Integer type; + +} + + + +package com.sdm.project.model.po; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class NodeAllBase extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 父节点id + */ + private String parentId; + + + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private String managers; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String exeStatusValue; + + /** + * 仿真负责人 + */ + private String sManager; + + private String nodeId; + + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 执行规范 + */ +// private String detailImgUrl; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + /** + * 指标名称 + */ + private String performanceName; + + /** + * 达标方式 + */ + private String method; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + public List children = new ArrayList<>(); //适配前端组件 + + public int nodeOrder; + + public String nodeVersion; + + public Long tenantId; + + public String members; + + public String extras; + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class PerformanceNodeExtraPo extends BaseEntity { + + /** + * 所属节点id + */ + private String nodeId; + + private String performanceId; + + private String taskId; + + private String uuid; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + + + +} + + + +package com.sdm.project.model.po; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class PerformanceNodePo extends NodeAllBase { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + private String nodeId; + + /** + * 当前节点id + */ + private String uuid; + + private String taskId; + + private String taskName; + + + /** + * 指标名称 + */ + private String performanceName; + + private String performanceType; + private String standard; + private String highValue; + private String lowValue; + private String englishName; + private String description; + + + private String nodeName; + + /** + * 达标方式 + */ + private String method; + + private String completeStatus; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + + /** + * 拓展属性集合 + */ + public String extras; + +// public void addNodeExtra(PerformanceNodeExtraPo nodeExtra) +// { +// extras.add(nodeExtra); +// } + + private String folderId; + + private String projectName; + + private String phaseName; + + private String disciplineName; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList = ""; + @JsonProperty(value = "eMemberList") + private String eMemberList = ""; + private String exeStatus = ""; + private Integer achieveStatus = 0; + private String beginTime = ""; + private String endTime = ""; + private String flowTemplate = ""; + private String analyseTarget = ""; + private String confidence = ""; + private Float difficult = 0F; + private Integer days = 0;; + private String analyseSoftware = ""; + private String imageFileId = ""; + @JsonProperty(value = "bCapacity") + private String bCapacity = ""; + private String department = ""; + private String section = ""; + private String group = ""; + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class ProjectNodeDetailPo extends BaseEntity { + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private String managers; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + /** + * 团队成员 + */ + List memberList; + + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class ProjectNodeExtraPo extends BaseEntity { + + /** + * 所属节点id + */ + private String nodeId; + + private String uuid; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + + private String taskId; + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class ProjectNodeMemberPo extends BaseEntity { + + /** + * 用户名 + */ + private String userName; + + /** + * 工号 + */ + private String jobNumber; + + /** + * 用户角色 + */ + private String userRole; + + /** + * 部门 + */ + private String department; + + /** + * 手机号 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + private String nodeId; + + private String uuid; + + private String identity; + private String name; + +} + + + +package com.sdm.project.model.po; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.bo.ProjectNode; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ProjectNodePo extends NodeAllBase { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 父节点id + */ + private String parentId; + + + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private String managers; + + /** + * 拓展属性集合 + */ + private String extras; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + public List children = new ArrayList<>(); + +// public void addNodeExtra(ProjectNodeExtraPo nodeExtra) +// { +// extras.add(nodeExtra); +// } + + public int nodeOrder; + + + public String nodeVersion; + + public String members; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private List pMemberList; + + private String pMembers; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private List eMemberList; + + private String eMembers; + + /** + * 拓展属性集合 + */ + private List extraList; + + private String folderId; + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + private Long imageFileId; + private String englishName; +} + + + +package com.sdm.project.model.po; + +import lombok.Data; + +@Data +public class RunNodePo extends NodeAllBase { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + private String nodeId; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 算例名称 + */ + private String runName; + + /** + * 算例类型 + */ + private Integer type; + + /** + * 算例关联的任务id + */ + private String taskId; + + /** + * 流程模板名称 + */ + private String flowTemplate; + + /** + * Run状态 0:未执行 1:执行中 2:完成 3:失败 + */ + private Integer status; + + /** + * run描述信息 + */ + private String description; + + /** + * Run总共的流程步骤 + */ + private Integer totalStep; + + /** + * 当前的步骤 + */ + private Integer currentStep; + + + /** + * Run执行结果 0:gray 1:red 2:yellow 3:green + */ + private Integer result; + + /** + * Run对应在文件系统中的路径 + */ + private String folderId; + + /** + * 父算例ID + */ + private String parentId; + + private Integer isPersonalTemplate; + + private Long tenantId; + + /** + * 拓展属性集合 + */ + public String extras; + + + /** + * 仿真负责人 + */ + private String pMembers; + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class TaskNodeExtraPo extends BaseEntity { + + private String uuid; + + /** + * 所属节点id + */ + private String nodeId; + + private String taskId; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + + + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class TaskNodeMemberPo extends BaseEntity { + + /** + * 用户名 + */ + private String userName; + + /** + * 工号 + */ + private String jobNumber; + + /** + * 用户角色 + */ + private String userRole; + + /** + * 部门 + */ + private String department; + + /** + * 手机号 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + private String nodeId; + + private String uuid; + private String identity; + private String name; + private String taskId; + + +} + + + +package com.sdm.project.model.po; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class TaskNodePo extends NodeAllBase { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + + /** + * 当前节点id + */ + private String uuid; + + private String nodeId; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String exeStatusValue; + + /** + * 仿真负责人 + */ + private String sManager; + + + /** + * 项目进度状态 + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 执行规范 + */ +// private String detailImgUrl; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + /** + * 拓展属性集合 + */ + private String extras; + + public List children = new ArrayList<>(); + +// public void addNodeExtra(TaskNodeExtraPo nodeExtra) +// { +// extras.add(nodeExtra); +// } + + public List performances = new ArrayList<>(); + + public String projectNodeName; + + public String nodeVersion; + + public String members; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private List pMemberList; + + private String pMembers; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private List eMemberList; + + private String eMembers; + + /** + * 拓展属性集合 + */ + private List extraList; + + private String folderId; + + private String standard; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String department; + private String section; + private String sectionName; + private String group; + private String groupName; + @JsonProperty("bCapacity") + private String bCapacity; + private String flowTemplate; + private String englishName; + private String description; + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + private Long imageFileId; + +} + + + +package com.sdm.project.model.po; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class TaskRunPo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + private String nodeId; + + /** + * 当前节点id + */ + private String uuid; + + private String taskId; + + private String taskName; + + + /** + * 指标名称 + */ + private String runName; + + private String type; + private String standard; + private String highValue; + private String lowValue; + private String englishName; + private String description; + + + private String nodeName; + + /** + * 达标方式 + */ + private String method; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + + /** + * 拓展属性集合 + */ + public List extras; + + public void addNodeExtra(PerformanceNodeExtraPo nodeExtra) + { + extras.add(nodeExtra); + } + + private String folderId; + + private String projectName; + + private String phaseName; + + private String disciplineName; + + /** + * 仿真负责人 + */ + private String pMembers; +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.project.ProjectNodeBase; +import com.sdm.common.entity.pojo.project.ProjectNodeExpand; +import com.sdm.common.entity.pojo.project.ProjectNodeMemberRelate; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class AddProjectNodeBatchReq { + @NotNull(message = "projectId不能为空") + private Long projectId; + + @NotEmpty(message = "projectNodeBases不能为空") + private List bases; + + @NotEmpty(message = "relates不能为空") + private List relates; + + private List expands; +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.bo.UserInfo; +import com.sdm.common.entity.pojo.project.ProjectBase; +import com.sdm.common.entity.pojo.project.ProjectExpand; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class AddProjectReq { + @NotNull(message = "projectBase不能为空") + private ProjectBase projectBase; + @NotEmpty(message = "userInfos不能为空") + private List userInfos; + private List expands; +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * 任务/指标 完成情况统计请求参数(工位、学科) + */ +@Data +@Schema(description = "任务/指标 完成情况统计请求参数(工位、学科)") +public class CommonGetCompleteStatisticsReq { + @Schema(description = "查询统计类型 task/performance") + @NotNull + private String queryType; + + @Schema(description = "数据返回Tag类型: tag1、tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10") + @NotNull + private String resultTagType; + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "标签2") + private String tag2; + + @Schema(description = "标签3") + private String tag3; + + @Schema(description = "标签4") + private String tag4; + + @Schema(description = "标签5") + private String tag5; + + @Schema(description = "标签6") + private String tag6; + + @Schema(description = "标签7") + private String tag7; + + @Schema(description = "标签8") + private String tag8; + + @Schema(description = "标签9") + private String tag9; + + @Schema(description = "标签10") + private String tag10; +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class DeliverableApproveReq { + + @Schema(description = "任务uuid") + private String taskId; + + @Schema(description = "难度系数") + private Float difficult; + + @Schema(description = "交付物审批模板id") + private String templateId; + + @Schema(description = "交付物审批模板名称") + private String templateName; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class DelProjectNodeReq { + @NotBlank(message = "projectName不能为空") + private String projectName; + @NotNull(message = "nodeId不能为空") + private Long nodeId; +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class DelProjectReq { + @NotBlank(message = "projectName不能为空") + private String projectName; +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class GetNodeDetailReq { + + @NotNull(message = "relatedResourceUuid不能为空") + private String relatedResourceUuid; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class GetProjectDetailReq { + + @NotNull(message = "projectNodeId不能为空") + private String projectNodeId; + + @NotNull(message = "phaseNodeId不能为空") + private String phaseNodeId; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class GetProjectListReq { + + @NotNull(message = "current不能为空") + private Integer current; + + @NotNull(message = "size不能为空") + private Integer size; + + private String projectNodeId; + + private String phaseNodeId; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @Author xuyundi + * @Date 2024/3/5 + * @Note + */ +@Data +public class GetRunVersionReq { + /** + * 算例uuid + */ + @Schema(description = "算例uuid") + private String runId; + /** + * 任务uuid + */ + @Schema(description = "任务uuid") + private String taskId; +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class GetTaskDetailReq { + + @NotNull(message = "relatedResourceUuid不能为空") + private String relatedResourceUuid; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +/** + * 用户组任务完成情况统计请求参数 + */ +@Data +@Schema(description = "用户组任务完成情况统计请求参数") +public class GetUserGroupTaskCompleteStatisticsReq { + @Schema(description = "用户组ID") + @NotNull(message = "用户组ID不能为空") + private Long userGroupId; + + @Schema(description = "用户ID") + private Long userId; + + @Schema(description = "用户") + private Set userIds; + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "标签2") + private String tag2; + + @Schema(description = "标签3") + private String tag3; + + @Schema(description = "标签4") + private String tag4; + + @Schema(description = "标签5") + private String tag5; + + @Schema(description = "标签6") + private String tag6; + + @Schema(description = "标签7") + private String tag7; + + @Schema(description = "标签8") + private String tag8; + + @Schema(description = "标签9") + private String tag9; + + @Schema(description = "标签10") + private String tag10; +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class GetWorkstationApproveStatusReq { + @Schema(description = "数据返回Tag类型: tag1、tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10") + @NotNull + private String resultTagType; + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "标签2") + private String tag2; + + @Schema(description = "标签3") + private String tag3; + + @Schema(description = "标签4") + private String tag4; + + @Schema(description = "标签5") + private String tag5; + + @Schema(description = "标签6") + private String tag6; + + @Schema(description = "标签7") + private String tag7; + + @Schema(description = "标签8") + private String tag8; + + @Schema(description = "标签9") + private String tag9; + + @Schema(description = "标签10") + private String tag10; +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.BaseReq; +import com.sdm.common.entity.enums.FileBizTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +@Data +public class KeyResultReq extends BaseReq { + private Long id; + + private String uuid; + + @Schema(description = "算例uuid") + private String runId; + + @Schema(description = "关键性能结果类型 1-图片/动画 2-曲线 3-报告 4-数值") + private Integer keyResultType; + + @Schema(description = "结果名称") + private String name; + + @Schema(description = "文件id") + private Long fileId; + + @Schema(description = "物理量") + private String quantityType; + + @Schema(description = "结果单位") + private String units; + + @Schema(description = "最大数值") + private String max; + + @Schema(description = "最小数值") + private String min; + + @Schema(description = "数值") + private String value; + + @Schema(description = "描述信息") + private String description; + + @Schema(description = "x轴物理量(曲线结果使用)") + private String xQuantityType; + + @Schema(description = "x轴结果单位(曲线结果使用)") + private String xUnits; + + @Schema(description = "y轴物理量(曲线结果使用)") + private String yQuantityType; + + @Schema(description = "y轴结果单位(曲线结果使用)") + private String yUnits; + + + @Schema(description = "上传文件所在父目录id") + private Long dirId; + + @Schema(description = "文件名") + private String fileName; + + @Schema(description = "文件大小") + private Long fileSize; + + @Schema(description = "文件类型",implementation = FileBizTypeEnum.class) + private Integer fileType; + + @Schema(description = "文件") + private MultipartFile file; + + @Schema(description = "是否仅曲线上传文件") + private boolean onlyFile = false; + + /** + * -------------------------------------------------上传交付物使用参数------------------------------------------------ + */ + @Schema(description = "上传交付物使用,批量文件属性信息") + private List keyResultList; + + @Schema(description = "用户勾选的所有的文件的原始名称,前端限制不能选择相同名称的文件,后端逻辑判断对应dirId下不能和历史文件名相同") + private List sourceFiles; + + @Schema(description = "审批模板id") + private String templateId; + + @Schema(description = "审批模板名称") + private String templateName; + + @Schema(description = "本次新增数据的任务id,毫秒值时间戳") + private String uploadTaskId; + + @Schema(description = "所属任务uuid") + private String taskId; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * 指标 完成情况统计请求参数(工位、学科) + */ +@Data +@Schema(description = "按工位、学科的仿真指标达成统计") +public class PerformanceCompleteStatisticsReq { + + @Schema(description = "数据返回Tag类型: tag1、tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10") + @NotNull + private String resultTagType; + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "标签2") + private String tag2; + + @Schema(description = "标签3") + private String tag3; + + @Schema(description = "标签4") + private String tag4; + + @Schema(description = "标签5") + private String tag5; + + @Schema(description = "标签6") + private String tag6; + + @Schema(description = "标签7") + private String tag7; + + @Schema(description = "标签8") + private String tag8; + + @Schema(description = "标签9") + private String tag9; + + @Schema(description = "标签10") + private String tag10; + +} + + + +package com.sdm.project.model.req; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class PerformanceInfoReq implements Serializable { + + private static final long serialVersionUID = 1L; + + private String value; + + private String englishName; + + private String highValue; + + private String performanceName; + + private String method; + + private String unit; + + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ProjectNodeListReq { + + /** + * 节点类型 + */ + private String projectNodeId; + + /** + * 阶段节点id + */ + private String phaseNodeId; + + private String taskName; + + private Integer taskStatus; + + private Integer achieveStatus; + + /** + * 所有、我发起的、我确认的、我执行的、我关注的(0、1、2、3、4) + */ + @NotNull(message = "任务类型不能为空!") + private Integer taskType; + + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class ProjectTreeReq { + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + +} + + + +package com.sdm.project.model.req; + +import com.sdm.project.model.bo.TaskNodeTag; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class ProjectTreeTagReq { + + private List idMap; + + private List tagMap; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmAddDemandReq extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 需求的唯一标识 + */ + private String uuid; + + /** + * 需求名称 + */ + @NotNull(message = "需求名称不能为空") + private String demandName; + + /** + * 需求编码 + */ + private String demandCode; + + /** + * 需求类型 + */ + private String demandType; + + /** + * 仿真类型 + */ + private String simType; + + /** + * 需求状态:未分配、未开始、进行中、暂停、已关闭、已闭环、已驳回 + */ + private String demandStatus; + + + /** + * 达成状态 + */ + private String achieveStatus; + + /** + * 进度 + */ + private Integer progress; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 计划开始时间(精确到秒) + */ + private String beginTime; + + /** + * 计划结束时间(精确到秒) + */ + private String endTime; + + /** + * 实际结束时间(精确到秒) + */ + private String finishTime; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 预留拓展属性 + */ + private List extras; + + /** + * 项目id + */ + private String projectId; + + /** + * 阶段id + */ + private String phaseId; + + /** + * 学科id + */ + private String nodeId; + + /** + * 3D负责人 + */ + @JsonProperty(value = "tMemberList") + private String tMemberList; + + /** + * 关注人 + */ + @JsonProperty(value = "aMemberList") + private String aMemberList; + + + +} + + + +package com.sdm.project.model.req; + +import com.sdm.project.model.bo.TaskNodeTag; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmAddNodeReq { + + @NotNull(message = "addNodeList不能为空") + List addNodeList; + + @NotNull(message = "tagMap不能为空") + List tagMap; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class SpdmAddTaskRunReq { + + @NotBlank(message = "runName不能为空") + @Schema(description = "算例名称") + private String runName; + + @Schema(description = "备注") + private String description; + + @NotBlank(message = "flowTemplate不能为空") + @Schema(description = "流程模板id") + private String flowTemplate; + +// @NotNull(message = "totalStep不能为空") + @Schema(description = "总步骤") + private Integer totalStep; + + @NotNull(message = "taskId不能为空") + @Schema(description = "任务uuid") + private String taskId; + + @Schema(description = "父算例uuid") + private String parentId; + + private String isPersonalTemplate; + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class SpdmAnalysisPerformanceListReq extends BaseEntity { + + @NotNull(message = "current不能为空") + private Integer current; + + @NotNull(message = "size不能为空") + private Integer size; + + @Schema( description = "项目节点id") + private String projectNodeId; + + @Schema( description = "阶段节点id") + private String phaseNodeId; + + @Schema( description = "专业节点id") + private String disciplineNodeId; + + @Schema( description = "指标名称") + private String performanceName; + + @Schema( description = "开始时间") + private String beginTime; + + @Schema( description = "结束时间") + private String endTime; + + @Schema( description = "名称(兼容数据总览使用)") + private String name; + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class SpdmAnalysisRunListReq extends BaseEntity { + + @NotNull(message = "current不能为空") + private Integer current; + + @NotNull(message = "size不能为空") + private Integer size; + + @Schema( description = "项目节点id") + private String projectNodeId; + + @Schema( description = "阶段节点id") + private String phaseNodeId; + + @Schema( description = "专业节点id") + private String disciplineNodeId; + + @Schema( description = "算例名称") + private String runName; + + @Schema( description = "开始时间") + private String beginTime; + + @Schema( description = "结束时间") + private String endTime; + + @Schema( description = "名称(兼容数据总览使用)") + private String name; +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class SpdmAnalysisTaskListReq extends BaseEntity { + + @NotNull(message = "current不能为空") + private Integer current; + + @NotNull(message = "size不能为空") + private Integer size; + + @Schema( description = "项目节点id") + private String projectNodeId; + + @Schema( description = "阶段节点id") + private String phaseNodeId; + + @Schema( description = "专业节点id") + private String disciplineNodeId; + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "标签2") + private String tag2; + + @Schema(description = "标签3") + private String tag3; + + @Schema(description = "标签4") + private String tag4; + + @Schema(description = "标签5") + private String tag5; + + @Schema(description = "标签6") + private String tag6; + + @Schema(description = "标签7") + private String tag7; + + @Schema(description = "标签8") + private String tag8; + + @Schema(description = "标签9") + private String tag9; + + @Schema(description = "标签10") + private String tag10; + + @Schema( description = "任务名称") + private String taskName; + + @Schema( description = "开始时间") + private String beginTime; + + @Schema( description = "结束时间") + private String endTime; + + @Schema( description = "名称(兼容数据总览使用)") + private String name; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmDeleteDemandReq { + + @NotNull(message = "删除需求的id不能为空") + List deleteNodeIdList; + + +} + + + +package com.sdm.project.model.req; + +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmDeleteNodeReq { + + List deleteNodeIdList; + + +} + + + +package com.sdm.project.model.req; + +import lombok.Data; + +@Data +public class SpdmDeleteProjectDetailReq { + + String nodeType; + + String uuid; + +} + + + +package com.sdm.project.model.req; + +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmDeleteProjectReq { + + List deleteNodeList; + + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmDemandExtraReq extends BaseEntity { + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 所属节点id + */ + private String nodeId; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class SpdmDemandListReq { + + @NotNull(message = "current不能为空") + private Integer current; + + @NotNull(message = "size不能为空") + private Integer size; + + /** + * 需求类型,0:我发起的 1:我确认的 + */ + @NotNull(message = "type不能为空") + private Integer type; + + /** + * 需求名称 + */ + private String demandName; + + /** + * 需求类型 + */ + private String demandType; + + /** + * 仿真类型 + */ + private String simType; + + /** + * 需求状态 + */ + private String demandStatus; + + /** + * 达成情况 + */ + private String achieveStatus; + + private String projectId; + + private String phaseId; + + private String disciplineName; + + /** + * 排序顺序 按创建时间 0-先序/1-倒序排序 + */ + private Integer sortOrder; + + + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmDemandRelateMemberReq extends BaseEntity { + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 成员类型,0:仿真负责人 1:仿真执行人 + */ + private Integer type; + + /** + * 工号 + */ + private String identity; + + /** + * 用户名 + */ + private String name; + + private Long userId; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmEditDemandReq extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 需求的唯一标识 + */ + private String uuid; + + /** + * 需求名称 + */ + private String demandName; + + /** + * 需求编码 + */ + private String demandCode; + + /** + * 需求类型 + */ + private String demandType; + + /** + * 仿真类型 + */ + private String simType; + + /** + * 需求状态:未分配、未开始、进行中、暂停、已关闭、已闭环、已驳回 + */ + private String demandStatus; + + + /** + * 达成状态 + */ + private String achieveStatus; + + /** + * 进度 + */ + private Integer progress; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 计划开始时间(精确到秒) + */ + private String beginTime; + + /** + * 计划结束时间(精确到秒) + */ + private String endTime; + + /** + * 实际结束时间(精确到秒) + */ + private String finishTime; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 预留拓展属性 + */ + private List extras; + + /** + * 项目id + */ + private String projectId; + + /** + * 阶段id + */ + private String phaseId; + + /** + * 学科id + */ + private String nodeId; + + /** + * 3D负责人 + */ + @JsonProperty(value = "tMemberList") + private String tMemberList; + + /** + * 关注人 + */ + @JsonProperty(value = "aMemberList") + private String aMemberList; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmEditNodeForDataReq { + + /** + * simulation_node关联的节点id + */ + @NotBlank(message = "relatedResourceUuid不能为空") + private String relatedResourceUuid; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 节点编码 + */ + private String nodeCode; + + /** + * 节点的英文名称 + */ + private String englishName; + + /** + * 预留拓展属性 + */ + private List extraList; + +} + + + +package com.sdm.project.model.req; + +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmEditNodeReq { + + + List editNodeList; + + +} + + + +package com.sdm.project.model.req; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmEditTaskForDataReq { + + /** + * simulation_node关联的节点id + */ + @NotBlank(message = "relatedResourceUuid不能为空") + private String relatedResourceUuid; + + private String uuid; + + private String taskName; + + + private String taskCode; + + private String taskPoolName; + + private String taskPoolVersion; + + private String nodeId; + + private Integer days; + + private Integer realDays; + + private String standard; + + private String foldId; + + private Integer status; + + private String achieveStatus; + + private String beginTime; + + private String endTime; + + private String finishTime; + + private Integer progress; + + private String exeStatus; + + private String confidence; + + private String analyseTarget; + + private String analyseSoftware; + + private String approvalStatus; + + private String comfirmStatus; + + private String description; + + private Float difficult; + + private String tenantId; + + private Integer pid; + + private Long creator; + + private String createTime; + + private Long updater; + + + private String updateTime; + + + private String department; + + + private String sectionName; + + + private String groupName; + + + private String bCapacity; + + + private String flowTemplate; + + private String englishName; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmNodeDetailReq extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 节点编码 + */ + private String nodeCode; + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 节点子类型(项目、节点、学科。。。) + */ + private String nodeSubType; + + /** + * 节点层级 + */ + private Integer nodeLevel; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progressStatus; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 memberList + */ + private String memberList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + /** + * 预留拓展属性 + */ + private List extraList; + + private Long tenantId; + + private String standard; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String analyseSoftwares; + private String department; + private String section; + private String group; + private String bCapacity; + private String englishName; + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + private String exeStatus; +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmNodeExtraReq extends BaseEntity { + + /** + * 所属节点id + */ + private String nodeId; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Map; + +@Data +public class SpdmNodeParamReq { + + @Schema(description = "节点uuid") + private String nodeUuid; + + @Schema(description = "算例uuid") + private String runId; + + @Schema(description = "用户输入的参数") + private Map inputParams; + +// @Schema(description = "上传脚本文件id") +// private String scriptFileId; +// +// @Schema(description = "用户输入的正则表达式参数") +// private String regExp; + + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmNodeRelateMemberReq extends BaseEntity { + + /** + * 关联的节点id + */ + private String nodeId; + + /** + * 工号 + */ + private String identity; + + /** + * 用户名 + */ + private String name; + + private Long userId; + +} + + + +package com.sdm.project.model.req; + +import com.sdm.project.model.bo.ProjectNode; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmNodeReq { + + List addNodeList; + + List editNodeList; + + List deleteNodeList; + + + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmProjectNodeEditReq extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 当前节点所属项目根节点uuid + */ + private String ownRootNodeUuid; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 节点编码 + */ + private String nodeCode; + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 节点子类型(项目、节点、学科。。。) + */ + private String nodeSubType; + + /** + * 节点层级 + */ + private Integer nodeLevel; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progressStatus; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 memberList + */ + private String memberList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + /** + * 预留拓展属性 + */ + private List extraList; + + + private String standard; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String analyseSoftwares; + private String department; + private String section; + private String group; + private String bCapacity; + + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + private String exeStatus; + private List extras; + private String englishName; + private String parentId; +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.bo.CidTaskNode; +import com.sdm.project.model.bo.TaskNode; +import com.sdm.project.model.bo.TaskNodeTag; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmSyncCidTaskReq extends BaseEntity { + + List taskList; + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmTaskAttentionReq extends BaseEntity { + + /** + * 关联的任务id + */ + private String taskId; + + + private Long userId; + + List addUserIdList; + + List cancelUserIdList; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.validator.annotation.EnumValue; +import com.sdm.project.common.TaskQryTypeEnum; +import com.sdm.project.model.bo.TaskNodeTag; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskCountReq { + /** + * 任务类型,0:我执行的 1:我关注的 2:所有 3-我分发的 + */ + @NotNull(message = "type不能为空") + @EnumValue(enumClass = TaskQryTypeEnum.class, message = "type任务类型无效") + private Integer type; + + private List idMap; + + /** + * 今明任务 筛选计划结束时间为今明两天的 + */ + private String todayTmrTasks; + /** + * 今天日期 + */ + private String todayTime; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.bo.ProjectNode; +import com.sdm.project.model.bo.TaskNode; +import com.sdm.project.model.bo.TaskNodeTag; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskIssue { + + List reqList; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.bo.TaskNode; +import com.sdm.project.model.bo.TaskNodeTag; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskIssueReq extends BaseEntity { + + List idMap; + + List addNodeList; + + String demandId; +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.validator.annotation.EnumValue; +import com.sdm.project.common.TaskQryTypeEnum; +import com.sdm.project.model.bo.TaskNodeTag; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskListReq { + + @NotNull(message = "current不能为空") + private Integer current; + + @NotNull(message = "size不能为空") + private Integer size; + + /** + * 任务类型,0:我执行的 1:我关注的 2:所有 3-我分发的 + */ + @NotNull(message = "type不能为空") + @EnumValue(enumClass = TaskQryTypeEnum.class, message = "type任务类型无效") + private Integer type; + + /** + * 任务名称 + */ + private String taskName; + + /** + * 任务状态 + */ + private String exeStatus; + + private List exeStatusList; + + /** + * 达成情况 + */ + private String achieveStatus; + + private List achieveStatusList; + + /** + * 任务进度 + */ + private Integer progress; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + private List idMap; + + /** + * 计划开始时间 + */ + private List beginTime; + + private String beginSTime; + + private String beginETime; + + /** + * 计划结束时间 + */ + private List endTime; + + private String endSTime; + + private String endETime; + + /** + * 实际结束时间 + */ + private List finishTime; + + private String finishSTime; + + private String finishETime; + + /** + * 今明任务 筛选计划结束时间为今明两天的 + */ + private String todayTmrTasks; + /** + * 今天日期 + */ + private String todayTime; + + /** + * 排序顺序 按创建时间 0-先序/1-倒序排序 + */ + private Integer sortOrder; + + private String demandId; + + private Boolean convertTag = true; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskOpr { + + List taskIds; + + SpdmTaskOprReq req; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskOprReq { + /** + * 任务名称 + */ + private String taskId; + + /** + * 任务状态 + */ + private String exeStatus; + + /** + * 达成情况 + */ + private String achieveStatus; + + /** + * 任务进度 + */ + private Integer progress; + + /** + * 实际结束时间 + */ + private String finishTime; + + /** + * 计划开始时间 + */ + private String beginTime; + + /** + * 计划结束时间 + */ + private String endTime; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 任务名称 + */ + private String nodeName; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.bo.TaskNode; +import com.sdm.project.model.bo.TaskNodeTag; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskReq extends BaseEntity { + + List addTaskList; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class SpdmTaskRunReq { + + @Schema(description = "算例名称") + private String runName; + + @Schema(description = "算例id") + private String runId; + + @Schema(description = "任务uuid") + private String taskId; + + @Schema(description = "流程模板id") + private String templateId; + + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * 任务 完成情况统计请求参数(工位、学科) + */ +@Data +@Schema(description = "按工位、学科的仿真任务达成统计") +public class TaskCompleteStatisticsReq { + + @Schema(description = "数据返回Tag类型: tag1、tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10") + @NotNull + private String resultTagType; + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "标签2") + private String tag2; + + @Schema(description = "标签3") + private String tag3; + + @Schema(description = "标签4") + private String tag4; + + @Schema(description = "标签5") + private String tag5; + + @Schema(description = "标签6") + private String tag6; + + @Schema(description = "标签7") + private String tag7; + + @Schema(description = "标签8") + private String tag8; + + @Schema(description = "标签9") + private String tag9; + + @Schema(description = "标签10") + private String tag10; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.project.model.bo.ProjectMemberNode; +import com.sdm.project.model.bo.TaskExtraNode; +import com.sdm.project.model.bo.TaskMemberNode; +import com.sdm.project.model.po.ProjectNodeExtraPo; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class TaskEditNodeReq extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + /** + * 节点编码 + */ + private String nodeCode; + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 节点子类型(项目、节点、学科。。。) + */ + private String nodeSubType; + + /** + * 节点层级 + */ + private Integer nodeLevel; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progressStatus; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private List nodeManager; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + /** + * 预留拓展属性 + */ + private List nodeExtraList; + + private Long tenantId; + + private String nodeId; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + /** + * 项目进度状态 + */ + private Integer progress; + + private String progressStatusValue; + + + private String achieveStatusValue; + + /** + * 仿真负责人 + */ + private String sManager; + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + + /** + * 项目经理 + */ + private String managers; + + + + /** + * 达标方式 + */ + private String method; + + private String taskId; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + private String highValue; + + private String lowValue; + + + private String nodeVersion; + + private List taskExtraNodeList; + + private List taskPerformanceExtraNodeList; + + private List memberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + + private String performanceId; + + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + /** + * 用户名 + */ + private String userName; + + /** + * 工号 + */ + private String jobNumber; + + /** + * 用户角色 + */ + private String userRole; + + /** + * 部门 + */ + private String department; + + /** + * 手机号 + */ + private String phone; + + /** + * 邮箱 + */ + private String email; + + private String identity; + + private String name; + + private List extra; + + private List members; + + private String levelType; + + + private String standard; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String analyseSoftwares; + private String section; + private String group; + @JsonProperty(value = "bCapacity") + private String bCapacity; + private String flowTemplate; + private String englishName; + private String performanceType; + + /** + * 关注人(id) + */ + private String attentionList; + + private Long imageFileId; + +} + + + +package com.sdm.project.model.req; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class TaskHandleReq { + + /** + * 节点类型 + */ + private String taskId; + + /** + * 所有、我发起的、我确认的、我执行的、我关注的(0、1、2、3、4) + */ + @NotNull(message = "任务类型不能为空!") + private Integer taskType; + + +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.bo.UserInfo; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class UpdateProjectLeaderReq { + + @NotNull(message = "projectId不能为空") + private Long projectId; + + @NotBlank(message = "projectName不能为空") + private String projectName; + + private List addUsers; + private List delUserIds; +} + + + +package com.sdm.project.model.req; + +import com.sdm.common.entity.pojo.project.ProjectNodeBase; +import com.sdm.common.entity.pojo.project.ProjectNodeExpand; +import lombok.Data; + +import java.util.List; + +@Data +public class UpdateProjectNodeBatchReq { + + private List nodeBases; + + private List updateNodeExpands; + private List addNodeExpands; + private List delNodeExpandIds; +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +/** + * 项目成员任务进度统计请求参数 + */ +@Data +@Schema(description = "项目成员任务进度统计请求参数") +public class UserDifficultCompleteStatisticsReq { + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "用户") + private List userIds; + +} + + + +package com.sdm.project.model.req; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; +import java.util.Set; + +/** + * 项目成员任务进度统计请求参数 + */ +@Data +@Schema(description = "项目成员任务进度统计请求参数") +public class UserTaskCompleteStatisticsReq { + + @Schema(description = "标签1") + private String tag1; + + @Schema(description = "用户") + private List userIds; + +} + + + +package com.sdm.project.model.req; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class UserWorkloadReq { + /** + * 用户id列表 + */ + List userIds; + /** + * 任务uuid列表 + */ + List taskIds; + + /** + * 起始时间 + */ + private String beginTime; + /** + * 结束时间 + */ + private String endTime; + + private Long userId; + +} + + + +package com.sdm.project.model.req.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "仿真模型删除参数") +public class DeleteModelNodeInfoReq { + + @Schema(description = "数据类型名称") + private String type; + + @Schema(description = "需要删除数据ObjectId") + private String objectId; + + @Schema(description = "需要删除数据id") + private String id; + + +} + + + +package com.sdm.project.model.req.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +@Schema(description = "获取仿真模型参数") +public class GetModelNodeInfoReq { + + @Schema(description = "数据类型名称") + private String type; + + @Schema(description = "需要删除数据ObjectId") + private String objectId; + +} + + + +package com.sdm.project.model.req.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class GetTaskSimulatinFileReq { + + @Schema(description = "项目ID") + @NotBlank(message = "项目ID不能为空") + private String taskId; + + @Schema(description = "当前页") + @NotNull(message = "当前页不能为空") + private Integer current; + + @Schema(description = "每页数据大小") + @NotNull(message = "显示页大小不能为空") + private Integer size; +} + + + +package com.sdm.project.model.req.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class ProjectTaskInfo { + + @Schema(description = "任务名称") + private String taskName; + + @Schema(description = "taskId") + private String taskId; +} + + + +package com.sdm.project.model.req.YA; + +import com.alibaba.fastjson2.annotation.JSONField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +@Schema(description = "仿真关键结果上传参数") +public class SaveKeyResultNodeInfoReq { + + @Schema(description = "数据类型名称") + private String type; + + @Schema(description = "数据名称") + private String name; + + @Schema(description = "数据类型编号,参考KeyResultTypeEnum") + private Integer code; + + @Schema(description = "仿真分析项") + private String scenario; + + @Schema(description = "数据访问控制级别") + private String dataLevel; + + @Schema(description = "所属项目ID") + private String project; + + @Schema(description = "父级节点ID") + private String parent; + + @Schema(description = "任务ID") + private String workRequest; + + @Schema(description = "分析对象") + private String item; + + @Schema(description = "轮次") + private String round; + + @Schema(description = "方案Id") + private String version; + + @Schema(description = "文件名称") + private String fileName; + + @Schema(description = "文件类型,参考FileBizTypeEnum") + private Integer fileType; + + @Schema(description = "数值") + private String value; + + @Schema(description = "单位") + private String units; + + @Schema(description = "状态") + private String status; + + @Schema(description = "物理量") + private String quantityType; + + @Schema(description = "文件传输对象") + @JSONField(serialize = false) + private MultipartFile file; + + @Schema(description = "分页参数,当前第几页") + private int current; + + @Schema(description = "分页参数,一页几条") + private int size; + + +} + + + +package com.sdm.project.model.req.YA; + +import com.alibaba.fastjson2.annotation.JSONField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +@Data +@Schema(description = "仿真模型上传参数") +public class SaveModelNodeInfoReq { + + @Schema(description = "数据类型名称") + private String type; + + @Schema(description = "数据名称") + private String name; + + @Schema(description = "数据类型编号") + private String code; + + @Schema(description = "所属项目ID") + private String project; + + @Schema(description = "父级节点ID") + private String parent; + + @Schema(description = "仿真分析项") + private String scenario; + + @Schema(description = "主负责人") + private String firstOwner; + + @Schema(description = "从负责人") + private List secondOwner; + + @Schema(description = "起止日期") + private String startEndData; + + @Schema(description = "学科") + private String disciplineClassification; + + @Schema(description = "格式") + private String format; + + @Schema(description = "分析对象") + private String item; + + @Schema(description = "文件传输对象") + @JSONField(serialize = false) + private MultipartFile file; + + +} + + + +package com.sdm.project.model.req.YA; + +import com.alibaba.fastjson2.annotation.JSONField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +@Schema(description = "仿真报告上传参数") +public class SaveReportNodeInfoReq { + + @Schema(description = "数据类型名称") + private String type; + + @Schema(description = "数据名称") + private String name; + + @Schema(description = "描述") + private String discription; + + @Schema(description = "数据类型编号") + private String code; + + @Schema(description = "所属项目ID") + private String project; + + @Schema(description = "父级节点ID") + private String parent; + + @Schema(description = "仿真分析项") + private String scenario; + + @Schema(description = "文件传输对象") + @JSONField(serialize = false) + private MultipartFile file; + + +} + + + +package com.sdm.project.model.req.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class SyncCidProjectReq { + + @Schema(description = "项目名称") + private String projectName; + + @Schema(description = "项目Id") + @NotBlank(message = "项目Id不能为空") + private String projectId; + +} + + + +package com.sdm.project.model.req.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class SyncCidTaskReq { + + @Schema(description = "项目名称") + private String projectName; + + @Schema(description = "项目Id") + @NotBlank(message = "项目Id不能为空") + private String projectId; + + @Schema(description = "项目关联的任务集合") + private List taskInfoList = new ArrayList<>(); +} + + + +package com.sdm.project.model.resp; + +import com.sdm.common.entity.flowable.dto.ProcessInstanceInfo; +import com.sdm.common.entity.req.capability.FlowNodeDto; +import lombok.Data; + +import java.util.List; + +@Data +public class FlowInfoDto { + + private ProcessInstanceInfo processInfo; + private List flowNodeDtoList; + +} + + + +package com.sdm.project.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class GetAllRunResultByTaskIdResp { + @Schema(description = "任务指标列表") + List tasKPerformanceRespList = new ArrayList<>(); + + @Schema(description = "工况算列运行结果") + List runResultResp; +} + + + +package com.sdm.project.model.resp; + +import com.sdm.common.entity.resp.data.SimulationTaskResultCurveResp; +import com.sdm.project.model.entity.SimulationTask; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class KeyResultAndTaskInfoResp { + + @Schema(description = "算例uuid") + private String runId; + + @Schema(description = "关键性能结果类型 1-图片/动画 2-曲线 3-报告 4-数值") + private Integer keyResultType; + + @Schema(description = "结果名称") + private String name; + + @Schema(description = "文件id") + private Long fileId; + + @Schema(description = "物理量") + private String quantityType; + + @Schema(description = "结果单位") + private String units; + + @Schema(description = "最大数值") + private String max; + + @Schema(description = "最小数值") + private String min; + + @Schema(description = "数值") + private String value; + + @Schema(description = "描述信息") + private String description; + + @Schema(description = "x轴物理量(曲线结果使用)") + private String xQuantityType; + + @Schema(description = "x轴结果单位(曲线结果使用)") + private String xUnits; + + @Schema(description = "y轴物理量(曲线结果使用)") + private String yQuantityType; + + @Schema(description = "y轴结果单位(曲线结果使用)") + private String yUnits; + + @Schema(description = "任务信息") + private SimulationTask simulationTask; + + @Schema(description = "文件信息") + private SimulationTaskResultCurveResp fileInfo; + +} + + + +package com.sdm.project.model.resp; + +import com.sdm.common.entity.req.project.SimulationPerformance; +import com.sdm.project.model.entity.SimulationRun; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class RunResultResp { + SimulationRun simulationRun; + List simulationPerformance = new ArrayList<>(); +} + + + +package com.sdm.project.model.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.sdm.project.model.entity.SimulationRun; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.List; + +@Data +public class RunVersionInfoResp { + private Integer id; + + private String uuid; + + @Schema(description = "算例名称") + private String runName; + + @Schema(description = "1:server 2:pbs 3:local only") + private Integer type; + + @Schema(description = "流程模板id") + private String taskId; + + @Schema(description = "流程模板id") + private String flowTemplate; + + @Schema(description = "Run状态 0:未执行 1:执行中 2:完成 3:失败") + private Integer status; + + @Schema(description = "Run总共的流程步骤") + private Integer totalStep; + + @Schema(description = "当前的流程步骤") + private Integer currentStep; + + @Schema(description = "当前的流程步骤名称") + private String currentStepName; + + @Schema(description = "Run执行结果 0:gray 1:red 2:yellow 3:green") + private Integer achieveStatus; + + @Schema(description = "run描述信息") + private String description; + + @Schema(description = "Run对应在文件系统中的路径") + private Long folderId; + + @Schema(description = "计算父版本Id") + private String parentId; + + @Schema(description = "是否个人模板") + private String isPersonalTemplate; + + @Schema(description = "租户id") + private Long tenantId; + + @Schema(description = "英文名") + private Long englishName; + + @Schema(description= "创建者ID") + private Long creator; + private String creatorName; + + @Schema(description= "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + @Schema(description= "更新者ID") + private Long updater; + private String updaterName; + + @Schema(description= "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + List children; + +} + + + +package com.sdm.project.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class TaskCountResp { + @Schema(description = "总数") + int total; + + @Schema(description = "今明任务") + int todayTmrTasks; + + @Schema(description = "进行中") + int inProgress; + + @Schema(description = "已逾期") + int postponed; + + @Schema(description = "未开始") + int noStarted; + + @Schema(description = "已完成") + int completed; + + @Schema(description = "已关闭") + int closed; + + @Schema(description = "已暂停") + int paused; + + @Schema(description = "已驳回") + int rejected; + +} + + + +package com.sdm.project.model.resp; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class TasKPerformanceResp { + @Schema(description = "指标名称") + String performanceName; + + @Schema(description = "单位") + String unit; + + @Schema(description = "达成方式") + String method; + + @Schema(description = "目标值") + String targetValue; +} + + + +package com.sdm.project.model.resp; + +import lombok.Data; + + +@Data +public class TaskWorkDaysResp { + /** + * 任务uuid + */ + private String taskId; + /** + * 任务名称 + */ + private String taskName; + /** + * 工时 + */ + private Integer days; + +} + + + +package com.sdm.project.model.resp; + +import com.sdm.project.model.entity.SimulationTask; +import lombok.Data; + +import java.util.List; + +@Data +public class UserWorkloadResp { + + /** + * 用户id + */ + private String userId; + /** + * 用户姓名 + */ + private String userName; + /** + * 任务数量 + */ + private Integer taskNum; + /** + * 任务量(未开始和进行中的) + */ + private Integer workNum; + /** + * 工作饱和度 任务数量*工时 + */ + private double workload; + /** + * 任务列表 + */ + private List taskList; + +} + + + +package com.sdm.project.model.resp.YA; + +import io.swagger.v3.oas.annotations.media.Schema; + +public class BosimErrorRespond { + + @Schema(description = "错误码") + private int errorCode; + + @Schema(description = "错误信息") + private String errorMsg; + +} + + + +package com.sdm.project.model.resp.YA; + +import com.sdm.common.entity.resp.PageDataResp; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class BosimKeyResultInfoRsp { + + @Schema(description = "返回码") + private String code ; + + @Schema(description = "返回信息") + private String message = ""; + + PageDataResp> data; +} + + + +package com.sdm.project.model.resp.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class BosimSaveNodeInfoRsp { + + @Schema(description = "返回码") + private String code ; + + @Schema(description = "返回信息") + private String message = ""; + + private List workRequest = new ArrayList<>(); +} + + + +package com.sdm.project.model.resp.YA; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class BosimSaveProjectTaskRsp { + + @Schema(description = "返回码") + private String code ; + + @Schema(description = "返回信息") + private String message = ""; + +} + + + +package com.sdm.project.model.resp.YA; + +import com.alibaba.fastjson2.annotation.JSONField; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +@Data +@Schema(description = "仿真关键结果上传参数") +public class KeyResultNodeInfo { + + @Schema(description = "唯一uuid") + private String uuid; + + @Schema(description = "数据类型名称") + private String type; + + @Schema(description = "数据名称") + private String name; + + @Schema(description = "数据类型编号,参考KeyResultTypeEnum") + private Integer code; + + @Schema(description = "仿真分析项") + private String scenario; + + @Schema(description = "数据访问控制级别") + private String dataLevel; + + @Schema(description = "所属项目ID") + private String project; + + @Schema(description = "父级节点ID") + private String parent; + + @Schema(description = "任务ID") + private String workRequest; + + @Schema(description = "分析对象") + private String item; + + @Schema(description = "轮次") + private String round; + + @Schema(description = "方案Id") + private String version; + + @Schema(description = "文件名称") + private String fileName; + + @Schema(description = "文件类型,参考FileBizTypeEnum") + private Integer fileType; + + @Schema(description = "数值") + private String value; + + @Schema(description = "单位") + private String units; + + @Schema(description = "状态") + private String status; + + @Schema(description = "物理量") + private String quantityType; + + @Schema(description = "文件id") + private Long fileId; + + +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +@Data +public class CommonGetCompleteFromPerformanceVo { + private String tag; + private String nodeName; + private String completeStatus; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +@Data +public class CommonGetCompleteFromTaskVo { + private String tag; + private String nodeName; + private String exeStatus; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class CommonStatisticsVo { + private String name; + private Map statusCount = new HashMap<>(); +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmAnalysisTaskVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String nodeId; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 难度系数 + */ + private Float difficult; + + private String projectName; + + private String phaseName; + + private String disciplineName; + + /** + * 仿真负责人 + */ + private String pMembers; + + + + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.req.SpdmDemandExtraReq; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmDemandExtraVo extends BaseEntity { + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 需求拓展属性编码 + */ + private String propertyName; + + /** + * 需求拓展属性值 + */ + private String propertyValue; + + + /** + * 需求拓展属性值类型 + */ + private String valueType; + + /** + * 需求拓展属性class + */ + private String propertyClass; + + + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmDemandMemberVo extends BaseEntity { + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 成员类型,0:仿真负责人 1:仿真执行人 + */ + private Integer type; + + /** + * 工号 + */ + private String identity; + + /** + * 用户名 + */ + private String name; + + private Long userId; + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.req.SpdmDemandExtraReq; +import com.sdm.project.model.vo.SpdmDemandMemberVo; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmDemandVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 需求的唯一标识 + */ + private String uuid; + + /** + * 需求名称 + */ + @NotNull(message = "需求名称不能为空") + private String demandName; + + /** + * 需求编码 + */ + private String demandCode; + + /** + * 需求状态:未分配、未开始、进行中、暂停、已关闭、已闭环、已驳回 + */ + private String demandStatus; + + + /** + * 达成状态 + */ + private String achieveStatus; + + /** + * 进度 + */ + private Integer progress; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 计划开始时间(精确到秒) + */ + private String beginTime; + + /** + * 计划结束时间(精确到秒) + */ + private String endTime; + + /** + * 实际结束时间(精确到秒) + */ + private String finishTime; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private List pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private List eMemberList; + + /** + * 预留拓展属性 + */ + private List extraList; + + private List extras; + + /** + * 项目名称 + */ + private String projectId; + + private String projectName; + + /** + * 阶段名称 + */ + private String phaseId; + + private String phaseName; + + /** + * 学科名称 + */ + private String nodeId; + + private String demandType; + + private String simType; + + /** + * 3D负责人 + */ + @JsonProperty(value = "tMemberList") + private List tMemberList; + + /** + * 关注人 + */ + @JsonProperty(value = "aMemberList") + private List aMemberList; + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.req.SpdmDemandExtraReq; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmExportDemandVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 需求的唯一标识 + */ + private String uuid; + + /** + * 需求名称 + */ + @NotNull(message = "需求名称不能为空") + private String demandName; + + /** + * 需求编码 + */ + private String demandCode; + + /** + * 需求状态:未分配、未开始、进行中、暂停、已关闭、已闭环、已驳回 + */ + private String demandStatus; + + + /** + * 达成状态 + */ + private String achieveStatus; + + /** + * 进度 + */ + private Integer progress; + + /** + * 审批状态 + */ + private String approvalStatus; + + /** + * 计划开始时间(精确到秒) + */ + private String beginTime; + + /** + * 计划结束时间(精确到秒) + */ + private String endTime; + + /** + * 实际结束时间(精确到秒) + */ + private String finishTime; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 3D负责人 + */ + @JsonProperty(value = "tMemberList") + private String tMemberList; + + /** + * 关注人 + */ + @JsonProperty(value = "aMemberList") + private String aMemberList; + + /** + * 预留拓展属性 + */ + private List extraList; + + /** + * 项目名称 + */ + private String projectId; + + private String projectName; + + /** + * 阶段名称 + */ + private String phaseId; + + private String phaseName; + + /** + * 学科名称 + */ + private String nodeId; + + private String demandType; + + private String simType; + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmExportNewTaskVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + + /** + * 当前节点id + */ + private String uuid; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String nodeId; + + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + private String standard; + + private String folderId; + + private Integer status; + + private String achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目进度状态 + */ + private Integer progress; + + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String confidence; + + private String analyseTarget; + private String analyseSoftware = ""; + private String approvalStatus; + private String comfirmStatus; + private String description; + /** + * 难度系数 + */ + private Float difficult; + + private String department = ""; + private String sectionName = ""; + private String groupName = ""; + @JsonProperty(value = "bCapacity") + private String bCapacity = ""; + private String flowTemplate; + private String englishName; + + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 0:未关注 1:已关注 + */ + private Integer attentionFlag; + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + private String machineName = ""; + private String machineCode = ""; + private String workspaceName = ""; + private String workspaceCode = ""; + private String disciplineName = ""; + private String disciplineCode = ""; + private String performanceName = ""; + private String performanceCode = ""; + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmExportNodeVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private String memberList; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + /** + * 备注 + */ + private String description; + + private CIDUserResp creatorObj; + + private String exeStatus; + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.po.TaskNodeExtraPo; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmNewTaskVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + + /** + * 当前节点id + */ + private String uuid; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String nodeId; + + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + private String standard; + + private String folderId; + + private Integer status; + + private String achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目进度状态 + */ + private Integer progress; + + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String confidence; + + private String analyseTarget; + private String analyseSoftware; + private Integer approvalStatus; + private String comfirmStatus; + private String description; + /** + * 难度系数 + */ + private Float difficult; + + private String department; + private String sectionName; + private String groupName; + @JsonProperty(value = "bCapacity") + private String bCapacity; + private String flowTemplate; + private String englishName; + + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 关联cid交付物审批流程id + */ + private String cidFlowId; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private List pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private List eMemberList; + + /** + * 0:未关注 1:已关注 + */ + private Integer attentionFlag; + + @JsonProperty(value = "tag1") + private String tag1; + @JsonProperty(value = "tag2") + private String tag2; + @JsonProperty(value = "tag3") + private String tag3; + @JsonProperty(value = "tag4") + private String tag4; + @JsonProperty(value = "tag5") + private String tag5; + @JsonProperty(value = "tag6") + private String tag6; + @JsonProperty(value = "tag7") + private String tag7; + @JsonProperty(value = "tag8") + private String tag8; + @JsonProperty(value = "tag9") + private String tag9; + @JsonProperty(value = "tag10") + private String tag10; + + private List extras; + + /** + * 关联的需求名称 + */ + private String demandName; + + + + + + + + + + private String taskId; + + + + /** + * 指标名称 + */ + private String performanceName; + + private String performanceType; + private String highValue; + private String lowValue; + + + private String nodeName; + + /** + * 达标方式 + */ + private String method; + + private String completeStatus; + + /** + * 目标值 + */ + private String targetValue; + + /** + * 单位 + */ + private String unit; + + + + private String projectName; + + private String phaseName; + + private String disciplineName; + + private String imageFileId = ""; + private String section = ""; + private String group = ""; + + + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmNodeDetailForDataVo extends BaseEntity { + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 英文名称 + */ + private String englishName; + + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmNodeDetailVo extends BaseEntity { + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private String managers; + + /** + * 拓展属性集合 + */ + private List extraList; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + + /** + * 备注 + */ + private String description; + + /** + * 团队成员 + */ + List memberList; + + private CIDUserResp creatorObj; + + private String exeStatus; + + /** + * 当前阶段 + */ + private String currentPhase; + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmNodeExtraVo extends BaseEntity { + + /** + * 所属节点id + */ + private String nodeId; + + /** + * 属性名 + */ + private String propertyName; + + /** + * 属性值 + */ + private String propertyValue; + + /** + * 值类型 + */ + private String valueType; + + /** + * 属性 + */ + private String propertyClass; + + + + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmNodeMemberVo extends BaseEntity { + + /** + * 所属节点id + */ + private String nodeId; + + /** + * 工号 + */ + private String identity; + + /** + * 用户名 + */ + private String name; + + private Long userId; + + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import lombok.Data; + +import java.util.List; + +@Data +public class SpdmNodeVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + /** + * 当前节点id + */ + private String uuid; + + /** + * 节点名称 + */ + private String nodeName; + + + /** + * 节点编码 + */ + private String nodeCode; + + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 项目类型 + */ + private String nodeSubType; + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目经理 + */ + private List memberList; + + /** + * 拓展属性集合 + */ + private List extraList; + + private List extras; + + /** + * 项目详情图片 + */ + private String detailImgUrl; + /** + * 备注 + */ + private String description; + + private CIDUserResp creatorObj; + + private String exeStatus; + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmTaskAttentionMemberVo extends BaseEntity { + + /** + * 关联的任务id + */ + private String taskId; + /** + * 工号 + */ + private String identity; + + /** + * 用户名 + */ + private String name; + + private Long userId; + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.po.NodeAllBase; +import com.sdm.project.model.po.PerformanceNodePo; +import com.sdm.project.model.po.ProjectNodeExtraPo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class SpdmTaskDetailVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + + /** + * 当前节点id + */ + private String uuid; + + private String nodeId; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String exeStatusValue; + + private String exeStatus; + + /** + * 仿真负责人 + */ + private String sManager; + + + /** + * 项目进度状态 + */ + private Integer progress; + + private String progressStatusValue; + + /** + * 项目达成状态(红黄绿灯) + */ + private Integer achieveStatus; + + private String achieveStatusValue; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + /** + * 难度系数 + */ + private Float difficult; + + /** + * 审批状态 + */ + private Integer approvalStatus; + + /** + * 确认状态 + */ + private String confirmStatus; + + /** + * 拓展属性集合 + */ + private String extras; + + public List performances = new ArrayList<>(); + + public String projectNodeName; + + public String nodeVersion; + + public String members; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private String pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private String eMemberList; + + /** + * 拓展属性集合 + */ + private List extraList; + + private String folderId; + + private String standard; + private String analyseTarget; + private String confidence; + private String analyseSoftware; + private String department; + private String section; + private String sectionName; + private String group; + private String groupName; + @JsonProperty("bCapacity") + private String bCapacity; + private String flowTemplate; + private String englishName; + private String description; + + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +@Data +public class SpdmTaskMemberVo extends BaseEntity { + + /** + * 关联的任务id + */ + private String taskId; + + /** + * 成员类型,0:仿真负责人 1:仿真执行人 + */ + private Integer type; + + /** + * 工号 + */ + private String identity; + + /** + * 用户名 + */ + private String name; + + private Long userId; + +} + + + +package com.sdm.project.model.vo; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.sdm.common.entity.pojo.BaseEntity; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.project.model.po.TaskNodeExtraPo; +import com.sdm.project.model.vo.SpdmTaskMemberVo; +import lombok.Data; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class SpdmTaskVo extends BaseEntity { + + /** + * 父节点id,第一级节点的pid为0 + */ + private String pid; + + private String pUuid; + + + /** + * 当前节点id + */ + private String uuid; + + /** + * 任务名称 + */ + private String taskName; + + + /** + * 任务编码 + */ + private String taskCode; + + private String nodeId; + + + /** + * 标准工时 + */ + private Integer days; + + /** + * 实际工时 + */ + private Integer realDays; + + private String standard; + + private String folderId; + + private Integer status; + + private String achieveStatus; + + /** + * 计划开始(精确到秒) + */ + private String beginTime; + + /** + * 计划结束(精确到秒)项目详情图片 + */ + private String endTime; + + /** + * 实际完成时间(精确到秒) + */ + private String finishTime; + + /** + * 项目进度状态 + */ + private Integer progress; + + + /** + * 项目进度状态(未开始、进行中、已完成) + */ + private String exeStatus; + + private String confidence; + + private String analyseTarget; + private String analyseSoftware; + private Integer approvalStatus; + private String comfirmStatus; + private String description; + /** + * 难度系数 + */ + private Float difficult; + + private String department; + private String sectionName; + private String groupName; + @JsonProperty(value = "bCapacity") + private String bCapacity; + private String flowTemplate; + private String englishName; + + + /** + * 关联的需求id + */ + private String demandId; + + /** + * 仿真负责人 + */ + @JsonProperty(value = "pMemberList") + private List pMemberList; + + /** + * 仿真执行人 + */ + @JsonProperty(value = "eMemberList") + private List eMemberList; + + /** + * 0:未关注 1:已关注 + */ + private Integer attentionFlag; + + /** + * 关联cid交付物审批流程id + */ + private String cidFlowId; + + private String tag1; + private String tag2; + private String tag3; + private String tag4; + private String tag5; + private String tag6; + private String tag7; + private String tag8; + private String tag9; + private String tag10; + + private List extras; + + /** + * 关联的需求名称 + */ + private String demandName; + +} + + + +package com.sdm.project.model.vo; + +import com.sdm.common.entity.pojo.BaseEntity; +import lombok.Data; + +import java.util.Date; + +@Data +public class SpdmUserVo extends BaseEntity { + + /** + * 关联的需求id + */ + private String username; + + /** + * 成员类型,0:仿真负责人 1:仿真执行人 + */ + private Integer type; + + /** + * 工号 + */ + private String phone; + + /** + * 用户名 + */ + private String nickname; + private String avatar; + private String email; + private Integer status; + private String idCard; + private String realName; + private String birthProvince; + private String birthCity; + private Integer sex; + +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class UserGroupDifficultyStatisticsVo { + private Long userId; + private String userName; + private Map difficultyCount = new HashMap<>(); + private Integer totalTasks; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +@Data +public class UserGroupDifficultyVo { + private float difficult; + private Long userId; + private String nickname; + private Long groupId; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +/** + * 用户项目统计VO + */ +@Data +public class UserGroupProjectVo { + private String nodeId; + private Long userId; + private String nickname; + private Long groupId; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class UserGroupTaskCompleteStatisticsVo { + private Long userId; + private String userName; + private Map statusCount = new HashMap<>(); + private Integer totalTasks; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +@Data +public class UserGroupTaskCompleteVo { + private String exeStatus; + private String nickname; + private Long userId; + private Long groupId; +} + + + +package com.sdm.project.model.vo; + +import lombok.Data; + +@Data +public class WorkstationApproveStatusVo { + private String tag; + private String nodeName; + private String approvalStatus; +} + + + +package com.sdm.project; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication(scanBasePackages = {"com.sdm.project", "com.sdm.common"}) +@EnableDiscoveryClient +@EnableScheduling +@EnableFeignClients(basePackages = "com.sdm.common.feign") +public class ProjectApplication { + + public static void main(String[] args) { + SpringApplication.run(ProjectApplication.class, args); + } + +} + + + +package com.sdm.project.service; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.task.DemandExportExcelFormat; +import com.sdm.common.entity.req.task.TaskExportExcelFormat; +import com.sdm.project.model.req.*; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Service; + + +@Service +public interface IDemandService { + + SdmResponse addDemand(SpdmAddDemandReq req); + + + SdmResponse editDemand(SpdmEditDemandReq req); + + SdmResponse deleteDemand(SpdmDeleteDemandReq req); + + SdmResponse list(SpdmDemandListReq req); + + SdmResponse issueTask(SpdmTaskIssue req); + + SdmResponse uploadDemandFiles(UploadFilesReq req); + + /** + * 导出需求列表 + * @param demandExportExcelFormat + * @param httpservletResponse + * @return + */ + SdmResponse exportDemand(DemandExportExcelFormat demandExportExcelFormat , HttpServletResponse httpservletResponse); + + SdmResponse detail(String demandId); + +} + + + +package com.sdm.project.service.impl; + + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.common.entity.ExportExcelFormat; +import com.sdm.common.entity.enums.DirTypeEnum; +import com.sdm.common.entity.enums.FilePermissionEnum; +import com.sdm.common.entity.enums.MessageTemplateEnum; +import com.sdm.common.entity.req.data.CreateDirReq; +import com.sdm.common.entity.req.data.UpdatePermissionReq; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.system.SendMsgReq; +import com.sdm.common.entity.req.system.UserQueryReq; +import com.sdm.common.entity.req.task.DemandExportExcelFormat; +import com.sdm.common.entity.req.task.DemandExportExcelParam; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.common.feign.impl.data.DataClientFeignClientImpl; +import com.sdm.common.feign.impl.system.MessageFeignClientImpl; +import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; +import com.sdm.common.feign.inter.data.IDataFeignClient; +import com.sdm.common.service.BaseService; +import com.sdm.common.utils.RandomUtil; +import com.sdm.common.utils.excel.ExcelUtil; +import com.sdm.project.common.MemberTypeEnum; +import com.sdm.project.common.TaskAchieveStatusEnum; +import com.sdm.project.common.TaskExeStatusEnum; +import com.sdm.project.dao.SimulationDemandMapper; +import com.sdm.project.dao.SimulationNodeMapper; +import com.sdm.project.dao.SimulationProjectMapper; +import com.sdm.project.dao.SimulationTaskMapper; +import com.sdm.project.model.bo.TaskExtraNode; +import com.sdm.project.model.bo.TaskMemberNode; +import com.sdm.project.model.bo.TaskNode; +import com.sdm.project.model.po.ProjectNodePo; +import com.sdm.project.model.po.TaskNodePo; +import com.sdm.project.model.req.*; +import com.sdm.project.model.vo.*; +import com.sdm.project.service.IDemandService; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import static com.sdm.project.service.impl.NodeServiceImpl.getTagListProperty; + +@Slf4j +@Service +public class DemandServiceImpl extends BaseService implements IDemandService { + + @Autowired + private SimulationDemandMapper mapper; + + @Autowired + private SimulationProjectMapper projectMapper; + + @Autowired + private SimulationTaskMapper taskMapper; + + @Autowired + private SimulationNodeMapper nodeMapper; + + @Autowired + private DataClientFeignClientImpl dataClientFeignClient; + + @Autowired + private SysUserFeignClientImpl sysUserFeignClient; + + @Autowired + private DataClientFeignClientImpl dataFeignClient; + + @Autowired + private MessageFeignClientImpl messageFeignClient; + + + @Transactional + @Override + public SdmResponse addDemand(SpdmAddDemandReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + log.info("新增需求时,当前租户id为:{},工号为:{}", tenantId, jobNumber); + // 获取仿真负责人 + String pMemberList = req.getPMemberList(); + // 获取仿真执行人 + String eMemberList = req.getEMemberList(); + // 3D负责人 + String threeDMemberList = req.getTMemberList(); + // 关注人 + String attentionMemberList = req.getAMemberList(); + // 获取需求额外属性 + List demandExtraList = req.getExtras(); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + req.setCreateTime(curDateStr); + req.setUuid(RandomUtil.generateString(32)); + SpdmDemandVo demandByName = mapper.getDemandByName(tenantId, req.getDemandName()); + if (ObjectUtils.isNotEmpty(demandByName)) { + return SdmResponse.failed("需求名称:" + demandByName.getDemandName() + "已存在,请修改"); + } + if (mapper.addDemand(req, tenantId, jobNumber) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("新增需求失败!"); + } + long demandId = req.getId(); + log.info("需求主键id为:{}", demandId); + List allMemberList = new ArrayList<>(); + String uuid = req.getUuid(); + if (StringUtils.isNotBlank(pMemberList)) { + String[] pMemberArray = pMemberList.split(","); + for (String userId : pMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(0); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (StringUtils.isNotBlank(eMemberList)) { + String[] eMemberArray = eMemberList.split(","); + for (String userId : eMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(1); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (StringUtils.isNotBlank(threeDMemberList)) { + String[] threeDMemberArray = threeDMemberList.split(","); + for (String userId : threeDMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(2); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (StringUtils.isNotBlank(attentionMemberList)) { + String[] attentionMemberArray = attentionMemberList.split(","); + for (String userId : attentionMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(3); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (CollectionUtils.isNotEmpty(allMemberList)) { + if (mapper.addDemandMember(allMemberList) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("新增需求关联成员失败!"); + } + } + if (CollectionUtils.isNotEmpty(demandExtraList)) { + demandExtraList.forEach(demandExtra -> { + demandExtra.setDemandId(req.getUuid()); + demandExtra.setCreateTime(curDateStr); + demandExtra.setCreator(jobNumber); + }); + if (mapper.addDemandExtra(demandExtraList) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("新增需求额外属性失败!"); + } + } + + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setParentUuId(null); + createDirReq.setDirName(req.getDemandName()); + createDirReq.setDirType(DirTypeEnum.PROJECT_NODE_DIR.getValue()); + log.info("创建需求时,调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataClientFeignClient.createDir(createDirReq); + log.info("创建需求时,调用创建文件夹的返回值为:{}", response); + // 更新文件权限 + Long userId = ThreadLocalContext.getUserId(); + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(userId); + updatePermissionReq.setUuid(uuid); + Map userPermissions = new HashMap<>(); + userPermissions.put(userId, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("创建需求时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataFeignClient.updatePermission(updatePermissionReq); + log.info("创建需求时,更新用户权限的返回值为:{}",updatePermissionResponse); + return SdmResponse.success(req.getUuid()); + } + + @Transactional + @Override + public SdmResponse editDemand(SpdmEditDemandReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + log.info("修改需求时,当前租户id为:{},工号为:{}", tenantId, jobNumber); + // 获取仿真负责人 + String pMemberList = req.getPMemberList(); + // 获取仿真执行人 + String eMemberList = req.getEMemberList(); + // 3D负责人 + String threeDMemberList = req.getTMemberList(); + // 关注人 + String attentionMemberList = req.getAMemberList(); + // 获取需求额外属性 + List demandExtraList = req.getExtras(); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + req.setUpdateTime(curDateStr); + if (mapper.editDemand(req, jobNumber) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("修改需求失败!"); + } + + // 先删除所有成员,然后再添加 + mapper.deleteDemandMember(Collections.singletonList(req.getUuid())); + List allMemberList = new ArrayList<>(); + String uuid = req.getUuid(); + if (StringUtils.isNotBlank(pMemberList)) { + String[] pMemberArray = pMemberList.split(","); + for (String userId : pMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(0); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (StringUtils.isNotBlank(eMemberList)) { + String[] eMemberArray = eMemberList.split(","); + for (String userId : eMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(1); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (StringUtils.isNotBlank(threeDMemberList)) { + String[] threeDMemberArray = threeDMemberList.split(","); + for (String userId : threeDMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(2); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (StringUtils.isNotBlank(attentionMemberList)) { + String[] attentionMemberArray = attentionMemberList.split(","); + for (String userId : attentionMemberArray) { + SpdmDemandRelateMemberReq spdmDemandRelateMemberReq = new SpdmDemandRelateMemberReq(); + spdmDemandRelateMemberReq.setDemandId(uuid); + spdmDemandRelateMemberReq.setType(3); + spdmDemandRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmDemandRelateMemberReq.setCreateTime(curDateStr); + spdmDemandRelateMemberReq.setCreator(jobNumber); + allMemberList.add(spdmDemandRelateMemberReq); + } + } + + if (CollectionUtils.isNotEmpty(allMemberList)) { + if (mapper.addDemandMember(allMemberList) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("修改需求关联成员失败!"); + } + } + + // 先删除所有额外属性,然后再添加 + mapper.deleteDemandExtra(Collections.singletonList(req.getUuid())); + if (CollectionUtils.isNotEmpty(demandExtraList)) { + demandExtraList.forEach(demandExtra -> { + demandExtra.setDemandId(req.getUuid()); + demandExtra.setCreateTime(curDateStr); + demandExtra.setCreator(jobNumber); + }); + if (mapper.addDemandExtra(demandExtraList) <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("修改需求额外属性失败!"); + } + } + return SdmResponse.success(); + } + + @Transactional + @Override + public SdmResponse deleteDemand(SpdmDeleteDemandReq req) { + mapper.deleteDemand(req.getDeleteNodeIdList()); + mapper.deleteDemandMember(req.getDeleteNodeIdList()); + mapper.deleteDemandExtra(req.getDeleteNodeIdList()); + return SdmResponse.success(); + } + + @Override + public SdmResponse list(SpdmDemandListReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + if (ObjectUtils.isEmpty(tenantId) || ObjectUtils.isEmpty(jobNumber)) { + log.error("公司和工号都不能为空"); + return SdmResponse.failed("公司和工号都不能为空"); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data", new ArrayList<>()); + List demandList = mapper.getDemandList(tenantId, req); + if (CollectionUtils.isEmpty(demandList)) { + log.error("根据tenantId:{},未查询到需求", tenantId); + return SdmResponse.success(jsonObject); + } + // 0:我发起的 1:我确认的 + Integer type = req.getType(); + if (type != 0 && type != 1) { + log.error("type必须为0或1"); + return SdmResponse.success(jsonObject); + } + List demandMemberVoList = mapper.getMemberList(demandList.stream().map(SpdmDemandVo::getUuid).toList(), null); + if (CollectionUtils.isEmpty(demandMemberVoList)) { + log.error("demandList0为空"); + return SdmResponse.success(jsonObject); + } + if (type == 0) { + // 创建人是当前用户 + demandList = demandList.stream().filter(demand -> jobNumber.equals(demand.getCreator())).toList(); + } else { + // 仿真负责人是当前用户 + demandMemberVoList = demandMemberVoList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType()) && Long.valueOf(jobNumber).equals(member.getUserId())).toList(); + if (CollectionUtils.isNotEmpty(demandMemberVoList)) { + List myDemandIdList = demandMemberVoList.stream().map(SpdmDemandMemberVo::getDemandId).toList(); + demandList = demandList.stream().filter(demand -> myDemandIdList.contains(demand.getUuid())).toList(); + } + } + if (CollectionUtils.isEmpty(demandList)) { + log.error("demandList1为空"); + return SdmResponse.success(jsonObject); + } + List taskList = taskMapper.getTaskListByDemandIdList(demandList.stream().map(SpdmDemandVo::getUuid).toList()); + Map> taskMap = Map.of(); + if (CollectionUtils.isNotEmpty(taskList)) { + taskMap = taskList.stream().collect(Collectors.groupingBy(SpdmTaskVo::getDemandId)); + } + // 需求的状态和进度需要根据任务来确定 + if (StringUtils.isNotBlank(req.getAchieveStatus()) || StringUtils.isNotBlank(req.getDemandStatus())) { + if (StringUtils.isNotBlank(req.getAchieveStatus())) { + if (CollectionUtils.isEmpty(taskList)) { + demandList = demandList.stream().filter(firstDemand -> req.getAchieveStatus().equals(firstDemand.getAchieveStatus())).toList(); + } else { + List eachTaskList; + String eachStatus; + List newDemandList = new ArrayList<>(); + for (SpdmDemandVo demand : demandList) { + eachTaskList = taskMap.get(demand.getUuid()); + if (CollectionUtils.isEmpty(eachTaskList)) { + log.info("当前需求:{}没有关联的任务", demand.getId()); + newDemandList.add(demand); + } else { + if (eachTaskList.stream().map(SpdmTaskVo::getAchieveStatus).toList().contains(TaskAchieveStatusEnum.UNQUALIFIED.getCode())) { + eachStatus = TaskAchieveStatusEnum.UNQUALIFIED.getCode(); + } else if (eachTaskList.stream().map(SpdmTaskVo::getAchieveStatus).toList().contains(TaskAchieveStatusEnum.NO_CALCULATE.getCode())) { + eachStatus = TaskAchieveStatusEnum.NO_CALCULATE.getCode(); + } else { + eachStatus = TaskAchieveStatusEnum.QUALIFIED.getCode(); + } + log.info("当前需求:{}的风险状态为:{}", demand.getId(), eachStatus); + if (!eachStatus.equals(req.getAchieveStatus())) { + continue; + } + newDemandList.add(demand); + } + } + demandList = newDemandList; + } + } + + if (CollectionUtils.isEmpty(demandList)) { + log.error("demandList2为空"); + return SdmResponse.success(jsonObject); + } + + if (StringUtils.isNotBlank(req.getDemandStatus())) { + if (CollectionUtils.isEmpty(taskList)) { + demandList = demandList.stream().filter(firstDemand -> req.getDemandStatus().equals(firstDemand.getDemandStatus())).toList(); + } else { + List eachTaskList; + String eachStatus = ""; + List newDemandList = new ArrayList<>(); + for (SpdmDemandVo demand : demandList) { + eachTaskList = taskMap.get(demand.getUuid()); + if (CollectionUtils.isEmpty(eachTaskList)) { + log.info("当前需求:{}没有关联的任务", demand.getId()); + newDemandList.add(demand); + } else { + + +// 有进行中就是进行中, +// 没有进行中,有暂停就是暂停 +// 没有进行中和暂停,有延期就是延期 +// 全部已完成就已完成 +// 全部关闭就已关闭 +// 全部未开始就未开始 +// 全部驳回就驳回 +// 其他 进行中 + + List statusList = eachTaskList.stream().map(SpdmTaskVo::getExeStatus).toList(); + if (statusList.contains(TaskExeStatusEnum.IN_PROGRESS.getCode())) { + eachStatus = TaskExeStatusEnum.IN_PROGRESS.getCode(); + } else if (statusList.contains(TaskExeStatusEnum.PAUSED.getCode())) { + eachStatus = TaskExeStatusEnum.PAUSED.getCode(); + } else if (statusList.contains(TaskExeStatusEnum.POSTPONED.getCode())) { + eachStatus = TaskExeStatusEnum.POSTPONED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.COMPLETED.getCode().equals(status))) { + eachStatus = TaskExeStatusEnum.COMPLETED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.CLOSED.getCode().equals(status))) { + eachStatus = TaskExeStatusEnum.CLOSED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.NO_STARTED.getCode().equals(status))) { + eachStatus = TaskExeStatusEnum.NO_STARTED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.REJECTED.getCode().equals(status))) { + eachStatus = TaskExeStatusEnum.REJECTED.getCode(); + } else { + eachStatus = TaskExeStatusEnum.IN_PROGRESS.getCode(); + } + log.info("当前需求:{}的需求状态为:{}", demand.getId(), eachStatus); + if (!eachStatus.equals(req.getDemandStatus())) { + continue; + } + newDemandList.add(demand); + } + } + demandList = newDemandList; + } + } + } + if (CollectionUtils.isEmpty(demandList)) { + log.error("demandList3为空"); + return SdmResponse.success(jsonObject); + } + + jsonObject.put("currentPage", req.getCurrent()); + jsonObject.put("pageSize", req.getSize()); + jsonObject.put("total", demandList.size()); + demandList = demandList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList(); + if (CollectionUtils.isEmpty(demandList)) { + log.error("demandList4为空"); + return SdmResponse.success(jsonObject); + } + List eachTaskList; + String eachAchieveStatus; + String eachExeStatus; + for (SpdmDemandVo demand : demandList) { + eachTaskList = taskMap.get(demand.getUuid()); + if (CollectionUtils.isEmpty(eachTaskList)) { + demand.setAchieveStatus("0"); + continue; + } + if (eachTaskList.stream().map(SpdmTaskVo::getAchieveStatus).toList().contains(TaskAchieveStatusEnum.UNQUALIFIED.getCode())) { + eachAchieveStatus = TaskAchieveStatusEnum.UNQUALIFIED.getCode(); + } else if (eachTaskList.stream().map(SpdmTaskVo::getAchieveStatus).toList().contains(TaskAchieveStatusEnum.NO_CALCULATE.getCode())) { + eachAchieveStatus = TaskAchieveStatusEnum.NO_CALCULATE.getCode(); + } else { + eachAchieveStatus = TaskAchieveStatusEnum.QUALIFIED.getCode(); + } + demand.setAchieveStatus(eachAchieveStatus); + + List statusList = eachTaskList.stream().map(SpdmTaskVo::getExeStatus).toList(); + if (statusList.contains(TaskExeStatusEnum.IN_PROGRESS.getCode())) { + eachExeStatus = TaskExeStatusEnum.IN_PROGRESS.getCode(); + } else if (statusList.contains(TaskExeStatusEnum.PAUSED.getCode())) { + eachExeStatus = TaskExeStatusEnum.PAUSED.getCode(); + } else if (statusList.contains(TaskExeStatusEnum.POSTPONED.getCode())) { + eachExeStatus = TaskExeStatusEnum.POSTPONED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.COMPLETED.getCode().equals(status))) { + eachExeStatus = TaskExeStatusEnum.COMPLETED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.CLOSED.getCode().equals(status))) { + eachExeStatus = TaskExeStatusEnum.CLOSED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.NO_STARTED.getCode().equals(status))) { + eachExeStatus = TaskExeStatusEnum.NO_STARTED.getCode(); + } else if (statusList.stream().allMatch(status -> TaskExeStatusEnum.REJECTED.getCode().equals(status))) { + eachExeStatus = TaskExeStatusEnum.REJECTED.getCode(); + } else { + eachExeStatus = TaskExeStatusEnum.IN_PROGRESS.getCode(); + } + demand.setDemandStatus(eachExeStatus); + } + Map> demandMemberMap = Map.of(); + if (CollectionUtils.isNotEmpty(demandMemberVoList)) { + demandMemberMap = demandMemberVoList.stream().collect(Collectors.groupingBy(SpdmDemandMemberVo::getDemandId)); + } + List eachDemandMemberList; + List nodeIdList = new ArrayList<>(); + List projectIdList = demandList.stream().map(SpdmDemandVo::getProjectId).toList(); + if (CollectionUtils.isNotEmpty(projectIdList)) { + nodeIdList.addAll(projectIdList); + } + List phaseIdList = demandList.stream().map(SpdmDemandVo::getPhaseId).toList(); + if (CollectionUtils.isNotEmpty(phaseIdList)) { + nodeIdList.addAll(phaseIdList); + } + Map> nodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(nodeIdList)) { + List nodeList = nodeMapper.getNodeListByIds(nodeIdList); + if (CollectionUtils.isNotEmpty(nodeList)) { + nodeMap = nodeList.stream().collect(Collectors.groupingBy(SpdmNodeVo::getUuid)); + } + } + List userIdList = demandMemberVoList.stream().map(SpdmDemandMemberVo::getUserId).toList(); + Map> userMap = Map.of(); + if (CollectionUtils.isNotEmpty(userIdList)) { + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build()); + List userList = cidUserResp.getData(); + if (CollectionUtils.isNotEmpty(userList)) { + userMap = userList.stream().collect(Collectors.groupingBy(CIDUserResp::getUserId)); + } + } + List demandIdList = demandList.stream().map(SpdmDemandVo::getUuid).toList(); + List demandExtraList = mapper.getDemandExtraList(demandIdList); + Map> demandExtraMap = Map.of(); + if (CollectionUtils.isNotEmpty(demandExtraList)) { + demandExtraMap = demandExtraList.stream().collect(Collectors.groupingBy(SpdmDemandExtraVo::getDemandId)); + } + for (SpdmDemandVo spdmDemandVo : demandList) { + spdmDemandVo.setExtras(demandExtraMap.get(spdmDemandVo.getUuid())); + eachTaskList = taskMap.get(spdmDemandVo.getUuid()); + spdmDemandVo.setProgress(CollectionUtils.isEmpty(eachTaskList) ? 0 : eachTaskList.stream().mapToInt(SpdmTaskVo::getProgress).sum() / eachTaskList.size()); + if (StringUtils.isNotBlank(spdmDemandVo.getProjectId())) { + spdmDemandVo.setProjectName(CollectionUtils.isNotEmpty(nodeMap.get(spdmDemandVo.getProjectId())) ? nodeMap.get(spdmDemandVo.getProjectId()).get(0).getNodeName() : ""); + } + if (StringUtils.isNotBlank(spdmDemandVo.getPhaseId())) { + spdmDemandVo.setPhaseName(CollectionUtils.isNotEmpty(nodeMap.get(spdmDemandVo.getPhaseId())) ? nodeMap.get(spdmDemandVo.getPhaseId()).get(0).getNodeName() : ""); + } + eachDemandMemberList = demandMemberMap.get(spdmDemandVo.getUuid()); + if (CollectionUtils.isEmpty(eachDemandMemberList)) { + continue; + } + List spdmPUserVoList = new ArrayList<>(); + for (Long userId : eachDemandMemberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmPUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setPMemberList(spdmPUserVoList); + List spdmEUserVoList = new ArrayList<>(); + for (Long userId : eachDemandMemberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmEUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setEMemberList(spdmEUserVoList); + + List spdmTUserVoList = new ArrayList<>(); + for (Long userId : eachDemandMemberList.stream().filter(member -> MemberTypeEnum.THREED.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmTUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setTMemberList(spdmTUserVoList); + + List spdmAUserVoList = new ArrayList<>(); + for (Long userId : eachDemandMemberList.stream().filter(member -> MemberTypeEnum.ATTENTION.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmAUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setAMemberList(spdmAUserVoList); + } + jsonObject.put("data", demandList); + return SdmResponse.success(jsonObject); + } + + @Override + public SdmResponse issueTask(SpdmTaskIssue issueReq) { + log.info("issueTask参数为:{}", issueReq); + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + SdmResponse response = SdmResponse.success(); + + if (CollectionUtils.isNotEmpty(issueReq.getReqList())) { + for (SpdmTaskIssueReq req : issueReq.getReqList()) { + List taskNodeList = req.getAddNodeList(); + if (CollectionUtils.isEmpty(taskNodeList)) { + return SdmResponse.success(new ArrayList<>()); + } + + String parentUuid = getLastNodeId(taskNodeList.get(0)); + log.info("下发任务时,parentId为:{}", parentUuid); + String demandId = req.getDemandId(); + List projectNodeMemberList = new ArrayList<>(); + List projectNodeExtraList = new ArrayList<>(); + List allPerformanceList = new ArrayList<>(); + List allPerformanceExtraList = new ArrayList<>(); + for (TaskNode task : taskNodeList) { + task.setUuid(RandomUtil.generateString(32)); + task.setDemandId(demandId); + task.setTaskName(task.getNodeName()); + task.setTaskCode(task.getNodeCode()); + task.setTenantId(tenantId); + String pUserIdStr = task.getPMemberList(); + String eUserIdStr = task.getEMemberList(); + log.info("下发的仿真负责人为:{}", pUserIdStr); + log.info("下发的仿真执行人为:{}", eUserIdStr); + if (StringUtils.isNotBlank(pUserIdStr)) { + String[] userIdArr = pUserIdStr.split(","); + for (String userId : userIdArr) { + TaskMemberNode taskMemberNode = new TaskMemberNode(); + taskMemberNode.setTaskId(task.getUuid()); + taskMemberNode.setNodeId(task.getUuid()); + taskMemberNode.setUserId(userId); + taskMemberNode.setType(MemberTypeEnum.PRINCIPAL.getCode()); + projectNodeMemberList.add(taskMemberNode); + } + } + if (StringUtils.isNotBlank(eUserIdStr)) { + String[] userIdArr = eUserIdStr.split(","); + for (String userId : userIdArr) { + TaskMemberNode taskMemberNode = new TaskMemberNode(); + taskMemberNode.setTaskId(task.getUuid()); + taskMemberNode.setNodeId(task.getUuid()); + taskMemberNode.setUserId(userId); + taskMemberNode.setType(MemberTypeEnum.EXECUTOR.getCode()); + projectNodeMemberList.add(taskMemberNode); + } + } + List extraList = task.getExtras(); + if (CollectionUtils.isNotEmpty(extraList)) { + for (TaskExtraNode extra : extraList) { + TaskExtraNode taskExtraNode = new TaskExtraNode(); + taskExtraNode.setTaskId(task.getUuid()); + taskExtraNode.setNodeId(task.getUuid()); + taskExtraNode.setPropertyName(extra.getPropertyName()); + taskExtraNode.setPropertyValue(extra.getPropertyValue()); + projectNodeExtraList.add(taskExtraNode); + } + } + + // 指标 + List performanceList = task.getChildren(); + for (TaskNode performance : performanceList) { + performance.setTaskId(task.getUuid()); + List performanceExtraList = performance.getExtras(); + if (CollectionUtils.isNotEmpty(performanceExtraList)) { + for (TaskExtraNode extra : performanceExtraList) { + extra.setPerformanceId(performance.getUuid()); + extra.setTaskId(performance.getTaskId()); + extra.setNodeId(performance.getNodeId()); + allPerformanceExtraList.add(extra); + } + } + allPerformanceList.add(performance); + } + + } + String createTime = DateUtil.now(); + Map taskNodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(taskNodeList)) { + taskNodeList.forEach(projectNode -> { + projectNode.setCreator(jobNumber); + projectNode.setCreateTime(createTime); + }); + if (projectMapper.batchAddSimulationTask(taskNodeList) <= 0) { + response = SdmResponse.failed("新增任务失败"); + return response; + } + taskNodeMap = taskNodeList.stream().collect(Collectors.groupingBy( + TaskNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + for (TaskNode taskNode : taskNodeList) { + createDir(taskNode.getUuid(), parentUuid, taskNode.getNodeName()); + // 发送消息通知 + sendMessage(MessageTemplateEnum.TASK_ISSUE, taskNode.getNodeName()); + } + for (TaskNode taskNode : taskNodeList) { + // 更新文件权限 + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(jobNumber); + updatePermissionReq.setUuid(taskNode.getUuid()); + Map userPermissions = new HashMap<>(); + userPermissions.put(jobNumber, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("下发任务时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataFeignClient.updatePermission(updatePermissionReq); + log.info("下发任务时,更新用户权限的返回值为:{}",updatePermissionResponse); + } + } + if (CollectionUtils.isNotEmpty(projectNodeExtraList)) { + projectNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (projectMapper.batchAddSimulationTaskExtra(projectNodeExtraList) <= 0) { + response = SdmResponse.failed("新增任务附加属性失败"); + } + } + if (CollectionUtils.isNotEmpty(projectNodeMemberList)) { + projectNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (projectMapper.batchAddSimulationTaskMember(projectNodeMemberList) <= 0) { + response = SdmResponse.failed("新增任务成员属性失败"); + return response; + } + } + + // 指标 + if (CollectionUtils.isNotEmpty(allPerformanceList)) { + allPerformanceList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (projectMapper.batchAddSimulationPerformance(allPerformanceList) <= 0) { + response = SdmResponse.failed("新增指标失败"); + return response; + } + for (TaskNode taskNode : allPerformanceList) { + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(jobNumber); + updatePermissionReq.setUuid(taskNode.getUuid()); + Map userPermissions = new HashMap<>(); + userPermissions.put(jobNumber, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("下发任务时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataFeignClient.updatePermission(updatePermissionReq); + log.info("下发任务时,更新用户权限的返回值为:{}",updatePermissionResponse); + } + + List newTaskNodeList = projectMapper.getTaskListByNodeIdList(allPerformanceList.stream().map(TaskNode::getTaskId).toList()); + Map taskNodePoMap = Map.of(); + if (CollectionUtils.isNotEmpty(newTaskNodeList)) { + taskNodePoMap = newTaskNodeList.stream().collect(Collectors.groupingBy( + TaskNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + for (TaskNode taskNode : allPerformanceList) { + if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId())) && ObjectUtils.isEmpty(taskNodeMap.get(taskNode.getTaskId()))) { + log.error("taskNodeMap不空,根据taskId:{},未查询到任务", taskNode.getTaskId()); + response = SdmResponse.failed("新增指标时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), + ObjectUtils.isNotEmpty(taskNodePoMap.get(taskNode.getTaskId())) ? taskNodePoMap.get(taskNode.getTaskId()).getUuid() : taskNodeMap.get(taskNode.getTaskId()).getUuid(), + taskNode.getNodeName()); + } + + } + if (CollectionUtils.isNotEmpty(allPerformanceExtraList)) { + allPerformanceExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (projectMapper.batchAddSimulationPerformanceExtra(allPerformanceExtraList) <= 0) { + response = SdmResponse.failed("新增任务指标附加属性失败"); + return response; + } + } + } + } + return response; + } + + private void sendMessage(MessageTemplateEnum templateEnum, String taskName) { + SendMsgReq req = new SendMsgReq(); + req.setTitle(templateEnum.getTitle()); + req.setContent(templateEnum.getContent(taskName)); + req.setTenantId(ThreadLocalContext.getTenantId().toString()); + req.setUserId(ThreadLocalContext.getUserId().toString()); + messageFeignClient.sendMessage(req); + } + + @Override + public SdmResponse uploadDemandFiles(UploadFilesReq req) { + return dataFeignClient.uploadFiles(req); + } + + @Override + public SdmResponse exportDemand(DemandExportExcelFormat demandExportExcelFormat, HttpServletResponse httpServletResponse) { + SdmResponse response = new SdmResponse(); + SpdmDemandListReq req = new SpdmDemandListReq(); + DemandExportExcelParam params = demandExportExcelFormat.getParams(); + if (ObjectUtils.isNotEmpty(params)) { + BeanUtils.copyProperties(params, req); + } + List exportExcelFormats = demandExportExcelFormat.getExcelHeaders(); + req.setCurrent(1); + req.setSize(10000); + SdmResponse taskRespond = list(req); + if (taskRespond.isSuccess()) { + JSONObject dataObj = (JSONObject) taskRespond.getData(); + List demandVoList = (List) dataObj.get("data"); + List exportDemandVoList = new ArrayList<>(); + List pMemberList; + String pMemberName = ""; + List eMemberList; + String eMemberName = ""; + List tMemberList; + String tMemberName = ""; + List aMemberList; + String aMemberName = ""; + String projectId; + String phaseId; + List nodeIdList = new ArrayList<>(); + List projectIdList = demandVoList.stream().map(SpdmDemandVo::getProjectId).distinct().toList(); + if (CollectionUtils.isNotEmpty(projectIdList)) { + nodeIdList.addAll(projectIdList); + } + List phaseIdList = demandVoList.stream().map(SpdmDemandVo::getPhaseId).distinct().toList(); + if (CollectionUtils.isNotEmpty(phaseIdList)) { + nodeIdList.addAll(phaseIdList); + } + Map nodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(nodeIdList)) { + List nodeList = projectMapper.getNodeListByNodeIdList(nodeIdList); + if (CollectionUtils.isNotEmpty(nodeList)) { + nodeMap = nodeList.stream().collect(Collectors.groupingBy( + ProjectNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + } + for (SpdmDemandVo spdmDemandVo : demandVoList) { + // 转换项目、阶段 + projectId = spdmDemandVo.getProjectId(); + if (StringUtils.isNotBlank(projectId) && ObjectUtils.isNotEmpty(nodeMap.get(projectId))) { + spdmDemandVo.setProjectId(nodeMap.get(projectId).getNodeName()); + } + phaseId = spdmDemandVo.getPhaseId(); + if (StringUtils.isNotBlank(phaseId) && ObjectUtils.isNotEmpty(nodeMap.get(phaseId))) { + spdmDemandVo.setPhaseId(nodeMap.get(phaseId).getNodeName()); + } + pMemberList = spdmDemandVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(pMemberList)) { + pMemberName = pMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + eMemberList = spdmDemandVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(eMemberList)) { + eMemberName = eMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + tMemberList = spdmDemandVo.getTMemberList(); + if (CollectionUtils.isNotEmpty(tMemberList)) { + tMemberName = tMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + aMemberList = spdmDemandVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(aMemberList)) { + aMemberName = aMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + SpdmExportDemandVo spdmExportDemandVo = new SpdmExportDemandVo(); + BeanUtils.copyProperties(spdmDemandVo, spdmExportDemandVo); + spdmExportDemandVo.setPMemberList(pMemberName); + spdmExportDemandVo.setEMemberList(eMemberName); + spdmExportDemandVo.setTMemberList(tMemberName); + spdmExportDemandVo.setAMemberList(aMemberName); + exportDemandVoList.add(spdmExportDemandVo); + } + ExcelUtil.exportExcelNoMerge(JSONArray.from(exportDemandVoList), exportExcelFormats, httpServletResponse); + } else { + response = SdmResponse.failed(taskRespond.getMessage()); + } + return response; + } + + @Override + public SdmResponse detail(String demandId) { + List demandList = mapper.getDemandListById(Collections.singletonList(demandId)); + if (CollectionUtils.isEmpty(demandList)) { + return SdmResponse.success(new ArrayList<>()); + } + SpdmDemandVo spdmDemandVo = demandList.get(0); + List demandMemberVoList = mapper.getMemberList(Collections.singletonList(spdmDemandVo.getUuid()), null); + List demandExtraList = mapper.getDemandExtraList(Collections.singletonList(demandId)); + Map> demandExtraMap = Map.of(); + if (CollectionUtils.isNotEmpty(demandExtraList)) { + demandExtraMap = demandExtraList.stream().collect(Collectors.groupingBy(SpdmDemandExtraVo::getDemandId)); + } + List nodeIdList = new ArrayList<>(); + String projectId = spdmDemandVo.getProjectId(); + if (StringUtils.isNotBlank(projectId)) { + nodeIdList.add(projectId); + } + String phaseId = spdmDemandVo.getPhaseId(); + if (StringUtils.isNotBlank(phaseId)) { + nodeIdList.add(phaseId); + } + Map> nodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(nodeIdList)) { + List nodeList = nodeMapper.getNodeListByIds(nodeIdList); + if (CollectionUtils.isNotEmpty(nodeList)) { + nodeMap = nodeList.stream().collect(Collectors.groupingBy(SpdmNodeVo::getUuid)); + } + } + List taskList = taskMapper.getTaskListByDemandIdList(demandList.stream().map(SpdmDemandVo::getUuid).toList()); + Map> taskMap = Map.of(); + if (CollectionUtils.isNotEmpty(taskList)) { + taskMap = taskList.stream().collect(Collectors.groupingBy(SpdmTaskVo::getDemandId)); + } + spdmDemandVo.setExtras(demandExtraMap.get(spdmDemandVo.getUuid())); + List taskVoList = taskMap.get(spdmDemandVo.getUuid()); + spdmDemandVo.setProgress(CollectionUtils.isEmpty(taskVoList) ? 0 : taskVoList.stream().mapToInt(SpdmTaskVo::getProgress).sum() / taskVoList.size()); + if (StringUtils.isNotBlank(spdmDemandVo.getProjectId())) { + spdmDemandVo.setProjectName(CollectionUtils.isNotEmpty(nodeMap.get(spdmDemandVo.getProjectId())) ? nodeMap.get(spdmDemandVo.getProjectId()).get(0).getNodeName() : ""); + } + if (StringUtils.isNotBlank(spdmDemandVo.getPhaseId())) { + spdmDemandVo.setPhaseName(CollectionUtils.isNotEmpty(nodeMap.get(spdmDemandVo.getPhaseId())) ? nodeMap.get(spdmDemandVo.getPhaseId()).get(0).getNodeName() : ""); + } + List userIdList = demandMemberVoList.stream().map(SpdmDemandMemberVo::getUserId).toList(); + Map> userMap = Map.of(); + if (CollectionUtils.isNotEmpty(userIdList)) { + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build()); + List userList = cidUserResp.getData(); + if (CollectionUtils.isNotEmpty(userList)) { + userMap = userList.stream().collect(Collectors.groupingBy(CIDUserResp::getUserId)); + } + } + if (CollectionUtils.isNotEmpty(demandMemberVoList)) { + List spdmPUserVoList = new ArrayList<>(); + for (Long userId : demandMemberVoList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmPUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setPMemberList(spdmPUserVoList); + List spdmEUserVoList = new ArrayList<>(); + for (Long userId : demandMemberVoList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmEUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setEMemberList(spdmEUserVoList); + List spdmTUserVoList = new ArrayList<>(); + for (Long userId : demandMemberVoList.stream().filter(member -> MemberTypeEnum.THREED.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmTUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setTMemberList(spdmTUserVoList); + + List spdmAUserVoList = new ArrayList<>(); + for (Long userId : demandMemberVoList.stream().filter(member -> MemberTypeEnum.ATTENTION.getCode().equals(member.getType())).map(SpdmDemandMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmAUserVoList.addAll(userMap.get(userId)); + } + } + spdmDemandVo.setAMemberList(spdmAUserVoList); + } + return SdmResponse.success(spdmDemandVo); + } + + private String getLastNodeId(TaskNode taskNode) { + List tagListProperty; + String lastNodeId = ""; + for (int i = 1; i <= 10; i++) { + try { + tagListProperty = getTagListProperty(taskNode, "tag" + i); + if (CollectionUtils.isNotEmpty(tagListProperty)) { + lastNodeId = tagListProperty.get(tagListProperty.size() - 1); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return projectMapper.getNodeListByNodeIdList(Collections.singletonList(lastNodeId)).get(0).getUuid(); + } + +// @Override +// public SdmResponse issueTask(SpdmTaskIssue req) { +// log.info("issueTask参数为:{}", req); +// List taskNodeList = req.getAddNodeList(); +// if (CollectionUtils.isEmpty(taskNodeList)) { +// return SdmResponse.success(new ArrayList<>()); +// } +// List idMapList = req.getIdMap(); +// idMapList = idMapList.stream().filter(idMap -> null != idMap.getKey() &&!"null".equals(idMap.getKey())).toList(); +// if (CollectionUtils.isEmpty(idMapList)) { +// return SdmResponse.success(new ArrayList<>()); +// } +// TaskNodeTag taskNodeTag = idMapList.get(idMapList.size() - 1); +// List nodeListByNodeIdList = projectMapper.getNodeListByNodeIdList(Collections.singletonList(taskNodeTag.getKey())); +// if (CollectionUtils.isEmpty(nodeListByNodeIdList)) { +// return SdmResponse.success(new ArrayList<>()); +// } +// long parentId = nodeListByNodeIdList.get(0).getId(); +// log.info("issueTask的idMap最后一层非空节点为:{}",taskNodeTag); +// String demandId = req.getDemandId(); +// List projectNodeMemberList = new ArrayList<>(); +// List projectNodeExtraList = new ArrayList<>(); +// List allPerformanceList = new ArrayList<>(); +// List allPerformanceExtraList = new ArrayList<>(); +// for (TaskNode task : taskNodeList) { +// for (TaskNodeTag tag : idMapList) { +// try { +// setTagProperty(task, tag.getValue(), Arrays.stream(tag.getKey().split(",")).toList()); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// } +// task.setUuid(generateUuid()); +// task.setDemandId(demandId); +// task.setTaskName(task.getNodeName()); +// task.setTaskCode(task.getNodeCode()); +// List taskMemberNodeList = task.getMemberList(); +// if (CollectionUtils.isNotEmpty(taskMemberNodeList)) { +// for (TaskMemberNode member : taskMemberNodeList) { +// TaskMemberNode taskMemberNode = new TaskMemberNode(); +// taskMemberNode.setTaskId(task.getUuid()); +// taskMemberNode.setNodeId(task.getUuid()); +// taskMemberNode.setIdentity(member.getIdentity()); +// taskMemberNode.setName(member.getName()); +// taskMemberNode.setUserId(member.getUserId()); +// taskMemberNode.setType(member.getType()); +// projectNodeMemberList.add(taskMemberNode); +// } +// } +// List extraList = task.getTaskExtraNodeList(); +// if (CollectionUtils.isNotEmpty(extraList)) { +// for (TaskExtraNode extra : extraList) { +// TaskExtraNode taskExtraNode = new TaskExtraNode(); +// taskExtraNode.setTaskId(task.getUuid()); +// taskExtraNode.setNodeId(task.getUuid()); +// taskExtraNode.setPropertyName(extra.getPropertyName()); +// taskExtraNode.setPropertyValue(extra.getPropertyValue()); +// projectNodeExtraList.add(taskExtraNode); +// } +// } +// +// // 指标 +// List performanceList = task.getChildren(); +// for (TaskNode performance : performanceList) { +// performance.setTaskId(task.getUuid()); +// List performanceExtraList = performance.getTaskExtraNodeList(); +// if (CollectionUtils.isNotEmpty(performanceExtraList)) { +// for (TaskExtraNode extra : performanceExtraList) { +// extra.setPerformanceId(performance.getUuid()); +// extra.setTaskId(performance.getTaskId()); +// extra.setNodeId(performance.getNodeId()); +// allPerformanceExtraList.add(extra); +// } +// } +// allPerformanceList.add(performance); +// } +// +// } +// String jobNumber = ThreadLocalContext.getCommonHeader().getJobNumber(); +// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// String createTime = format.format(new Date()); +// SdmResponse response = SdmResponse.success(); +// Map taskNodeMap = Map.of(); +// if (CollectionUtils.isNotEmpty(taskNodeList)) { +// taskNodeList.forEach(projectNode -> { +// projectNode.setCreator(jobNumber); +// projectNode.setCreateTime(createTime); +// }); +// if (projectMapper.batchAddSimulationTask(taskNodeList) <= 0) { +// response = SdmResponse.failed("新增任务失败"); +// return response; +// } +// taskNodeMap = taskNodeList.stream().collect(Collectors.groupingBy( +// TaskNode::getUuid, +// Collectors.collectingAndThen( +// Collectors.toList(), +// list -> list.get(0) +// ) +// )); +// for (TaskNode taskNode : taskNodeList) { +// createDir(taskNode.getId(),parentId, taskNode.getNodeName()); +// } +// } +// if (CollectionUtils.isNotEmpty(projectNodeExtraList)) { +// projectNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationTaskExtra(projectNodeExtraList) <= 0) { +// response = SdmResponse.failed("新增任务附加属性失败"); +// } +// } +// if (CollectionUtils.isNotEmpty(projectNodeMemberList)) { +// projectNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationTaskMember(projectNodeMemberList) <= 0) { +// response = SdmResponse.failed("新增任务成员属性失败"); +// return response; +// } +// } +// +// +// // 指标 +// if (CollectionUtils.isNotEmpty(allPerformanceList)) { +// allPerformanceList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationPerformance(allPerformanceList) <= 0) { +// response = SdmResponse.failed("新增指标失败"); +// return response; +// } +// +// List newTaskNodeList = projectMapper.getTaskListByNodeIdList(allPerformanceList.stream().map(TaskNode::getTaskId).toList()); +// Map taskNodePoMap = Map.of(); +// if (CollectionUtils.isNotEmpty(newTaskNodeList)) { +// taskNodePoMap = newTaskNodeList.stream().collect(Collectors.groupingBy( +// TaskNodePo::getUuid, +// Collectors.collectingAndThen( +// Collectors.toList(), +// list -> list.get(0) +// ) +// )); +// } +// for (TaskNode taskNode : allPerformanceList) { +// if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId())) && ObjectUtils.isEmpty(taskNodeMap.get(taskNode.getTaskId()))) { +// log.error("taskNodeMap不空,根据taskId:{},未查询到任务", taskNode.getTaskId()); +// response = SdmResponse.failed("新增指标时,创建文件失败"); +// return response; +// } +// createDir(taskNode.getId(), +// ObjectUtils.isNotEmpty(taskNodePoMap.get(taskNode.getTaskId())) ? taskNodePoMap.get(taskNode.getTaskId()).getId() : taskNodeMap.get(taskNode.getTaskId()).getId(), +// taskNode.getNodeName()); +// } +// +// } +// if (CollectionUtils.isNotEmpty(allPerformanceExtraList)) { +// allPerformanceExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationPerformanceExtra(allPerformanceExtraList) <= 0) { +// response = SdmResponse.failed("新增任务指标附加属性失败"); +// return response; +// } +// } +// +// return response; +// } + + + private void createDir(String uuid, String parentUuid, String dirName) { + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setParentUuId(parentUuid); + createDirReq.setDirName(dirName); + log.info("下发任务调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataClientFeignClient.createDir(createDirReq); + log.info("下发任务调用创建文件夹的返回值为:{}", response); + } + +} + + + +package com.sdm.project.service.impl; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.common.common.ResultCode; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.common.entity.ExportExcelFormat; +import com.sdm.common.entity.bo.DataDictionary; +import com.sdm.common.entity.constants.TagConstant; +import com.sdm.common.entity.enums.DirTypeEnum; +import com.sdm.common.entity.enums.FilePermissionEnum; +import com.sdm.common.entity.enums.NodeTypeEnum; +import com.sdm.common.entity.req.data.*; +import com.sdm.common.entity.req.project.*; +import com.sdm.common.entity.req.system.QueryGroupDetailReq; +import com.sdm.common.entity.req.system.UserQueryReq; +import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; +import com.sdm.common.entity.resp.project.SimulationNodeResp; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.common.entity.resp.system.SysUserGroupDetailResp; +import com.sdm.common.feign.impl.data.DataClientFeignClientImpl; +import com.sdm.common.feign.impl.system.SysConfigFeignClientImpl; +import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; +import com.sdm.common.feign.inter.data.IDataFeignClient; +import com.sdm.common.log.CoreLogger; +import com.sdm.common.utils.DateUtils; +import com.sdm.common.utils.RandomUtil; +import com.sdm.common.utils.excel.ExcelUtil; +import com.sdm.project.dao.SimulationDemandMapper; +import com.sdm.project.dao.SimulationNodeMapper; +import com.sdm.project.dao.SimulationProjectMapper; +import com.sdm.project.model.bo.TaskExtraNode; +import com.sdm.project.model.bo.TaskNode; +import com.sdm.project.model.bo.TaskNodeTag; +import com.sdm.project.model.entity.SimulationNode; +import com.sdm.project.model.entity.SimulationRun; +import com.sdm.project.model.entity.SimulationTask; +import com.sdm.project.model.entity.SimulationTaskMember; +import com.sdm.project.model.po.PerformanceNodePo; +import com.sdm.project.model.po.ProjectNodePo; +import com.sdm.project.model.po.TaskNodePo; +import com.sdm.project.model.req.*; +import com.sdm.project.model.req.YA.SyncCidProjectReq; +import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; +import com.sdm.project.model.vo.*; +import com.sdm.project.service.*; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import javax.annotation.Resource; +import java.lang.reflect.Field; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class NodeServiceImpl extends ServiceImpl implements INodeService { + + @Resource + private SimulationNodeMapper nodeMapper; + + @Autowired + private SimulationProjectMapper mapper; + + @Autowired + private DataClientFeignClientImpl dataClientFeignClient; + + @Autowired + private ISimulationTaskService simulationTaskService; + + @Autowired + private ISimulationRunService simulationRunService; + + @Autowired + private ISimulationTaskMemberService simulationTaskMemberService; + + @Resource + private SimulationDemandMapper demandMapper; + + @Autowired + private SysUserFeignClientImpl sysUserFeignClient; + + @Autowired + IProjectService projectService; + + @Autowired + private IDataFeignClient dataFeignClient; + + @Autowired + private SysConfigFeignClientImpl sysConfigFeignClient; + + @Value("${node.batch.queryCounts:1000}") + private Integer queryCounts; + + private HashMap idMap = new HashMap<>(); + + @Autowired + private SimulationProjectMapper projectMapper; + + + @Transactional + @Override + public SdmResponse add(SpdmAddNodeReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + log.info("当前租户id为:{},工号为:{}", tenantId, jobNumber); + // 增 + List addNodeList = req.getAddNodeList(); + if (CollectionUtils.isEmpty(addNodeList)) { + return SdmResponse.failed("addNodeList不能为空!"); + } + for (SpdmProjectNodeEditReq addNode : addNodeList) { + // 项目/阶段名称重名校验 + if (CollectionUtils.isNotEmpty(this.lambdaQuery().eq(SimulationNode::getNodeName, addNode.getNodeName()).list())) { + if (NodeTypeEnum.PROJECT.getValue().equals(addNode.getNodeType())) { + return SdmResponse.failed("同名项目已存在,请检查"); + } + } + if (StringUtils.isNotBlank(addNode.getEndTime()) && StringUtils.isNotBlank(addNode.getBeginTime())) { + if (DateUtils.parse(addNode.getEndTime(), DateUtils.PATTERN_DEFAULT).before(DateUtils.parse(addNode.getBeginTime(), DateUtils.PATTERN_DEFAULT))) { + return SdmResponse.failed("计划结束时间不能早于计划开始时间"); + } + } + } + List tagMap = req.getTagMap(); + // 手动回滚数据 + addNodeList = addNode(addNodeList, tagMap, tenantId, jobNumber); + if (CollectionUtils.isEmpty(addNodeList)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("操作节点失败,原因:新增节点时失败!"); + } + for (SpdmProjectNodeEditReq addNode : addNodeList) { + // 更新文件权限 + Long userId = ThreadLocalContext.getUserId(); + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(userId); + updatePermissionReq.setUuid(addNode.getUuid()); + Map userPermissions = new HashMap<>(); + userPermissions.put(userId, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("创建项目阶段时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataFeignClient.updatePermission(updatePermissionReq); + log.info("创建项目阶段时,更新用户权限的返回值为:{}",updatePermissionResponse); + } + return SdmResponse.success(addNodeList); + } + + @Transactional + @Override + public SdmResponse edit(SpdmEditNodeReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + log.info("当前租户id为:{},jobNumber:{}", tenantId, jobNumber); + // 改 + List editNodeList = req.getEditNodeList(); + if (CollectionUtils.isNotEmpty(editNodeList)) { + for (SpdmNodeDetailReq editNode : editNodeList) { + // 项目/阶段名称重名校验 + if (CollectionUtils.isNotEmpty(this.lambdaQuery().eq(SimulationNode::getNodeName, editNode.getNodeName()).ne(SimulationNode::getUuid, editNode.getUuid()).list())) { + if (NodeTypeEnum.PROJECT.getValue().equals(editNode.getNodeType())) { + return SdmResponse.failed("同名项目已存在,请检查"); + } + } + if (StringUtils.isNotBlank(editNode.getEndTime()) && StringUtils.isNotBlank(editNode.getBeginTime())) { + if (DateUtils.parse(editNode.getEndTime(), DateUtils.PATTERN_DEFAULT).before(DateUtils.parse(editNode.getBeginTime(), DateUtils.PATTERN_DEFAULT))) { + return SdmResponse.failed("计划结束时间不能早于计划开始时间"); + } + } + renameDirNew(editNode.getUuid(),editNode.getNodeName()); + } + // 手动回滚数据 + if (!editNode(editNodeList, tenantId, jobNumber)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("操作节点失败,原因:更新节点时失败!"); + } + } + return SdmResponse.success(); + } + + @Transactional + @Override + public SdmResponse delete(SpdmDeleteNodeReq req) { + log.info("node delete参数:{}", req); + Long tenantId = ThreadLocalContext.getTenantId(); + log.info("当前租户id为:{}", tenantId); + // 删 + List deleteNodeIdList = req.getDeleteNodeIdList(); + if (CollectionUtils.isNotEmpty(deleteNodeIdList)) { + // 手动回滚数据 + if (!deleteNode(deleteNodeIdList)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("操作节点失败,原因:删除节点时失败!"); + } + deleteDirNew(deleteNodeIdList); + } + return SdmResponse.success(); + } + + // 删除文件夹 + public boolean deleteDirNew(List uuidList) { + for (String uuid : uuidList) { + DelDirReq req = new DelDirReq(); + req.setDelUuid(uuid); + log.info("调用删除文件夹的参数为:{}", req); + SdmResponse response = dataClientFeignClient.delDir(req); + log.info("调用删除文件夹的返回值为:{}", response); + if (response.getCode() != ResultCode.SUCCESS.getCode()) { + return false; + } + } + return true; + } + + + private boolean deleteNode(List deleteNodeIdList) { + List projectNodePoList = nodeMapper.allList(deleteNodeIdList); + if (CollectionUtils.isEmpty(projectNodePoList)) { + log.error("删除节点时,未查询到节点信息"); + return false; + } + // 删除当前节点及子节点信息 + if (nodeMapper.deleteNodeBatch(deleteNodeIdList) <= 0) { + return false; + } + // 删除当前节点及子节点的额外信息 + nodeMapper.deleteNodeExtraBatch(deleteNodeIdList); + // 删除当前节点及子节点的成员信息 + nodeMapper.deleteNodeMemberBatch(deleteNodeIdList); + // 删除当前节点及子节点下的分析项相关信息 + List taskNodePoList = nodeMapper.getTaskListByNodeIdList(deleteNodeIdList); + if (CollectionUtils.isEmpty(taskNodePoList)) { + return true; + } + nodeMapper.deleteTaskBatch(deleteNodeIdList); + List taskIdList = taskNodePoList.stream().map(TaskNodePo::getUuid).toList(); + nodeMapper.deleteTaskExtraBatch(taskIdList); + nodeMapper.deleteTaskMemberBatch(taskIdList); + // 删除当前节点及子节点下的指标相关信息 + List performanceNodePoList = nodeMapper.getPerformanceListByNodeIdList(taskIdList); + if (CollectionUtils.isEmpty(performanceNodePoList)) { + return true; + } + List performanceIdList = performanceNodePoList.stream().map(PerformanceNodePo::getId).toList(); + nodeMapper.deletePerformanceBatch(performanceIdList); + nodeMapper.deletePerformanceExtraBatch(performanceIdList); + List childrenNodeList = nodeMapper.getNodeListByNodeIdList(deleteNodeIdList); + if (CollectionUtils.isEmpty(childrenNodeList)) { + return true; + } + return deleteNode(childrenNodeList.stream().map(SpdmNodeVo::getUuid).toList()); + } + + @Override + public SdmResponse list(SpdmNodeListReq req) { + int pos = (req.getCurrent() - 1) * req.getSize(); + int limit = req.getSize(); + Long tenantId = ThreadLocalContext.getTenantId(); + List nodeList = nodeMapper.getNodeList(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), + tenantId, pos, limit); + CoreLogger.info("getNodeList param:{},tenantId:{}", JSONObject.toJSONString(req), tenantId); + if (CollectionUtils.isEmpty(nodeList)) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data", nodeList); + jsonObject.put("total", 0); + return SdmResponse.success(jsonObject); + } + int total = nodeMapper.getNodeListCount(req.getNodeType(), req.getNodeSubType(), req.getProgressStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), ThreadLocalContext.getTenantId()); + log.info("总数为:{}", total); + Integer progressStatus; + Integer achieveStatus; + // 查询节点的额外属性 + List nodeIdList = nodeList.stream().map(SpdmNodeVo::getUuid).toList(); + List spdmNodeMemberVoList = nodeMapper.getNodeMemberListByNodeIdList(nodeIdList); + if (CollectionUtils.isNotEmpty(spdmNodeMemberVoList)) { + List usewrIdList = spdmNodeMemberVoList.stream().map(SpdmNodeMemberVo::getUserId).distinct().toList(); + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(usewrIdList).build()); + List userList = cidUserResp.getData(); + + Map> userMap = Map.of(); + if (CollectionUtils.isNotEmpty(userList)) { + userMap = userList.stream().collect(Collectors.groupingBy(CIDUserResp::getUserId)); + } + String nodeId; + // 关联到节点上 + Map> nodeMemberMap = spdmNodeMemberVoList.stream().collect(Collectors.groupingBy(SpdmNodeMemberVo::getNodeId)); + for (Map.Entry> nodeMemberEntry : nodeMemberMap.entrySet()) { + List memberList = new ArrayList<>(); + nodeId = nodeMemberEntry.getKey(); + for (SpdmNodeVo spdmNodeVo : nodeList) { + if (nodeId.equals(spdmNodeVo.getUuid())) { + for (SpdmNodeMemberVo spdmNodeMemberVo : nodeMemberEntry.getValue()) { + if (CollectionUtils.isNotEmpty(userMap.get(spdmNodeMemberVo.getUserId()))) { + memberList.add(userMap.get(spdmNodeMemberVo.getUserId()).get(0)); + } + } + spdmNodeVo.setMemberList(memberList); + } + } + } + + + } + List spdmNodeExtraVoList = nodeMapper.getNodeExtraListByNodeIdList(nodeIdList); + if (CollectionUtils.isNotEmpty(spdmNodeExtraVoList)) { + String nodeId; + // 关联到节点上 + Map> nodeExtraMap = spdmNodeExtraVoList.stream().collect(Collectors.groupingBy(SpdmNodeExtraVo::getNodeId)); + for (Map.Entry> nodeExtraEntry : nodeExtraMap.entrySet()) { + nodeId = nodeExtraEntry.getKey(); + for (SpdmNodeVo spdmNodeVo : nodeList) { + if (nodeId.equals(spdmNodeVo.getUuid())) { + spdmNodeVo.setExtras(nodeExtraEntry.getValue()); + } + } + } + } + for (SpdmNodeVo spdmNodeVo : nodeList) { + // TODO 转换项目进度状态 + progressStatus = spdmNodeVo.getProgress(); + if (ObjectUtils.isNotEmpty(progressStatus)) { + switch (progressStatus) { + case 0: + spdmNodeVo.setProgressStatusValue("未开始"); + break; + case 1: + spdmNodeVo.setProgressStatusValue("进行中"); + break; + case 2: + spdmNodeVo.setProgressStatusValue("已完成"); + break; + default: + spdmNodeVo.setProgressStatusValue("未知"); + break; + } + } + // TODO 项目达成状态(红黄绿灯) + achieveStatus = spdmNodeVo.getAchieveStatus(); + if (ObjectUtils.isNotEmpty(achieveStatus)) { + switch (achieveStatus) { + case 1: + spdmNodeVo.setAchieveStatusValue("red"); + break; + case 2: + spdmNodeVo.setProgressStatusValue("yellow"); + break; + case 3: + spdmNodeVo.setProgressStatusValue("grey"); + break; + case 4: + spdmNodeVo.setProgressStatusValue("grey"); + break; + default: + spdmNodeVo.setProgressStatusValue("unknown"); + break; + } + } + Long creator = spdmNodeVo.getCreator(); + if (ObjectUtils.isNotEmpty(creator)) { + SdmResponse cidUserRespSdmResponse = sysUserFeignClient.queryUserDetail(UserQueryReq.builder().userId(creator).build()); + if (cidUserRespSdmResponse.isSuccess()) { + spdmNodeVo.setCreatorObj(cidUserRespSdmResponse.getData()); + } + } + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data", nodeList); + jsonObject.put("total", total); + return SdmResponse.success(jsonObject); + } + + + private List addNode(List addNodeList, List tagMap, Long tenantId, Long jobNumber) { + log.info("addNode参数为:{}", addNodeList); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + String nodeManagerList; + List allNodeManagerList = new ArrayList<>(); + List extraList; + List allExtraList = new ArrayList<>(); + List currentNodeList; + if (CollectionUtils.isNotEmpty(tagMap)) { + // {key: "project", value: "Tag1"}, {key: "phase", value: "Tag2"} + for (TaskNodeTag tagReq : tagMap) { + String currentNodeType = tagReq.getKey(); // project phase + log.info("当前nodeType为:{},tag为:{}", currentNodeType, tagReq.getValue()); + currentNodeList = addNodeList.stream().filter(node -> node.getNodeType().equals(currentNodeType)).toList(); // projectNodeList phaseNodeList + if (CollectionUtils.isEmpty(currentNodeList)) { + log.error("addNodeList中不存在{}类型的节点", currentNodeType); + continue; + } + List currentNodeIdList = new ArrayList<>(); + for (SpdmProjectNodeEditReq addNode : currentNodeList) { + // idMap = {"tag1": "uuid1,uuid2", "tag2": "uuid3"} + if (MapUtils.isNotEmpty(idMap)) { + for (Map.Entry entry : idMap.entrySet()) { + // 之前的tag + // preTag = entry.getKey() = "tag1" + String preTag = entry.getKey(); + log.info("preTag为:{}", preTag); + try { + // entry.getValue() = "uuid1,uuid2" + setTagProperty(addNode, preTag, entry.getValue()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + addNode.setUuid(RandomUtil.generateString(32)); + // 设置 当前节点所属项目根节点uuid + // addNode.getPid()为空时,在创建项目,ownRootNodeUuid就是addNode本身uuid + // addNode.getPid()不为空时,在创建阶段,ownRootNodeUuid就是入参的pid父节点 + addNode.setOwnRootNodeUuid(ObjectUtils.isEmpty(addNode.getPid()) ? addNode.getUuid() : addNode.getPid()); + addNode.setCreateTime(curDateStr); + addNode.setCreator(jobNumber); + addNode.setTenantId(tenantId); + try { + // tagReq.getValue()="Tag1" + setTagProperty(addNode, tagReq.getValue(), addNode.getUuid()); + } catch (Exception e) { + throw new RuntimeException(e); + } + currentNodeIdList.add(addNode.getUuid()); + nodeManagerList = addNode.getMemberList(); + if (StringUtils.isNoneBlank(nodeManagerList)) { + for (String userId : nodeManagerList.split(",")) { + SpdmNodeRelateMemberReq spdmNodeRelateMemberReq = new SpdmNodeRelateMemberReq(); + spdmNodeRelateMemberReq.setNodeId(addNode.getUuid()); + spdmNodeRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmNodeRelateMemberReq.setCreateTime(curDateStr); + spdmNodeRelateMemberReq.setCreator(jobNumber); + allNodeManagerList.add(spdmNodeRelateMemberReq); + } + } + extraList = addNode.getExtras(); + if (CollectionUtils.isNotEmpty(extraList)) { + extraList.forEach(extra -> { + extra.setNodeId(addNode.getUuid()); + extra.setCreateTime(curDateStr); + extra.setCreator(jobNumber); + }); + allExtraList.addAll(extraList); + } + } + // tagReq.getValue()= "tag1" "tag2" + idMap.put(tagReq.getValue(), String.join(",", currentNodeIdList)); + } + } + + if (nodeMapper.addNodeBatch(addNodeList) <= 0) { + return null; + } + Optional projectOptional = addNodeList.stream().filter(node -> NodeTypeEnum.PROJECT.getValue().equals(node.getNodeType())).findFirst(); + if (projectOptional.isPresent()) { + SpdmProjectNodeEditReq projectNode = projectOptional.get(); + // 创建项目节点的文件夹 + createDir(projectNode.getUuid(), projectNode.getNodeType(), null, projectNode.getNodeName()); + } else { + List projectNodePoList = mapper.queryNodeListByNodeId(addNodeList.get(0).getPid()); + if (CollectionUtils.isEmpty(projectNodePoList)) { + log.error("根据nodeId:{},未查询到项目节点", addNodeList.get(0).getPid()); + return null; + } + ProjectNodePo projectNodePo = projectNodePoList.get(0); + String projectUuid = projectNodePo.getUuid(); + for (SpdmProjectNodeEditReq node : addNodeList) { + createDir(node.getUuid(), node.getNodeType(), projectUuid, node.getNodeName()); + } + } + if (CollectionUtils.isNotEmpty(allNodeManagerList) && nodeMapper.addNodeMemberBatch(allNodeManagerList) <= 0) { + return null; + } + if (CollectionUtils.isNotEmpty(allExtraList) && nodeMapper.addNodeExtraBatch(allExtraList) <= 0) { + return null; + } + addNodeList.forEach(addNode -> addNode.setPid(addNode.getUuid())); + return addNodeList; + } + + private boolean editNode(List editNodeList, Long tenantId, Long jobNumber) { + log.info("editNode参数为:{}", editNodeList); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + String nodeManagerList; + List allNodeManagerList = new ArrayList<>(); + List extraList; + List allExtraList = new ArrayList<>(); + for (SpdmNodeDetailReq editNode : editNodeList) { + editNode.setUpdateTime(curDateStr); + editNode.setUpdater(jobNumber); + nodeManagerList = editNode.getMemberList(); + if (StringUtils.isNoneBlank(nodeManagerList)) { + for (String userId : nodeManagerList.split(",")) { + SpdmNodeRelateMemberReq spdmNodeRelateMemberReq = new SpdmNodeRelateMemberReq(); + spdmNodeRelateMemberReq.setNodeId(editNode.getUuid()); + spdmNodeRelateMemberReq.setUserId(Long.valueOf(userId)); + spdmNodeRelateMemberReq.setCreateTime(curDateStr); + spdmNodeRelateMemberReq.setCreator(jobNumber); + allNodeManagerList.add(spdmNodeRelateMemberReq); + } + } + extraList = editNode.getExtraList(); + if (CollectionUtils.isNotEmpty(extraList)) { + extraList.forEach(extra -> { + extra.setUpdateTime(curDateStr); + extra.setUpdater(jobNumber); + }); + allExtraList.addAll(extraList); + } + } + + for (SpdmNodeDetailReq editNode : editNodeList) { + if (nodeMapper.editNode(editNode) <= 0) { + return false; + } + } + + // 先删除所有成员 + nodeMapper.deleteNodeMemberBatch(editNodeList.stream().map(SpdmNodeDetailReq::getUuid).toList()); + + if (CollectionUtils.isNotEmpty(allNodeManagerList)) { + allNodeManagerList.forEach(node -> { + node.setCreateTime(curDateStr); + node.setCreator(jobNumber); + }); + if (nodeMapper.addNodeMemberBatch(allNodeManagerList) <= 0) { + return false; + } + } + + if (CollectionUtils.isNotEmpty(allExtraList)) { + for (SpdmNodeExtraReq nodeExtra : allExtraList) { + if (nodeMapper.editNodeExtra(nodeExtra) <= 0) { + return false; + } + } + } + + return true; + } + + @Override + public SdmResponse getNodeDetail(GetProjectDetailReq req) { + log.info("项目详情参数为:{}", req); + SpdmNodeVo projectNode = nodeMapper.getNodeById(req.getProjectNodeId()); + if (ObjectUtils.isEmpty(projectNode)) { + log.error("根据节点id:{},未查询到项目节点!", req.getProjectNodeId()); + return SdmResponse.failed("根据节点id未查询到项目节点!"); + } + Integer progressStatus; + Integer achieveStatus; + // 查询节点的额外属性 + + List spdmNodeMemberVoList = nodeMapper.getNodeMemberListByNodeIdList(Collections.singletonList(projectNode.getUuid())); + if (CollectionUtils.isNotEmpty(spdmNodeMemberVoList)) { + List usewrIdList = spdmNodeMemberVoList.stream().map(SpdmNodeMemberVo::getUserId).distinct().toList(); + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(usewrIdList).build()); + List userList = cidUserResp.getData(); + + Map> userMap = Map.of(); + if (CollectionUtils.isNotEmpty(userList)) { + userMap = userList.stream().collect(Collectors.groupingBy(CIDUserResp::getUserId)); + } + List memberList = new ArrayList<>(); + for (SpdmNodeMemberVo spdmNodeMemberVo : spdmNodeMemberVoList) { + if (CollectionUtils.isNotEmpty(userMap.get(spdmNodeMemberVo.getUserId()))) { + memberList.add(userMap.get(spdmNodeMemberVo.getUserId()).get(0)); + } + } + projectNode.setMemberList(memberList); + } + List spdmNodeExtraVoList = nodeMapper.getNodeExtraListByNodeIdList(Collections.singletonList(projectNode.getUuid())); + if (CollectionUtils.isNotEmpty(spdmNodeExtraVoList)) { + projectNode.setExtraList(spdmNodeExtraVoList); + } + // TODO 转换项目进度状态 + progressStatus = projectNode.getProgress(); + if (ObjectUtils.isNotEmpty(progressStatus)) { + switch (progressStatus) { + case 0: + projectNode.setProgressStatusValue("未开始"); + break; + case 1: + projectNode.setProgressStatusValue("进行中"); + break; + case 2: + projectNode.setProgressStatusValue("已完成"); + break; + default: + projectNode.setProgressStatusValue("未知"); + break; + } + } + // TODO 项目达成状态(红黄绿灯) + achieveStatus = projectNode.getAchieveStatus(); + if (ObjectUtils.isNotEmpty(achieveStatus)) { + switch (achieveStatus) { + case 1: + projectNode.setAchieveStatusValue("red"); + break; + case 2: + projectNode.setProgressStatusValue("yellow"); + break; + case 3: + projectNode.setProgressStatusValue("grey"); + break; + case 4: + projectNode.setProgressStatusValue("grey"); + break; + default: + projectNode.setProgressStatusValue("unknown"); + break; + } + } + // 创建人要返回对象 + Long creator = projectNode.getCreator(); + if (ObjectUtils.isNotEmpty(creator)) { + SdmResponse cidUserRespSdmResponse = sysUserFeignClient.queryUserDetail(UserQueryReq.builder().userId(creator).build()); + if (cidUserRespSdmResponse.isSuccess()) { + projectNode.setCreatorObj(cidUserRespSdmResponse.getData()); + } + } + SpdmNodeDetailVo spdmNodeDetailVo = new SpdmNodeDetailVo(); + BeanUtils.copyProperties(projectNode, spdmNodeDetailVo); + // 设置当前阶段 + String uuid = spdmNodeDetailVo.getUuid(); + List phaseNodeList = this.lambdaQuery().eq(SimulationNode::getParentId, uuid).eq(SimulationNode::getNodeType, NodeTypeEnum.PHASE.getValue()).list(); + if (CollectionUtils.isEmpty(phaseNodeList)) { + return SdmResponse.success(spdmNodeDetailVo); + } + phaseNodeList = phaseNodeList.stream().filter(phaseNode -> StringUtils.isNotBlank(phaseNode.getBeginTime()) && StringUtils.isNotBlank(phaseNode.getEndTime())).toList(); + if (CollectionUtils.isEmpty(phaseNodeList)) { + return SdmResponse.success(spdmNodeDetailVo); + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + phaseNodeList = phaseNodeList.stream().sorted(Comparator.comparingLong(phaseNode -> { + try { + return sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + })).toList(); + Long currentTime = System.currentTimeMillis(); + SimulationNode currentPhaseNode = null; + for (SimulationNode simulationNode : phaseNodeList) { + try { + if (currentTime >= sdf.parse(simulationNode.getBeginTime()).getTime() && currentTime <= sdf.parse(simulationNode.getEndTime()).getTime()) { + currentPhaseNode = simulationNode; + } + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + if (ObjectUtils.isNotEmpty(currentPhaseNode)) { + spdmNodeDetailVo.setCurrentPhase(currentPhaseNode.getNodeName()); + return SdmResponse.success(spdmNodeDetailVo); + } + + // 开始时间比当前时间小的里面的最大的一个 + List bigPhaseNodeList = phaseNodeList.stream().filter(phaseNode -> { + try { + return currentTime <= sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + }).toList(); + if (CollectionUtils.isEmpty(bigPhaseNodeList)) { + SimulationNode simulationNode = phaseNodeList.stream().max(Comparator.comparingLong(phaseNode -> { + try { + return sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + })).get(); + spdmNodeDetailVo.setCurrentPhase(simulationNode.getNodeName()); + return SdmResponse.success(spdmNodeDetailVo); + } + SimulationNode simulationNode = phaseNodeList.stream().min(Comparator.comparingLong(phaseNode -> { + try { + return sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + })).get(); + spdmNodeDetailVo.setCurrentPhase(simulationNode.getNodeName()); + return SdmResponse.success(spdmNodeDetailVo); + } + + @Override + public SdmResponse getProjectMemberList(GetProjectListReq req) { + JSONObject jsonObject = new JSONObject(); + String projectNodeId = req.getProjectNodeId(); + SpdmNodeVo spdmNodeVo = nodeMapper.getNodeById(projectNodeId); + if (ObjectUtils.isEmpty(spdmNodeVo)) { + log.error("根据projectNodeId:{},未查询到团队成员", projectNodeId); + jsonObject.put("data", new ArrayList()); + return SdmResponse.success(jsonObject); + } + List allNodeIdList = new ArrayList<>(); + allNodeIdList.add(spdmNodeVo.getUuid()); + recursionAllNodeIdList(Collections.singletonList(spdmNodeVo.getUuid()), allNodeIdList); + List spdmNodeMemberVoList = nodeMapper.getNodeMemberListByNodeIdList(allNodeIdList); + if (CollectionUtils.isEmpty(spdmNodeMemberVoList)) { + log.error("allNodeIdList:{},未查询到团队成员", allNodeIdList); + jsonObject.put("data", new ArrayList()); + return SdmResponse.success(jsonObject); + } + List userIdList = spdmNodeMemberVoList.stream().map(SpdmNodeMemberVo::getUserId).distinct().collect(Collectors.toList()); + ; + + // 查询node节点下的task的成员(仿真负责人和执行人) + List taskList = simulationTaskService.lambdaQuery().in(SimulationTask::getNodeId, allNodeIdList).list(); + if (CollectionUtils.isNotEmpty(taskList)) { + List taskMemberList = simulationTaskMemberService.lambdaQuery().in(SimulationTaskMember::getTaskId, taskList.stream().map(SimulationTask::getUuid).toList()).list(); + if (CollectionUtils.isNotEmpty(taskMemberList)) { + userIdList.addAll(taskMemberList.stream().map(SimulationTaskMember::getUserId).distinct().toList()); + } + } + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build()); + List userList = cidUserResp.getData(); + if (CollectionUtils.isEmpty(userList)) { + log.error("getProjectMemberList未查询到用户"); + jsonObject.put("data", new ArrayList()); + return SdmResponse.success(jsonObject); + } + jsonObject.put("data", userList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList()); + return SdmResponse.success(jsonObject); + } + + private void recursionAllNodeIdList(List currentNodeIdList, List allNodeIdList) { + List spdmNodeVoList = nodeMapper.getNodeListByNodeIdList(currentNodeIdList); + if (CollectionUtils.isEmpty(spdmNodeVoList)) { + return; + } + List addNodeIdList = spdmNodeVoList.stream().map(SpdmNodeVo::getUuid).toList(); + allNodeIdList.addAll(addNodeIdList); + recursionAllNodeIdList(addNodeIdList, allNodeIdList); + } + + @Override + public SdmResponse getChildrenNodeList(List nodeIdList, String nodeType) { + log.info("getChildrenNodeList,nodeIdList:{},nodeType:{}", nodeIdList, nodeType); + List projectNodePoList = mapper.queryNodeListByParentNodeId(nodeIdList); + if (CollectionUtils.isEmpty(projectNodePoList)) { + return SdmResponse.success(new ArrayList<>()); + } + // 兼容处理cid同步的数据 + List dirtyProjectNodeList = projectNodePoList.stream().filter(projectNode -> projectNode.getUuid().equals(projectNode.getParentId())).toList(); + if (CollectionUtils.isNotEmpty(dirtyProjectNodeList)) { + log.error("以下节点id:{},的uuid和parentId相同,需要处理",dirtyProjectNodeList.stream().map(ProjectNodePo::getUuid).collect(Collectors.joining(","))); + return SdmResponse.failed("节点:" + dirtyProjectNodeList.stream().map(ProjectNodePo::getNodeName).collect(Collectors.joining(",")) + "的数据有误,需要处理"); + } + log.info("getChildrenNodeList为:{}",projectNodePoList); + List returnProjectNodeList = projectNodePoList.stream().filter(projectNode -> nodeType.equals(projectNode.getNodeType())).toList(); + if (CollectionUtils.isNotEmpty(returnProjectNodeList)) { + return SdmResponse.success(returnProjectNodeList); + } + return getChildrenNodeList(projectNodePoList.stream().map(ProjectNodePo::getUuid).toList(), nodeType); + } + + /** + * 创建文件夹 + * + * @param uuid 待创建节点uuid + * @param uuidOwnType 待创建节点类型:node,task,run,performance + * @param parentUuid 父节点uuid + * @param dirName 待长江文件夹名称 + */ + private SdmResponse createDir(String uuid, String uuidOwnType, String parentUuid, String dirName) { + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setUuIdOwnType(uuidOwnType); + createDirReq.setParentUuId(ObjectUtils.isNotEmpty(parentUuid) ? parentUuid : null); + createDirReq.setDirName(dirName); + createDirReq.setDirType(DirTypeEnum.PROJECT_NODE_DIR.getValue()); + log.info("创建项目阶段时,调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataClientFeignClient.createDir(createDirReq); + log.info("创建项目阶段时,调用创建文件夹的返回值为:{}", response); + return response; + } + + + @Override + public SdmResponse> getAllNodeByBodeType(String nodeType, Long nodeId) { + try { + List allNodeByProjectIdAndTypeRespList = new ArrayList<>(); + List nodeList = this.lambdaQuery() + .eq(ObjectUtils.isNotEmpty(nodeId), SimulationNode::getId, nodeId) + .eq(ObjectUtils.isNotEmpty(nodeType), SimulationNode::getNodeType, nodeType) + .orderByDesc(SimulationNode::getCreateTime) + .list(); + if (CollectionUtils.isEmpty(nodeList)) { + return SdmResponse.failed("未找到节点"); + } + + nodeList.forEach(simulationNode -> { + AllNodeByProjectIdAndTypeResp allNodeByProjectIdAndTypeResp = new AllNodeByProjectIdAndTypeResp(); + BeanUtils.copyProperties(simulationNode, allNodeByProjectIdAndTypeResp); + allNodeByProjectIdAndTypeResp.setId(simulationNode.getId().longValue()); + allNodeByProjectIdAndTypeRespList.add(allNodeByProjectIdAndTypeResp); + }); + + return SdmResponse.success(allNodeByProjectIdAndTypeRespList); + } catch (Exception e) { + return SdmResponse.failed(e.getMessage()); + } + } + + @Override + public SdmResponse> getAllNodeByProjectIdAndType(String uuid, String nextNodeType) { + SdmResponse> tagMapList = sysConfigFeignClient.getDictionaryData(TagConstant.DICTIONARY_TAG_KEY); + if (!tagMapList.isSuccess() || ObjectUtils.isEmpty(tagMapList.getData())) { + log.error("字典信息查询失败"); + return SdmResponse.success(); + } + // project-->tag1 phase-->tag2 + Map TagMap = tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName)); + + Optional simulationNodeOptional = this.lambdaQuery().eq(SimulationNode::getUuid, uuid).oneOpt(); + if (!simulationNodeOptional.isPresent()) { + return SdmResponse.failed("未找到节点"); + } + + SimulationNode currentNode = simulationNodeOptional.get(); + String currentNodeType = currentNode.getNodeType(); + String currentNodeTag = TagMap.get(currentNodeType); + + List simulationNodeList = this.lambdaQuery() + .eq(TagConstant.TAG1.equals(currentNodeTag), SimulationNode::getTag1, uuid) + .eq(TagConstant.TAG2.equals(currentNodeTag), SimulationNode::getTag2, uuid) + .eq(TagConstant.TAG3.equals(currentNodeTag), SimulationNode::getTag3, uuid) + .eq(TagConstant.TAG4.equals(currentNodeTag), SimulationNode::getTag4, uuid) + .eq(TagConstant.TAG5.equals(currentNodeTag), SimulationNode::getTag5, uuid) + .eq(TagConstant.TAG6.equals(currentNodeTag), SimulationNode::getTag6, uuid) + .eq(TagConstant.TAG7.equals(currentNodeTag), SimulationNode::getTag7, uuid) + .eq(TagConstant.TAG8.equals(currentNodeTag), SimulationNode::getTag8, uuid) + .eq(TagConstant.TAG9.equals(currentNodeTag), SimulationNode::getTag9, uuid) + .eq(TagConstant.TAG10.equals(currentNodeTag), SimulationNode::getTag10, uuid) + .eq(SimulationNode::getNodeType, nextNodeType) + .list(); + + if (CollectionUtils.isEmpty(simulationNodeList)) { + return SdmResponse.success(); + } + List allNodeByProjectIdAndTypeRespList = new ArrayList<>(); + simulationNodeList.forEach(simulationNode -> { + AllNodeByProjectIdAndTypeResp allNodeByProjectIdAndTypeResp = new AllNodeByProjectIdAndTypeResp(); + BeanUtils.copyProperties(simulationNode, allNodeByProjectIdAndTypeResp); + allNodeByProjectIdAndTypeResp.setId(simulationNode.getId().longValue()); + allNodeByProjectIdAndTypeRespList.add(allNodeByProjectIdAndTypeResp); + }); + + return SdmResponse.success(allNodeByProjectIdAndTypeRespList); + } + + @Override + public SdmResponse> getNodeTaskList(String uuid) { + if(ObjectUtils.isEmpty(uuid)){ + return SdmResponse.success(); + } + List simulationTasks = simulationTaskService.lambdaQuery().eq(SimulationTask::getNodeId, uuid).list(); + if(CollectionUtils.isEmpty(simulationTasks)){ + return SdmResponse.success(); + } + List allNodeByProjectIdAndTypeRespList = new ArrayList<>(); + simulationTasks.forEach(simulationTask -> { + AllNodeByProjectIdAndTypeResp allNodeByProjectIdAndTypeResp = new AllNodeByProjectIdAndTypeResp(); + allNodeByProjectIdAndTypeResp.setId(simulationTask.getId().longValue()); + allNodeByProjectIdAndTypeResp.setUuid(simulationTask.getUuid()); + allNodeByProjectIdAndTypeResp.setNodeName(simulationTask.getTaskName()); + allNodeByProjectIdAndTypeResp.setNodeType(NodeTypeEnum.TASK.getValue()); + allNodeByProjectIdAndTypeRespList.add(allNodeByProjectIdAndTypeResp); + }); + + return SdmResponse.success(allNodeByProjectIdAndTypeRespList); + } + + @Override + public SdmResponse> getTaskRunList(String uuid) { + if(ObjectUtils.isEmpty(uuid)){ + return SdmResponse.success(); + } + List simulationRunList = simulationRunService.lambdaQuery().eq(SimulationRun::getTaskId, uuid).list(); + if(CollectionUtils.isEmpty(simulationRunList)){ + return SdmResponse.success(); + } + List allNodeByProjectIdAndTypeRespList = new ArrayList<>(); + simulationRunList.forEach(simulationRun -> { + AllNodeByProjectIdAndTypeResp allNodeByProjectIdAndTypeResp = new AllNodeByProjectIdAndTypeResp(); + allNodeByProjectIdAndTypeResp.setId(simulationRun.getId().longValue()); + allNodeByProjectIdAndTypeResp.setUuid(simulationRun.getUuid()); + allNodeByProjectIdAndTypeResp.setNodeName(simulationRun.getRunName()); + allNodeByProjectIdAndTypeResp.setNodeType(NodeTypeEnum.RUN.getValue()); + allNodeByProjectIdAndTypeRespList.add(allNodeByProjectIdAndTypeResp); + }); + return SdmResponse.success(allNodeByProjectIdAndTypeRespList); + } + + public static void setTagProperty(Object obj, String propertyName, Object value) throws Exception { + Class clazz = obj.getClass(); + Field field = clazz.getDeclaredField(propertyName); + field.setAccessible(true); + field.set(obj, value); + field.setAccessible(false); + } + + public static String getTagProperty(Object obj, String propertyName) throws Exception { + Class clazz = obj.getClass(); + Field field = clazz.getDeclaredField(propertyName); + field.setAccessible(true); + return (String) field.get(obj); + } + + public static List getTagListProperty(Object obj, String propertyName) throws Exception { + Class clazz = obj.getClass(); + Field field = clazz.getDeclaredField(propertyName); + field.setAccessible(true); + return (List) field.get(obj); + } + + @Override + public SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId) { + Map userId2Nickname = getUserIdToNicknameMap(userGroupId); + if (MapUtils.isEmpty(userId2Nickname)) { + return SdmResponse.success(); + } + + Set userIds = new HashSet<>(); + if (ObjectUtils.isEmpty(userId)) { + userIds = userId2Nickname.keySet(); + }else { + userIds.add(userId); + } + + List userGroupProjectStatistics = this.baseMapper.getUserGroupProjectStatistics(userIds); + if (CollectionUtils.isEmpty(userGroupProjectStatistics)) { + return SdmResponse.success(new ArrayList<>()); + } + + // 按用户ID统计项目数量 + Map userProjectCountMap = new HashMap<>(); + for (UserGroupProjectVo vo : userGroupProjectStatistics) { + Long userIdKey = vo.getUserId(); + userProjectCountMap.put(userIdKey, userProjectCountMap.getOrDefault(userIdKey, 0) + 1); + + } + + // 转换为List>格式,便于前端展示 + List> userResult = new ArrayList<>(); + // 添加用户项目统计 + for (Map.Entry entry : userProjectCountMap.entrySet()) { + Map item = new HashMap<>(); + item.put("userId", entry.getKey()); + item.put("userName", userId2Nickname.get(entry.getKey())); + item.put("projectCount", entry.getValue()); + userResult.add(item); + } + return SdmResponse.success(userResult); + } + + /** + * 获取用户组内用户ID到昵称的映射 + * + * @param userGroupId 用户组ID + * @return 用户ID到昵称的映射 + */ + private Map getUserIdToNicknameMap(Long userGroupId) { + QueryGroupDetailReq req = new QueryGroupDetailReq(); + req.setCurrent(1); + req.setSize(1000); + req.setId(userGroupId); + req.setTenantId(ThreadLocalContext.getTenantId()); + SdmResponse sysUserGroupDetailRespSdmResponse = sysUserFeignClient.queryGroupDetail(req); + if (!sysUserGroupDetailRespSdmResponse.isSuccess() + || ObjectUtils.isEmpty(sysUserGroupDetailRespSdmResponse.getData()) + || ObjectUtils.isEmpty(sysUserGroupDetailRespSdmResponse.getData().getUsers()) + || ObjectUtils.isEmpty(sysUserGroupDetailRespSdmResponse.getData().getUsers().getData())) { + return Collections.emptyMap(); + } + return sysUserGroupDetailRespSdmResponse.getData().getUsers().getData().stream().collect(Collectors.toMap(CIDUserResp::getUserId, CIDUserResp::getNickname)); + } + + @Override + public SdmResponse getUserGroupTaskCompleteStatistics(GetUserGroupTaskCompleteStatisticsReq req) { + Map userId2Nickname = getUserIdToNicknameMap(req.getUserGroupId()); + if (MapUtils.isEmpty(userId2Nickname)) { + return SdmResponse.success(); + } + + // 设置用户ID列表 + Set userIds = new HashSet<>(); + if (ObjectUtils.isEmpty(req.getUserId())) { + userIds = userId2Nickname.keySet(); + } else { + userIds.add(req.getUserId()); + } + + req.setUserIds(userIds); + + List userGroupTaskCompleteStatistics = this.baseMapper.getUserGroupTaskCompleteStatistics(req); + + // 按用户分组统计任务状态 + Map userStatisticsMap = new HashMap<>(); + + // 所有任务执行状态 + Set allExeStatus = new HashSet<>(); + // 统计每个用户的各种状态任务数量 + for (UserGroupTaskCompleteVo item : userGroupTaskCompleteStatistics) { + Long userId = item.getUserId(); + String exeStatus = item.getExeStatus(); + + allExeStatus.add(exeStatus); + + UserGroupTaskCompleteStatisticsVo userStat = userStatisticsMap.getOrDefault(userId, new UserGroupTaskCompleteStatisticsVo()); + userStat.setUserId(userId); + userStat.setUserName(userId2Nickname.getOrDefault(userId, "Unknown User")); + + Map statusCount = userStat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + userStat.setStatusCount(statusCount); + } + + statusCount.put(exeStatus, statusCount.getOrDefault(exeStatus, 0) + 1); + userStat.setTotalTasks(userStat.getTotalTasks() == null ? 1 : userStat.getTotalTasks() + 1); + + userStatisticsMap.put(userId, userStat); + } + + // 转换为列表返回 + List result = new ArrayList<>(userStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", result); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse getUserGroupDifficultyStatistics(GetUserGroupTaskCompleteStatisticsReq req) { + Map userId2Nickname = getUserIdToNicknameMap(req.getUserGroupId()); + if (MapUtils.isEmpty(userId2Nickname)) { + return SdmResponse.success(); + } + + // 设置用户ID列表 + Set userIds = new HashSet<>(); + if (ObjectUtils.isEmpty(req.getUserId())) { + userIds = userId2Nickname.keySet(); + } else { + userIds.add(req.getUserId()); + } + req.setUserIds(userIds); + + List userGroupDifficultyStatistics = this.baseMapper.getUserGroupDifficultyStatistics(req); + + // 按用户分组统计任务状态 + Map userStatisticsMap = new HashMap<>(); + + // 所有难度值 + Set alldifficultyValue = new HashSet<>(); + + // 统计每个用户的各种状态任务数量 + for (UserGroupDifficultyVo item : userGroupDifficultyStatistics) { + Long userId = item.getUserId(); + Float difficulty = item.getDifficult(); + alldifficultyValue.add(difficulty); + + UserGroupDifficultyStatisticsVo userStat = userStatisticsMap.getOrDefault(userId, new UserGroupDifficultyStatisticsVo()); + userStat.setUserId(userId); + userStat.setUserName(userId2Nickname.getOrDefault(userId, "Unknown User")); + + Map statusCount = userStat.getDifficultyCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + userStat.setDifficultyCount(statusCount); + } + + statusCount.put(difficulty, statusCount.getOrDefault(difficulty, 0) + 1); + userStat.setTotalTasks(userStat.getTotalTasks() == null ? 1 : userStat.getTotalTasks() + 1); + + userStatisticsMap.put(userId, userStat); + } + + // 转换为列表返回 + List result = new ArrayList<>(userStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("alldifficultyValue", alldifficultyValue); + resultResponse.put("result", result); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse getCommonCompleteStatistics(CommonGetCompleteStatisticsReq req) { + // 所有任务执行状态 + Set allExeStatus = new HashSet<>(); + + if (NodeTypeEnum.TASK.getValue().equals(req.getQueryType())) { + // 处理任务完成情况统计 + List commonCompleteStatisticsFromTask = this.baseMapper.getCommonCompleteStatisticsFromTask(req); + + // 按tag分组统计任务状态 + Map taskStatisticsMap = new HashMap<>(); + + // 统计每个tag的各种状态任务数量 + for (CommonGetCompleteFromTaskVo item : commonCompleteStatisticsFromTask) { + String name = item.getNodeName(); + + CommonStatisticsVo stat = taskStatisticsMap.getOrDefault(name, new CommonStatisticsVo()); + stat.setName(name); + + Map statusCount = stat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + stat.setStatusCount(statusCount); + } + + String exeStatus = item.getExeStatus(); + allExeStatus.add(exeStatus); + statusCount.put(exeStatus, statusCount.getOrDefault(exeStatus, 0) + 1); + taskStatisticsMap.put(name, stat); + } + + // 转换为列表返回 + List taskResult = new ArrayList<>(taskStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", taskResult); + return SdmResponse.success(resultResponse); + } else if (NodeTypeEnum.PERFORMANCE.getValue().equals(req.getQueryType())) { + // 处理指标完成情况统计 + List commonCompleteStatisticsFromPerformance = this.baseMapper.getCommonCompleteStatisticsFromPerformance(req); + + // 按tag分组统计指标状态 + Map performanceStatisticsMap = new HashMap<>(); + + // 统计每个tag的各种状态指标数量 + for (CommonGetCompleteFromPerformanceVo item : commonCompleteStatisticsFromPerformance) { + String nodeName = item.getNodeName(); + + CommonStatisticsVo stat = performanceStatisticsMap.getOrDefault(nodeName, new CommonStatisticsVo()); + stat.setName(nodeName); + + Map statusCount = stat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + stat.setStatusCount(statusCount); + } + + String completeStatus = item.getCompleteStatus(); + allExeStatus.add(completeStatus); + statusCount.put(completeStatus, statusCount.getOrDefault(completeStatus, 0) + 1); + + performanceStatisticsMap.put(nodeName, stat); + } + + // 转换为列表返回 + List performanceResult = new ArrayList<>(performanceStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", performanceResult); + return SdmResponse.success(resultResponse); + } + return SdmResponse.success(new ArrayList<>()); + } + + @Override + public SdmResponse getWorkstationReviewStatistics(GetWorkstationApproveStatusReq req) { + List workstationApproveStatus = this.baseMapper.getWorkstationApproveStatus(req); + + // 按tag分组统计审批状态 + Map reviewStatisticsMap = new HashMap<>(); + + // 所有审批状态 + Set allApprovalStatus = new HashSet<>(); + + // 统计每个tag的各种审批状态数量 + for (WorkstationApproveStatusVo item : workstationApproveStatus) { + String nodeName = item.getNodeName(); + + CommonStatisticsVo stat = reviewStatisticsMap.getOrDefault(nodeName, new CommonStatisticsVo()); + stat.setName(nodeName); + + Map statusCount = stat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + stat.setStatusCount(statusCount); + } + + String approvalStatus = item.getApprovalStatus(); + allApprovalStatus.add(approvalStatus); + statusCount.put(approvalStatus, statusCount.getOrDefault(approvalStatus, 0) + 1); + reviewStatisticsMap.put(nodeName, stat); + } + + // 转换为列表返回 + List result = new ArrayList<>(reviewStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allApprovalStatus", allApprovalStatus); + resultResponse.put("result", result); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse renameNode(RenameNodeReq req) { + if (NodeTypeEnum.TASK.getValue().equals(req.getUuidOwnType())) { + simulationTaskService.lambdaUpdate() + .set(SimulationTask::getTaskName, req.getNewName()) + .eq(SimulationTask::getUuid, req.getUuid()) + .update(); + } else if (NodeTypeEnum.RUN.getValue().equals(req.getUuidOwnType())) { + simulationRunService.lambdaUpdate() + .set(SimulationRun::getRunName, req.getNewName()) + .eq(SimulationRun::getUuid, req.getUuid()) + .update(); + } else { + this.lambdaUpdate() + .set(SimulationNode::getNodeName, req.getNewName()) + .eq(SimulationNode::getUuid, req.getUuid()) + .update(); + } + return SdmResponse.success(); + } + + @Override + public SdmResponse delteNode(DelNodeReq req) { + log.info("开始删除节点: {}", req); + SpdmDeleteProjectDetailReq deleteNode = new SpdmDeleteProjectDetailReq(); + deleteNode.setNodeType(req.getUuidOwnType()); + deleteNode.setUuid(req.getUuid()); + + List deleteNodeList = new ArrayList<>(); + deleteNodeList.add(deleteNode); + + SpdmDeleteProjectReq spdmDeleteProjectReq = new SpdmDeleteProjectReq(); + spdmDeleteProjectReq.setDeleteNodeList(deleteNodeList); + + projectService.delete(spdmDeleteProjectReq); + return SdmResponse.success(); + } + + @Override + public SdmResponse uploadProjectFiles(UploadFilesReq req) { + return dataFeignClient.uploadFiles(req); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SdmResponse addNodeForData(SpdmAddNodeReq req) { + log.info("addNodeForData参数为:{}",req); + Map tagMap = req.getTagMap().stream().collect(Collectors.groupingBy( + TaskNodeTag::getKey, + Collectors.collectingAndThen( + Collectors.toList(), + tagList -> tagList.get(0).getValue() + ) + )); + log.info("tagMap为:{}",tagMap); + List result = addNodeForData(req.getAddNodeList(), tagMap); + if (CollectionUtils.isEmpty(result)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("数据总览新增节点失败!"); + } + return SdmResponse.success(); + } + + private List addNodeForData(List addNodeList, Map tagMap) { + List nodeExtraReqList = new ArrayList<>(); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + List topNodeList = addNodeList.stream().filter(node -> StringUtils.isBlank(node.getPid())).toList(); + if (CollectionUtils.isNotEmpty(topNodeList)) { + for (SpdmProjectNodeEditReq projectNode : topNodeList) { + projectNode.setUuid(RandomUtil.generateString(32)); + projectNode.setOwnRootNodeUuid(projectNode.getUuid()); + projectNode.setCreateTime(curDateStr); + projectNode.setCreator(jobNumber); + projectNode.setTenantId(tenantId); + try { + setTagProperty(projectNode, tagMap.get(projectNode.getNodeType()), projectNode.getUuid()); + } catch (Exception e) { + throw new RuntimeException(e); + } + List extras = projectNode.getExtras(); + if (CollectionUtils.isEmpty(extras)) { + continue; + } + for (SpdmNodeExtraReq extra : extras) { + extra.setNodeId(projectNode.getUuid()); + extra.setCreateTime(curDateStr); + extra.setCreator(jobNumber); + } + nodeExtraReqList.addAll(extras); + } + } + List nodeList = addNodeList.stream().filter(node -> StringUtils.isNotBlank(node.getPid())).toList(); + if (CollectionUtils.isNotEmpty(nodeList)) { + List pidList = nodeList.stream().map(SpdmProjectNodeEditReq::getPid).distinct().toList(); + log.info("pidList为:{}",pidList); + List parentNodeList = this.lambdaQuery().in(SimulationNode::getUuid, pidList).list(); + log.info("parentNodeList为:{}",parentNodeList); + if (CollectionUtils.isEmpty(parentNodeList)) { + log.error("根据pidList:{},未查询到节点信息",pidList); + return null; + } + Map nodeMap = parentNodeList.stream().collect(Collectors.groupingBy( + SimulationNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + for (SpdmProjectNodeEditReq addNode : nodeList) { + SimulationNode parentNode = nodeMap.get(addNode.getPid()); + if (ObjectUtils.isEmpty(parentNode)) { + log.error("根据pid:{},未查询到父节点信息",addNode.getPid()); + continue; + } + String parentNodeType = parentNode.getNodeType(); + String nodeType = addNode.getNodeType(); + addNode.setUuid(RandomUtil.generateString(32)); + addNode.setOwnRootNodeUuid(ObjectUtils.isEmpty(addNode.getPid()) ? addNode.getUuid() : addNode.getPid()); + addNode.setCreateTime(curDateStr); +// addNode.setCreator(jobNumber); + addNode.setTenantId(tenantId); + // 复制标签信息 + copyTagInfoFromParentNode(addNode, tagMap.get(nodeType),parentNode, tagMap.get(parentNodeType)); + List extras = addNode.getExtras(); + if (CollectionUtils.isEmpty(extras)) { + continue; + } + for (SpdmNodeExtraReq extra : extras) { + extra.setNodeId(addNode.getUuid()); + extra.setCreateTime(curDateStr); +// extra.setCreator(jobNumber); + } + nodeExtraReqList.addAll(extras); + } + } + + if (CollectionUtils.isNotEmpty(topNodeList) && nodeMapper.addNodeBatch(topNodeList) <= 0) { + log.error("保存节点信息失败1"); + return null; + } + if (CollectionUtils.isNotEmpty(nodeList) && nodeMapper.addNodeBatch(nodeList) <= 0) { + log.error("保存节点信息失败2"); + return null; + } + if (CollectionUtils.isNotEmpty(nodeExtraReqList) && nodeMapper.addNodeExtraBatch(nodeExtraReqList) <= 0) { + log.error("保存节点额外信息失败"); + return null; + } + for (SpdmProjectNodeEditReq projectNode : topNodeList) { + createDir(projectNode.getUuid(), projectNode.getNodeType(), null, projectNode.getNodeName()); + } + for (SpdmProjectNodeEditReq projectNode : nodeList) { + createDir(projectNode.getUuid(), projectNode.getNodeType(), projectNode.getPid(), projectNode.getNodeName()); + } + return addNodeList; + } + + /** + * + * @param addNode 当前新增节点 + * @param addNodeTag 当前新增节点的标签 + * @param parentNode 当前新增节点的父节点 + * @param parentNodeTag 当前新增节点的父节点的标签 + */ + private void copyTagInfoFromParentNode(SpdmProjectNodeEditReq addNode,String addNodeTag, SimulationNode parentNode,String parentNodeTag) { + String tagListProperty; + for (int i = 1; i <= 10; i++) { + try { + tagListProperty = getTagProperty(parentNode, "tag" + i); + if (StringUtils.isBlank(tagListProperty)) { + continue; + } + setTagProperty(addNode, "tag" + i, tagListProperty); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + if (addNodeTag.equals(parentNodeTag)) { + // 如果新增节点与父节点的类型相同,需要将当前新增节点的uuid追加到该类型标签中 + try { + tagListProperty = getTagProperty(parentNode, parentNodeTag); + tagListProperty = tagListProperty + "," + addNode.getUuid(); +// tagListProperty.add(addNode.getUuid()); + setTagProperty(addNode, addNodeTag, tagListProperty); + } catch (Exception e) { + throw new RuntimeException(e); + } + }else { + // 如果新增节点与父节点的类型不同,直接设置该标签为当前新增节点的uuid即可 + try { + setTagProperty(addNode, addNodeTag, addNode.getUuid()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + @Override + public SdmResponse addTaskForData(SpdmTaskReq req) { + log.info("addTaskForData参数为:{}",req); + List result = handleAddTaskForData(req.getAddTaskList()); + if (CollectionUtils.isEmpty(result)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("数据总览新增任务失败!"); + } + return SdmResponse.success(); + } + + private List handleAddTaskForData(List addTaskList) { + List nodeExtraReqList = new ArrayList<>(); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + List pidList = addTaskList.stream().map(TaskNode::getPid).distinct().toList(); + log.info("pidList为:{}",pidList); + List parentNodeList = this.lambdaQuery().in(SimulationNode::getUuid, pidList).list(); + log.info("parentNodeList为:{}",parentNodeList); + if (CollectionUtils.isEmpty(parentNodeList)) { + log.error("根据pidList:{},未查询到节点信息",pidList); + return null; + } + Map nodeMap = parentNodeList.stream().collect(Collectors.groupingBy( + SimulationNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + for (TaskNode addTask : addTaskList) { + SimulationNode parentNode = nodeMap.get(addTask.getPid()); + if (ObjectUtils.isEmpty(parentNode)) { + log.error("根据pid:{},未查询到父节点信息",addTask.getPid()); + continue; + } + addTask.setUuid(RandomUtil.generateString(32)); + addTask.setOwnRootNodeUuid(ObjectUtils.isEmpty(addTask.getPid()) ? addTask.getUuid() : addTask.getPid()); + addTask.setCreateTime(curDateStr); +// addTask.setCreator(jobNumber); + addTask.setTenantId(tenantId); + addTask.setNodeId(addTask.getPid()); + addTask.setTaskName(addTask.getNodeName()); + // 复制标签信息 + copyTaskTagInfoFromParentNode(addTask,parentNode); + List extras = addTask.getExtras(); + if (CollectionUtils.isEmpty(extras)) { + continue; + } + for (TaskExtraNode extra : extras) { + extra.setNodeId(addTask.getUuid()); + extra.setCreateTime(curDateStr); +// extra.setCreator(jobNumber); + } + nodeExtraReqList.addAll(extras); + } + if (projectMapper.batchAddSimulationTask(addTaskList) <= 0) { + log.error("保存任务失败"); + return null; + } + if (CollectionUtils.isNotEmpty(nodeExtraReqList) && projectMapper.batchAddSimulationTaskExtra(nodeExtraReqList) <= 0) { + log.error("保存任务额外信息失败"); + return null; + } + for (TaskNode taskNode : addTaskList) { + createDir(taskNode.getUuid(), taskNode.getNodeType(), taskNode.getPid(), taskNode.getNodeName()); + } + return addTaskList; + } + + /** + * + * @param addNode 当前新增节点 + * @param parentNode 当前新增节点的父节点 + */ + private void copyTaskTagInfoFromParentNode(TaskNode addNode, SimulationNode parentNode) { + String tagListProperty; + for (int i = 1; i <= 10; i++) { + try { + tagListProperty = getTagProperty(parentNode, "tag" + i); + if (StringUtils.isBlank(tagListProperty)) { + continue; + } + setTagProperty(addNode, "tag" + i, Arrays.stream(tagListProperty.split(",")).toList()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + + @Override + public SdmResponse> querySimulationNodeByUuids(List uuids) { + if(CollectionUtils.isEmpty(uuids)){ + return SdmResponse.failed("参数为空"); + } + if(uuids.size()>queryCounts){ + return SdmResponse.failed("单次批量查询不允许超过"+queryCounts); + } + List simulationNodeResps = mapper.querySimulationNodeByUuids(uuids); + return SdmResponse.success(simulationNodeResps); + } + + @Override + public SdmResponse exportProject(ProjectExportExcelFormat projectExportExcelFormat, HttpServletResponse httpServletResponse) { + SdmResponse response = new SdmResponse(); + SpdmNodeListReq req = new SpdmNodeListReq(); + ProjectExportExcelParam params = projectExportExcelFormat.getParams(); + if (ObjectUtils.isNotEmpty(params)) { + BeanUtils.copyProperties(params,req); + } + req.setCurrent(1); + req.setSize(10000); + List exportExcelFormats = projectExportExcelFormat.getExcelHeaders(); + SdmResponse taskRespond = list(req); + if(taskRespond.isSuccess()) { + JSONObject dataObj = (JSONObject) taskRespond.getData(); + List taskVoList = (List) dataObj.get("data"); + List exportNodeVoList = new ArrayList<>(); + List memberList; + String memberName = ""; + for (SpdmNodeVo spdmNodeVo : taskVoList) { + memberList = spdmNodeVo.getMemberList(); + if (CollectionUtils.isNotEmpty(memberList)) { + memberName = memberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + SpdmExportNodeVo spdmExportNodeVo = new SpdmExportNodeVo(); + BeanUtils.copyProperties(spdmNodeVo,spdmExportNodeVo); + spdmExportNodeVo.setMemberList(memberName); + exportNodeVoList.add(spdmExportNodeVo); + } + ExcelUtil.exportExcelNoMerge(JSONArray.from(exportNodeVoList),exportExcelFormats,httpServletResponse); + } else { + response = SdmResponse.failed(taskRespond.getMessage()); + } + return response; + } + + // 重命名文件夹 + public SdmResponse renameDirNew(String uuid, String newDirName) { + RenameDirReq req = new RenameDirReq(); + req.setUuid(uuid); + req.setNewName(newDirName); + log.info("调用重命名文件夹的参数为:{}", req); + SdmResponse response = dataClientFeignClient.renameDirNew(req); + log.info("调用重命名文件夹的返回值为:{}", response); + return response; + } + + + @Override + public SdmResponse getNodeDetailForData(GetNodeDetailReq req) { + log.info("getNodeDetailForData参数为:{}",req); + SimulationNode node = this.lambdaQuery().eq(SimulationNode::getUuid, req.getRelatedResourceUuid()).one(); + if (ObjectUtils.isEmpty(node)) { + log.error("根据id:{},未查询到节点",req.getRelatedResourceUuid()); + return SdmResponse.failed("未查询到节点"); + } + List nodeExtraListByNodeIdList = nodeMapper.getNodeExtraListByNodeIdList(Collections.singletonList(node.getUuid())); + SpdmNodeDetailForDataVo spdmNodeDetailForDataVo = new SpdmNodeDetailForDataVo(); + BeanUtils.copyProperties(node,spdmNodeDetailForDataVo); + spdmNodeDetailForDataVo.setId(node.getId()); + spdmNodeDetailForDataVo.setExtraList(nodeExtraListByNodeIdList); + return SdmResponse.success(spdmNodeDetailForDataVo); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public BosimSaveProjectTaskRsp syncProject(SyncCidProjectReq req) { + log.info("syncProject参数为:{}", req); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + SpdmProjectNodeEditReq spdmProjectNodeEditReq = new SpdmProjectNodeEditReq(); + spdmProjectNodeEditReq.setNodeName(req.getProjectName()); + spdmProjectNodeEditReq.setNodeType(NodeTypeEnum.PROJECT.getValue()); + spdmProjectNodeEditReq.setUuid(req.getProjectId()); + spdmProjectNodeEditReq.setPid(req.getProjectId()); + spdmProjectNodeEditReq.setTag1(req.getProjectId()); + spdmProjectNodeEditReq.setCreateTime(curDateStr); + spdmProjectNodeEditReq.setTenantId(ThreadLocalContext.getTenantId()); + BosimSaveProjectTaskRsp resp = new BosimSaveProjectTaskRsp(); + if (nodeMapper.addNodeBatch(Collections.singletonList(spdmProjectNodeEditReq)) <= 0) { + log.error("同步CID项目:{}失败",req.getProjectId() + " " + req.getProjectName()); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + try { + // 创建项目节点的文件夹 + SdmResponse response = createDir(spdmProjectNodeEditReq.getUuid(), spdmProjectNodeEditReq.getNodeType(), null, spdmProjectNodeEditReq.getNodeName()); + if (ObjectUtils.isEmpty(response) || response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("同步CID项目:{}时,创建文件夹失败,原因为:{}",req.getProjectId() + " " + req.getProjectName(),response.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + }catch (Exception ex) { + log.error("同步CID项目:{}时,创建文件夹异常,原因为:{}",req.getProjectId() + " " + req.getProjectName(),ex.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + resp.setCode(String.valueOf(ResultCode.SUCCESS.getCode())); + resp.setMessage("success"); + return resp; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SdmResponse editNodeForData(SpdmEditNodeForDataReq req) { + String relatedResourceUuid = req.getRelatedResourceUuid(); + // 修改节点属性 + boolean updateNodeFlag = this.lambdaUpdate().set(SimulationNode::getNodeName, req.getNodeName()) + .set(SimulationNode::getNodeCode, req.getNodeCode()) + .set(SimulationNode::getEnglishName, req.getEnglishName()) + .eq(SimulationNode::getUuid, relatedResourceUuid).update(); + if (!updateNodeFlag) { + log.error("修改节点信息失败"); + return SdmResponse.failed("修改节点失败,原因为:修改节点信息失败"); + } + // 删除节点额外属性 + nodeMapper.deleteNodeExtraBatch(Collections.singletonList(relatedResourceUuid)); + // 新增节点额外属性 + List extraList = req.getExtraList(); + if (CollectionUtils.isNotEmpty(extraList)) { + for (SpdmNodeExtraReq spdmNodeExtraReq : extraList) { + spdmNodeExtraReq.setNodeId(relatedResourceUuid); + } + if (nodeMapper.addNodeExtraBatch(extraList) == 0) { + log.error("新增节点额外属性失败"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("修改节点失败,原因为:新增节点额外属性失败"); + } + } + // 修改文件夹名称 + SdmResponse response = renameDirNew(relatedResourceUuid, req.getNodeName()); + if (ObjectUtils.isEmpty(response) || response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("修改节点时,修改文件夹名称失败,原因为:{}",response.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("修改节点失败,原因为:" + response.getMessage()); + } + return SdmResponse.success(); + } + +} + + + +package com.sdm.project.service.impl; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.sdm.common.common.ResultCode; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.common.entity.ExportExcelFormat; +import com.sdm.common.entity.enums.DirTypeEnum; +import com.sdm.common.entity.enums.FilePermissionEnum; +import com.sdm.common.entity.enums.NodeTypeEnum; +import com.sdm.common.entity.req.data.CreateDirReq; +import com.sdm.common.entity.req.data.DelDirReq; +import com.sdm.common.entity.req.data.RenameDirReq; +import com.sdm.common.entity.req.data.UpdatePermissionReq; +import com.sdm.common.entity.req.system.UserQueryReq; +import com.sdm.common.entity.req.task.TaskExportExcelParam; +import com.sdm.common.entity.req.task.TaskTreeExportExcelFormat; +import com.sdm.common.entity.req.task.TaskTreeExportExcelParam; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.common.feign.impl.data.DataClientFeignClientImpl; +import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; +import com.sdm.common.service.BaseService; +import com.sdm.common.utils.RandomUtil; +import com.sdm.common.utils.excel.ExcelUtil; +import com.sdm.project.common.MemberTypeEnum; +import com.sdm.project.common.VersionEnum; +import com.sdm.project.dao.SimulationNodeMapper; +import com.sdm.project.dao.SimulationProjectMapper; +import com.sdm.project.model.bo.*; +import com.sdm.project.model.entity.SimulationTaskMember; +import com.sdm.project.model.po.*; +import com.sdm.project.model.req.*; +import com.sdm.project.model.vo.SpdmExportNewTaskVo; +import com.sdm.project.model.vo.SpdmNewTaskVo; +import com.sdm.project.service.IProjectService; +import com.sdm.project.service.ISimulationTaskMemberService; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import static com.sdm.project.service.impl.NodeServiceImpl.getTagProperty; +import static com.sdm.project.service.impl.NodeServiceImpl.setTagProperty; + +@Slf4j +@Service +public class ProjectServiceImpl extends BaseService implements IProjectService { + + @Autowired + private SimulationProjectMapper mapper; + + @Autowired + private SimulationNodeMapper nodeMapper; + + @Autowired + private DataClientFeignClientImpl dataClientFeignClient; + + @Autowired + private ISimulationTaskMemberService simulationTaskMemberService; + + @Autowired + SysUserFeignClientImpl sysUserFeignClient; + + private String currentTopNodeType = ""; + + List tagMap; + + List taskTreeNodeList; + + List taskTreeTaskList; + + List taskTreePerformanceList; + + List taskTreeTagMap; + + Map taskTreeTagNodeTypeMap; + + Map taskTreeNodeTypeTagMap; + + Map> taskTreeProjectNodeMap = new HashMap<>(); + + String lastNodeTag; + + String firstNodeTag; + + List nodeTypeList = Arrays.asList(NodeTypeEnum.MACHINE.getValue(),NodeTypeEnum.WORKSPACE.getValue(),NodeTypeEnum.DISCIPLINE.getValue(),NodeTypeEnum.TASK.getValue(),NodeTypeEnum.PERFORMANCE.getValue()); + + private static final String NODE_NAME_KEY = "nodeName"; + + private static final String NODE_CODE_KEY = "nodeCode"; + private static final String PMEMBER_CODE_KEY = "pMemberList"; + private static final String EMEMBER_CODE_KEY = "eMemberList"; + private static final String PMEMBER_NAME = "仿真负责人"; + private static final String EMEMBER_NAME = "仿真执行人"; + + private static final String MACHINE_NAME = "机台名称"; + + private static final String MACHINE_CODE = "机台编号"; + + private static final String WORKSPACE_NAME = "工位名称"; + + private static final String WORKSPACE_CODE = "工位编号"; + + private static final String DISCIPLINE_NAME = "学科名称"; + + private static final String DISCIPLINE_CODE = "学科编号"; + + private static final String TASK_NAME = "任务名称"; + + private static final String TASK_CODE = "任务编号"; + + private static final String PERFORMANCE_NAME = "指标名称"; + + private static final String PERFORMANCE_CODE = "指标编号"; + + @Override + @Transactional + public SdmResponse add(JSONObject jsonObject) { + Long tenantId = ThreadLocalContext.getTenantId(); + TaskNodeTree taskNodeTree = parseTaskTree(jsonObject); + HashMap> idMap = new HashMap<>(); + HashMap> taskIdMap = new HashMap<>(); + SdmResponse response = realAddSimulationTaskItems(taskNodeTree, "", tenantId,idMap,taskIdMap); + if (response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("新增任务失败,清理新增数据!"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("新增任务失败!"); + } + return response; + } + + @Override + public SdmResponse edit(List taskEditNodeReqList) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long jobNumber = ThreadLocalContext.getUserId(); + String nodeType; + Map> editNodeListMap = taskEditNodeReqList.stream().collect(Collectors.groupingBy(TaskEditNodeReq::getNodeType)); + String updateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + for (Map.Entry> taskEntry : editNodeListMap.entrySet()) { + nodeType = taskEntry.getKey(); + log.info("nodeType为:{}", nodeType); + if (NodeTypeEnum.TASK.getValue().equals(nodeType)) { + editTaskList(taskEntry.getValue()); + }else if (NodeTypeEnum.PERFORMANCE.getValue().equals(nodeType)) { + editPerformanceList(taskEntry.getValue()); + }else { + SpdmEditNodeReq spdmEditNodeReq = new SpdmEditNodeReq(); + List editNodeList = new ArrayList<>(); + for (TaskEditNodeReq taskEditNodeReq : taskEntry.getValue()) { + SpdmNodeDetailReq spdmNodeDetailReq = new SpdmNodeDetailReq(); + BeanUtils.copyProperties(taskEditNodeReq, spdmNodeDetailReq); + spdmNodeDetailReq.setTenantId(tenantId); + spdmNodeDetailReq.setUpdater(jobNumber); + spdmNodeDetailReq.setUpdateTime(updateTime); + editNodeList.add(spdmNodeDetailReq); + } + spdmEditNodeReq.setEditNodeList(editNodeList); + if (!editNode(editNodeList, tenantId, jobNumber)) { + log.error("更新节点失败!"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("更新节点失败!"); + } + } + } + return SdmResponse.success(); + } + + private boolean editNode(List editNodeList, Long tenantId, Long jobNumber) { + log.info("editNode参数为:{}", editNodeList); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + List extraList; + List allExtraList = new ArrayList<>(); + for (SpdmNodeDetailReq editNode : editNodeList) { + renameDirNew(editNode.getUuid(),editNode.getNodeName()); + editNode.setUpdateTime(curDateStr); + editNode.setUpdater(jobNumber); + extraList = editNode.getExtraList(); + if (CollectionUtils.isNotEmpty(extraList)) { + extraList.forEach(extra -> { + extra.setUpdateTime(curDateStr); + extra.setUpdater(jobNumber); + }); + allExtraList.addAll(extraList); + } + } + for (SpdmNodeDetailReq editNode : editNodeList) { + if (nodeMapper.editNode(editNode) <= 0) { + return false; + } + } + if (CollectionUtils.isNotEmpty(allExtraList)) { + for (SpdmNodeExtraReq nodeExtra : allExtraList) { + if (nodeMapper.editNodeExtra(nodeExtra) <= 0) { + return false; + } + } + } + return true; + } + + private void editPerformanceList(List taskEditNodeReqList) { + List taskExtraNodeList; + for (TaskEditNodeReq taskEditNodeReq : taskEditNodeReqList) { + mapper.updateProjectNodePerformance(taskEditNodeReq); + renameDirNew(taskEditNodeReq.getUuid(),taskEditNodeReq.getNodeName()); + taskExtraNodeList = taskEditNodeReq.getTaskPerformanceExtraNodeList(); + if (CollectionUtils.isNotEmpty(taskExtraNodeList)) { + for (TaskExtraNode taskExtraNode : taskExtraNodeList) { + mapper.updateProjectNodePerformanceExtra(taskExtraNode); + } + } + } + } + + private void editTaskList(List taskEditNodeReqList) { + List taskExtraNodeList; + List taskMemberNodeList; + for (TaskEditNodeReq taskEditNodeReq : taskEditNodeReqList) { + mapper.updateProjectNodeItem(taskEditNodeReq); + renameDirNew(taskEditNodeReq.getUuid(),taskEditNodeReq.getNodeName()); + taskExtraNodeList = taskEditNodeReq.getTaskExtraNodeList(); + if (CollectionUtils.isNotEmpty(taskExtraNodeList)) { + for (TaskExtraNode taskExtraNode : taskExtraNodeList) { + mapper.updateProjectNodeItemExtra(taskExtraNode); + } + } + // 修改仿真执行人 + if (StringUtils.isNotBlank(taskEditNodeReq.getEMemberList())) { + String[] userIdArr = taskEditNodeReq.getEMemberList().split(","); + List longUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); + simulationTaskMemberService.deleteTaskMemberList(taskEditNodeReq.getUuid(), MemberTypeEnum.EXECUTOR.getCode()); + simulationTaskMemberService.saveTaskMemberList(taskEditNodeReq.getUuid(), MemberTypeEnum.EXECUTOR.getCode(), longUserIdList); + } + // 修改仿真负责人 + if (StringUtils.isNotBlank(taskEditNodeReq.getPMemberList())) { + String[] userIdArr = taskEditNodeReq.getPMemberList().split(","); + List longUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); + simulationTaskMemberService.deleteTaskMemberList(taskEditNodeReq.getUuid(), MemberTypeEnum.PRINCIPAL.getCode()); + simulationTaskMemberService.saveTaskMemberList(taskEditNodeReq.getUuid(), MemberTypeEnum.PRINCIPAL.getCode(), longUserIdList); + } + } + } + + @Override + public SdmResponse getTaskTree(ProjectTreeTagReq req) { + List idMapList = req.getIdMap(); + if (CollectionUtils.isEmpty(idMapList)) { + log.error("getTaskTree tagMap不能为空!"); + return SdmResponse.success(new ArrayList<>()); + } + List topTagList = idMapList.stream().filter(tag -> StringUtils.isNotBlank(tag.getKey())).toList(); + log.info("topTagList:{}", topTagList); + if (CollectionUtils.isEmpty(topTagList)) { + log.error("至少要有一层顶级节点"); + return SdmResponse.success(new ArrayList<>()); + } + // topTagList中最后一层可以认为是最顶层节点,但并不需要展示 + TaskNodeTag topNodeTag = topTagList.get(topTagList.size() - 1); + log.info("实际顶层节点为:{}", topNodeTag); + ProjectTreeReq taskTreeReq = new ProjectTreeReq(); + try { + setTagProperty(taskTreeReq, topNodeTag.getValue(), topNodeTag.getKey()); + } catch (Exception e) { + throw new RuntimeException(e); + } + log.info("taskTreeReq为:{}", taskTreeReq); + taskTreeNodeList = mapper.getNodeListByTag(taskTreeReq); + if (CollectionUtils.isEmpty(taskTreeNodeList)) { + log.error("未查询到顶级节点"); + return SdmResponse.success(new ArrayList<>()); + } + log.info("查询到的节点为:{}", taskTreeNodeList.stream().map(ProjectNodePo::getId).toList()); + taskTreeTaskList = mapper.getTaskListByTag(taskTreeReq); + if (CollectionUtils.isNotEmpty(taskTreeTaskList)) { + log.info("查询到的任务为:{}", taskTreeTaskList.stream().map(TaskNodePo::getId).toList()); + taskTreeTaskList.forEach(task -> task.setNodeType("task")); + taskTreePerformanceList = mapper.getPerformanceListByNodeIdList(taskTreeTaskList.stream().map(TaskNodePo::getUuid).toList()); + if (CollectionUtils.isNotEmpty(taskTreePerformanceList)) { + log.info("查询到的指标为:{}", taskTreePerformanceList.stream().map(PerformanceNodePo::getId).toList()); + taskTreePerformanceList.forEach(performance -> performance.setNodeType("performance")); + } + } + taskTreeTagMap = req.getTagMap(); + firstNodeTag = taskTreeTagMap.get(0).getValue(); + lastNodeTag = taskTreeTagMap.get(taskTreeTagMap.size()-1).getValue(); + log.info("taskTreeTagMap为:{}", taskTreeTagMap); + if (CollectionUtils.isEmpty(taskTreeTagMap)) { + log.error("tagMap不能为空"); + return SdmResponse.success(new ArrayList<>()); + } + // key:节点类型,value:标签 + taskTreeNodeTypeTagMap = taskTreeTagMap.stream().collect(Collectors.toMap(TaskNodeTag::getKey, TaskNodeTag::getValue)); + // key:标签,value:节点类型 + taskTreeTagNodeTypeMap = taskTreeTagMap.stream().collect(Collectors.toMap(TaskNodeTag::getValue, TaskNodeTag::getKey)); + log.info("taskTreeTagNodeTypeMap为:{}", taskTreeTagNodeTypeMap); + // 如果idMap中的id都不为null,说明查的是最后一层节点下的所有任务、指标 + TaskNodeTag realFirstTaskNodeTag = idMapList.get(idMapList.size() - 1); + for (TaskNodeTag taskNodeTag : idMapList) { + if (StringUtils.isNotBlank(taskNodeTag.getKey())) { + realFirstTaskNodeTag = taskNodeTag; + } + } + String realFirstTaskNodeType = taskTreeTagNodeTypeMap.get(realFirstTaskNodeTag.getValue()); + log.info("实际需要展示的最顶层节点类型为:{},id为:{}", taskTreeTagNodeTypeMap.get(realFirstTaskNodeTag.getValue()),realFirstTaskNodeType); + taskTreeProjectNodeMap = taskTreeNodeList.stream().collect(Collectors.groupingBy(ProjectNodePo::getNodeType)); + List realTopProjectNodeList = taskTreeNodeList.stream().filter(node -> node.getNodeType().equals(realFirstTaskNodeType)).toList(); + List addedIdList = new ArrayList<>(); + List currentAddedIdList = new ArrayList<>(); + for (ProjectNodePo projectNodePo : realTopProjectNodeList) { + generateTaskTree(projectNodePo,addedIdList,currentAddedIdList); + addedIdList.clear(); + } + return SdmResponse.success(realTopProjectNodeList.stream().flatMap(item -> item.getChildren().stream().filter(Objects::nonNull)).toList()); + } + + private int getCurrentNodeDepth(NodeAllBase eachNode) { + String tag1 = eachNode.getTag1(); + String tag2 = eachNode.getTag2(); + String tag3 = eachNode.getTag3(); + String tag4 = eachNode.getTag4(); + String tag5 = eachNode.getTag5(); + String tag6 = eachNode.getTag6(); + String tag7 = eachNode.getTag7(); + String tag8 = eachNode.getTag8(); + String tag9 = eachNode.getTag9(); + String tag10 = eachNode.getTag10(); + int currentNodeDepth = 0; + if (StringUtils.isNotBlank(tag1) && !tag1.equals("null")) { + currentNodeDepth += tag1.split(",").length; + } + if (StringUtils.isNotBlank(tag2) && !tag2.equals("null")) { + currentNodeDepth += tag2.split(",").length; + } + if (StringUtils.isNotBlank(tag3) && !tag3.equals("null")) { + currentNodeDepth += tag3.split(",").length; + } + if (StringUtils.isNotBlank(tag4) && !tag4.equals("null")) { + currentNodeDepth += tag4.split(",").length; + } + if (StringUtils.isNotBlank(tag5) && !tag5.equals("null")) { + currentNodeDepth += tag5.split(",").length; + } + if (StringUtils.isNotBlank(tag6) && !tag6.equals("null")) { + currentNodeDepth += tag6.split(",").length; + } + if (StringUtils.isNotBlank(tag7) && !tag7.equals("null")) { + currentNodeDepth += tag7.split(",").length; + } + if (StringUtils.isNotBlank(tag8) && !tag8.equals("null")) { + currentNodeDepth += tag8.split(",").length; + } + if (StringUtils.isNotBlank(tag9) && !tag9.equals("null")) { + currentNodeDepth += tag9.split(",").length; + } + if (StringUtils.isNotBlank(tag10) && !tag10.equals("null")) { + currentNodeDepth += tag10.split(",").length; + } + return currentNodeDepth; + } + + private void generateTaskTree(ProjectNodePo projectNodePo,List addedIdList,List currentAddedIdList) { + currentAddedIdList.add(projectNodePo.getUuid()); + String currentNodeType = projectNodePo.getNodeType(); + String currentTag = taskTreeNodeTypeTagMap.get(currentNodeType); + TaskNodeTag nextNodeTag = getNextNodeTag(currentTag); + if (ObjectUtils.isEmpty(nextNodeTag)) { + log.error("未找到子标签"); + return; + } + log.info("当前标签:{},子标签:{}",currentTag,nextNodeTag); + String currentNodeTagId = ""; + try { + currentNodeTagId = getTagProperty(projectNodePo, currentTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (StringUtils.isBlank(currentNodeTagId)) { + String realCurrentTag = currentTag; + log.info("找前一个标签"); + while (StringUtils.isBlank(currentNodeTagId) && !firstNodeTag.equals(realCurrentTag) && !lastNodeTag.equals(realCurrentTag)) { + realCurrentTag = getPreNodeTag(realCurrentTag).getValue(); + try { + currentNodeTagId = getTagProperty(projectNodePo, realCurrentTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + currentTag = realCurrentTag; + } + if (StringUtils.isBlank(currentNodeTagId)) { + log.error("currentNodeTagId为空"); + return; + } + String finalCurrentNodeTagId = currentNodeTagId; + // 需要找到当前节点创建节点时的tagId + TaskNodeTag realTagObj = getRealTagId(projectNodePo); + if (StringUtils.isBlank(realTagObj.getKey()) && StringUtils.isBlank(realTagObj.getValue())) { + log.error("realTagObj为空"); + return; + } + String realTag = realTagObj.getKey(); + String realTagId = realTagObj.getValue(); + // 查询当前节点下任务 + List currentNodeAssociatedTaskList = new ArrayList<>(); + int currentNodeDepth = getCurrentNodeDepth(projectNodePo); + if (CollectionUtils.isNotEmpty(taskTreeTaskList)) { + currentNodeAssociatedTaskList = taskTreeTaskList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, realTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + // tagId相同且:当前深度 = task深度 + 1 + return nodeTagId.equals(realTagId) && currentNodeDepth == getCurrentNodeDepth(node); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + + if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) { + // 查询当前任务下指标 + Map taskMap = currentNodeAssociatedTaskList.stream().collect(Collectors.groupingBy( + TaskNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + if (CollectionUtils.isNotEmpty(taskTreePerformanceList)) { + List eachPerformanceNodeList; + List currentTaskAssociatedPerformanceList = taskTreePerformanceList.stream().filter(performance -> ObjectUtils.isNotEmpty(taskMap.get(performance.getTaskId()))).toList(); + if (CollectionUtils.isNotEmpty(currentTaskAssociatedPerformanceList)) { + Map> performanceMap = currentTaskAssociatedPerformanceList.stream().collect(Collectors.groupingBy(PerformanceNodePo::getTaskId)); + for (TaskNodePo taskNodePo : currentNodeAssociatedTaskList) { + eachPerformanceNodeList = performanceMap.get(taskNodePo.getUuid()); + if (CollectionUtils.isNotEmpty(eachPerformanceNodeList)) { + for (PerformanceNodePo performanceNodePo : eachPerformanceNodeList) { + if (StringUtils.isBlank(performanceNodePo.getEnglishName())) { + performanceNodePo.setEnglishName(""); + } + } + taskNodePo.getChildren().addAll(eachPerformanceNodeList); + } + } + } + } + // 查询当前任务的负责人和执行人 + for (TaskNodePo taskNodePo : currentNodeAssociatedTaskList) { + List memberList = simulationTaskMemberService.lambdaQuery().eq(SimulationTaskMember::getTaskId, taskNodePo.getUuid()).list(); + if (CollectionUtils.isNotEmpty(memberList)) { + List eUserIdList = memberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).map(SimulationTaskMember::getUserId).distinct().toList(); + List pUserIdList = memberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).map(SimulationTaskMember::getUserId).distinct().toList(); + if (CollectionUtils.isNotEmpty(eUserIdList)) { + SdmResponse> cidUserResp= sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(eUserIdList).build()); + taskNodePo.setEMemberList(cidUserResp.getData()); + taskNodePo.setEMembers(taskNodePo.getEMemberList().stream().map(CIDUserResp::getNickname).collect(Collectors.joining(","))); + } + if (CollectionUtils.isNotEmpty(pUserIdList)) { + SdmResponse> cidUserResp= sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(pUserIdList).build()); + taskNodePo.setPMemberList(cidUserResp.getData()); + taskNodePo.setPMembers(taskNodePo.getPMemberList().stream().map(CIDUserResp::getNickname).collect(Collectors.joining(","))); + } + } + } + } + } + // 查询子节点,可能是同类型节点也可能是不同类型节点 + // 先查同类型节点:当前标签下,包含currentNodeTagId且深度+1 + int depth = getCurrentNodeDepth(projectNodePo); + String finalCurrentTag = currentTag; + List sameTypeNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, finalCurrentTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + return node.getNodeType().equals(currentNodeType) && nodeTagId.contains(finalCurrentNodeTagId) && getCurrentNodeDepth(node) == depth + 1; + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + // 再查不同类型的节点:下一标签下的节点 + TaskNodeTag finalNextNodeTag = nextNodeTag; + List children = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(sameTypeNodeList)) { + // 递归 + for (ProjectNodePo nodePo : sameTypeNodeList) { + generateTaskTree(nodePo,addedIdList,currentAddedIdList); + } + if (CollectionUtils.isNotEmpty(sameTypeNodeList)) { + addedIdList.addAll(sameTypeNodeList.stream().map(ProjectNodePo::getUuid).toList()); + for (ProjectNodePo nodePo : sameTypeNodeList) { + if (StringUtils.isBlank(nodePo.getEnglishName())) { + nodePo.setEnglishName(""); + } + } + children.addAll(sameTypeNodeList); + } + } + if (!currentTag.equals(finalNextNodeTag.getValue()) && !lastNodeTag.equals(currentTag)){ + String nextNodeTagId = ""; + try { + nextNodeTagId = getTagProperty(projectNodePo, finalNextNodeTag.getValue()); + } catch (Exception e) { + throw new RuntimeException(e); + } + List childrenTypeNodeList = getChildrenTypeNodeList(currentTag,finalNextNodeTag,finalCurrentNodeTagId,nextNodeTagId); + List childrenTypeNodeIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) { + childrenTypeNodeIdList = childrenTypeNodeList.stream().map(ProjectNodePo::getId).toList(); + int firstLayerNodeDepth = getFirstLayerNodeDepth(childrenTypeNodeList); + childrenTypeNodeList = childrenTypeNodeList.stream().filter(node -> getCurrentNodeDepth(node) == firstLayerNodeDepth).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) { + // 递归 + for (ProjectNodePo nodePo : childrenTypeNodeList) { + generateTaskTree(nodePo,addedIdList,currentAddedIdList); + } + addedIdList.addAll(childrenTypeNodeList.stream().map(ProjectNodePo::getUuid).toList()); + for (ProjectNodePo nodePo : childrenTypeNodeList) { + if (StringUtils.isBlank(nodePo.getEnglishName())) { + nodePo.setEnglishName(""); + } + } + children.addAll(childrenTypeNodeList); + } + } + // 查找当前节点的其他子节点(非直接顺序子节点) + List finalChildrenTypeNodeIdList = childrenTypeNodeIdList; + List otherChildrenNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, finalCurrentTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + return !node.getNodeType().equals(currentNodeType) && Integer.parseInt(taskTreeNodeTypeTagMap.get(currentNodeType).substring(3,4)) < Integer.parseInt(taskTreeNodeTypeTagMap.get(node.getNodeType()).substring(3,4)) + && !addedIdList.contains(node.getUuid()) && nodeTagId.equals(finalCurrentNodeTagId) && getCurrentNodeDepth(node) == depth + 1 && !finalChildrenTypeNodeIdList.contains(node.getId()) + && !currentAddedIdList.contains(node.getUuid()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(otherChildrenNodeList)) { + int firstLayerNodeDepth = getFirstLayerNodeDepth(otherChildrenNodeList); + otherChildrenNodeList = otherChildrenNodeList.stream().filter(node -> getCurrentNodeDepth(node) == firstLayerNodeDepth).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(otherChildrenNodeList)) { + // 递归 + for (ProjectNodePo nodePo : otherChildrenNodeList) { + generateTaskTree(nodePo,addedIdList,currentAddedIdList); + } + addedIdList.addAll(otherChildrenNodeList.stream().map(ProjectNodePo::getUuid).toList()); + for (ProjectNodePo nodePo : otherChildrenNodeList) { + if (StringUtils.isBlank(nodePo.getEnglishName())) { + nodePo.setEnglishName(""); + } + } + children.addAll(otherChildrenNodeList); + } + } + } + if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) { + currentNodeAssociatedTaskList.forEach(task -> { + task.setNodeName(task.getTaskName()); + task.setNodeCode(task.getTaskCode()); + task.setSection(task.getSectionName()); + task.setGroup(task.getGroupName()); + }); + for (TaskNodePo nodePo : currentNodeAssociatedTaskList) { + if (StringUtils.isBlank(nodePo.getEnglishName())) { + nodePo.setEnglishName(""); + } + } + children.addAll(currentNodeAssociatedTaskList); + } + projectNodePo.setChildren(children); + } + + private TaskNodeTag getRealTagId(ProjectNodePo projectNodePo) { + TaskNodeTag taskNodeTag = new TaskNodeTag(); + String tag10 = projectNodePo.getTag10(); + if (StringUtils.isNotBlank(tag10)) { + taskNodeTag.setKey("tag10"); + taskNodeTag.setValue(tag10); + return taskNodeTag; + } + String tag9 = projectNodePo.getTag9(); + if (StringUtils.isNotBlank(tag9)) { + taskNodeTag.setKey("tag9"); + taskNodeTag.setValue(tag9); + return taskNodeTag; + } + String tag8 = projectNodePo.getTag8(); + if (StringUtils.isNotBlank(tag8)) { + taskNodeTag.setKey("tag8"); + taskNodeTag.setValue(tag8); + return taskNodeTag; + } + String tag7 = projectNodePo.getTag7(); + if (StringUtils.isNotBlank(tag7)) { + taskNodeTag.setKey("tag7"); + taskNodeTag.setValue(tag7); + return taskNodeTag; + } + String tag6 = projectNodePo.getTag6(); + if (StringUtils.isNotBlank(tag6)) { + taskNodeTag.setKey("tag6"); + taskNodeTag.setValue(tag6); + return taskNodeTag; + } + String tag5 = projectNodePo.getTag5(); + if (StringUtils.isNotBlank(tag5)) { + taskNodeTag.setKey("tag5"); + taskNodeTag.setValue(tag5); + return taskNodeTag; + } + String tag4 = projectNodePo.getTag4(); + if (StringUtils.isNotBlank(tag4)) { + taskNodeTag.setKey("tag4"); + taskNodeTag.setValue(tag4); + return taskNodeTag; + } + String tag3 = projectNodePo.getTag3(); + if (StringUtils.isNotBlank(tag3)) { + taskNodeTag.setKey("tag3"); + taskNodeTag.setValue(tag3); + return taskNodeTag; + } + String tag2 = projectNodePo.getTag2(); + if (StringUtils.isNotBlank(tag2)) { + taskNodeTag.setKey("tag2"); + taskNodeTag.setValue(tag2); + return taskNodeTag; + } + String tag1 = projectNodePo.getTag1(); + if (StringUtils.isNotBlank(tag1)) { + taskNodeTag.setKey("tag1"); + taskNodeTag.setValue(tag1); + } + return taskNodeTag; + } + + private List getChildrenTypeNodeList(String currentTag, TaskNodeTag nextNodeTag, String currentNodeTagId,String nextNodeTagId) { + List childrenTypeNodeList; + if (StringUtils.isBlank(nextNodeTagId)) { + childrenTypeNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, currentTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + // tagId相同,且nodeType是nextNodeTag类型且子tagId的深度最少 + return nodeTagId.equals(currentNodeTagId) && node.getNodeType().equals(nextNodeTag.getKey()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + }else { + childrenTypeNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, nextNodeTag.getValue()); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + // tagId相同,且nodeType是nextNodeTag类型且子tagId的深度最少 + return nodeTagId.equals(nextNodeTagId) && node.getNodeType().equals(nextNodeTag.getKey()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(childrenTypeNodeList) || lastNodeTag.equals(nextNodeTag.getValue())) { + return childrenTypeNodeList; + } + return getChildrenTypeNodeList(currentTag,getNextNodeTag(nextNodeTag.getValue()),currentNodeTagId,nextNodeTagId); + } + + private TaskNodeTag getNextNodeTag(String currentTag) { + TaskNodeTag nextNodeTag = null; + for (int i = 0; i < taskTreeTagMap.size(); i++) { + if (taskTreeTagMap.get(i).getValue().equals(currentTag)) { + nextNodeTag = taskTreeTagMap.get(Math.min(i+1,taskTreeTagMap.size()-1)); + break; + } + } + return nextNodeTag; + } + + private TaskNodeTag getPreNodeTag(String currentTag) { + TaskNodeTag nextNodeTag = null; + for (int i = 0; i < taskTreeTagMap.size(); i++) { + if (taskTreeTagMap.get(i).getValue().equals(currentTag)) { + nextNodeTag = taskTreeTagMap.get(Math.max(i-1,0)); + break; + } + } + return nextNodeTag; + } + + private int getFirstLayerNodeDepth(List childrenTypeNodeList) { + int firstLayerNodeDepth = getCurrentNodeDepth(childrenTypeNodeList.get(0)); + for (ProjectNodePo projectNodePo : childrenTypeNodeList) { + firstLayerNodeDepth = Math.min(getCurrentNodeDepth(projectNodePo),firstLayerNodeDepth); + } + return firstLayerNodeDepth; + } + + @Override + public SdmResponse delete(SpdmDeleteProjectReq req) { + List deleteNodeList = req.getDeleteNodeList(); + if (CollectionUtils.isEmpty(deleteNodeList)) { + log.error("参数不能为空"); + return SdmResponse.failed("参数不能为空"); + } + List nodeList = deleteNodeList.stream().filter(node -> !NodeTypeEnum.TASK.getValue().equals(node.getNodeType()) && !NodeTypeEnum.PERFORMANCE.getValue().equals(node.getNodeType())).toList(); + List taskList = deleteNodeList.stream().filter(node -> NodeTypeEnum.TASK.getValue().equals(node.getNodeType())).toList(); + List performanceList = deleteNodeList.stream().filter(node -> NodeTypeEnum.PERFORMANCE.getValue().equals(node.getNodeType())).toList(); + if (CollectionUtils.isNotEmpty(performanceList)) { + List performanceNodeIdList = performanceList.stream().map(SpdmDeleteProjectDetailReq::getUuid).toList(); + log.info("删除指标:{}",performanceNodeIdList); + mapper.deletePerformanceList(performanceNodeIdList); + mapper.deletePerformanceExtraList(performanceNodeIdList); + } + + if (CollectionUtils.isNotEmpty(taskList)) { + List taskIdList = taskList.stream().map(SpdmDeleteProjectDetailReq::getUuid).toList(); + log.info("删除分析项:{}",taskIdList); + mapper.deleteTaskList(taskIdList); + mapper.deleteTaskExtraList(taskIdList); + mapper.deleteTaskMemberList(taskIdList); + } + + if (CollectionUtils.isNotEmpty(nodeList)) { + List nodeIdList = nodeList.stream().map(SpdmDeleteProjectDetailReq::getUuid).toList(); + log.info("删除节点:{}",nodeIdList); + mapper.deleteNodeList(nodeIdList); + mapper.deleteNodeExtraList(nodeIdList); + mapper.deleteNodeMemberList(nodeIdList); + for (String uuid : nodeIdList) { + deleteDirNew(uuid); + } + } + return SdmResponse.success(); + } + + private void handlePerformanceExtra(TaskNode projectNode, List performanceNodeList, List performanceNodeExtraList) { + performanceNodeList.add(projectNode); + List extraList = projectNode.getExtras(); + if (CollectionUtils.isNotEmpty(extraList)) { + for (TaskExtraNode extra : extraList) { + TaskExtraNode taskExtraNode = new TaskExtraNode(); + taskExtraNode.setUuid(RandomUtil.generateString(32)); + taskExtraNode.setPerformanceId(projectNode.getUuid()); + taskExtraNode.setTaskId(projectNode.getTaskId()); + taskExtraNode.setNodeId(projectNode.getNodeId()); + taskExtraNode.setPropertyName(extra.getPropertyName()); + taskExtraNode.setPropertyValue(extra.getPropertyValue()); + performanceNodeExtraList.add(taskExtraNode); + } + } + } + + private void handleTaskExtraAndMember(TaskNode projectNode, List taskNodeList, List projectNodeMemberList, List projectNodeExtraList, List tagList,HashMap> taskIdMap) { + if (StringUtils.isBlank(projectNode.getTaskName())) { + projectNode.setTaskName(projectNode.getNodeName()); + } + if (StringUtils.isBlank(projectNode.getTaskCode())) { + projectNode.setTaskCode(projectNode.getNodeCode()); + } + projectNode.setAnalyseSoftwares(projectNode.getAnalyseSoftware()); + if (CollectionUtils.isNotEmpty(tagList)) { +// List needAddTagList = new ArrayList<>(); +// List tags = tagList.stream().map(TaskNodeTag::getValue).toList(); + // 找出需要赋值的tag + List tag1List = projectNode.getTag1(); + if (CollectionUtils.isNotEmpty(tag1List)) { + if (tag1List.contains(null)) { + tag1List = tag1List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag1".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag1List)) { + tag1List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag1List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag1List)) { + projectNode.setTag1(new ArrayList<>(tag1List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag1".equals(taskNodeTag.getValue())) { + tag1List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag1List)) { + projectNode.setTag1(new ArrayList<>(tag1List)); + } + } + } + } + + List tag2List = projectNode.getTag2(); + if (CollectionUtils.isNotEmpty(tag2List)) { + if (tag2List.contains(null)) { + tag2List = tag2List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag2".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag2List)) { + tag2List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag2List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag2List)) { + projectNode.setTag2(new ArrayList<>(tag2List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag2".equals(taskNodeTag.getValue())) { + tag2List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag2List)) { + projectNode.setTag2(new ArrayList<>(tag2List)); + } + } + } + } + + List tag3List = projectNode.getTag3(); + if (CollectionUtils.isNotEmpty(tag3List)) { + if (tag3List.contains(null)) { + tag3List = tag3List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag3".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag3List)) { + tag3List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag3List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag3List)) { + projectNode.setTag3(new ArrayList<>(tag3List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag3".equals(taskNodeTag.getValue())) { + tag3List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag3List)) { + projectNode.setTag3(new ArrayList<>(tag3List)); + } + } + } + } + + List tag4List = projectNode.getTag4(); + if (CollectionUtils.isNotEmpty(tag4List)) { + if (tag4List.contains(null)) { + tag4List = tag4List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag4".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag4List)) { + tag4List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag4List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag4List)) { + projectNode.setTag4(new ArrayList<>(tag4List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag4".equals(taskNodeTag.getValue())) { + tag4List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag4List)) { + projectNode.setTag4(new ArrayList<>(tag4List)); + } + } + } + } + + + List tag5List = projectNode.getTag5(); + if (CollectionUtils.isNotEmpty(tag5List)) { + if (tag5List.contains(null)) { + tag5List = tag5List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag5".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag5List)) { + tag5List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag5List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag5List)) { + projectNode.setTag5(new ArrayList<>(tag5List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag5".equals(taskNodeTag.getValue())) { + tag5List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag5List)) { + projectNode.setTag5(new ArrayList<>(tag5List)); + } + } + } + } + + List tag6List = projectNode.getTag6(); + if (CollectionUtils.isNotEmpty(tag6List)) { + if (tag6List.contains(null)) { + tag6List = tag6List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag6".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag6List)) { + tag6List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag6List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag6List)) { + projectNode.setTag6(new ArrayList<>(tag6List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag6".equals(taskNodeTag.getValue())) { + tag6List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag6List)) { + projectNode.setTag6(new ArrayList<>(tag6List)); + } + } + } + } + + List tag7List = projectNode.getTag7(); + if (CollectionUtils.isNotEmpty(tag7List)) { + if (tag7List.contains(null)) { + tag7List = tag7List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag7".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag7List)) { + tag7List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag7List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag7List)) { + projectNode.setTag7(new ArrayList<>(tag7List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag7".equals(taskNodeTag.getValue())) { + tag7List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag7List)) { + projectNode.setTag7(new ArrayList<>(tag7List)); + } + } + } + } + + List tag8List = projectNode.getTag8(); + if (CollectionUtils.isNotEmpty(tag8List)) { + if (tag8List.contains(null)) { + tag8List = tag8List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag8".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag8List)) { + tag8List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag8List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag8List)) { + projectNode.setTag8(new ArrayList<>(tag8List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag8".equals(taskNodeTag.getValue())) { + tag8List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag8List)) { + projectNode.setTag8(new ArrayList<>(tag8List)); + } + } + } + } + + List tag9List = projectNode.getTag9(); + if (CollectionUtils.isNotEmpty(tag9List)) { + if (tag9List.contains(null)) { + tag9List = tag9List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag9".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag9List)) { + tag9List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag9List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag9List)) { + projectNode.setTag9(new ArrayList<>(tag9List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag9".equals(taskNodeTag.getValue())) { + tag9List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag9List)) { + projectNode.setTag9(new ArrayList<>(tag9List)); + } + } + } + } + + List tag10List = projectNode.getTag10(); + if (CollectionUtils.isNotEmpty(tag10List)) { + if (tag10List.contains(null)) { + tag10List = tag10List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag10".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag10List)) { + tag10List.addAll(taskIdMap.get(taskNodeTag.getKey())); + } else { + tag10List = taskIdMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag10List)) { + projectNode.setTag10(new ArrayList<>(tag10List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag10".equals(taskNodeTag.getValue())) { + tag10List = taskIdMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag10List)) { + projectNode.setTag10(new ArrayList<>(tag10List)); + } + } + } + } + + + } + + + taskNodeList.add(projectNode); + List taskMemberNodeList = projectNode.getMemberList(); + // 设置仿真执行人 + if (StringUtils.isNotBlank(projectNode.getEMemberList())) { + String[] userIdArr = projectNode.getEMemberList().split(","); + List longUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); + simulationTaskMemberService.saveTaskMemberList(projectNode.getUuid(), MemberTypeEnum.EXECUTOR.getCode(), longUserIdList); + } + // 设置仿真负责人 + if (StringUtils.isNotBlank(projectNode.getPMemberList())) { + String[] userIdArr = projectNode.getPMemberList().split(","); + List longUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); + simulationTaskMemberService.saveTaskMemberList(projectNode.getUuid(), MemberTypeEnum.PRINCIPAL.getCode(), longUserIdList); + } + + List extraList = projectNode.getExtras(); + if (CollectionUtils.isNotEmpty(extraList)) { + for (TaskExtraNode extra : extraList) { + TaskExtraNode taskExtraNode = new TaskExtraNode(); + taskExtraNode.setTaskId(projectNode.getUuid()); + taskExtraNode.setNodeId(projectNode.getUuid()); + taskExtraNode.setPropertyName(extra.getPropertyName()); + taskExtraNode.setPropertyValue(extra.getPropertyValue()); + projectNodeExtraList.add(taskExtraNode); + } + } + } + + private void handleNodeExtraAndMember(TaskNode projectNode, List projectNodeList, List projectNodeMemberList, List projectNodeExtraList,HashMap> idMap,HashMap> taskIdMap,List tagList) { + List tagStrList = idMap.get(projectNode.getNodeType()); + if (CollectionUtils.isEmpty(tagStrList)) { + tagStrList = new ArrayList<>(); + } + tagStrList.add(projectNode.getUuid()); + idMap.put(projectNode.getNodeType(), tagStrList); + taskIdMap.put(projectNode.getNodeType(), tagStrList); + List tag1List = projectNode.getTag1(); + if (CollectionUtils.isNotEmpty(tag1List)) { + if (tag1List.contains(null)) { + tag1List = tag1List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag1".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag1List)) { + tag1List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag1List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag1List)) { + projectNode.setTag1(new ArrayList<>(tag1List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag1".equals(taskNodeTag.getValue())) { + tag1List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag1List)) { + projectNode.setTag1(new ArrayList<>(tag1List)); + } + } + } + } + + List tag2List = projectNode.getTag2(); + if (CollectionUtils.isNotEmpty(tag2List)) { + if (tag2List.contains(null)) { + tag2List = tag2List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag2".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag2List)) { + tag2List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag2List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag2List)) { + projectNode.setTag2(new ArrayList<>(tag2List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag2".equals(taskNodeTag.getValue())) { + tag2List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag2List)) { + projectNode.setTag2(new ArrayList<>(tag2List)); + } + } + } + } + + List tag3List = projectNode.getTag3(); + if (CollectionUtils.isNotEmpty(tag3List)) { + if (tag3List.contains(null)) { + tag3List = tag3List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag3".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag3List)) { + tag3List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag3List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag3List)) { + projectNode.setTag3(new ArrayList<>(tag3List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag3".equals(taskNodeTag.getValue())) { + tag3List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag3List)) { + projectNode.setTag3(new ArrayList<>(tag3List)); + } + } + } + } + + List tag4List = projectNode.getTag4(); + if (CollectionUtils.isNotEmpty(tag4List)) { + if (tag4List.contains(null)) { + tag4List = tag4List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag4".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag4List)) { + tag4List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag4List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag4List)) { + projectNode.setTag4(new ArrayList<>(tag4List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag4".equals(taskNodeTag.getValue())) { + tag4List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag4List)) { + projectNode.setTag4(new ArrayList<>(tag4List)); + } + } + } + } + + List tag5List = projectNode.getTag5(); + if (CollectionUtils.isNotEmpty(tag5List)) { + if (tag5List.contains(null)) { + tag5List = tag5List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag5".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag5List)) { + tag5List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag5List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag5List)) { + projectNode.setTag5(new ArrayList<>(tag5List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag5".equals(taskNodeTag.getValue())) { + tag5List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag5List)) { + projectNode.setTag5(new ArrayList<>(tag5List)); + } + } + } + } + + List tag6List = projectNode.getTag6(); + if (CollectionUtils.isNotEmpty(tag6List)) { + if (tag6List.contains(null)) { + tag6List = tag6List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag6".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag6List)) { + tag6List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag6List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag6List)) { + projectNode.setTag6(new ArrayList<>(tag6List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag6".equals(taskNodeTag.getValue())) { + tag6List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag6List)) { + projectNode.setTag6(new ArrayList<>(tag6List)); + } + } + } + } + + List tag7List = projectNode.getTag7(); + if (CollectionUtils.isNotEmpty(tag7List)) { + if (tag7List.contains(null)) { + tag7List = tag7List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag7".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag7List)) { + tag7List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag7List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag7List)) { + projectNode.setTag7(new ArrayList<>(tag7List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag7".equals(taskNodeTag.getValue())) { + tag7List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag7List)) { + projectNode.setTag7(new ArrayList<>(tag7List)); + } + } + } + } + + List tag8List = projectNode.getTag8(); + if (CollectionUtils.isNotEmpty(tag8List)) { + if (tag8List.contains(null)) { + tag8List = tag8List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag8".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag8List)) { + tag8List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag8List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag8List)) { + projectNode.setTag8(new ArrayList<>(tag8List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag8".equals(taskNodeTag.getValue())) { + tag8List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag8List)) { + projectNode.setTag8(new ArrayList<>(tag8List)); + } + } + } + } + + List tag9List = projectNode.getTag9(); + if (CollectionUtils.isNotEmpty(tag9List)) { + if (tag9List.contains(null)) { + tag9List = tag9List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag9".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag9List)) { + tag9List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag9List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag9List)) { + projectNode.setTag9(new ArrayList<>(tag9List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag9".equals(taskNodeTag.getValue())) { + tag9List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag9List)) { + projectNode.setTag9(new ArrayList<>(tag9List)); + } + } + } + } + + List tag10List = projectNode.getTag10(); + if (CollectionUtils.isNotEmpty(tag10List)) { + if (tag10List.contains(null)) { + tag10List = tag10List.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()); + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag10".equals(taskNodeTag.getValue())) { + if (CollectionUtils.isNotEmpty(tag10List)) { + tag10List.addAll(idMap.get(taskNodeTag.getKey())); + } else { + tag10List = idMap.get(taskNodeTag.getKey()); + } + if (CollectionUtils.isNotEmpty(tag10List)) { + projectNode.setTag10(new ArrayList<>(tag10List)); + } + } + } + } + }else { + for (TaskNodeTag taskNodeTag : tagList) { + if ("tag10".equals(taskNodeTag.getValue())) { + tag10List = idMap.get(taskNodeTag.getKey()); + if (CollectionUtils.isNotEmpty(tag10List)) { + projectNode.setTag10(new ArrayList<>(tag10List)); + } + } + } + } + + + + + + projectNodeList.add(projectNode); + List taskMemberNodeList = projectNode.getMemberList(); + if (CollectionUtils.isNotEmpty(taskMemberNodeList)) { + for (TaskMemberNode member : taskMemberNodeList) { + TaskMemberNode taskMemberNode = new TaskMemberNode(); + taskMemberNode.setNodeId(projectNode.getUuid()); + taskMemberNode.setIdentity(member.getIdentity()); + taskMemberNode.setName(member.getName()); + projectNodeMemberList.add(taskMemberNode); + } + } + + List extraList = projectNode.getExtras(); + if (CollectionUtils.isNotEmpty(extraList)) { + for (TaskExtraNode extra : extraList) { + TaskExtraNode taskExtraNode = new TaskExtraNode(); + taskExtraNode.setNodeId(projectNode.getUuid()); + taskExtraNode.setPropertyName(extra.getPropertyName()); + taskExtraNode.setPropertyValue(extra.getPropertyValue()); + projectNodeExtraList.add(taskExtraNode); + } + } + } + + private void updatePermission(Long userId,String uuid) { + // 更新文件权限 + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(userId); + updatePermissionReq.setUuid(uuid); + Map userPermissions = new HashMap<>(); + userPermissions.put(userId, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("仿真策划时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataClientFeignClient.updatePermission(updatePermissionReq); + log.info("仿真策划时,更新用户权限的返回值为:{}",updatePermissionResponse); + } + + private SdmResponse newRealAddSimulationTaskItems(TaskNodeTree taskNodeTree, Long tenantId, List tagList, String ownRootNodeUuid) { + Long userId = ThreadLocalContext.getUserId(); + SdmResponse response = SdmResponse.success(); + if (CollectionUtils.isEmpty(taskNodeTree.getNodeList())) { + response = SdmResponse.failed("节点不能为空"); + } else { + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + List projectNodeList = new ArrayList<>(); + List projectNodeMemberList = new ArrayList<>(); + List projectNodeExtraList = new ArrayList<>(); + List taskNodeList = new ArrayList<>(); + List taskNodeMemberList = new ArrayList<>(); + List taskNodeExtraList = new ArrayList<>(); + List projectNodePerformanceList = new ArrayList<>(); + List projectNodePerformanceExtraList = new ArrayList<>(); + HashMap> idMap = new HashMap<>(); + HashMap> taskIdMap = new HashMap<>(); + for (TaskNode taskNode : taskNodeTree.getNodeList()) { + currentTopNodeType = taskNode.getNodeType(); + traverseTaskNode(taskNode.getPid(), tenantId, VersionEnum.INITIAL.getCode(), taskNode, projectNodeList, projectNodeMemberList, projectNodeExtraList, taskNodeList, taskNodeMemberList, taskNodeExtraList, projectNodePerformanceList, projectNodePerformanceExtraList, tagList,idMap,taskIdMap); + taskIdMap.clear(); + idMap.clear(); + } + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String createTime = format.format(new Date()); + Map projectNodeMap = Map.of(); + Map taskNodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(projectNodeList)) { + projectNodeList.forEach(node -> + { + node.setCreateTime(curDateStr); + node.setOwnRootNodeUuid(ownRootNodeUuid); + }); + + if (mapper.batchAddSimulationNodes(projectNodeList) <= 0) { + response = SdmResponse.failed("添加节点失败"); + return response; + } + log.info("添加节点成功,项目根节点:ownRootNodeUuid:{}",ownRootNodeUuid); + projectNodeMap = projectNodeList.stream().collect(Collectors.groupingBy( + TaskNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + Map projectNodePoMap = Map.of(); + List newProjectNodeList = mapper.getNodeListByNodeIdList(projectNodeList.stream().map(TaskNode::getParentId).toList()); + if (CollectionUtils.isNotEmpty(newProjectNodeList)) { + projectNodePoMap = newProjectNodeList.stream().collect(Collectors.groupingBy( + ProjectNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + for (TaskNode taskNode : projectNodeList) { + if (ObjectUtils.isEmpty(projectNodeMap.get(taskNode.getParentId())) + && ObjectUtils.isEmpty(projectNodePoMap.get(taskNode.getParentId())) && !NodeTypeEnum.PROJECT.getValue().equals(taskNode.getNodeType())) { + log.error("新增节点时,根据parentId:{},未查询到节点", taskNode.getParentId()); + response = SdmResponse.failed("新增节点时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(),taskNode.getNodeType(), + NodeTypeEnum.PROJECT.getValue().equals(taskNode.getNodeType()) ? null : (ObjectUtils.isNotEmpty(projectNodePoMap.get(taskNode.getParentId())) + ? projectNodePoMap.get(taskNode.getParentId()).getUuid() + : projectNodeMap.get(taskNode.getParentId()).getUuid()), + taskNode.getNodeName()); + } + for (TaskNode taskNode : projectNodeList) { + updatePermission(userId,taskNode.getUuid()); + } + } + if (CollectionUtils.isNotEmpty(projectNodeExtraList)) { + projectNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationNodeExtra(projectNodeExtraList) <= 0) { + response = SdmResponse.failed("添加节点附加属性失败"); + return response; + } + } + if (CollectionUtils.isNotEmpty(projectNodeMemberList)) { + projectNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationNodeMember(projectNodeMemberList) <= 0) { + response = SdmResponse.failed("添加节点成员属性失败"); + } + } + + if (CollectionUtils.isNotEmpty(taskNodeList)) { + taskNodeList.forEach(projectNode -> { +// projectNode.setCreator(jobNumber); + projectNode.setCreateTime(createTime); + }); + if (mapper.batchAddSimulationTask(taskNodeList) <= 0) { + response = SdmResponse.failed("新增任务失败"); + return response; + } + taskNodeMap = taskNodeList.stream().collect(Collectors.groupingBy( + TaskNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + Map projectNodePoMap = Map.of(); + List newProjectNodeList = mapper.getNodeListByNodeIdList(taskNodeList.stream().map(TaskNode::getParentId).toList()); + if (CollectionUtils.isNotEmpty(newProjectNodeList)) { + projectNodePoMap = newProjectNodeList.stream().collect(Collectors.groupingBy( + ProjectNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + if (projectNodeMap.isEmpty()) { + // projectNodeMap为空说明是直接添加分析项的情况 + for (TaskNode taskNode : taskNodeList) { + if (ObjectUtils.isEmpty(projectNodePoMap.get(taskNode.getParentId()))) { + log.error("projectNodeMap为空,根据parentId:{},未查询到节点", taskNode.getParentId()); + response = SdmResponse.failed("新增分析项时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(),taskNode.getNodeType(), projectNodePoMap.get(taskNode.getParentId()).getUuid(), taskNode.getNodeName()); + + } + } else { + for (TaskNode taskNode : taskNodeList) { + if (ObjectUtils.isEmpty(projectNodePoMap.get(taskNode.getParentId())) && ObjectUtils.isEmpty(projectNodeMap.get(taskNode.getParentId()))) { + log.error("projectNodeMap不空,根据parentId:{},未查询到节点", taskNode.getParentId()); + response = SdmResponse.failed("新增分析项时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(),taskNode.getNodeType(), + ObjectUtils.isNotEmpty(projectNodePoMap.get(taskNode.getParentId())) ? projectNodePoMap.get(taskNode.getParentId()).getUuid() : projectNodeMap.get(taskNode.getParentId()).getUuid(), + taskNode.getNodeName()); + } + } + for (TaskNode taskNode : taskNodeList) { + updatePermission(userId,taskNode.getUuid()); + } + } + if (CollectionUtils.isNotEmpty(taskNodeExtraList)) { + taskNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationTaskExtra(taskNodeExtraList) <= 0) { + response = SdmResponse.failed("新增任务附加属性失败"); + } + } + if (CollectionUtils.isNotEmpty(taskNodeMemberList)) { + taskNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationTaskMember(taskNodeMemberList) <= 0) { + response = SdmResponse.failed("新增任务成员属性失败"); + return response; + } + } + if (CollectionUtils.isNotEmpty(projectNodePerformanceList)) { + projectNodePerformanceList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationPerformance(projectNodePerformanceList) <= 0) { + response = SdmResponse.failed("新增指标失败"); + return response; + } + List newTaskNodeList = mapper.getTaskListByNodeIdList(projectNodePerformanceList.stream().map(TaskNode::getTaskId).toList()); + Map taskNodePoMap = Map.of(); + if (CollectionUtils.isNotEmpty(newTaskNodeList)) { + taskNodePoMap = newTaskNodeList.stream().collect(Collectors.groupingBy( + TaskNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + if (taskNodeMap.isEmpty()) { + // taskNodeMap为空说明是直接添加指标的情况 + for (TaskNode taskNode : projectNodePerformanceList) { + if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId()))) { + log.error("taskNodeMap为空,根据taskId:{},未查询到任务", taskNode.getTaskId()); + response = SdmResponse.failed("新增指标时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), taskNode.getNodeType(), taskNodePoMap.get(taskNode.getTaskId()).getUuid(), taskNode.getNodeName()); + } + } else { + for (TaskNode taskNode : projectNodePerformanceList) { + if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId())) && ObjectUtils.isEmpty(taskNodeMap.get(taskNode.getTaskId()))) { + log.error("taskNodeMap不空,根据taskId:{},未查询到任务", taskNode.getTaskId()); + response = SdmResponse.failed("新增指标时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(),taskNode.getNodeType(), + ObjectUtils.isNotEmpty(taskNodePoMap.get(taskNode.getTaskId())) ? taskNodePoMap.get(taskNode.getTaskId()).getUuid() : taskNodeMap.get(taskNode.getTaskId()).getUuid(), + taskNode.getNodeName()); + } + } + for (TaskNode taskNode : projectNodePerformanceList) { + updatePermission(userId,taskNode.getUuid()); + } + } + if (CollectionUtils.isNotEmpty(projectNodePerformanceExtraList)) { + projectNodePerformanceExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationPerformanceExtra(projectNodePerformanceExtraList) <= 0) { + response = SdmResponse.failed("新增任务指标附加属性失败"); + return response; + } + } + } + return response; + } + + private SdmResponse realAddSimulationTaskItems(TaskNodeTree taskNodeTree, String parentId, Long tenantId,HashMap> idMap,HashMap> taskIdMap) { + Long jobNumber = ThreadLocalContext.getUserId(); + SdmResponse response = SdmResponse.success(); + if (CollectionUtils.isEmpty(taskNodeTree.getNodeList())) { + response = SdmResponse.failed("节点不能为空"); + } else { + List projectNodeList = new ArrayList<>(); + List projectNodeMemberList = new ArrayList<>(); + List projectNodeExtraList = new ArrayList<>(); + List taskNodeList = new ArrayList<>(); + List taskNodeMemberList = new ArrayList<>(); + List taskNodeExtraList = new ArrayList<>(); + List projectNodePerformanceList = new ArrayList<>(); + List projectNodePerformanceExtraList = new ArrayList<>(); + for (TaskNode taskNode : taskNodeTree.getNodeList()) { + traverseTaskNode(taskNode.getPid(), tenantId, VersionEnum.INITIAL.getCode(), taskNode, projectNodeList, projectNodeMemberList, projectNodeExtraList, taskNodeList, taskNodeMemberList, taskNodeExtraList, projectNodePerformanceList, projectNodePerformanceExtraList, null,idMap,taskIdMap); + } + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String createTime = format.format(new Date()); + Map projectNodeMap = Map.of(); + Map taskNodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(projectNodeList)) { + projectNodeList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationNodes(projectNodeList) <= 0) { + response = SdmResponse.failed("添加节点失败"); + return response; + } + projectNodeMap = projectNodeList.stream().collect(Collectors.groupingBy( + TaskNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + Map projectNodePoMap = Map.of(); + List newProjectNodeList = mapper.getNodeListByNodeIdList(projectNodeList.stream().map(TaskNode::getParentId).toList()); + if (CollectionUtils.isNotEmpty(newProjectNodeList)) { + projectNodePoMap = newProjectNodeList.stream().collect(Collectors.groupingBy( + ProjectNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + for (TaskNode taskNode : projectNodeList) { + if (ObjectUtils.isEmpty(projectNodeMap.get(taskNode.getParentId())) + && ObjectUtils.isEmpty(projectNodePoMap.get(taskNode.getParentId())) && !NodeTypeEnum.PROJECT.getValue().equals(taskNode.getNodeType())) { + log.error("新增节点时,根据parentId:{},未查询到节点", taskNode.getParentId()); + response = SdmResponse.failed("新增节点时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), + NodeTypeEnum.PROJECT.getValue().equals(taskNode.getNodeType()) ? null : (ObjectUtils.isNotEmpty(projectNodePoMap.get(taskNode.getParentId())) + ? projectNodePoMap.get(taskNode.getParentId()).getUuid() + : projectNodeMap.get(taskNode.getParentId()).getUuid()), + taskNode.getNodeName()); + } + } + if (CollectionUtils.isNotEmpty(projectNodeExtraList)) { + projectNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationNodeExtra(projectNodeExtraList) <= 0) { + response = SdmResponse.failed("添加节点附加属性失败"); + return response; + } + } + if (CollectionUtils.isNotEmpty(projectNodeMemberList)) { + projectNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationNodeMember(projectNodeMemberList) <= 0) { + response = SdmResponse.failed("添加节点成员属性失败"); + } + } + + if (CollectionUtils.isNotEmpty(taskNodeList)) { + taskNodeList.forEach(projectNode -> { +// projectNode.setCreator(jobNumber); + projectNode.setCreateTime(createTime); + }); + if (mapper.batchAddSimulationTask(taskNodeList) <= 0) { + response = SdmResponse.failed("新增任务失败"); + return response; + } + taskNodeMap = taskNodeList.stream().collect(Collectors.groupingBy( + TaskNode::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + Map projectNodePoMap = Map.of(); + List newProjectNodeList = mapper.getNodeListByNodeIdList(taskNodeList.stream().map(TaskNode::getParentId).toList()); + if (CollectionUtils.isNotEmpty(newProjectNodeList)) { + projectNodePoMap = newProjectNodeList.stream().collect(Collectors.groupingBy( + ProjectNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + if (projectNodeMap.isEmpty()) { + // projectNodeMap为空说明是直接添加分析项的情况 + for (TaskNode taskNode : taskNodeList) { + if (ObjectUtils.isEmpty(projectNodePoMap.get(taskNode.getParentId()))) { + log.error("projectNodeMap为空,根据parentId:{},未查询到节点", taskNode.getParentId()); + response = SdmResponse.failed("新增分析项时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), projectNodePoMap.get(taskNode.getParentId()).getUuid(), taskNode.getNodeName()); + } + } else { + for (TaskNode taskNode : taskNodeList) { + if (ObjectUtils.isEmpty(projectNodePoMap.get(taskNode.getParentId())) && ObjectUtils.isEmpty(projectNodeMap.get(taskNode.getParentId()))) { + log.error("projectNodeMap不空,根据parentId:{},未查询到节点", taskNode.getParentId()); + response = SdmResponse.failed("新增分析项时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), + ObjectUtils.isNotEmpty(projectNodePoMap.get(taskNode.getParentId())) ? projectNodePoMap.get(taskNode.getParentId()).getUuid() : projectNodeMap.get(taskNode.getParentId()).getUuid(), + taskNode.getNodeName()); + } + } + } + if (CollectionUtils.isNotEmpty(taskNodeExtraList)) { + taskNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationTaskExtra(taskNodeExtraList) <= 0) { + response = SdmResponse.failed("新增任务附加属性失败"); + } + } + if (CollectionUtils.isNotEmpty(taskNodeMemberList)) { + taskNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationTaskMember(taskNodeMemberList) <= 0) { + response = SdmResponse.failed("新增任务成员属性失败"); + return response; + } + } + if (CollectionUtils.isNotEmpty(projectNodePerformanceList)) { + projectNodePerformanceList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationPerformance(projectNodePerformanceList) <= 0) { + response = SdmResponse.failed("新增指标失败"); + return response; + } + + List newTaskNodeList = mapper.getTaskListByNodeIdList(projectNodePerformanceList.stream().map(TaskNode::getTaskId).toList()); + Map taskNodePoMap = Map.of(); + if (CollectionUtils.isNotEmpty(newTaskNodeList)) { + taskNodePoMap = newTaskNodeList.stream().collect(Collectors.groupingBy( + TaskNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + if (taskNodeMap.isEmpty()) { + // taskNodeMap为空说明是直接添加指标的情况 + for (TaskNode taskNode : projectNodePerformanceList) { + if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId()))) { + log.error("taskNodeMap为空,根据taskId:{},未查询到任务", taskNode.getTaskId()); + response = SdmResponse.failed("新增指标时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), taskNodePoMap.get(taskNode.getTaskId()).getUuid(), taskNode.getNodeName()); + } + } else { + for (TaskNode taskNode : projectNodePerformanceList) { + if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId())) && ObjectUtils.isEmpty(taskNodeMap.get(taskNode.getTaskId()))) { + log.error("taskNodeMap不空,根据taskId:{},未查询到任务", taskNode.getTaskId()); + response = SdmResponse.failed("新增指标时,创建文件失败"); + return response; + } + createDir(taskNode.getUuid(), + ObjectUtils.isNotEmpty(taskNodePoMap.get(taskNode.getTaskId())) ? taskNodePoMap.get(taskNode.getTaskId()).getUuid() : taskNodeMap.get(taskNode.getTaskId()).getUuid(), + taskNode.getNodeName()); + } + } + } + if (CollectionUtils.isNotEmpty(projectNodePerformanceExtraList)) { + projectNodePerformanceExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); + if (mapper.batchAddSimulationPerformanceExtra(projectNodePerformanceExtraList) <= 0) { + response = SdmResponse.failed("新增任务指标附加属性失败"); + return response; + } + } + } + return response; + } + + private void createDir(String uuid, String parentUuid, String dirName) { + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setParentUuId(parentUuid); + createDirReq.setDirName(dirName); + log.info("调用创建文件夹的参数为:{}", createDirReq); +// SdmResponse response = dataClientAPIClient.createDir(createDirReq); +// log.info("调用创建文件夹的返回值为:{}", response); + } + + /** + * 创建文件夹 + * + * @param uuid 待创建节点uuid + * @param uuidOwnType 待创建节点类型:node,task,run,performance + * @param parentUuid 父节点uuid + * @param dirName 待长江文件夹名称 + */ + private void createDir(String uuid, String uuidOwnType, String parentUuid, String dirName) { + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setUuIdOwnType(uuidOwnType); + createDirReq.setParentUuId(ObjectUtils.isNotEmpty(parentUuid) ? parentUuid : null); + createDirReq.setDirName(dirName); + createDirReq.setDirType(DirTypeEnum.PROJECT_NODE_DIR.getValue()); + log.info("创建项目阶段时,调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataClientFeignClient.createDir(createDirReq); + log.info("创建项目阶段时,调用创建文件夹的返回值为:{}", response); + } + + // 重命名文件夹 + public void renameDirNew(String uuid, String newDirName) { + RenameDirReq req = new RenameDirReq(); + req.setUuid(uuid); + req.setNewName(newDirName); + log.info("调用重命名文件夹的参数为:{}", req); + SdmResponse response = dataClientFeignClient.renameDirNew(req); + log.info("调用重命名文件夹的返回值为:{}", response); + } + + // 删除文件夹 + public void deleteDirNew(String uuid) { + DelDirReq req = new DelDirReq(); + req.setDelUuid(uuid); + log.info("调用删除文件夹的参数为:{}", req); + SdmResponse response = dataClientFeignClient.delDir(req); + log.info("调用删除文件夹的返回值为:{}", response); + } + + + private void traverseTaskNode(String parentId, Long tenantId, String nodeVersion, TaskNode eachProjectNode, List projectNodeList, List projectNodeMemberList, List projectNodeExtraList, List taskNodeList, List taskNodeMemberList, List taskNodeExtraList, List taskPerformanceList, List performanceExtraList, List tagList,HashMap> idMap,HashMap> taskIdMap) { + log.info("当前顶级节点类型为:{}", currentTopNodeType); + eachProjectNode.setUuid(RandomUtil.generateString(32)); + eachProjectNode.setParentId(StringUtils.isNotEmpty(parentId) ? parentId : "0"); + eachProjectNode.setNodeId(eachProjectNode.getParentId()); + eachProjectNode.setNodeVersion(nodeVersion); + eachProjectNode.setTenantId(tenantId); + String nodeType = eachProjectNode.getNodeType(); + List childrenNodeList = eachProjectNode.getChildren(); + if (NodeTypeEnum.TASK.getValue().equals(nodeType)) { + handleTaskExtraAndMember(eachProjectNode, taskNodeList, taskNodeMemberList, taskNodeExtraList, tagList,taskIdMap); + } else if (NodeTypeEnum.PERFORMANCE.getValue().equals(nodeType)) { + eachProjectNode.setTaskId(parentId); + handlePerformanceExtra(eachProjectNode, taskPerformanceList, performanceExtraList); + } else { + handleNodeExtraAndMember(eachProjectNode, projectNodeList, projectNodeMemberList, projectNodeExtraList,idMap,taskIdMap, tagList); + } + if (CollectionUtils.isEmpty(childrenNodeList)) { + return; + } + // 在处理子节点前,保留当前父节点id + HashMap> currentIdMap = new HashMap<>(); + for (Map.Entry> entry : idMap.entrySet()) { + currentIdMap.put(entry.getKey(),new ArrayList<>(entry.getValue())); + } + HashMap> currentTaskIdMap = new HashMap<>(taskIdMap); + for (Map.Entry> entry : taskIdMap.entrySet()) { + currentTaskIdMap.put(entry.getKey(),new ArrayList<>(entry.getValue())); + } + // 处理子节点 + for (TaskNode node : childrenNodeList) { + traverseTaskNode(eachProjectNode.getUuid(), tenantId, nodeVersion, node, projectNodeList, projectNodeMemberList, projectNodeExtraList, taskNodeList, taskNodeMemberList, taskNodeExtraList, taskPerformanceList, performanceExtraList, tagList,idMap,taskIdMap); + idMap = new HashMap<>(currentIdMap); + taskIdMap = new HashMap<>(currentTaskIdMap); + } + } + + private TaskNodeTree newParseTaskTree(JSONArray nodeArray) { + TaskNodeTree taskNodeTree = new TaskNodeTree(); + try { + if (nodeArray != null) { + for (int index = 0; index < nodeArray.size(); index++) { + JSONObject nodeObj = nodeArray.getJSONObject(index); + TaskNode taskNode = parseNodeJson(nodeObj); + if (taskNode != null) { + taskNodeTree.getNodeList().add(taskNode); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return taskNodeTree; + } + + private TaskNodeTree parseTaskTree(JSONObject taskTree) { + TaskNodeTree taskNodeTree = new TaskNodeTree(); + try { + JSONArray nodeArray = taskTree.getJSONArray("nodeList"); + if (nodeArray != null) { + for (int index = 0; index < nodeArray.size(); index++) { + JSONObject nodeObj = nodeArray.getJSONObject(index); + TaskNode taskNode = parseNodeJson(nodeObj); + if (taskNode != null) { + taskNodeTree.getNodeList().add(taskNode); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return taskNodeTree; + } + + private TaskNode parseNodeJson(JSONObject nodeJson) { + ObjectMapper objectMapper = new ObjectMapper(); + TaskNode taskNode = null; + try { + taskNode = objectMapper.readValue(nodeJson.toString(), TaskNode.class); + JSONArray nodeChildArray = nodeJson.getJSONArray("children"); + if (nodeChildArray != null && !nodeChildArray.isEmpty()) { + List taskNodeList = new ArrayList<>(); + for (int index = 0; index < nodeChildArray.size(); index++) { + JSONObject jsonObject = nodeChildArray.getJSONObject(index); + if (jsonObject != null) { + TaskNode subNode = parseNodeJson(jsonObject); + if (subNode != null) { + taskNodeList.add(subNode); + } + } + } + taskNode.setChildren(taskNodeList); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return taskNode; + } + + @Override + public SdmResponse taskHandle(String taskId, Integer handleType) { + Long jobNumber = ThreadLocalContext.getUserId(); + List taskNodePoList = mapper.getTaskListByNodeIdList(Collections.singletonList(taskId)); + if (CollectionUtils.isEmpty(taskNodePoList)) { + log.error("根据taskId:{},未查询到任务", taskId); + return SdmResponse.failed("未查询到任务"); + } + // 0:驳回,1:通过 + TaskEditNodeReq taskEditNodeReq = new TaskEditNodeReq(); + taskEditNodeReq.setUuid(taskId); + taskEditNodeReq.setConfirmStatus(handleType == 0 ? "0" : "1"); + taskEditNodeReq.setUpdater(jobNumber); + taskEditNodeReq.setUpdateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + if (mapper.updateProjectNodeItem(taskEditNodeReq) <= 0) { + return SdmResponse.failed((handleType == 0 ? "驳回" : "通过") + "任务失败"); + } + return SdmResponse.success(); + } + + @Transactional + @Override + public SdmResponse modify(ModifyProjectNode req) { + log.info("newModify参数为:{}", req); + List addNodeList = req.getAddNodeList(); + List editNodeList = req.getEditNodeList(); + List deleteNodeList = req.getDeleteNodeList(); + if (CollectionUtils.isNotEmpty(addNodeList)) { + Long tenantId = ThreadLocalContext.getTenantId(); + TaskNodeTree taskNodeTree = newParseTaskTree(JSONArray.parseArray(JSONArray.toJSONString(addNodeList))); + tagMap = req.getTagMap(); + SdmResponse response = newRealAddSimulationTaskItems(taskNodeTree, tenantId, req.getTagMap(),req.getOwnRootNodeUuid()); + if (response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("新增任务、分析项失败,清理新增数据!"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("新增任务、分析项失败!"); + } + } else if (CollectionUtils.isNotEmpty(editNodeList)) { + SdmResponse response = edit(editNodeList); + if (response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("修改任务、分析项失败,清理新增数据!"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("新增任务、分析项失败!"); + } + } else if (CollectionUtils.isNotEmpty(deleteNodeList)) { + log.info("删除节点参数为:{}",deleteNodeList); + SpdmDeleteProjectReq spdmDeleteProjectReq = new SpdmDeleteProjectReq(); + spdmDeleteProjectReq.setDeleteNodeList(deleteNodeList); + SdmResponse response = delete(spdmDeleteProjectReq); + if (response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("删除任务、分析项失败,清理新增数据!"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return SdmResponse.failed("删除任务、分析项失败!"); + } + } + return SdmResponse.success(); + } + + @Override + public SdmResponse exportTaskTree(TaskTreeExportExcelFormat taskTreeExportExcelFormat, HttpServletResponse httpServletResponse) { + // 补充表头 + List exportExcelFormats = taskTreeExportExcelFormat.getExcelHeaders(); + if (CollectionUtils.isEmpty(exportExcelFormats)) { + log.error("导出的表头为空"); + return SdmResponse.failed("导出的表头不能为空"); + } + Optional nodeNameOptional = exportExcelFormats.stream().filter(header -> "nodeName".equals(header.getKey())).findAny(); + Optional nodeCodeOptional = exportExcelFormats.stream().filter(header -> "nodeCode".equals(header.getKey())).findAny(); + Optional pMemberListOptional = exportExcelFormats.stream().filter(header -> "pMemberList".equals(header.getKey())).findAny(); + Optional eMemberListOptional = exportExcelFormats.stream().filter(header -> "eMemberList".equals(header.getKey())).findAny(); + List fixedHeaderList = new ArrayList<>(); + if (nodeNameOptional.isPresent() && nodeCodeOptional.isPresent()) { + // 机台 + ExportExcelFormat machineNameExportExcelFormat = new ExportExcelFormat(); + machineNameExportExcelFormat.setKey(NODE_NAME_KEY); + machineNameExportExcelFormat.setTitle(MACHINE_NAME); + ExportExcelFormat machineCodeExportExcelFormat = new ExportExcelFormat(); + machineCodeExportExcelFormat.setKey(NODE_CODE_KEY); + machineCodeExportExcelFormat.setTitle(MACHINE_CODE); + + // 工位 + ExportExcelFormat workspaceNameExportExcelFormat = new ExportExcelFormat(); + workspaceNameExportExcelFormat.setKey(NODE_NAME_KEY); + workspaceNameExportExcelFormat.setTitle(WORKSPACE_NAME); + ExportExcelFormat workspaceCodeExportExcelFormat = new ExportExcelFormat(); + workspaceCodeExportExcelFormat.setKey(NODE_CODE_KEY); + workspaceCodeExportExcelFormat.setTitle(WORKSPACE_CODE); + + // 学科 + ExportExcelFormat disciplineNameExportExcelFormat = new ExportExcelFormat(); + disciplineNameExportExcelFormat.setKey(NODE_NAME_KEY); + disciplineNameExportExcelFormat.setTitle(DISCIPLINE_NAME); + ExportExcelFormat disciplineCodeExportExcelFormat = new ExportExcelFormat(); + disciplineCodeExportExcelFormat.setKey(NODE_CODE_KEY); + disciplineCodeExportExcelFormat.setTitle(DISCIPLINE_CODE); + + // 任务 + ExportExcelFormat taskNameExportExcelFormat = new ExportExcelFormat(); + taskNameExportExcelFormat.setKey(NODE_NAME_KEY); + taskNameExportExcelFormat.setTitle(TASK_NAME); + ExportExcelFormat taskCodeExportExcelFormat = new ExportExcelFormat(); + taskCodeExportExcelFormat.setKey(NODE_CODE_KEY); + taskCodeExportExcelFormat.setTitle(TASK_CODE); + ExportExcelFormat taskPmemberListExportExcelFormat = new ExportExcelFormat(); + if (pMemberListOptional.isPresent()) { + taskPmemberListExportExcelFormat.setKey(PMEMBER_CODE_KEY); + taskPmemberListExportExcelFormat.setTitle(PMEMBER_NAME); + } + ExportExcelFormat taskEmemberListExportExcelFormat = new ExportExcelFormat(); + if (eMemberListOptional.isPresent()) { + taskEmemberListExportExcelFormat.setKey(EMEMBER_CODE_KEY); + taskEmemberListExportExcelFormat.setTitle(EMEMBER_NAME); + } + + // 指标 + ExportExcelFormat performanceNameExportExcelFormat = new ExportExcelFormat(); + performanceNameExportExcelFormat.setKey(NODE_NAME_KEY); + performanceNameExportExcelFormat.setTitle(PERFORMANCE_NAME); + ExportExcelFormat performanceCodeExportExcelFormat = new ExportExcelFormat(); + performanceCodeExportExcelFormat.setKey(NODE_CODE_KEY); + performanceCodeExportExcelFormat.setTitle(PERFORMANCE_CODE); + + fixedHeaderList.add(machineNameExportExcelFormat); + fixedHeaderList.add(machineCodeExportExcelFormat); + fixedHeaderList.add(workspaceNameExportExcelFormat); + fixedHeaderList.add(workspaceCodeExportExcelFormat); + fixedHeaderList.add(disciplineNameExportExcelFormat); + fixedHeaderList.add(disciplineCodeExportExcelFormat); + fixedHeaderList.add(taskNameExportExcelFormat); + fixedHeaderList.add(taskCodeExportExcelFormat); + if (pMemberListOptional.isPresent()) { + fixedHeaderList.add(taskPmemberListExportExcelFormat); + } + if (eMemberListOptional.isPresent()) { + fixedHeaderList.add(taskEmemberListExportExcelFormat); + } + fixedHeaderList.add(performanceNameExportExcelFormat); + fixedHeaderList.add(performanceCodeExportExcelFormat); + }else if (nodeNameOptional.isPresent()) { + // 机台 + ExportExcelFormat machineNameExportExcelFormat = new ExportExcelFormat(); + machineNameExportExcelFormat.setKey(NODE_NAME_KEY); + machineNameExportExcelFormat.setTitle(MACHINE_NAME); + + // 工位 + ExportExcelFormat workspaceNameExportExcelFormat = new ExportExcelFormat(); + workspaceNameExportExcelFormat.setKey(NODE_NAME_KEY); + workspaceNameExportExcelFormat.setTitle(WORKSPACE_NAME); + + // 学科 + ExportExcelFormat disciplineNameExportExcelFormat = new ExportExcelFormat(); + disciplineNameExportExcelFormat.setKey(NODE_NAME_KEY); + disciplineNameExportExcelFormat.setTitle(DISCIPLINE_NAME); + + // 任务 + ExportExcelFormat taskNameExportExcelFormat = new ExportExcelFormat(); + taskNameExportExcelFormat.setKey(NODE_NAME_KEY); + taskNameExportExcelFormat.setTitle(TASK_NAME); + ExportExcelFormat taskPmemberListExportExcelFormat = new ExportExcelFormat(); + if (pMemberListOptional.isPresent()) { + taskPmemberListExportExcelFormat.setKey(PMEMBER_CODE_KEY); + taskPmemberListExportExcelFormat.setTitle(PMEMBER_NAME); + } + ExportExcelFormat taskEmemberListExportExcelFormat = new ExportExcelFormat(); + if (eMemberListOptional.isPresent()) { + taskEmemberListExportExcelFormat.setKey(EMEMBER_CODE_KEY); + taskEmemberListExportExcelFormat.setTitle(EMEMBER_NAME); + } + + // 指标 + ExportExcelFormat performanceNameExportExcelFormat = new ExportExcelFormat(); + performanceNameExportExcelFormat.setKey(NODE_NAME_KEY); + performanceNameExportExcelFormat.setTitle(PERFORMANCE_NAME); + + fixedHeaderList.add(machineNameExportExcelFormat); + fixedHeaderList.add(workspaceNameExportExcelFormat); + fixedHeaderList.add(disciplineNameExportExcelFormat); + fixedHeaderList.add(taskNameExportExcelFormat); + if (pMemberListOptional.isPresent()) { + fixedHeaderList.add(taskPmemberListExportExcelFormat); + } + if (eMemberListOptional.isPresent()) { + fixedHeaderList.add(taskEmemberListExportExcelFormat); + } + fixedHeaderList.add(performanceNameExportExcelFormat); + }else if (nodeCodeOptional.isPresent()) { + // 机台 + ExportExcelFormat machineCodeExportExcelFormat = new ExportExcelFormat(); + machineCodeExportExcelFormat.setKey(NODE_CODE_KEY); + machineCodeExportExcelFormat.setTitle(MACHINE_CODE); + + // 工位 + ExportExcelFormat workspaceCodeExportExcelFormat = new ExportExcelFormat(); + workspaceCodeExportExcelFormat.setKey(NODE_CODE_KEY); + workspaceCodeExportExcelFormat.setTitle(WORKSPACE_CODE); + + // 学科 + ExportExcelFormat disciplineCodeExportExcelFormat = new ExportExcelFormat(); + disciplineCodeExportExcelFormat.setKey(NODE_CODE_KEY); + disciplineCodeExportExcelFormat.setTitle(DISCIPLINE_CODE); + + // 任务 + ExportExcelFormat taskCodeExportExcelFormat = new ExportExcelFormat(); + taskCodeExportExcelFormat.setKey(NODE_CODE_KEY); + taskCodeExportExcelFormat.setTitle(TASK_CODE); + ExportExcelFormat taskPmemberListExportExcelFormat = new ExportExcelFormat(); + if (pMemberListOptional.isPresent()) { + taskPmemberListExportExcelFormat.setKey(PMEMBER_CODE_KEY); + taskPmemberListExportExcelFormat.setTitle(PMEMBER_NAME); + } + ExportExcelFormat taskEmemberListExportExcelFormat = new ExportExcelFormat(); + if (eMemberListOptional.isPresent()) { + taskEmemberListExportExcelFormat.setKey(EMEMBER_CODE_KEY); + taskEmemberListExportExcelFormat.setTitle(EMEMBER_NAME); + } + + // 指标 + ExportExcelFormat performanceCodeExportExcelFormat = new ExportExcelFormat(); + performanceCodeExportExcelFormat.setKey(NODE_CODE_KEY); + performanceCodeExportExcelFormat.setTitle(PERFORMANCE_CODE); + + fixedHeaderList.add(machineCodeExportExcelFormat); + fixedHeaderList.add(workspaceCodeExportExcelFormat); + fixedHeaderList.add(disciplineCodeExportExcelFormat); + fixedHeaderList.add(taskCodeExportExcelFormat); + if (pMemberListOptional.isPresent()) { + fixedHeaderList.add(taskPmemberListExportExcelFormat); + } + if (eMemberListOptional.isPresent()) { + fixedHeaderList.add(taskEmemberListExportExcelFormat); + } + fixedHeaderList.add(performanceCodeExportExcelFormat); + } + if (CollectionUtils.isNotEmpty(fixedHeaderList)) { + if (nodeNameOptional.isPresent()) { + exportExcelFormats.remove(0); + } + if (nodeCodeOptional.isPresent()) { + exportExcelFormats.remove(0); + } + if (pMemberListOptional.isPresent()) { + exportExcelFormats.remove(0); + } + if (eMemberListOptional.isPresent()) { + exportExcelFormats.remove(0); + } + fixedHeaderList.addAll(exportExcelFormats); + exportExcelFormats = fixedHeaderList; + } + TaskTreeExportExcelParam params = taskTreeExportExcelFormat.getParams(); + List originIdMap = params.getIdMap(); + List originTagMap = params.getTagMap(); + if (CollectionUtils.isEmpty(originIdMap) || CollectionUtils.isEmpty(originTagMap)) { + log.error("idMap和tagMap都不能为空"); + return SdmResponse.failed("导出失败,原因为:idMap和tagMap都不能为空"); + } + ProjectTreeTagReq req = new ProjectTreeTagReq(); + List currentIdMapList = new ArrayList<>(); + List currentTagMapList = new ArrayList<>(); + for (com.sdm.common.entity.bo.TaskNodeTag originTaskNodeTag : originIdMap) { + TaskNodeTag taskNodeTag = new TaskNodeTag(); + taskNodeTag.setKey(originTaskNodeTag.getKey()); + taskNodeTag.setValue(originTaskNodeTag.getValue()); + currentIdMapList.add(taskNodeTag); + } + for (com.sdm.common.entity.bo.TaskNodeTag originTaskNodeTag : originTagMap) { + TaskNodeTag taskNodeTag = new TaskNodeTag(); + taskNodeTag.setKey(originTaskNodeTag.getKey()); + taskNodeTag.setValue(originTaskNodeTag.getValue()); + currentTagMapList.add(taskNodeTag); + } + req.setIdMap(currentIdMapList); + req.setTagMap(currentTagMapList); + SdmResponse taskRespond = getTaskTree(req); + SdmResponse response = new SdmResponse(); + List allTopProjectNodeList = new ArrayList<>(); + if(taskRespond.isSuccess()) { + List realTopProjectNodeList = (List) taskRespond.getData(); + if (CollectionUtils.isEmpty(realTopProjectNodeList)) { + return response; + } + // 补充空节点,暂时定死顺序:机台——》工位——》学科——》任务——》指标 + for (ProjectNodePo projectNodePo : realTopProjectNodeList) { + if (NodeTypeEnum.MACHINE.getValue().equals(projectNodePo.getNodeType())) { + fillChildrenNode(projectNodePo); + allTopProjectNodeList.add(projectNodePo); + continue; + } + // 先补全前面类型节点 + ProjectNodePo machineNode = new ProjectNodePo(); + if (NodeTypeEnum.WORKSPACE.getValue().equals(projectNodePo.getNodeType())) { + machineNode.setNodeName(" "); + machineNode.setNodeCode(" "); + machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue()); + machineNode.setChildren(Collections.singletonList(projectNodePo)); + fillChildrenNode(machineNode); + }else if (NodeTypeEnum.DISCIPLINE.getValue().equals(projectNodePo.getNodeType())) { + machineNode.setNodeName(" "); + machineNode.setNodeCode(" "); + machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue()); + NodeAllBase workspaceNode = new ProjectNodePo(); + workspaceNode.setNodeName(" "); + workspaceNode.setNodeCode(" "); + workspaceNode.setNodeType(NodeTypeEnum.WORKSPACE.getValue()); + workspaceNode.setChildren(Collections.singletonList(projectNodePo)); + machineNode.setChildren(Collections.singletonList(workspaceNode)); + fillChildrenNode(machineNode); + }else if (NodeTypeEnum.TASK.getValue().equals(projectNodePo.getNodeType())) { + machineNode.setNodeName(" "); + machineNode.setNodeCode(" "); + machineNode.setNodeType(NodeTypeEnum.MACHINE.getValue()); + ProjectNodePo workspaceNode = new ProjectNodePo(); + workspaceNode.setNodeName(" "); + workspaceNode.setNodeCode(" "); + workspaceNode.setNodeType(NodeTypeEnum.WORKSPACE.getValue()); + ProjectNodePo disciplineNode = new ProjectNodePo(); + disciplineNode.setNodeName(" "); + disciplineNode.setNodeCode(" "); + disciplineNode.setNodeType(NodeTypeEnum.DISCIPLINE.getValue()); + disciplineNode.setChildren(Collections.singletonList(projectNodePo)); + workspaceNode.setChildren(Collections.singletonList(disciplineNode)); + machineNode.setChildren(Collections.singletonList(workspaceNode)); + fillChildrenNode(machineNode); + } + allTopProjectNodeList.add(machineNode); + } + ExcelUtil.exportExcelWithMerge(JSONArray.from(allTopProjectNodeList),exportExcelFormats,new ArrayList<>(),httpServletResponse); + } else { + response = SdmResponse.failed(taskRespond.getMessage()); + } + return response; + } + + + + + private NodeAllBase fillChildrenNode(NodeAllBase projectNodePo) { + String nodeType = projectNodePo.getNodeType(); + if (StringUtils.isBlank(projectNodePo.getNodeCode())) { + projectNodePo.setNodeCode(" "); + } + List childrenNodeList = projectNodePo.getChildren(); + if (CollectionUtils.isEmpty(childrenNodeList)) { + return projectNodePo; + } + String childrenNodeType = nodeTypeList.get(nodeTypeList.indexOf(nodeType) + 1); + List removeIdList = new ArrayList<>(); + List newNodeList = new ArrayList<>(); + for (NodeAllBase childNode : childrenNodeList) { + if ((nodeType.equals(childNode.getNodeType()) || childrenNodeType.equals(childNode.getNodeType())) && CollectionUtils.isEmpty(childNode.getChildren())) { + continue; + } + if (!childrenNodeType.equals(childNode.getNodeType()) && nodeTypeList.indexOf(childrenNodeType) < nodeTypeList.indexOf(childNode.getNodeType())) { + ProjectNodePo emptyNode = new ProjectNodePo(); + emptyNode.setNodeName(" "); + emptyNode.setNodeCode(" "); + emptyNode.setNodeType(childrenNodeType); + if (CollectionUtils.isEmpty(childNode.getChildren())) { + emptyNode.setChildren(Collections.singletonList(childNode)); + }else { + emptyNode.setChildren(Collections.singletonList(fillChildrenNode(childNode))); + } + removeIdList.add(childNode.getId()); + newNodeList.add(emptyNode); + }else { + fillChildrenNode(childNode); + } + } + + if (CollectionUtils.isNotEmpty(removeIdList)) { + Iterator iterator = childrenNodeList.iterator(); + while (iterator.hasNext()) { + NodeAllBase nodeAllBase = iterator.next(); + if (removeIdList.contains(nodeAllBase.getId())) { // 假设我们想删除所有偶数 + iterator.remove(); // 使用迭代器的remove方法安全删除元素 + } + } + } + if (CollectionUtils.isNotEmpty(newNodeList)) { + childrenNodeList.addAll(newNodeList); + } + return projectNodePo; + } + +} + + + +package com.sdm.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.project.dao.SimulationBaseUnitsMapper; +import com.sdm.project.model.entity.SimulationBaseUnits; +import com.sdm.project.service.ISimulationBaseUnitsService; +import org.springframework.stereotype.Service; + +@Service +public class SimulationBaseUnitsServiceImpl extends ServiceImpl implements ISimulationBaseUnitsService { + +} + + + +package com.sdm.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.project.dao.SimulationKeyResultMapper; +import com.sdm.project.model.entity.SimulationRunKeyResult; +import com.sdm.project.service.ISimulationKeyResultService; +import org.springframework.stereotype.Service; + +@Service +public class SimulationKeyResultServiceImpl extends ServiceImpl implements ISimulationKeyResultService { + +} + + + +package com.sdm.project.service.impl; + +import com.sdm.common.entity.req.project.SimulationPerformance; +import com.sdm.project.dao.SimulationPerformanceMapper; +import com.sdm.project.service.ISimulationPerformanceService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2025-11-03 + */ +@Service +public class SimulationPerformanceServiceImpl extends ServiceImpl implements ISimulationPerformanceService { + +} +
+ + +package com.sdm.project.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.common.entity.constants.NumberConstants; +import com.sdm.common.entity.enums.ApproveTypeEnum; +import com.sdm.common.entity.enums.DirTypeEnum; +import com.sdm.common.entity.enums.FileBizTypeEnum; +import com.sdm.common.entity.enums.NodeTypeEnum; +import com.sdm.common.entity.flowable.dto.FlowElementDTO; +import com.sdm.common.entity.flowable.dto.ProcessDefinitionDTO; +import com.sdm.common.entity.req.capability.FlowNodeDto; +import com.sdm.common.entity.req.data.*; +import com.sdm.common.entity.req.project.ProjecInfoReq; +import com.sdm.common.entity.req.project.SimulationPerformance; +import com.sdm.common.entity.req.project.SpdmReportReq; +import com.sdm.common.entity.req.system.LaunchApproveReq; +import com.sdm.common.entity.req.system.UserQueryReq; +import com.sdm.common.entity.resp.PageDataResp; +import com.sdm.common.entity.resp.capability.FlowTemplateResp; +import com.sdm.common.entity.resp.data.BatchAddFileInfoResp; +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import com.sdm.common.entity.resp.data.SimulationTaskResultCurveResp; +import com.sdm.common.entity.resp.flowable.ProcessInstanceDetailResponse; +import com.sdm.common.entity.resp.flowable.ProcessInstanceResp; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.common.feign.impl.capability.SimulationFlowFeignClientImpl; +import com.sdm.common.feign.impl.data.DataAnalysisFeignClientImpl; +import com.sdm.common.feign.impl.data.DataClientFeignClientImpl; +import com.sdm.common.feign.impl.flowable.FlowableClientFeignClientImpl; +import com.sdm.common.feign.impl.system.ApproveFeignClientImpl; +import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; +import com.sdm.common.utils.PageUtils; +import com.sdm.common.utils.RandomUtil; +import com.sdm.project.common.*; +import com.sdm.project.dao.SimulationBaseUnitsMapper; +import com.sdm.project.dao.SimulationProjectMapper; +import com.sdm.project.dao.SimulationRunMapper; +import com.sdm.project.model.bo.ApprovalDeliverableContentsModel; +import com.sdm.project.model.bo.CurveParamDto; +import com.sdm.project.model.bo.TaskNodeTag; +import com.sdm.project.model.entity.*; +import com.sdm.project.model.po.NodeAllBase; +import com.sdm.project.model.po.ProjectNodePo; +import com.sdm.project.model.po.RunNodePo; +import com.sdm.project.model.po.TaskNodePo; +import com.sdm.project.model.req.*; +import com.sdm.project.model.resp.FlowInfoDto; +import com.sdm.project.model.resp.KeyResultAndTaskInfoResp; +import com.sdm.project.model.resp.RunVersionInfoResp; +import com.sdm.project.service.*; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.*; +import java.util.stream.Collectors; + +import static com.sdm.common.service.BaseService.generateUuid; +import static com.sdm.project.service.impl.NodeServiceImpl.getTagProperty; +import static com.sdm.project.service.impl.NodeServiceImpl.setTagProperty; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2025-11-03 + */ +@Service +@Slf4j +public class SimulationRunServiceImpl extends ServiceImpl implements ISimulationRunService { + + @Autowired + private SimulationProjectMapper mapper; + + @Autowired + private ISimulationTaskMemberService simulationTaskMemberService; + + @Autowired + private ISimulationTaskService simulationTaskService; + + @Autowired + private ISimulationPerformanceService simulationPerformanceService; + + @Autowired + private ISimulationKeyResultService simulationKeyResultService; + + @Autowired + SysUserFeignClientImpl sysUserFeignClient; + + @Autowired + private DataClientFeignClientImpl dataFeignClient; + + @Autowired + private FlowableClientFeignClientImpl flowableFeignClient; + + @Autowired + private SimulationFlowFeignClientImpl flowFeignClient; + + @Autowired + private ApproveFeignClientImpl approveFeignClient; + + @Autowired + private DataAnalysisFeignClientImpl analysisFeignClient; + + @Autowired + private ISimulationBaseUnitsService baseUnitsService; + + @Autowired + private ISimulationBaseQuantitiesService baseQuantitiesService; + + private final ObjectMapper objectMapper = new ObjectMapper(); + + private static final String TEMP_REPORT_PATH = "/opt/report/"; + + private static final String TEMPLATE_PATH = " /opt/script/template "; + + // 临时文件存储目录 + private final String tempFileDir = System.getProperty("user.dir") + "/csv_uploads/"; + + private int getCurrentNodeDepth(NodeAllBase eachNode) { + String tag1 = eachNode.getTag1(); + String tag2 = eachNode.getTag2(); + String tag3 = eachNode.getTag3(); + String tag4 = eachNode.getTag4(); + String tag5 = eachNode.getTag5(); + String tag6 = eachNode.getTag6(); + String tag7 = eachNode.getTag7(); + String tag8 = eachNode.getTag8(); + String tag9 = eachNode.getTag9(); + String tag10 = eachNode.getTag10(); + int currentNodeDepth = 0; + if (StringUtils.isNotBlank(tag1) && !tag1.equals("null")) { + currentNodeDepth += tag1.split(",").length; + } + if (StringUtils.isNotBlank(tag2) && !tag2.equals("null")) { + currentNodeDepth += tag2.split(",").length; + } + if (StringUtils.isNotBlank(tag3) && !tag3.equals("null")) { + currentNodeDepth += tag3.split(",").length; + } + if (StringUtils.isNotBlank(tag4) && !tag4.equals("null")) { + currentNodeDepth += tag4.split(",").length; + } + if (StringUtils.isNotBlank(tag5) && !tag5.equals("null")) { + currentNodeDepth += tag5.split(",").length; + } + if (StringUtils.isNotBlank(tag6) && !tag6.equals("null")) { + currentNodeDepth += tag6.split(",").length; + } + if (StringUtils.isNotBlank(tag7) && !tag7.equals("null")) { + currentNodeDepth += tag7.split(",").length; + } + if (StringUtils.isNotBlank(tag8) && !tag8.equals("null")) { + currentNodeDepth += tag8.split(",").length; + } + if (StringUtils.isNotBlank(tag9) && !tag9.equals("null")) { + currentNodeDepth += tag9.split(",").length; + } + if (StringUtils.isNotBlank(tag10) && !tag10.equals("null")) { + currentNodeDepth += tag10.split(",").length; + } + return currentNodeDepth; + } + + private void generateTaskTree(ProjectNodePo projectNodePo, List taskTreeNodeList, List taskTreeTaskList, List taskTreeTagMap, String firstNodeTag, String lastNodeTag, Map taskTreeNodeTypeTagMap, List taskTreeRunList) { + String currentNodeType = projectNodePo.getNodeType(); + String currentTag = taskTreeNodeTypeTagMap.get(currentNodeType); + TaskNodeTag nextNodeTag = getNextNodeTag(currentTag, taskTreeTagMap); + if (ObjectUtils.isEmpty(nextNodeTag)) { + log.error("未找到子标签"); + return; + } + String currentNodeTagId = ""; + try { + currentNodeTagId = getTagProperty(projectNodePo, currentTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (StringUtils.isBlank(currentNodeTagId)) { + String realCurrentTag = currentTag; + while (StringUtils.isBlank(currentNodeTagId) && !firstNodeTag.equals(realCurrentTag) && !lastNodeTag.equals(realCurrentTag)) { + realCurrentTag = getPreNodeTag(realCurrentTag, taskTreeTagMap).getValue(); + try { + currentNodeTagId = getTagProperty(projectNodePo, realCurrentTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + currentTag = realCurrentTag; + } + if (StringUtils.isBlank(currentNodeTagId)) { + return; + } + String finalCurrentNodeTagId = currentNodeTagId; + // 需要找到当前节点创建节点时的tagId + TaskNodeTag realTagObj = getRealTagId(projectNodePo); + if (StringUtils.isBlank(realTagObj.getKey()) && StringUtils.isBlank(realTagObj.getValue())) { + return; + } + String realTag = realTagObj.getKey(); + String realTagId = realTagObj.getValue(); + // 查询当前节点下任务 + List currentNodeAssociatedTaskList = new ArrayList<>(); + int currentNodeDepth = getCurrentNodeDepth(projectNodePo); + if (CollectionUtils.isNotEmpty(taskTreeTaskList)) { + currentNodeAssociatedTaskList = taskTreeTaskList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, realTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + // tagId相同且:当前深度 = task深度 + 1 + return nodeTagId.equals(realTagId) && currentNodeDepth == getCurrentNodeDepth(node); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + + if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) { + // 查询当前任务下算例 + Map taskMap = currentNodeAssociatedTaskList.stream().collect(Collectors.groupingBy( + TaskNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + if (CollectionUtils.isNotEmpty(taskTreeRunList)) { + List eachRunNodeList; + List currentTaskAssociatedRunList = taskTreeRunList.stream().filter(run -> ObjectUtils.isNotEmpty(taskMap.get(run.getTaskId()))).toList(); + if (CollectionUtils.isNotEmpty(currentTaskAssociatedRunList)) { + Map> runMap = currentTaskAssociatedRunList.stream().collect(Collectors.groupingBy(RunNodePo::getTaskId)); + for (TaskNodePo taskNodePo : currentNodeAssociatedTaskList) { + eachRunNodeList = runMap.get(taskNodePo.getUuid()); + if (CollectionUtils.isNotEmpty(eachRunNodeList)) { + taskNodePo.getChildren().addAll(eachRunNodeList); + } + } + } + } + // 查询当前任务的负责人和执行人 + for (TaskNodePo taskNodePo : currentNodeAssociatedTaskList) { + List memberList = simulationTaskMemberService.lambdaQuery().eq(SimulationTaskMember::getTaskId, taskNodePo.getUuid()).list(); + if (CollectionUtils.isNotEmpty(memberList)) { + List eUserIdList = memberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).map(SimulationTaskMember::getUserId).distinct().toList(); + List pUserIdList = memberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).map(SimulationTaskMember::getUserId).distinct().toList(); + if (CollectionUtils.isNotEmpty(eUserIdList)) { + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(eUserIdList).build()); + taskNodePo.setEMemberList(cidUserResp.getData()); + } + if (CollectionUtils.isNotEmpty(pUserIdList)) { + SdmResponse> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(pUserIdList).build()); + taskNodePo.setPMemberList(cidUserResp.getData()); + } + } + } + } + } + // 查询子节点,可能是同类型节点也可能是不同类型节点 + // 先查同类型节点:当前标签下,包含currentNodeTagId且深度+1 + int depth = getCurrentNodeDepth(projectNodePo); + String finalCurrentTag = currentTag; + List sameTypeNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, finalCurrentTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + return node.getNodeType().equals(currentNodeType) && nodeTagId.contains(finalCurrentNodeTagId) && getCurrentNodeDepth(node) == depth + 1; + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + // 再查不同类型的节点:下一标签下的节点 + TaskNodeTag finalNextNodeTag = nextNodeTag; + List children = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(sameTypeNodeList)) { + // 递归 + for (ProjectNodePo nodePo : sameTypeNodeList) { + generateTaskTree(nodePo, taskTreeNodeList, taskTreeTaskList, taskTreeTagMap, firstNodeTag, lastNodeTag, taskTreeNodeTypeTagMap, taskTreeRunList); + } + if (CollectionUtils.isNotEmpty(sameTypeNodeList)) { + children.addAll(sameTypeNodeList); + } + } + if (!currentTag.equals(finalNextNodeTag.getValue()) && !lastNodeTag.equals(currentTag)) { + List childrenTypeNodeList = getChildrenTypeNodeList(currentTag, finalNextNodeTag, finalCurrentNodeTagId, taskTreeNodeList, taskTreeTagMap, lastNodeTag); + List childrenTypeNodeIdList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) { + childrenTypeNodeIdList = childrenTypeNodeList.stream().map(ProjectNodePo::getId).toList(); + int firstLayerNodeDepth = getFirstLayerNodeDepth(childrenTypeNodeList); + childrenTypeNodeList = childrenTypeNodeList.stream().filter(node -> getCurrentNodeDepth(node) == firstLayerNodeDepth).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(childrenTypeNodeList)) { + // 递归 + for (ProjectNodePo nodePo : childrenTypeNodeList) { + generateTaskTree(nodePo, taskTreeNodeList, taskTreeTaskList, taskTreeTagMap, firstNodeTag, lastNodeTag, taskTreeNodeTypeTagMap, taskTreeRunList); + } + children.addAll(childrenTypeNodeList); + } + } + // 查找当前节点的其他子节点(非直接顺序子节点) + List finalChildrenTypeNodeIdList = childrenTypeNodeIdList; + List otherChildrenNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, finalCurrentTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + return !node.getNodeType().equals(currentNodeType) && nodeTagId.equals(finalCurrentNodeTagId) && getCurrentNodeDepth(node) == depth + 1 && !finalChildrenTypeNodeIdList.contains(node.getId()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(otherChildrenNodeList)) { + int firstLayerNodeDepth = getFirstLayerNodeDepth(otherChildrenNodeList); + otherChildrenNodeList = otherChildrenNodeList.stream().filter(node -> getCurrentNodeDepth(node) == firstLayerNodeDepth).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(otherChildrenNodeList)) { + // 递归 + for (ProjectNodePo nodePo : otherChildrenNodeList) { + generateTaskTree(nodePo, taskTreeNodeList, taskTreeTaskList, taskTreeTagMap, firstNodeTag, lastNodeTag, taskTreeNodeTypeTagMap, taskTreeRunList); + } + children.addAll(otherChildrenNodeList); + } + } + } + if (CollectionUtils.isNotEmpty(currentNodeAssociatedTaskList)) { + currentNodeAssociatedTaskList.forEach(task -> { + task.setNodeName(task.getTaskName()); + task.setNodeCode(task.getTaskCode()); + task.setSection(task.getSectionName()); + task.setGroup(task.getGroupName()); + }); + children.addAll(currentNodeAssociatedTaskList); + } + projectNodePo.setChildren(children); + } + + private TaskNodeTag getRealTagId(ProjectNodePo projectNodePo) { + TaskNodeTag taskNodeTag = new TaskNodeTag(); + String tag10 = projectNodePo.getTag10(); + if (StringUtils.isNotBlank(tag10)) { + taskNodeTag.setKey("tag10"); + taskNodeTag.setValue(tag10); + return taskNodeTag; + } + String tag9 = projectNodePo.getTag9(); + if (StringUtils.isNotBlank(tag9)) { + taskNodeTag.setKey("tag9"); + taskNodeTag.setValue(tag9); + return taskNodeTag; + } + String tag8 = projectNodePo.getTag8(); + if (StringUtils.isNotBlank(tag8)) { + taskNodeTag.setKey("tag8"); + taskNodeTag.setValue(tag8); + return taskNodeTag; + } + String tag7 = projectNodePo.getTag7(); + if (StringUtils.isNotBlank(tag7)) { + taskNodeTag.setKey("tag7"); + taskNodeTag.setValue(tag7); + return taskNodeTag; + } + String tag6 = projectNodePo.getTag6(); + if (StringUtils.isNotBlank(tag6)) { + taskNodeTag.setKey("tag6"); + taskNodeTag.setValue(tag6); + return taskNodeTag; + } + String tag5 = projectNodePo.getTag5(); + if (StringUtils.isNotBlank(tag5)) { + taskNodeTag.setKey("tag5"); + taskNodeTag.setValue(tag5); + return taskNodeTag; + } + String tag4 = projectNodePo.getTag4(); + if (StringUtils.isNotBlank(tag4)) { + taskNodeTag.setKey("tag4"); + taskNodeTag.setValue(tag4); + return taskNodeTag; + } + String tag3 = projectNodePo.getTag3(); + if (StringUtils.isNotBlank(tag3)) { + taskNodeTag.setKey("tag3"); + taskNodeTag.setValue(tag3); + return taskNodeTag; + } + String tag2 = projectNodePo.getTag2(); + if (StringUtils.isNotBlank(tag2)) { + taskNodeTag.setKey("tag2"); + taskNodeTag.setValue(tag2); + return taskNodeTag; + } + String tag1 = projectNodePo.getTag1(); + if (StringUtils.isNotBlank(tag1)) { + taskNodeTag.setKey("tag1"); + taskNodeTag.setValue(tag1); + } + return taskNodeTag; + } + + private List getChildrenTypeNodeList(String currentTag, TaskNodeTag nextNodeTag, String currentNodeTagId, List taskTreeNodeList, List taskTreeTagMap, String lastNodeTag) { + List childrenTypeNodeList = taskTreeNodeList.stream().filter(node -> { + try { + String nodeTagId = getTagProperty(node, currentTag); + if (StringUtils.isBlank(nodeTagId)) { + return false; + } + // tagId相同,且nodeType是nextNodeTag类型且子tagId的深度最少 + return nodeTagId.equals(currentNodeTagId) && node.getNodeType().equals(nextNodeTag.getKey()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(childrenTypeNodeList) || lastNodeTag.equals(nextNodeTag.getValue())) { + return childrenTypeNodeList; + } + return getChildrenTypeNodeList(currentTag, getNextNodeTag(nextNodeTag.getValue(), taskTreeTagMap), currentNodeTagId, taskTreeNodeList, taskTreeTagMap, lastNodeTag); + } + + private TaskNodeTag getNextNodeTag(String currentTag, List taskTreeTagMap) { + TaskNodeTag nextNodeTag = null; + for (int i = 0; i < taskTreeTagMap.size(); i++) { + if (taskTreeTagMap.get(i).getValue().equals(currentTag)) { + nextNodeTag = taskTreeTagMap.get(Math.min(i + 1, taskTreeTagMap.size() - 1)); + break; + } + } + return nextNodeTag; + } + + private TaskNodeTag getPreNodeTag(String currentTag, List taskTreeTagMap) { + TaskNodeTag nextNodeTag = null; + for (int i = 0; i < taskTreeTagMap.size(); i++) { + if (taskTreeTagMap.get(i).getValue().equals(currentTag)) { + nextNodeTag = taskTreeTagMap.get(Math.max(i - 1, 0)); + break; + } + } + return nextNodeTag; + } + + private int getFirstLayerNodeDepth(List childrenTypeNodeList) { + int firstLayerNodeDepth = getCurrentNodeDepth(childrenTypeNodeList.get(0)); + for (ProjectNodePo projectNodePo : childrenTypeNodeList) { + firstLayerNodeDepth = Math.min(getCurrentNodeDepth(projectNodePo), firstLayerNodeDepth); + } + return firstLayerNodeDepth; + } + + + @Override + public SdmResponse getTaskRunTree(ProjectTreeTagReq req) { + List idMapList = req.getIdMap(); + if (CollectionUtils.isEmpty(idMapList)) { + return SdmResponse.success(new ArrayList<>()); + } + List topTagList = idMapList.stream().filter(tag -> StringUtils.isNotBlank(tag.getKey())).toList(); + if (CollectionUtils.isEmpty(topTagList)) { + return SdmResponse.success(new ArrayList<>()); + } + // topTagList中最后一层可以认为是最顶层节点,但并不需要展示 + TaskNodeTag topNodeTag = topTagList.get(topTagList.size() - 1); + ProjectTreeReq taskTreeReq = new ProjectTreeReq(); + try { + setTagProperty(taskTreeReq, topNodeTag.getValue(), topNodeTag.getKey()); + } catch (Exception e) { + throw new RuntimeException(e); + } + List taskTreeNodeList = mapper.getNodeListByTag(taskTreeReq); + if (CollectionUtils.isEmpty(taskTreeNodeList)) { + log.error("未查询到顶级节点"); + return SdmResponse.success(new ArrayList<>()); + } + List taskTreeRunList = new ArrayList<>(); + List taskTreeTaskList = mapper.getTaskListByTag(taskTreeReq); + if (CollectionUtils.isNotEmpty(taskTreeTaskList)) { + taskTreeTaskList.forEach(task -> task.setNodeType(NodeTypeEnum.TASK.getValue())); + taskTreeRunList = mapper.getRunListByNodeIdList(taskTreeTaskList.stream().map(TaskNodePo::getUuid).toList()); + if (CollectionUtils.isNotEmpty(taskTreeRunList)) { + taskTreeRunList.forEach(run -> run.setNodeType(NodeTypeEnum.RUN.getValue())); + } + } + List taskTreeTagMap = req.getTagMap(); + String firstNodeTag = taskTreeTagMap.get(0).getValue(); + String lastNodeTag = taskTreeTagMap.get(taskTreeTagMap.size() - 1).getValue(); + if (CollectionUtils.isEmpty(taskTreeTagMap)) { + log.error("tagMap不能为空"); + return SdmResponse.success(new ArrayList<>()); + } + // key:节点类型,value:标签 + Map taskTreeNodeTypeTagMap = taskTreeTagMap.stream().collect(Collectors.toMap(TaskNodeTag::getKey, TaskNodeTag::getValue)); + // key:标签,value:节点类型 + Map taskTreeTagNodeTypeMap = taskTreeTagMap.stream().collect(Collectors.toMap(TaskNodeTag::getValue, TaskNodeTag::getKey)); + // 如果idMap中的id都不为null,说明查的是最后一层节点下的所有任务、指标 + TaskNodeTag realFirstTaskNodeTag = idMapList.get(idMapList.size() - 1); + for (TaskNodeTag taskNodeTag : idMapList) { + if (StringUtils.isNotBlank(taskNodeTag.getKey())) { + realFirstTaskNodeTag = taskNodeTag; + } + } + String realFirstTaskNodeType = taskTreeTagNodeTypeMap.get(realFirstTaskNodeTag.getValue()); + List realTopProjectNodeList = taskTreeNodeList.stream().filter(node -> node.getNodeType().equals(realFirstTaskNodeType)).toList(); + for (ProjectNodePo projectNodePo : realTopProjectNodeList) { + generateTaskTree(projectNodePo, taskTreeNodeList, taskTreeTaskList, taskTreeTagMap, firstNodeTag, lastNodeTag, taskTreeNodeTypeTagMap, taskTreeRunList); + } + return SdmResponse.success(realTopProjectNodeList.stream().flatMap(item -> item.getChildren().stream().filter(Objects::nonNull)).toList()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse addTaskRun(SpdmAddTaskRunReq req) { + Long userId = ThreadLocalContext.getUserId(); + Long tenantId = ThreadLocalContext.getTenantId(); + + SimulationTask simulationTask = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, req.getTaskId()).one(); + SimulationRun taskRun = this.lambdaQuery().eq(SimulationRun::getTaskId, req.getTaskId()).eq(SimulationRun::getRunName, req.getRunName()).one(); + if (simulationTask == null) { + return SdmResponse.failed("任务不存在"); + } else if (taskRun != null) { + return SdmResponse.failed("算例已存在"); + } else { + SimulationRun simulationRun = new SimulationRun(); + // 设置算例的文件夹路径 挂在所属任务下面 + SdmResponse fileMetadataInfoResp = dataFeignClient.queryFileMetadataInfo(simulationTask.getUuid(), NodeTypeEnum.TASK.getValue(), 0L); + if (fileMetadataInfoResp.getData() != null) { + simulationRun.setFolderId(fileMetadataInfoResp.getData().getId()); + } + BeanUtils.copyProperties(req, simulationRun); + simulationRun.setUuid(RandomUtil.generateString(32)); + simulationRun.setCreator(userId); + simulationRun.setUpdater(userId); + simulationRun.setTenantId(tenantId); + + if (!this.save(simulationRun)) { + return SdmResponse.failed("新建算例失败"); + } else { + // taskId不为null,runId为null,查询所有工况设定的标准指标 + List simulationTaskPerformances = simulationPerformanceService.lambdaQuery() + .eq(SimulationPerformance::getTaskId, simulationTask.getUuid()) + .isNull(SimulationPerformance::getRunId) + .list(); + if (CollectionUtils.isNotEmpty(simulationTaskPerformances)) { + List runPerformanceList = new ArrayList<>(); + for (SimulationPerformance performanceBean : simulationTaskPerformances) { + SimulationPerformance runPerformance = new SimulationPerformance(); + BeanUtils.copyProperties(performanceBean, runPerformance); + runPerformance.setId(null); + runPerformance.setRunId(simulationRun.getUuid()); + runPerformance.setUuid(RandomUtil.generateString(32)); + runPerformance.setCompleteStatus(RunPerformanceStatusEnum.UNCOMPLETED.getCode()); + runPerformance.setCreator(userId); + runPerformance.setCreateTime(null); + runPerformanceList.add(runPerformance); + } + if (CollectionUtils.size(runPerformanceList) > 0) { + simulationPerformanceService.saveBatch(runPerformanceList); + } + } + + // 创建算例文件夹 + SdmResponse runDirResponse = createDir(simulationRun.getUuid(), simulationTask.getUuid(), req.getRunName(), DirTypeEnum.PROJECT_NODE_DIR.getValue(), NodeTypeEnum.RUN.getValue()); + if (!runDirResponse.isSuccess()) { + log.error("创建算例文件夹失败:{}", runDirResponse.getMessage()); + throw new RuntimeException("创建算例文件夹失败:" + runDirResponse.getMessage()); + } + + // 解析流程模板中的节点结构,初始化流程节点表 + SdmResponse flowTemplateResp = flowFeignClient.queryFlowTemplateInfo(simulationRun.getFlowTemplate()); + if (flowTemplateResp.getData() != null) { + simulationRun.setProcessDefinitionId(flowTemplateResp.getData().getProcessDefinitionId()); + this.updateById(simulationRun); + try { + List flowNodeDtoList = new ArrayList<>(); + ProcessDefinitionDTO definitionDTO = JSON.parseObject(flowTemplateResp.getData().getTemplateContent(), ProcessDefinitionDTO.class); + for (FlowElementDTO flowElement : definitionDTO.getFlowElements()) { + if (flowElement.getName() == null) { + continue; + } + FlowNodeDto flowNodeDto = new FlowNodeDto(); + flowNodeDto.setUuid(generateUuid("flow_node_")); + flowNodeDto.setNodeName(flowElement.getName()); + flowNodeDto.setNodeId(flowElement.getId()); + flowNodeDto.setRunId(simulationRun.getUuid()); + flowNodeDtoList.add(flowNodeDto); + } + for (FlowNodeDto flowNodeDto : flowNodeDtoList) { + // 每个流程节点建立节点文件夹 + SdmResponse nodeDirResponse = createDir(flowNodeDto.getUuid(), simulationRun.getUuid(), flowNodeDto.getNodeName(), DirTypeEnum.PROJECT_NODE_DIR.getValue(), NodeTypeEnum.FLOW_NODE.getValue()); + if (!nodeDirResponse.isSuccess()) { + log.error("创建节点文件夹失败:{}", nodeDirResponse.getMessage()); + throw new RuntimeException("创建节点文件夹失败:" + nodeDirResponse.getMessage()); + } + // 每个流程节点初始化输入输出两个文件夹 + SdmResponse inputDir = createDir(null, flowNodeDto.getUuid(), "数据输入", DirTypeEnum.PROJECT_NODE_DIR.getValue(), null); + SdmResponse outputDir = createDir(null, flowNodeDto.getUuid(), "数据输出", DirTypeEnum.PROJECT_NODE_DIR.getValue(), null); + flowNodeDto.setInputDirId(Long.parseLong(inputDir.getData().toString())); + flowNodeDto.setOutputDirId(Long.parseLong(outputDir.getData().toString())); + } + FlowNodeDto addReq = new FlowNodeDto(); + addReq.setFlowNodeDtoList(flowNodeDtoList); + if (!flowFeignClient.batchAddSimulationFlowNode(addReq).isSuccess()) { + log.error("新增流程节点失败"); + throw new RuntimeException("新增流程节点失败"); + } + // 子算例继承父算例的用户输入参数 + if (StringUtils.isNotBlank(simulationRun.getParentId())) { + SimulationRun parentRun = this.lambdaQuery().eq(SimulationRun::getUuid, simulationRun.getParentId()).one(); + SdmResponse parentResp = flowableFeignClient.getProcessAndNodeDetailByInstanceId(parentRun.getProcessDefinitionId(), parentRun.getFlowInstanceId(), parentRun.getUuid()); + if (parentResp.getData() != null && CollectionUtils.isNotEmpty(parentResp.getData().getNodes())) { + for (FlowNodeDto flowNodeDto : flowNodeDtoList) { + parentResp.getData().getNodes().stream().filter(i -> StringUtils.equals(i.getId(), flowNodeDto.getNodeId()) && ObjectUtils.isNotEmpty(i.getUserParam())).findFirst().ifPresent(i -> { + Map params = new HashMap<>(i.getUserParam()); + flowableFeignClient.saveParamsByDefinitionId(simulationRun.getProcessDefinitionId(), flowNodeDto.getNodeId(), simulationRun.getUuid(), params); + }); + } + } + } + } catch (Exception e) { + log.error("解析流程模板json文件失败,flowTemplateId:{}", simulationRun.getFlowTemplate(), e); + throw new RuntimeException("解析流程模板json文件失败:" + e.getMessage(), e); + } + } + } + return SdmResponse.success(simulationRun.getUuid()); + } + } + + private SdmResponse createDir(String uuid, String parentUuid, String dirName, Integer dirType, String uuidOwnType) { + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setParentUuId(parentUuid); + createDirReq.setUuIdOwnType(uuidOwnType); + createDirReq.setDirName(dirName); + createDirReq.setDirType(dirType); + log.info("创建算例阶段时,调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataFeignClient.createDir(createDirReq); + log.info("创建算例阶段时,调用创建文件夹的返回值为:{}", response); + return response; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse deleteTaskRun(SpdmTaskRunReq req) { + // 删除算例 + SimulationRun simulationRun = this.getById(req.getRunId()); + this.removeById(req.getRunId()); + // 删除算例指标 + simulationPerformanceService.lambdaUpdate().eq(SimulationPerformance::getRunId, simulationRun.getUuid()).remove(); + // 删除算例目录 + DelDirReq delDirReq = new DelDirReq(); + delDirReq.setDelUuid(simulationRun.getUuid()); + SdmResponse response = dataFeignClient.delDir(delDirReq); + if (!response.isSuccess()) { + log.error("删除算例文件夹失败:{}", response.getMessage()); + throw new RuntimeException("删除算例文件夹失败:" + response.getMessage()); + } + return SdmResponse.success(response); + } + + @Override + public SdmResponse> queryTaskRun(SpdmTaskRunReq req) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotBlank(req.getRunId())) { + queryWrapper.eq(SimulationRun::getUuid, req.getRunId()); + } + if (StringUtils.isNotBlank(req.getRunName())) { + queryWrapper.eq(SimulationRun::getRunName, req.getRunName()); + } + if (StringUtils.isNotBlank(req.getTaskId())) { + queryWrapper.eq(SimulationRun::getTaskId, req.getTaskId()); + } + List simulationRunList = this.list(queryWrapper); + return SdmResponse.success(simulationRunList); + } + + @Override + public SdmResponse createRunDir(CreateDirReq req) { + CreateDirReq createDirReq = new CreateDirReq(); + // 获取算例文件夹id + SdmResponse fileMetadataInfoResp = dataFeignClient.queryFileMetadataInfo(req.getUuId(), NodeTypeEnum.RUN.getValue(), 0L); + if (fileMetadataInfoResp.getData() != null) { + createDirReq.setParDirId(fileMetadataInfoResp.getData().getId()); + } + createDirReq.setDirName(req.getDirName()); + createDirReq.setDirType(DirTypeEnum.PROJECT_NODE_DIR.getValue()); + log.info("创建算例结果时,调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataFeignClient.createDir(createDirReq); + log.info("创建算例结果时,调用创建文件夹的返回值为:{}", response); + return SdmResponse.success(response); + } + + @Override + public SdmResponse>> queryRunDir(QueryDirReq req) { + return dataFeignClient.queryDir(req); + } + + @Override + public SdmResponse uploadRunFiles(UploadFilesReq req) { + return dataFeignClient.uploadFiles(req); + } + + @Override + public SdmResponse> getTaskRunVersion(GetRunVersionReq req) { + List runList = this.lambdaQuery().eq(SimulationRun::getTaskId, req.getTaskId()).list(); + if (CollectionUtils.isNotEmpty(runList)) { + List runRespList = runList.stream() + .map(source -> { + RunVersionInfoResp target = new RunVersionInfoResp(); + BeanUtils.copyProperties(source, target); + return target; + }).collect(Collectors.toList()); + return SdmResponse.success(buildRunTreeWithMap(runRespList)); + } + return SdmResponse.success(); + } + + @Override + public SdmResponse getRunVersion(GetRunVersionReq req) { + // 获取目标算例 + SimulationRun targetRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one(); + if (targetRun == null) { + return null; + } + // 获取该算例及其所有子孙节点的ID + List relatedRunIds = this.baseMapper.findRunAndDescendantsIds(req.getRunId()); + // 获取相关算例 + List relatedRuns = this.lambdaQuery().in(SimulationRun::getUuid, relatedRunIds).list(); + List relatedRunsResp = relatedRuns.stream() + .map(source -> { + RunVersionInfoResp target = new RunVersionInfoResp(); + BeanUtils.copyProperties(source, target); + return target; + }).collect(Collectors.toList()); + // 构建子树 + buildRunTreeWithMap(relatedRunsResp); + return SdmResponse.success(relatedRunsResp.stream().filter(i -> StringUtils.equals(i.getUuid(), targetRun.getUuid())).findFirst().get()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse addSimulationKeyResult(KeyResultReq req) { + if (KeyResultTypeEnum.CURVE.getKeyResultType().equals(req.getKeyResultType()) && req.isOnlyFile()) { + CurveParamDto curveParamDto = getCurveParamsFromUpload(req.getFile(), 2); + return SdmResponse.success(curveParamDto); + } + + SimulationRunKeyResult simulationRunKeyResult = new SimulationRunKeyResult(); + BeanUtils.copyProperties(req, simulationRunKeyResult); + simulationRunKeyResult.setUuid(RandomUtil.generateString(32)); + simulationRunKeyResult.setCreator(ThreadLocalContext.getUserId()); + simulationRunKeyResult.setUpdater(ThreadLocalContext.getUserId()); + // 外围调用不关心dirId,只传keyResultType-关键结果类型,所以需要根据算例id和keyResultType获取到上传到哪个结果目录下 + if (req.getDirId() == null) { + setDirId(req); + } + // 上传文件 + if (req.getFile() != null) { + UploadFilesReq filesReq = new UploadFilesReq(); + BeanUtils.copyProperties(req, filesReq); + SdmResponse response = uploadRunFiles(filesReq); + if (response.isSuccess() && response.getData() != null) { + JSONObject result = JSONObject.from(response.getData()); + simulationRunKeyResult.setFileId(Long.valueOf((Integer) result.get("fileId"))); + } else { + return SdmResponse.failed("上传文件失败"); + } + } + if (!simulationKeyResultService.save(simulationRunKeyResult)) { + return SdmResponse.failed("添加关键结果失败"); + } + return SdmResponse.success(simulationRunKeyResult.getUuid()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse editSimulationKeyResult(KeyResultReq req) { + SimulationRunKeyResult simulationRunKeyResult = new SimulationRunKeyResult(); + BeanUtils.copyProperties(req, simulationRunKeyResult); + if (!simulationKeyResultService.updateById(simulationRunKeyResult)) { + return SdmResponse.failed("更新关键结果失败"); + } + return SdmResponse.success(); + } + + /** + * 保存上传的文件到临时目录 + */ + private String saveUploadedFile(MultipartFile file) throws IOException { + // 确保临时目录存在 + Path uploadPath = Paths.get(tempFileDir); + if (!Files.exists(uploadPath)) { + Files.createDirectories(uploadPath); + } + // 生成唯一的文件名 + String fileName = RandomUtil.generateString(16) + "_" + file.getOriginalFilename(); + Path filePath = uploadPath.resolve(fileName); + // 保存文件 + Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING); + log.info("文件已保存到临时目录: {}", filePath.toString()); + return filePath.toString(); + } + + /** + * 清理临时文件 + */ + private void cleanupTempFile(String filePath) { + try { + Path path = Paths.get(filePath); + if (Files.exists(path)) { + Files.delete(path); + log.info("临时文件已删除: {}", filePath); + } + } catch (IOException e) { + log.warn("删除临时文件失败: {}", filePath, e); + } + } + + /** + * 执行 Python 脚本获取曲线参数(通过上传的文件) + */ + public CurveParamDto getCurveParamsFromUpload(MultipartFile file, Integer decimal) { + String tempFilePath = null; + try { + // 保存上传的文件到临时目录 + tempFilePath = saveUploadedFile(file); + // 执行 Python 脚本 + return executePythonScript(tempFilePath, decimal); + } catch (Exception e) { + log.error("处理上传文件时发生错误", e); + throw new RuntimeException("处理文件失败: " + e.getMessage()); + } finally { + // 清理临时文件 + if (tempFilePath != null) { + cleanupTempFile(tempFilePath); + } + } + } + + /** + * 执行 Python 脚本 + */ + private CurveParamDto executePythonScript(String filePath, Integer decimal) { + try { + String pythonInterpreter = "python"; + + // 构建 Python 脚本路径 +// String projectRoot = System.getProperty("user.dir") + File.separator + "project"; +// String pythonScriptPath = projectRoot + File.separator +"get_curve_params.py"; + String pythonScriptPath = "/opt/script/get_curve_params.py"; + + // 构建命令参数 + List command = new ArrayList<>(); + command.add(pythonInterpreter); + command.add(pythonScriptPath); + command.add(filePath); + + if (decimal != null) { + command.add(decimal.toString()); + } + String commands = String.join(" ", command); + log.info("执行 Python 命令: {}", commands); + + // 执行命令 + Process process = Runtime.getRuntime().exec(commands); + + // 读取输出 + StringBuilder output = new StringBuilder(); + StringBuilder errors = new StringBuilder(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) { + // 读取标准输出 + String line; + while ((line = reader.readLine()) != null) { + output.append(line); + log.info("Python输出: {}", line); + } + // 读取错误输出 + while (errorReader.ready()) { + String errorLine = errorReader.readLine(); + if (errorLine != null) { + errors.append(errorLine).append("\n"); + log.error("Python错误: {}", errorLine); + } + } + } + // 等待进程结束 + int exitCode = process.waitFor(); + if (exitCode != 0) { + throw new RuntimeException("Python执行失败,退出码: " + exitCode + "错误信息: " + errors.toString()); + } + // 解析结果 + if (!output.isEmpty()) { + log.info("Python返回JSON: {}", output.toString()); + return objectMapper.readValue(output.toString(), CurveParamDto.class); + } else { + throw new RuntimeException("Python脚本没有输出"); + } + } catch (IOException | InterruptedException e) { + log.error("执行Python脚本时发生错误", e); + throw new RuntimeException("执行Python脚本时发生错误: " + e.getMessage()); + } + } + + /** + * 重载方法,不指定小数位数 + */ + public CurveParamDto getCurveParamsFromUpload(MultipartFile file) { + return getCurveParamsFromUpload(file, null); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse> batchAddSimulationKeyResult(KeyResultReq req) { + if (CollectionUtils.isNotEmpty(req.getKeyResultList())) { + UploadFilesReq filesReq = new UploadFilesReq(); + BeanUtils.copyProperties(req, filesReq); + filesReq.setUuid(req.getTaskId()); + filesReq.setSourceFiles(req.getKeyResultList().stream().map(i -> new UploadFilesReq(i.getFileName(), i.getFileSize(), i.getFileType())).toList()); + // 批量存储文件信息,返回数据供第二步分片上传使用 + SdmResponse> sdmResponse = dataFeignClient.batchAddFileInfo(filesReq); + if (sdmResponse.isSuccess() && CollectionUtils.isNotEmpty(sdmResponse.getData())) { + List batchAddFileInfoResps = sdmResponse.getData(); + + List simulationRunKeyResultList = new ArrayList<>(); + for (KeyResultReq keyResultReq : req.getKeyResultList()) { + SimulationRunKeyResult simulationRunKeyResult = new SimulationRunKeyResult(); + BeanUtils.copyProperties(keyResultReq, simulationRunKeyResult); + simulationRunKeyResult.setUuid(RandomUtil.generateString(32)); + // 上传交付物不挂在算例下面 不属于关键结果 但是又有文件属性 所以还用这张表 但是不记得RunId +// simulationRunKeyResult.setRunId(req.getRunId()); + simulationRunKeyResult.setCreator(ThreadLocalContext.getUserId()); + simulationRunKeyResult.setUpdater(ThreadLocalContext.getUserId()); + batchAddFileInfoResps.stream().filter(i -> StringUtils.equals(i.getSourceFileName(), keyResultReq.getFileName())).findFirst().ifPresent(i -> { + simulationRunKeyResult.setFileId(i.getBusinessId()); + }); + simulationRunKeyResultList.add(simulationRunKeyResult); + } + // 批量存储文件属性 + simulationKeyResultService.saveBatch(simulationRunKeyResultList); + return sdmResponse; + } + return sdmResponse; + } + return SdmResponse.success(new ArrayList<>()); + } + + @Override + public SdmResponse deliverableApprove(DeliverableApproveReq req) { + SimulationTask simulationTask = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, req.getTaskId()).one(); + if (simulationTask != null) { + ApprovalDeliverableContentsModel contentsModel = new ApprovalDeliverableContentsModel(); + contentsModel.setTaskId(req.getTaskId()); + contentsModel.setDifficult(req.getDifficult()); + // 发起审批 + String cidFlowId = launchParamApprove(req.getTemplateId(), req.getTemplateName(), JSONObject.toJSONString(contentsModel), 1); + if (StringUtils.isEmpty(cidFlowId)) { + return SdmResponse.failed("发起评审失败"); + } + simulationTask.setCidFlowId(cidFlowId); + simulationTask.setApprovalStatus(ApprovalStatusEnum.ING.getCode()); + simulationTaskService.updateById(simulationTask); + return SdmResponse.success(cidFlowId); + } + return SdmResponse.success(); + } + + @Override + public SdmResponse deliverableApproveCallback(LaunchApproveReq req) { + SdmResponse response = SdmResponse.success(); + int approveStatus = req.approveStatus; + String approveContent = req.approveContents; + JSONObject contentObj = JSONObject.parseObject(approveContent); + if (contentObj != null && contentObj.containsKey("taskId")) { + String taskId = contentObj.getString("taskId"); + Float difficult = contentObj.getFloat("difficult"); + SimulationTask simulationTask = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, taskId).one(); + if (simulationTask != null) { + // 审批通过 部署流程 保存部署流程部署id和流程定义id + if (NumberConstants.TWO == approveStatus) { + simulationTask.setDifficult(difficult); + simulationTask.setProgress(100); + simulationTask.setExeStatus(TaskExeStatusEnum.CLOSED.getCode()); + simulationTask.setApprovalStatus(ApprovalStatusEnum.PASSED.getCode()); + simulationTaskService.updateById(simulationTask); + } else { + simulationTask.setApprovalStatus(ApprovalStatusEnum.REJECTED.getCode()); + simulationTaskService.updateById(simulationTask); + } + } + } + return response; + } + + private String launchParamApprove(String templateId, String templateName, String approveContents, int approveAction) { + LaunchApproveReq req = new LaunchApproveReq(); + req.templateId = templateId; + req.templateName = templateName; + req.approveContents = approveContents; + req.approveAction = approveAction; + req.approveStatus = 1; + req.approveType = ApproveTypeEnum.DELIVERABLE_APPROVE.getCode(); + req.approveTitle = "交付物评审"; + req.tenantId = ThreadLocalContext.getTenantId(); + req.userId = ThreadLocalContext.getUserId(); + req.creator = ThreadLocalContext.getUserId(); + SdmResponse response = approveFeignClient.launchApproval(req); + if (response.isSuccess()) { + // 成功 + String cidFlowId = Optional.ofNullable(response.getData()) + .map(Object::toString) + .orElse(""); + return cidFlowId; + } + return ""; + } + + @Override + public SdmResponse>> listSimulationKeyResult(KeyResultReq req) { + PageHelper.startPage(req.getCurrent(), req.getSize()); + List runKeyResults = simulationKeyResultService.lambdaQuery().eq(SimulationRunKeyResult::getRunId, req.getRunId()) + .eq(SimulationRunKeyResult::getKeyResultType, req.getKeyResultType()).list(); + PageInfo page = new PageInfo<>(runKeyResults); + return PageUtils.getJsonObjectSdmResponse(runKeyResults, page); + } + + @Override + public SdmResponse> getSimulationKeyResultFileIds(String runId) { + List runKeyResults = simulationKeyResultService.lambdaQuery().eq(SimulationRunKeyResult::getRunId, runId).list(); + if (CollectionUtils.isNotEmpty(runKeyResults)) { + return SdmResponse.success(runKeyResults.stream().map(SimulationRunKeyResult::getFileId).collect(Collectors.toList())); + } + return SdmResponse.success(new ArrayList<>()); + } + + @Override + public SdmResponse>> queryKeyResultAndTaskInfo(KeyResultReq req) { + List respList = new ArrayList<>(); + + GetSimulationTaskFileReq taskFileReq = new GetSimulationTaskFileReq(); + taskFileReq.setUuid(req.getTaskId()); + taskFileReq.setFileBizType(req.getFileType()); + taskFileReq.setCurrent(req.getCurrent()); + taskFileReq.setSize(req.getSize()); + SdmResponse>> sdmResponse = analysisFeignClient.getSimulationTaskFile(taskFileReq); + + if (sdmResponse.getData() != null && sdmResponse.getData().getData() != null) { + List resultCurveResps = sdmResponse.getData().getData(); + for (SimulationTaskResultCurveResp resultCurveResp : resultCurveResps) { + KeyResultAndTaskInfoResp keyResultAndTaskInfoResp = new KeyResultAndTaskInfoResp(); + keyResultAndTaskInfoResp.setFileInfo(resultCurveResp); + SimulationRunKeyResult simulationRunKeyResult = simulationKeyResultService.lambdaQuery().eq(SimulationRunKeyResult::getFileId, resultCurveResp.getId()).one(); + if (simulationRunKeyResult != null) { + BeanUtils.copyProperties(simulationRunKeyResult, keyResultAndTaskInfoResp); + } + respList.add(keyResultAndTaskInfoResp); + } + } + PageInfo page = new PageInfo<>(respList); + return PageUtils.getJsonObjectSdmResponse(respList, page); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse deleteSimulationKeyResult(KeyResultReq req) { + // 删除结果 + simulationKeyResultService.lambdaUpdate().eq(SimulationRunKeyResult::getUuid, req.getUuid()).remove(); + // 删除文件 + DelDirReq delDirReq = new DelDirReq(); + delDirReq.setDelDirId(req.getFileId()); + log.info("删除关键结果调用删除文件夹的参数为:{}", req); + SdmResponse response = dataFeignClient.delDir(delDirReq); + log.info("删除关键结果调用删除文件夹的返回值为:{}", response); + return SdmResponse.success(response); + } + + private List buildRunTreeWithMap(List allRuns) { + // 按父节点ID分组 + Map> childrenMap = allRuns.stream().filter(run -> StringUtils.isNotEmpty(run.getParentId())) + .collect(Collectors.groupingBy(RunVersionInfoResp::getParentId)); + // 设置每个节点的子节点 + allRuns.forEach(run -> { + List children = childrenMap.getOrDefault(run.getUuid(), new ArrayList<>()); + // 对子节点排序 + children.sort(Comparator.comparing(RunVersionInfoResp::getCreateTime)); + run.setChildren(children); + }); + // 返回根节点 + return allRuns.stream().filter(run -> StringUtils.isEmpty(run.getParentId())).collect(Collectors.toList()); + } + + private void setDirId(KeyResultReq req) { + String dirName = KeyResultTypeEnum.getDirNameByType(req.getKeyResultType()); + QueryDirReq queryDirReq = new QueryDirReq(); + queryDirReq.setUuid(req.getRunId()); + queryDirReq.setCurrent(1); + queryDirReq.setSize(10); + SdmResponse>> sdmResponse = queryRunDir(queryDirReq); + if (sdmResponse.getData() != null) { + List fileMetadataInfoRespList = sdmResponse.getData().getData(); + if (CollectionUtils.isNotEmpty(fileMetadataInfoRespList)) { + fileMetadataInfoRespList.stream().filter(i -> StringUtils.equals(i.getOriginalName(), dirName)).findFirst().ifPresent(i -> { + req.setDirId(i.getId()); + }); + } + } + } + + + @Override + public void generateReport(SpdmReportReq req, HttpServletResponse response) { + log.info("生成自动化报告参数为:{}", req); + // 父节点信息 + ProjecInfoReq projecInfoReq = req.getProjecInfoReq(); + if (ObjectUtils.isEmpty(projecInfoReq) || StringUtils.isBlank(projecInfoReq.getLoadcaseName())) { + log.error("父节点信息不能为空"); + return; + } + // 根据文件id下载文件到临时目录 + List imageFileIdList = req.getImageFileIdList(); + String randomId = RandomUtil.generateString(16); + if (CollectionUtils.isNotEmpty(imageFileIdList)) { + for (Long fileId : imageFileIdList) { + dataFeignClient.downloadFileToLocal(fileId, TEMP_REPORT_PATH + randomId); + } + } + Path folder = Paths.get(TEMP_REPORT_PATH + randomId); + if (!Files.exists(folder) || !Files.isDirectory(folder)) { + if (!new File(TEMP_REPORT_PATH + randomId).mkdir()) { + log.error("创建临时文件夹:{}失败",TEMP_REPORT_PATH + randomId); + throw new RuntimeException("生成报告失败,原因为:创建临时文件夹失败"); + } + } + log.info("临时路径为:{}", randomId); + String commands = "python /opt/script/exportWord.py " + TEMP_REPORT_PATH + randomId + File.separator + TEMPLATE_PATH + projecInfoReq.getLoadcaseName() + "Analyse"; + // 生成projectInfo.json + projecInfoReq.setReportCommand(commands); + FileOutputStream projectInfoOutputStream = null; + try { + projectInfoOutputStream = new FileOutputStream(TEMP_REPORT_PATH + randomId + File.separator + "projectInfo.json"); + projectInfoOutputStream.write(JSON.toJSONString(projecInfoReq).getBytes(StandardCharsets.UTF_8)); + projectInfoOutputStream.flush(); + projectInfoOutputStream.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + // 生成performance.json + List performanceList = req.getPerformanceList(); + if (CollectionUtils.isNotEmpty(performanceList)) { + JSONObject allPerformanceInfoJson = new JSONObject(); + for (SimulationPerformance performance : performanceList) { + PerformanceInfoReq performanceInfoReq = new PerformanceInfoReq(); + performanceInfoReq.setValue(StringUtils.isNotBlank(performance.getTargetValue()) ? performance.getTargetValue() : ""); + performanceInfoReq.setEnglishName(StringUtils.isNotBlank(performance.getEnglishName()) ? performance.getEnglishName() : ""); + performanceInfoReq.setHighValue(StringUtils.isNotBlank(performance.getHighValue()) ? performance.getHighValue() : ""); + performanceInfoReq.setPerformanceName(StringUtils.isNotBlank(performance.getPerformanceName()) ? performance.getPerformanceName() : ""); + performanceInfoReq.setMethod(StringUtils.isNotBlank(performance.getMethod()) ? performance.getMethod() : ""); + performanceInfoReq.setUnit(StringUtils.isNotBlank(performance.getUnit()) ? performance.getUnit() : ""); + allPerformanceInfoJson.put(performanceInfoReq.getEnglishName(), performanceInfoReq); + } + allPerformanceInfoJson.put("type", "insert"); + FileOutputStream performanceOutputStream = null; + try { + performanceOutputStream = new FileOutputStream(TEMP_REPORT_PATH + randomId + File.separator + "performance.json"); + performanceOutputStream.write(JSON.toJSONString(allPerformanceInfoJson).getBytes(StandardCharsets.UTF_8)); + performanceOutputStream.flush(); + performanceOutputStream.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + // 调用脚本 + log.info("调用脚本中。。。。。。"); + log.info("command:" + commands); + List result = new ArrayList<>(); + int runningStatus = -1; + try { + log.info("开始同步执行脚本"); + Process process = Runtime.getRuntime().exec(commands); + log.info("准备获取脚本输出"); + log.info("开始获取脚本输出"); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + log.info("executePython:" + line); + result.add(line); + } + log.info("脚本执行完成"); + runningStatus = process.waitFor(); + log.info("脚本运行状态:" + runningStatus); + } catch (IOException | InterruptedException e) { + log.error("执行脚本失败:" + e); + return; + } + if (runningStatus != 0) { + log.error("执行脚本失败"); + return; + } else { + log.info(commands + "执行脚本完成!"); + } + byte[] fileData = null; + if (response != null) { + try { + // 获取临时路径中脚本生成的报告 + FileInputStream fileInputStream = new FileInputStream(TEMP_REPORT_PATH + randomId + File.separator + "report" + File.separator + "report.docx"); + fileData = fileInputStream.readAllBytes(); + // 设置响应头 + response.reset(); + response.setContentType("application/octet-stream;charset=UTF-8"); + response.addHeader("Content-Length", String.valueOf(fileData.length)); + // 写入响应流 + OutputStream outputStream = response.getOutputStream(); + outputStream.write(fileData); + outputStream.flush(); + outputStream.close(); + fileInputStream.close(); + } catch (Exception ex) { + log.error("生成自动化报告失败:{}", ex.getMessage()); + throw new RuntimeException("生成自动化报告失败"); + } + } + if (StringUtils.isNotBlank(req.getFlowPath()) && fileData != null) { + // 将生成的报告上传到flowPath路径下 + // 写入响应流 + FileOutputStream outputStream = null; + try { + outputStream = new FileOutputStream(req.getFlowPath()); + outputStream.write(fileData); + outputStream.flush(); + outputStream.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + // 删除临时路径 + log.info("删除临时路径:{},中。。。。。。", randomId); + deleteFolder(new File(TEMP_REPORT_PATH + randomId)); + } + + @Override + public SdmResponse generateReportInternal(SpdmReportReq req) { + log.info("内部调用生成自动化报告参数为:{}", req); + + // 父节点信息 + ProjecInfoReq projecInfoReq = req.getProjecInfoReq(); + if (ObjectUtils.isEmpty(projecInfoReq) || StringUtils.isBlank(projecInfoReq.getLoadcaseName())) { + log.error("父节点信息不能为空"); + return SdmResponse.failed("父节点信息不能为空"); + } + + // 根据文件id下载文件到临时目录 + List imageFileIdList = req.getImageFileIdList(); + String randomId = RandomUtil.generateString(16); + String tempPath = TEMP_REPORT_PATH + randomId; + + if (CollectionUtils.isNotEmpty(imageFileIdList)) { + for (Long fileId : imageFileIdList) { + dataFeignClient.downloadFileToLocal(fileId, tempPath); + } + } + + Path folder = Paths.get(tempPath); + if (!Files.exists(folder) || !Files.isDirectory(folder)) { + if (!new File(tempPath).mkdir()) { + log.error("创建临时文件夹:{}失败", tempPath); + throw new RuntimeException("生成报告失败,原因为:创建临时文件夹失败"); + } + } + + log.info("临时路径为:{}", randomId); + String commands = "python /opt/script/exportWord.py " + tempPath + File.separator + TEMPLATE_PATH + projecInfoReq.getLoadcaseName() + "Analyse"; + + // 生成projectInfo.json + projecInfoReq.setReportCommand(commands); + try (FileOutputStream projectInfoOutputStream = new FileOutputStream(tempPath + File.separator + "projectInfo.json")) { + projectInfoOutputStream.write(JSON.toJSONString(projecInfoReq).getBytes(StandardCharsets.UTF_8)); + projectInfoOutputStream.flush(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + // 生成performance.json + List performanceList = req.getPerformanceList(); + if (CollectionUtils.isNotEmpty(performanceList)) { + JSONObject allPerformanceInfoJson = new JSONObject(); + for (SimulationPerformance performance : performanceList) { + PerformanceInfoReq performanceInfoReq = new PerformanceInfoReq(); + performanceInfoReq.setValue(StringUtils.isNotBlank(performance.getTargetValue()) ? performance.getTargetValue() : ""); + performanceInfoReq.setEnglishName(StringUtils.isNotBlank(performance.getEnglishName()) ? performance.getEnglishName() : ""); + performanceInfoReq.setHighValue(StringUtils.isNotBlank(performance.getHighValue()) ? performance.getHighValue() : ""); + performanceInfoReq.setPerformanceName(StringUtils.isNotBlank(performance.getPerformanceName()) ? performance.getPerformanceName() : ""); + performanceInfoReq.setMethod(StringUtils.isNotBlank(performance.getMethod()) ? performance.getMethod() : ""); + performanceInfoReq.setUnit(StringUtils.isNotBlank(performance.getUnit()) ? performance.getUnit() : ""); + allPerformanceInfoJson.put(performanceInfoReq.getEnglishName(), performanceInfoReq); + } + allPerformanceInfoJson.put("type", "insert"); + + try (FileOutputStream performanceOutputStream = new FileOutputStream(tempPath + File.separator + "performance.json")) { + performanceOutputStream.write(JSON.toJSONString(allPerformanceInfoJson).getBytes(StandardCharsets.UTF_8)); + performanceOutputStream.flush(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + // 调用脚本 + log.info("调用脚本中。。。。。。"); + log.info("command:" + commands); + int runningStatus = -1; + try { + log.info("开始同步执行脚本"); + Process process = Runtime.getRuntime().exec(commands); + log.info("准备获取脚本输出"); + log.info("开始获取脚本输出"); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + log.info("executePython:" + line); + } + log.info("脚本执行完成"); + runningStatus = process.waitFor(); + log.info("脚本运行状态:" + runningStatus); + } catch (IOException | InterruptedException e) { + log.error("执行脚本失败:" + e); + return SdmResponse.failed("执行脚本失败:" + e.getMessage()); + } + + if (runningStatus != 0) { + log.error("执行脚本失败"); + return SdmResponse.failed("执行脚本失败"); + } else { + log.info(commands + "执行脚本完成!"); + } + + try { + // 获取临时路径中脚本生成的报告 + Path reportPath = Paths.get(tempPath + File.separator + "report" + File.separator + "report.docx"); + Path outputPath = Paths.get(req.getOutPutDirPath()); + + // 移动文件到目标路径 + if (Files.exists(reportPath) && Files.exists(outputPath) && Files.isDirectory(outputPath)) { + Path targetPath = outputPath.resolve("report.docx"); + Files.move(reportPath, targetPath, StandardCopyOption.REPLACE_EXISTING); + log.info("报告已移动至: {}", targetPath); + } else { + log.error("源文件或目标目录不存在"); + return SdmResponse.failed("源文件或目标目录不存在"); + } + } catch (Exception ex) { + log.error("移动报告文件失败:{}", ex.getMessage()); + throw new RuntimeException("移动报告文件失败"); + } finally { + // 删除临时路径 + log.info("删除临时路径:{},中。。。。。。", randomId); + deleteFolder(new File(tempPath)); + } + + return SdmResponse.success(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse startProcessInstance(SpdmTaskRunReq req) { + String runId = req.getRunId(); + SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid,runId ).one(); + Map variables = new HashMap<>(); + variables.put("runId", runId); + variables.put("userId",ThreadLocalContext.getUserId()); + variables.put("userName", ThreadLocalContext.getUserName()); + variables.put("tenantId", ThreadLocalContext.getTenantId()); + // 启动流程实例 多次执行会生成多个流程实例id,更新算例run表、同时更新flowable流程参数的流程实例id + SdmResponse sdmResponse = flowableFeignClient.startByProcessDefinitionId(simulationRun.getProcessDefinitionId(), variables); + if (sdmResponse.getData() != null) { + this.lambdaUpdate() + .set(SimulationRun::getFlowInstanceId, sdmResponse.getData().getProcessInstanceId()) + .set(SimulationRun::getStatus, RunStatusEnum.RUNNING.getCode()) + .eq(SimulationRun::getUuid, runId).update(); + flowableFeignClient.updateNodeParamProcessInstanceId(runId, simulationRun.getProcessDefinitionId(), sdmResponse.getData().getProcessInstanceId()); + } else { + return SdmResponse.failed("流程实例启动失败"); + } + return sdmResponse; + } + + @Override + public SdmResponse saveNodeParams(SpdmNodeParamReq req) { + SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one(); + SdmResponse flowTemplateResp = flowFeignClient.queryFlowTemplateInfo(simulationRun.getFlowTemplate()); + if (flowTemplateResp.getData() != null) { + ProcessDefinitionDTO definitionDTO = JSON.parseObject(flowTemplateResp.getData().getTemplateContent(), ProcessDefinitionDTO.class); + FlowNodeDto flowNodeReq = new FlowNodeDto(); + flowNodeReq.setUuid(req.getNodeUuid()); + SdmResponse sdmResponse = flowFeignClient.querySimulationFlowNode(flowNodeReq); + if (sdmResponse.getData() != null) { + FlowNodeDto flowNodeDto = sdmResponse.getData(); + definitionDTO.getFlowElements().stream().filter(i -> StringUtils.equals(i.getId(), flowNodeDto.getNodeId())).findFirst().ifPresent(i -> { + if (i.getExtensionElements() != null && i.getExtensionElements().getExecuteConfig() != null) { + Map params = new HashMap<>(); + // 输出文件夹id 保存到用户输入参数 + params.put("outputDirId", flowNodeDto.getOutputDirId()); + // 前端用户输入参数 + params.putAll(req.getInputParams()); + flowableFeignClient.saveParamsByDefinitionId(simulationRun.getProcessDefinitionId(), flowNodeDto.getNodeId(), simulationRun.getUuid(), params); + } + }); + } + } + + return SdmResponse.success(); + } + + @Override + public SdmResponse listFlowNodes(SpdmTaskRunReq req) { + FlowInfoDto flowInfoDto = new FlowInfoDto(); + FlowNodeDto nodeReq = new FlowNodeDto(); + nodeReq.setRunId(req.getRunId()); + SdmResponse> sdmResponse = flowFeignClient.listSimulationFlowNode(nodeReq); + if (sdmResponse.getData() != null) { + List flowNodeDtoList = sdmResponse.getData(); + SimulationRun simulationRun = this.lambdaQuery().eq(SimulationRun::getUuid, req.getRunId()).one(); + SdmResponse response = flowableFeignClient.getProcessAndNodeDetailByInstanceId(simulationRun.getProcessDefinitionId(), simulationRun.getFlowInstanceId(), simulationRun.getUuid()); + if (response.getData() != null && CollectionUtils.isNotEmpty(response.getData().getNodes())) { + flowInfoDto.setProcessInfo(response.getData().getProcessInfo()); + for (FlowNodeDto flowNodeDto : flowNodeDtoList) { + response.getData().getNodes().stream().filter(i -> StringUtils.equals(i.getId(), flowNodeDto.getNodeId())).findFirst().ifPresent(i -> { + flowNodeDto.setNodeStatus(i.getStatus()); + flowNodeDto.setUserParams(i.getUserParam()); + flowNodeDto.setProcessInstanceId(simulationRun.getFlowInstanceId()); + flowNodeDto.setNodeDetailInfo(i); + }); + } + } + + if (simulationRun.getFlowInstanceId() == null) { + flowNodeDtoList.forEach(node -> { + node.setNodeStatus("pending"); + }); + } + flowInfoDto.setFlowNodeDtoList(flowNodeDtoList); + return SdmResponse.success(flowInfoDto); + } + return SdmResponse.success(); + } + + @Override + public SdmResponse flowRelateReport(SpdmReportReq req) { + generateReport(req,null); + return SdmResponse.success(); + } + + @Override + public SdmResponse> listQuantities() { + return SdmResponse.success(baseQuantitiesService.list()); + } + + @Override + public SdmResponse> listUnits(String quantityType) { + if (StringUtils.isEmpty(quantityType)) { + return SdmResponse.success(baseUnitsService.list()); + } else { + return SdmResponse.success(baseUnitsService.lambdaQuery().eq(SimulationBaseUnits::getFamily, quantityType).list()); + } + } + + public static void deleteFolder(File folder) { + if (folder.isDirectory()) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + deleteFolder(file); + } + } + } + folder.delete(); + } + +} +
+ + +package com.sdm.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.project.dao.SimulationTaskAttentionMapper; +import com.sdm.project.model.entity.SimulationTaskAttention; +import com.sdm.project.service.ISimulationTaskAttentionService; +import com.sdm.project.service.ISimulationTaskMemberService; +import org.springframework.stereotype.Service; + + +@Service +public class SimulationTaskAttentionServiceImpl extends ServiceImpl implements ISimulationTaskAttentionService { + +} + + + +package com.sdm.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.project.dao.SimulationTaskExtraMapper; +import com.sdm.project.model.entity.SimulationTaskExtra; +import com.sdm.project.service.ISimulationTaskExtraService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2025-09-16 + */ +@Service +public class SimulationTaskExtraServiceImpl extends ServiceImpl implements ISimulationTaskExtraService { + +} +
+ + +package com.sdm.project.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.project.dao.SimulationTaskMemberMapper; +import com.sdm.project.model.entity.SimulationTaskMember; +import com.sdm.project.service.ISimulationTaskMemberService; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class SimulationTaskMemberServiceImpl extends ServiceImpl implements ISimulationTaskMemberService { + + @Override + public void deleteTaskMemberList(String taskId, Integer type) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SimulationTaskMember::getTaskId, taskId); + wrapper.eq(SimulationTaskMember::getType, type); + this.remove(wrapper); + } + + @Override + public boolean saveTaskMemberList(String taskId, Integer type, List userIds) { + for (Long userId : userIds) { + SimulationTaskMember entity = new SimulationTaskMember(); + entity.setTaskId(taskId); + entity.setType(type); + entity.setUserId(userId); + entity.setCreator(ThreadLocalContext.getUserId()); + entity.setCreateTime(DateUtil.now()); + this.save(entity); + } + return true; + } + +} + + + +package com.sdm.project.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.project.model.entity.SimulationTask; +import com.sdm.project.dao.SimulationTaskMapper; +import com.sdm.project.model.entity.SimulationTaskMember; +import com.sdm.project.model.req.SpdmEditNodeForDataReq; +import com.sdm.project.model.req.SpdmEditTaskForDataReq; +import com.sdm.project.model.req.SpdmTaskOprReq; +import com.sdm.project.service.ISimulationTaskService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author author + * @since 2025-11-03 + */ +@Service +public class SimulationTaskServiceImpl extends ServiceImpl implements ISimulationTaskService { + + @Override + public boolean updateSimulationTask(SpdmTaskOprReq req) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SimulationTask::getUuid, req.getTaskId()); + if (req.getExeStatus() != null) { + wrapper.set(SimulationTask::getExeStatus, req.getExeStatus()); + } + if (req.getAchieveStatus() != null) { + wrapper.set(SimulationTask::getAchieveStatus, req.getAchieveStatus()); + } + if (req.getProgress() != null) { + wrapper.set(SimulationTask::getProgress, req.getProgress()); + } + if (req.getFinishTime() != null) { + wrapper.set(SimulationTask::getFinishTime, req.getFinishTime()); + } + if (req.getBeginTime() != null) { + wrapper.set(SimulationTask::getBeginTime, req.getBeginTime()); + } + if (req.getEndTime() != null) { + wrapper.set(SimulationTask::getEndTime, req.getEndTime()); + } + if (req.getNodeName() != null) { + wrapper.set(SimulationTask::getTaskName, req.getNodeName()); + } + wrapper.set(SimulationTask::getCreator, ThreadLocalContext.getUserId()); + wrapper.set(SimulationTask::getUpdateTime, DateUtil.now()); + return this.update(wrapper); + } + + @Override + public SdmResponse editTaskForData(SpdmEditTaskForDataReq req) { + SimulationTask simulationTask = new SimulationTask(); + BeanUtils.copyProperties(req,simulationTask); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + this.update(updateWrapper.setEntity(simulationTask)); + return SdmResponse.success(); + } + +} +
+ + +package com.sdm.project.service.impl; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.sdm.common.common.ResultCode; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.common.ThreadLocalContext; +import com.sdm.common.entity.ExportExcelFormat; +import com.sdm.common.entity.constants.ProjectConstants; +import com.sdm.common.entity.enums.DirTypeEnum; +import com.sdm.common.entity.enums.FilePermissionEnum; +import com.sdm.common.entity.enums.NodeTypeEnum; +import com.sdm.common.entity.req.data.CreateDirReq; +import com.sdm.common.entity.req.data.UpdatePermissionReq; +import com.sdm.common.entity.req.project.SimulationPerformance; +import com.sdm.common.entity.req.system.UserQueryReq; +import com.sdm.common.entity.req.task.TaskExportExcelFormat; +import com.sdm.common.entity.req.task.TaskExportExcelParam; +import com.sdm.common.entity.req.task.TaskTreeExportExcelFormat; +import com.sdm.common.entity.req.task.TaskTreeExportExcelParam; +import com.sdm.common.entity.resp.system.CIDUserResp; +import com.sdm.common.feign.impl.data.DataClientFeignClientImpl; +import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; +import com.sdm.common.utils.excel.ExcelUtil; +import com.sdm.project.common.MemberTypeEnum; +import com.sdm.project.common.RunPerformanceStatusEnum; +import com.sdm.project.common.TaskExeStatusEnum; +import com.sdm.project.dao.SimulationDemandMapper; +import com.sdm.project.dao.SimulationNodeMapper; +import com.sdm.project.dao.SimulationProjectMapper; +import com.sdm.project.dao.SimulationTaskMapper; +import com.sdm.project.model.bo.*; +import com.sdm.project.model.entity.*; +import com.sdm.project.model.po.*; +import com.sdm.project.model.req.*; +import com.sdm.project.model.req.YA.ProjectTaskInfo; +import com.sdm.project.model.req.YA.SyncCidTaskReq; +import com.sdm.project.model.resp.*; +import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; +import com.sdm.project.model.vo.*; +import com.sdm.project.service.*; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static com.sdm.project.service.impl.NodeServiceImpl.getTagProperty; +import static com.sdm.project.service.impl.NodeServiceImpl.setTagProperty; + +@Slf4j +@Service +public class TaskServiceImpl implements ITaskService { + + @Autowired + private SimulationTaskMapper mapper; + + @Resource + private SimulationNodeMapper nodeMapper; + + @Resource + private SimulationProjectMapper projectMapper; + + @Resource + private SimulationDemandMapper demandMapper; + + @Autowired + private ISimulationRunService simulationRunService; + + @Autowired + private ISimulationPerformanceService simulationPerformanceService; + + @Autowired + private SysUserFeignClientImpl sysUserFeignClient; + + @Autowired + private ISimulationTaskMemberService simulationTaskMemberService; + @Autowired + private ISimulationTaskService simulationTaskService; + @Autowired + private ISimulationTaskExtraService simulationTaskExtraService; + @Autowired + private ISimulationTaskAttentionService simulationTaskAttentionService; + + @Autowired + private DataClientFeignClientImpl dataClientFeignClient; + + @Resource + private INodeService nodeService; + + private static final String NODE_NAME_KEY = "nodeName"; + + private static final String NODE_CODE_KEY = "nodeCode"; + private static final String PMEMBER_CODE_KEY = "pMemberList"; + private static final String EMEMBER_CODE_KEY = "eMemberList"; + private static final String PMEMBER_NAME = "仿真负责人"; + private static final String EMEMBER_NAME = "仿真执行人"; + + private static final String MACHINE_NAME_KEY = "machineName"; + private static final String MACHINE_CODE_KEY = "machineCode"; + private static final String MACHINE_NAME = "机台名称"; + private static final String MACHINE_CODE = "机台编号"; + + private static final String WORKSPACE_NAME_KEY = "workspaceName"; + private static final String WORKSPACE_CODE_KEY = "workspaceCode"; + private static final String WORKSPACE_NAME = "工位名称"; + private static final String WORKSPACE_CODE = "工位编号"; + + private static final String DISCIPLINE_NAME_KEY = "disciplineName"; + private static final String DISCIPLINE_CODE_KEY = "disciplineCode"; + private static final String DISCIPLINE_NAME = "学科名称"; + private static final String DISCIPLINE_CODE = "学科编号"; + + private static final String TASK_NAME_KEY = "taskName"; + private static final String TASK_CODE_KEY = "taskCode"; + private static final String TASK_NAME = "任务名称"; + private static final String TASK_CODE = "任务编号"; + + private static final String PERFORMANCE_NAME_KEY = "performanceName"; + private static final String PERFORMANCE_CODE_KEY = "performanceCode"; + private static final String PERFORMANCE_NAME = "指标名称"; + private static final String PERFORMANCE_CODE = "指标编号"; + + @Override + public SdmResponse list(SpdmTaskListReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long userId = ThreadLocalContext.getUserId(); + if (Objects.isNull(tenantId) || Objects.isNull(userId)) { + log.error("公司和工号都不能为空"); + return SdmResponse.failed("公司和工号都不能为空"); + } + // 0:我执行的 1:我关注的 2:所有 3:我分发的 + Integer type = req.getType(); + + if (StringUtils.isNotBlank(req.getExeStatus())) { + req.setExeStatusList(Arrays.stream(req.getExeStatus().split(",")).toList()); + } + if (StringUtils.isNotBlank(req.getAchieveStatus())) { + req.setAchieveStatusList(Arrays.stream(req.getAchieveStatus().split(",")).toList()); + } + List beginTime = req.getBeginTime(); + if (CollectionUtils.isNotEmpty(beginTime)) { + req.setBeginSTime(beginTime.get(0)); + req.setBeginETime(beginTime.get(1)); + } + List endTime = req.getEndTime(); + if (CollectionUtils.isNotEmpty(endTime)) { + req.setEndSTime(endTime.get(0)); + req.setEndETime(endTime.get(1)); + } + List finishTime = req.getFinishTime(); + if (CollectionUtils.isNotEmpty(finishTime)) { + req.setFinishSTime(finishTime.get(0)); + req.setFinishETime(finishTime.get(1)); + } + List allTaskList = mapper.getTaskList(tenantId, req); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data", new ArrayList<>()); + if (CollectionUtils.isEmpty(allTaskList)) { + log.error("根据tenantId:{},未查询到任务", tenantId); + return SdmResponse.success(jsonObject); + } + List taskList = new ArrayList<>(); + List idMapList = req.getIdMap(); + if (CollectionUtils.isEmpty(idMapList)) { + log.error("任务列表中的idMap不能为空"); + return SdmResponse.failed("任务列表中的idMap不能为空"); + } + if (idMapList.stream().anyMatch(idMap -> StringUtils.isNotBlank(idMap.getKey()))) { + List realIdMapList = idMapList.stream().filter(idMap -> StringUtils.isNotBlank(idMap.getKey())).toList(); + TaskNodeTag realTaskNodeTag = realIdMapList.get(realIdMapList.size() - 1); + log.info("实际查询节点类型为:{}", realTaskNodeTag); + String currentNodeTagId = ""; + for (SpdmTaskVo spdmTaskVo : allTaskList) { + try { + currentNodeTagId = getTagProperty(spdmTaskVo, realTaskNodeTag.getValue()); + if (StringUtils.isNotBlank(currentNodeTagId) && currentNodeTagId.contains(realTaskNodeTag.getKey())) { + taskList.add(spdmTaskVo); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } else { + taskList = allTaskList; + } + if (CollectionUtils.isEmpty(taskList)) { + log.info("未查询到任务"); + return SdmResponse.success(jsonObject); + } + jsonObject.put("currentPage", req.getCurrent()); + jsonObject.put("pageSize", req.getSize()); + List taskIdList = taskList.stream().map(SpdmTaskVo::getUuid).toList(); + List taskMemberVoList = mapper.getMemberList(taskIdList, null); + List copyTaskMemberList = taskMemberVoList.stream().map(i -> { + SpdmTaskMemberVo o = new SpdmTaskMemberVo(); + o.setTaskId(i.getTaskId()); + o.setType(i.getType()); + o.setUserId(i.getUserId()); + return o; + }).collect(Collectors.toList()); + + Map> memberMap = Map.of(); + if (CollectionUtils.isNotEmpty(taskMemberVoList)) { + memberMap = taskMemberVoList.stream().collect(Collectors.groupingBy(SpdmTaskMemberVo::getTaskId)); + } + + List eachMemberList; + List tagList = idMapList.stream().map(TaskNodeTag::getValue).toList(); + List nodeIdList = new ArrayList<>(); + List eachNodeIdList; + String eachNodeId; + SpdmNodeVo eachNodeVo; + List taskExtraList = mapper.getTaskExtraList(taskIdList); + Map> taskExtraMap = Map.of(); + if (CollectionUtils.isNotEmpty(taskExtraList)) { + taskExtraMap = taskExtraList.stream().collect(Collectors.groupingBy(TaskNodeExtraPo::getTaskId)); + } + Boolean convertTag = req.getConvertTag(); + if (type == 2) { + if (CollectionUtils.isEmpty(taskList)) { + return SdmResponse.success(jsonObject); + } + List attentionMemberList = mapper.getAttentionMemberList(taskList.stream().map(SpdmTaskVo::getUuid).toList()); + Map> attentionMap = Map.of(); + List eachAttentionMemberList; + if (CollectionUtils.isNotEmpty(attentionMemberList)) { + attentionMap = attentionMemberList.stream().collect(Collectors.groupingBy(SpdmTaskAttentionMemberVo::getTaskId)); + } + for (SpdmTaskVo spdmTaskVo : taskList) { + for (String tag : tagList) { + try { + eachNodeId = getTagProperty(spdmTaskVo, tag); + if (StringUtils.isNotBlank(eachNodeId)) { + eachNodeIdList = Arrays.stream(eachNodeId.split(",")).filter(nodeId -> !nodeId.equals("null")).toList(); + if (CollectionUtils.isNotEmpty(eachNodeIdList)) { + nodeIdList.addAll(eachNodeIdList); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + Map nodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(nodeIdList)) { + List nodeList = nodeMapper.getNodeListByIds(nodeIdList.stream().distinct().toList()); + nodeMap = nodeList.stream().collect(Collectors.groupingBy( + SpdmNodeVo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + for (SpdmTaskVo task : taskList) { + for (String tag : tagList) { + tag = tag.replace("T", "t"); + try { + eachNodeId = getTagProperty(task, tag); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (StringUtils.isNotBlank(eachNodeId)) { + eachNodeIdList = Arrays.stream(eachNodeId.split(",")).filter(nodeId -> !nodeId.equals("null")).toList(); + if (CollectionUtils.isNotEmpty(eachNodeIdList)) { + List eachNodeList = new ArrayList<>(); + for (String nodeId : eachNodeIdList) { + eachNodeVo = nodeMap.get(nodeId); + if (ObjectUtils.isNotEmpty(eachNodeVo)) { + eachNodeList.add(eachNodeVo); + } + } + if (CollectionUtils.isNotEmpty(eachNodeList) && convertTag) { + try { + setTagProperty(task, tag, eachNodeList.stream().map(SpdmNodeVo::getNodeName).collect(Collectors.joining(","))); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + } + } + eachAttentionMemberList = attentionMap.get(task.getUuid()); + task.setAttentionFlag(CollectionUtils.isEmpty(eachAttentionMemberList) ? 0 : + (eachAttentionMemberList.stream().map(SpdmTaskAttentionMemberVo::getUserId).toList().contains(userId) ? 1 : 0)); + eachMemberList = memberMap.get(task.getUuid()); + if (CollectionUtils.isEmpty(eachMemberList)) { + continue; + } +// task.setPMemberList(eachMemberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).toList()); +// task.setEMemberList(eachMemberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).toList()); + + setPMemberList(task, eachMemberList); + setEMemberList(task, eachMemberList); + } + jsonObject.put("total", taskList.size()); + taskList = taskList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList(); + List newTaskList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(taskList)) { + List demandIdList = taskList.stream().map(SpdmTaskVo::getDemandId).toList(); + Map demandMap = Map.of(); + if (CollectionUtils.isNotEmpty(demandIdList)) { + // 根据demandId查询demandName + List demandVoList = demandMapper.getDemandListById(demandIdList); + if (CollectionUtils.isNotEmpty(demandVoList)) { + demandMap = demandVoList.stream().collect(Collectors.toMap(SpdmDemandVo::getUuid, SpdmDemandVo::getDemandName)); + } + } + for (SpdmTaskVo taskVo : taskList) { + SpdmNewTaskVo spdmNewTaskVo = new SpdmNewTaskVo(); + BeanUtils.copyProperties(taskVo, spdmNewTaskVo); + spdmNewTaskVo.setTag1(taskVo.getTag1()); + spdmNewTaskVo.setTag2(taskVo.getTag2()); + spdmNewTaskVo.setTag3(taskVo.getTag3()); + spdmNewTaskVo.setTag4(taskVo.getTag4()); + spdmNewTaskVo.setTag5(taskVo.getTag5()); + spdmNewTaskVo.setTag6(taskVo.getTag6()); + spdmNewTaskVo.setTag7(taskVo.getTag7()); + spdmNewTaskVo.setTag8(taskVo.getTag8()); + spdmNewTaskVo.setTag9(taskVo.getTag9()); + spdmNewTaskVo.setTag10(taskVo.getTag10()); + spdmNewTaskVo.setPMemberList(taskVo.getPMemberList()); + spdmNewTaskVo.setEMemberList(taskVo.getEMemberList()); + spdmNewTaskVo.setExtras(taskExtraMap.get(taskVo.getUuid())); + if (StringUtils.isNotBlank(spdmNewTaskVo.getDemandId())) { + spdmNewTaskVo.setDemandName(demandMap.get(spdmNewTaskVo.getDemandId())); + } + newTaskList.add(spdmNewTaskVo); + } + } + jsonObject.put("data", newTaskList); + return SdmResponse.success(jsonObject); + } + if (type == 0) { + // 仿真执行人是当前用户 + if (CollectionUtils.isNotEmpty(taskMemberVoList)) { + SdmResponse cidUserResp = sysUserFeignClient.queryUserDetail(UserQueryReq.builder().userId(userId).build()); + if (ObjectUtils.isEmpty(cidUserResp.getData())) { + log.error("根据jobNumber:{},未查询到用户", userId); + return SdmResponse.success(new ArrayList<>()); + } + CIDUserResp cidUser = cidUserResp.getData(); + taskMemberVoList = taskMemberVoList.stream().filter(taskMember -> MemberTypeEnum.EXECUTOR.getCode().equals(taskMember.getType())).toList(); + if (CollectionUtils.isEmpty(taskMemberVoList)) { + log.error("任务列表中未查询到仿真执行人1"); + return SdmResponse.success(new ArrayList<>()); + } + Long curUserId = cidUser.getUserId(); + taskMemberVoList = taskMemberVoList.stream().filter(member -> curUserId.equals(member.getUserId())).toList(); + if (CollectionUtils.isEmpty(taskMemberVoList)) { + log.error("任务列表中未查询到仿真执行人2"); + return SdmResponse.success(new ArrayList<>()); + } + List myTaskIdList = taskMemberVoList.stream().map(SpdmTaskMemberVo::getTaskId).toList(); + taskList = taskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList(); + } + } else if (type == 3) { + // 仿真负责人是当前用户 + if (CollectionUtils.isNotEmpty(taskMemberVoList)) { + SdmResponse cidUserResp = sysUserFeignClient.queryUserDetail(UserQueryReq.builder().userId(userId).build()); + if (ObjectUtils.isEmpty(cidUserResp.getData())) { + log.error("根据jobNumber:{},未查询到用户", userId); + return SdmResponse.success(new ArrayList<>()); + } + taskMemberVoList = taskMemberVoList.stream().filter(taskMember -> MemberTypeEnum.PRINCIPAL.getCode().equals(taskMember.getType()) && userId.equals(taskMember.getUserId())).toList(); + if (CollectionUtils.isEmpty(taskMemberVoList)) { + log.error("任务列表中未查询到仿真负责人"); + return SdmResponse.success(new ArrayList<>()); + } + List myTaskIdList = taskMemberVoList.stream().map(SpdmTaskMemberVo::getTaskId).toList(); + taskList = taskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList(); + } + } else { + SdmResponse cidUserResp = sysUserFeignClient.queryUserDetail(UserQueryReq.builder().userId(userId).build()); + if (ObjectUtils.isEmpty(cidUserResp.getData())) { + log.error("根据jobNumber:{},未查询到用户", userId); + return SdmResponse.success(new ArrayList<>()); + } + CIDUserResp cidUser = cidUserResp.getData(); + List taskAttentionMemberVoList = mapper.getAttentionMemberList(taskIdList); + if (CollectionUtils.isEmpty(taskAttentionMemberVoList)) { + log.error("未查询到关注人"); + return SdmResponse.success(new ArrayList<>()); + } + // 当前用户的主键id + Long curUserId = cidUser.getUserId(); + taskAttentionMemberVoList = taskAttentionMemberVoList.stream().filter(member -> curUserId.equals(member.getUserId())).toList(); + if (CollectionUtils.isEmpty(taskAttentionMemberVoList)) { + log.error("任务列表中未查询到仿真执行人3"); + return SdmResponse.success(new ArrayList<>()); + } + List myTaskIdList = taskAttentionMemberVoList.stream().map(SpdmTaskAttentionMemberVo::getTaskId).toList(); + taskList = taskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList(); + } + if (CollectionUtils.isEmpty(taskList)) { + log.error("taskList为空"); + return SdmResponse.success(new ArrayList<>()); + } + + taskMemberVoList = mapper.getMemberList(taskList.stream().map(SpdmTaskVo::getUuid).toList(), null); + + if (CollectionUtils.isNotEmpty(taskMemberVoList)) { + if (ObjectUtils.isNotEmpty(req.getPMemberList())) { + List pMemberIdList = Stream.of(req.getPMemberList().split(",")).map(Long::valueOf).toList(); + // 通过仿真负责人过滤 + taskMemberVoList = taskMemberVoList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType()) && pMemberIdList.contains(member.getUserId())).collect(Collectors.toList()); + } +// if (StringUtils.isNotBlank(req.getEMemberList())) { +// // 通过仿真执行人过滤 +// List eMemberIdList = Stream.of(req.getEMemberList().split(",")).map(Long::valueOf).toList(); +// // 通过仿真负责人过滤 +// taskMemberVoList = taskMemberVoList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType()) && eMemberIdList.contains(member.getUserId())).collect(Collectors.toList()); +// } + if (CollectionUtils.isEmpty(taskMemberVoList)) { + log.error("taskMemberVoList为空"); + jsonObject.put("total", 0); + return SdmResponse.success(jsonObject); + } + memberMap = taskMemberVoList.stream().collect(Collectors.groupingBy(SpdmTaskMemberVo::getTaskId)); + List realTaskIdList = taskMemberVoList.stream().map(SpdmTaskMemberVo::getTaskId).distinct().toList(); + // 根据负责人信息过滤任务 + taskList = taskList.stream().filter(task -> realTaskIdList.contains(task.getUuid())).toList(); + if (CollectionUtils.isEmpty(taskList)) { + log.error("taskList为空"); + jsonObject.put("total", 0); + return SdmResponse.success(jsonObject); + } + } + + jsonObject.put("total", taskList.size()); + taskList = taskList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList(); + + if (CollectionUtils.isEmpty(taskList)) { + jsonObject.put("data", taskList); + return SdmResponse.success(jsonObject); + } + List demandIdList = taskList.stream().map(SpdmTaskVo::getDemandId).toList(); + Map demandMap = Map.of(); + if (CollectionUtils.isNotEmpty(demandIdList)) { + // 根据demandId查询demandName + List demandVoList = demandMapper.getDemandListById(demandIdList); + if (CollectionUtils.isNotEmpty(demandVoList)) { + demandMap = demandVoList.stream().collect(Collectors.toMap(SpdmDemandVo::getUuid, SpdmDemandVo::getDemandName)); + } + } + for (SpdmTaskVo spdmTaskVo : taskList) { + for (String tag : tagList) { + try { + eachNodeId = getTagProperty(spdmTaskVo, tag.replace("T", "t")); + if (StringUtils.isNotBlank(eachNodeId)) { + eachNodeIdList = Arrays.stream(eachNodeId.split(",")).filter(nodeId -> !nodeId.equals("null")).toList(); + if (CollectionUtils.isNotEmpty(eachNodeIdList)) { + nodeIdList.addAll(eachNodeIdList); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + Map nodeMap = Map.of(); + if (CollectionUtils.isNotEmpty(nodeIdList)) { + List nodeList = nodeMapper.getNodeListByIds(nodeIdList.stream().distinct().toList()); + nodeMap = nodeList.stream().collect(Collectors.groupingBy( + SpdmNodeVo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + } + + + List attentionMemberList = mapper.getAttentionMemberList(taskList.stream().map(SpdmTaskVo::getUuid).toList()); + Map> attentionMap = Map.of(); + List eachAttentionMemberList; + if (CollectionUtils.isNotEmpty(attentionMemberList)) { + attentionMap = attentionMemberList.stream().collect(Collectors.groupingBy(SpdmTaskAttentionMemberVo::getTaskId)); + } + List eachTaskMemberList; + for (SpdmTaskVo task : taskList) { + for (String tag : tagList) { + tag = tag.replace("T", "t"); + try { + eachNodeId = getTagProperty(task, tag); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (StringUtils.isNotBlank(eachNodeId)) { + eachNodeIdList = Arrays.stream(eachNodeId.split(",")).filter(nodeId -> !nodeId.equals("null")).toList(); + if (CollectionUtils.isNotEmpty(eachNodeIdList)) { + List eachNodeList = new ArrayList<>(); + for (String nodeId : eachNodeIdList) { + eachNodeVo = nodeMap.get(nodeId); + if (ObjectUtils.isNotEmpty(eachNodeVo)) { + eachNodeList.add(eachNodeVo); + } + } + if (CollectionUtils.isNotEmpty(eachNodeList)) { + try { + setTagProperty(task, tag, eachNodeList.stream().map(SpdmNodeVo::getNodeName).collect(Collectors.joining(","))); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + } + } + eachAttentionMemberList = attentionMap.get(task.getUuid()); + task.setAttentionFlag(CollectionUtils.isEmpty(eachAttentionMemberList) ? 0 : + (eachAttentionMemberList.stream().map(SpdmTaskAttentionMemberVo::getUserId).toList().contains(userId) ? 1 : 0)); + eachTaskMemberList = memberMap.get(task.getUuid()); + if (CollectionUtils.isEmpty(eachTaskMemberList)) { + continue; + } + // 设置仿真负责人和执行人 + setPMemberList(task, copyTaskMemberList); + setEMemberList(task, copyTaskMemberList); + } + List newTaskList = new ArrayList<>(); + for (SpdmTaskVo taskVo : taskList) { + SpdmNewTaskVo spdmNewTaskVo = new SpdmNewTaskVo(); + BeanUtils.copyProperties(taskVo, spdmNewTaskVo); + spdmNewTaskVo.setTag1(taskVo.getTag1()); + spdmNewTaskVo.setTag2(taskVo.getTag2()); + spdmNewTaskVo.setTag3(taskVo.getTag3()); + spdmNewTaskVo.setTag4(taskVo.getTag4()); + spdmNewTaskVo.setTag5(taskVo.getTag5()); + spdmNewTaskVo.setTag6(taskVo.getTag6()); + spdmNewTaskVo.setTag7(taskVo.getTag7()); + spdmNewTaskVo.setTag8(taskVo.getTag8()); + spdmNewTaskVo.setTag9(taskVo.getTag9()); + spdmNewTaskVo.setTag10(taskVo.getTag10()); + spdmNewTaskVo.setPMemberList(taskVo.getPMemberList()); + spdmNewTaskVo.setEMemberList(taskVo.getEMemberList()); + spdmNewTaskVo.setExtras(taskExtraMap.get(taskVo.getUuid())); + if (StringUtils.isNotBlank(spdmNewTaskVo.getDemandId())) { + spdmNewTaskVo.setDemandName(demandMap.get(spdmNewTaskVo.getDemandId())); + } + newTaskList.add(spdmNewTaskVo); + } + jsonObject.put("data", newTaskList); + return SdmResponse.success(jsonObject); + } + + private void setPMemberList(SpdmTaskVo task, List eachMemberList) { + // 由于我分发的、我执行的、我关注的、所有任务,都需要展示仿真负责人,故将负责人抽成方法调用 + List pUserIdList = eachMemberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType()) && StringUtils.equals(task.getUuid(), member.getTaskId())).map(SpdmTaskMemberVo::getUserId).distinct().toList(); + if (CollectionUtils.isNotEmpty(pUserIdList)) { + SdmResponse> cidUserResp= sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(pUserIdList).build()); + task.setPMemberList(cidUserResp.getData()); + } + } + + private void setEMemberList(SpdmTaskVo task, List eachMemberList) { + // 由于我分发的、我关注的、所有任务,都需要展示仿真执行人,故将执行人抽成方法调用 + List eUserIdList = eachMemberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType()) && StringUtils.equals(task.getUuid(), member.getTaskId())).map(SpdmTaskMemberVo::getUserId).distinct().toList(); + if (CollectionUtils.isNotEmpty(eUserIdList)) { + SdmResponse> cidUserResp= sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(eUserIdList).build()); + task.setEMemberList(cidUserResp.getData()); + } + } + + @Override + public SdmResponse countByStatus(SpdmTaskCountReq req) { + Long tenantId = ThreadLocalContext.getTenantId(); + Long userId = ThreadLocalContext.getUserId(); + if (Objects.isNull(tenantId) || Objects.isNull(userId)) { + log.error("公司和工号都不能为空"); + return SdmResponse.failed("公司和工号都不能为空"); + } + // 0:我执行的 1:我关注的 2:所有 3:我分发的 + Integer type = req.getType(); + + SpdmTaskListReq qry = new SpdmTaskListReq(); + List allTaskList = mapper.getTaskList(tenantId, qry); + // 今明任务 + qry.setTodayTmrTasks(ProjectConstants.TODAY_TMR_TASKS); + List todayTmrTaskList = mapper.getTaskList(tenantId, qry); + if (CollectionUtils.isEmpty(allTaskList)) { + log.error("根据tenantId:{},未查询到任务", tenantId); + return SdmResponse.success(); + } + List taskList = new ArrayList<>(); + List idMapList = req.getIdMap(); + if (CollectionUtils.isEmpty(idMapList)) { + log.error("任务列表中的idMap不能为空"); + return SdmResponse.failed("任务列表中的idMap不能为空"); + } + if (idMapList.stream().anyMatch(idMap -> StringUtils.isNotBlank(idMap.getKey()))) { + List realIdMapList = idMapList.stream().filter(idMap -> StringUtils.isNotBlank(idMap.getKey())).toList(); + TaskNodeTag realTaskNodeTag = realIdMapList.get(realIdMapList.size() - 1); + log.info("实际查询节点类型为:{}", realTaskNodeTag); + String currentNodeTagId = ""; + for (SpdmTaskVo spdmTaskVo : allTaskList) { + try { + currentNodeTagId = getTagProperty(spdmTaskVo, realTaskNodeTag.getValue().replace("T", "t")); + if (StringUtils.isNotBlank(currentNodeTagId) && currentNodeTagId.contains(realTaskNodeTag.getKey())) { + taskList.add(spdmTaskVo); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } else { + taskList = allTaskList; + } + if (CollectionUtils.isEmpty(taskList)) { + log.info("未查询到任务"); + return SdmResponse.success(); + } + + TaskCountResp taskCountResp = new TaskCountResp(); + List taskIdList = taskList.stream().map(SpdmTaskVo::getUuid).toList(); + List taskMemberVoList = mapper.getMemberList(taskIdList, null); + + List realTaskIdList = taskMemberVoList.stream().map(SpdmTaskMemberVo::getTaskId).distinct().toList(); + // 根据负责人信息过滤任务 + taskList = taskList.stream().filter(task -> realTaskIdList.contains(task.getUuid())).toList(); + + if (type == 2) { + // 所有任务 + countTask(taskList, todayTmrTaskList, taskCountResp); + } else { + // 我分发的、我执行的、我关注的 需要查询当前登陆人信息 + SdmResponse cidUserResp = sysUserFeignClient.queryUserDetail(UserQueryReq.builder().userId(userId).build()); + if (ObjectUtils.isEmpty(cidUserResp.getData())) { + log.error("根据jobNumber:{},未查询到用户", userId); + return SdmResponse.success(); + } + if (type == 0) { + // 仿真执行人是当前用户 + if (CollectionUtils.isNotEmpty(taskMemberVoList)) { + taskMemberVoList = taskMemberVoList.stream().filter(taskMember -> MemberTypeEnum.EXECUTOR.getCode().equals(taskMember.getType()) && userId.equals(taskMember.getUserId())).toList(); + if (CollectionUtils.isEmpty(taskMemberVoList)) { + log.error("任务列表中未查询到仿真执行人"); + return SdmResponse.success(); + } + List myTaskIdList = taskMemberVoList.stream().map(SpdmTaskMemberVo::getTaskId).toList(); + taskList = taskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList(); + countTask(taskList, todayTmrTaskList, taskCountResp); + } + } else if (type == 3) { + // 仿真负责人是当前用户 + if (CollectionUtils.isNotEmpty(taskMemberVoList)) { + taskMemberVoList = taskMemberVoList.stream().filter(taskMember -> MemberTypeEnum.PRINCIPAL.getCode().equals(taskMember.getType()) && userId.equals(taskMember.getUserId())).toList(); + if (CollectionUtils.isEmpty(taskMemberVoList)) { + log.error("任务列表中未查询到仿真负责人"); + return SdmResponse.success(); + } + List myTaskIdList = taskMemberVoList.stream().map(SpdmTaskMemberVo::getTaskId).toList(); + taskList = taskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList(); + countTask(taskList, todayTmrTaskList, taskCountResp); + } + } else { + CIDUserResp cidUser = cidUserResp.getData(); + List taskAttentionMemberVoList = mapper.getAttentionMemberList(taskIdList); + if (CollectionUtils.isEmpty(taskAttentionMemberVoList)) { + log.error("未查询到关注人"); + return SdmResponse.success(); + } + // 当前用户的主键id + Long curUserId = cidUser.getUserId(); + taskAttentionMemberVoList = taskAttentionMemberVoList.stream().filter(member -> curUserId.equals(member.getUserId())).toList(); + if (CollectionUtils.isEmpty(taskAttentionMemberVoList)) { + log.error("任务列表中未查询到仿真执行人3"); + return SdmResponse.success(); + } + List myTaskIdList = taskAttentionMemberVoList.stream().map(SpdmTaskAttentionMemberVo::getTaskId).toList(); + taskList = taskList.stream().filter(task -> myTaskIdList.contains(task.getUuid())).toList(); + countTask(taskList, todayTmrTaskList, taskCountResp); + } + } + return SdmResponse.success(taskCountResp); + } + + private void countTask(List taskList, List todayTmrTaskList, TaskCountResp taskCountResp) { + // 计数 + taskCountResp.setTotal(taskList.size()); + taskCountResp.setTodayTmrTasks(taskList.size()); + taskCountResp.setInProgress((int) taskList.stream().filter(i -> TaskExeStatusEnum.IN_PROGRESS.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setPostponed((int) taskList.stream().filter(i -> TaskExeStatusEnum.POSTPONED.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setNoStarted((int) taskList.stream().filter(i -> TaskExeStatusEnum.NO_STARTED.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setCompleted((int) taskList.stream().filter(i -> TaskExeStatusEnum.COMPLETED.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setClosed((int) taskList.stream().filter(i -> TaskExeStatusEnum.CLOSED.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setPaused((int) taskList.stream().filter(i -> TaskExeStatusEnum.PAUSED.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setRejected((int) taskList.stream().filter(i -> TaskExeStatusEnum.REJECTED.getCode().equals(i.getExeStatus())).count()); + taskCountResp.setTodayTmrTasks((int) taskList.stream().filter(todayTmrTaskList::contains).count()); + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse operation(SpdmTaskOpr taskOpr) { + if (CollectionUtils.isNotEmpty(taskOpr.getTaskIds()) && ObjectUtils.isNotEmpty(taskOpr.getReq())) { + SpdmTaskOprReq req = taskOpr.getReq(); + if (ObjectUtils.isNotEmpty(req.getProgress()) && req.getProgress() > 100) { + return SdmResponse.failed("任务进度超过100%,请核查"); + } + for (String taskId : taskOpr.getTaskIds()) { + req.setTaskId(taskId); + if (simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, taskId).count() <= 0) { + log.error("根据taskId:{},未查询到任务", taskId); + return SdmResponse.failed("未查询到任务"); + } + if (!simulationTaskService.updateSimulationTask(req)) { + return SdmResponse.failed("编辑任务失败"); + } + if (StringUtils.isNotBlank(req.getEMemberList())) { + String[] userIdArr = req.getEMemberList().split(","); + List longUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList()); + simulationTaskMemberService.deleteTaskMemberList(taskId, MemberTypeEnum.EXECUTOR.getCode()); + if (!simulationTaskMemberService.saveTaskMemberList(taskId, MemberTypeEnum.EXECUTOR.getCode(), longUserIdList)) { + return SdmResponse.failed("编辑仿真执行人失败"); + } + } + } + } + return SdmResponse.success(); + } + + + private void recursionAllNodeIdList(List currentNodeIdList, List allNodeIdList) { + List spdmNodeVoList = nodeMapper.getNodeListByNodeIdList(currentNodeIdList); + if (CollectionUtils.isEmpty(spdmNodeVoList)) { + return; + } + List addNodeIdList = spdmNodeVoList.stream().map(SpdmNodeVo::getUuid).toList(); + allNodeIdList.addAll(addNodeIdList); + recursionAllNodeIdList(addNodeIdList, allNodeIdList); + } + + @Override + public SdmResponse analysisPerformanceList(SpdmAnalysisPerformanceListReq req) { + SpdmAnalysisTaskListReq taskReq = new SpdmAnalysisTaskListReq(); + BeanUtils.copyProperties(req, taskReq); + taskReq.setCurrent(1); + taskReq.setSize(10000); + taskReq.setName(""); + taskReq.setBeginTime(""); + taskReq.setEndTime(""); + SdmResponse response = analysisTaskList(taskReq); + if (ObjectUtils.isEmpty(response)) { + log.error("指标查询中,未查询到任务1"); + return SdmResponse.success(new ArrayList<>()); + } + JSONObject data = (JSONObject) response.getData(); + List taskVoList = (List) data.get("data"); + if (CollectionUtils.isEmpty(taskVoList)) { + log.error("指标查询中,未查询到任务2"); + return SdmResponse.success(new ArrayList<>()); + } + + List taskIdList = taskVoList.stream().map(SpdmAnalysisTaskVo::getUuid).toList(); + List performanceNodePoList = projectMapper.queryPerformanceNodeByNodeIdList(taskIdList,req.getBeginTime(),req.getEndTime(),req.getName()); + if (CollectionUtils.isEmpty(performanceNodePoList)) { + log.error("指标查询中,未查询到指标1"); + return SdmResponse.success(new ArrayList<>()); + } + if (StringUtils.isNotBlank(req.getPerformanceName())) { + performanceNodePoList = performanceNodePoList.stream().filter(performance -> performance.getPerformanceName().contains(req.getName())).toList(); + } + if (CollectionUtils.isEmpty(performanceNodePoList)) { + log.error("指标查询中,未查询到指标2"); + return SdmResponse.success(new ArrayList<>()); + } + Map taskMap = taskVoList.stream().collect(Collectors.groupingBy( + SpdmAnalysisTaskVo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + SpdmAnalysisTaskVo eachTaskVo; + for (PerformanceNodePo performanceNodePo : performanceNodePoList) { + eachTaskVo = taskMap.get(performanceNodePo.getTaskId()); + if (ObjectUtils.isEmpty(eachTaskVo)) { + continue; + } + performanceNodePo.setPerformanceName(performanceNodePo.getNodeName()); + performanceNodePo.setProjectName(eachTaskVo.getProjectName()); + performanceNodePo.setPhaseName(eachTaskVo.getPhaseName()); + performanceNodePo.setDisciplineName(eachTaskVo.getDisciplineName()); + performanceNodePo.setPMemberList(eachTaskVo.getPMembers()); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("currentPage", req.getCurrent()); + jsonObject.put("pageSize", req.getSize()); + jsonObject.put("total", performanceNodePoList.size()); + jsonObject.put("data", performanceNodePoList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList()); + return SdmResponse.success(jsonObject); + } + + @Override + public SdmResponse analysisTaskList(SpdmAnalysisTaskListReq req) { + int pos = (req.getCurrent() - 1) * req.getSize(); + int limit = req.getSize(); + Long tenantId = ThreadLocalContext.getTenantId(); + String projectNodeId = req.getProjectNodeId(); + String phaseNodeId = req.getPhaseNodeId(); + String disciplineNodeId = req.getDisciplineNodeId(); + String nodeId = ""; + if (StringUtils.isNotBlank(projectNodeId)) { + nodeId = projectNodeId; + } else if (StringUtils.isNotBlank(phaseNodeId)) { + nodeId = phaseNodeId; + } else if (StringUtils.isNotBlank(disciplineNodeId)) { + nodeId = disciplineNodeId; + } + List allNodeIdList = new ArrayList<>(); + if (StringUtils.isNotBlank(nodeId)) { + allNodeIdList.add(nodeId); + recursionAllNodeIdList(Collections.singletonList(nodeId), allNodeIdList); + } + List taskVoList = mapper.taskList(req, tenantId, allNodeIdList, pos, limit); + JSONObject jsonObject = new JSONObject(); + if (CollectionUtils.isEmpty(taskVoList)) { + log.error("数据分析中未查询到任务信息"); + jsonObject.put("data", new ArrayList<>()); + return SdmResponse.success(jsonObject); + } + List allNodeList = projectMapper.getNodeListByNodeIdList(allNodeIdList); + Map nodeMap = allNodeList.stream().collect(Collectors.groupingBy( + ProjectNodePo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + // 设置仿真负责人 + List taskIdList = taskVoList.stream().map(SpdmAnalysisTaskVo::getUuid).toList(); + List taskNodeMemberPoList = projectMapper.queryTaskNodeMembersByNodeIdList(taskIdList); + Map> memberMap = Map.of(); + if (CollectionUtils.isNotEmpty(taskNodeMemberPoList)) { + memberMap = taskNodeMemberPoList.stream().collect(Collectors.groupingBy(TaskNodeMemberPo::getTaskId)); + } + ProjectNodePo eachProjectNodePo; + List eachTaskNodeMemberPoList; + for (SpdmAnalysisTaskVo task : taskVoList) { + eachProjectNodePo = nodeMap.get(task.getNodeId()); + if (ObjectUtils.isNotEmpty(eachProjectNodePo)) { + if (NodeTypeEnum.PROJECT.getValue().equals(eachProjectNodePo.getNodeType())) { + task.setProjectName(eachProjectNodePo.getNodeName()); + } else if (NodeTypeEnum.PHASE.getValue().equals(eachProjectNodePo.getNodeType())) { + task.setPhaseName(eachProjectNodePo.getNodeName()); + } else if (NodeTypeEnum.DISCIPLINE.getValue().equals(eachProjectNodePo.getNodeType())) { + task.setDisciplineName(eachProjectNodePo.getNodeName()); + } + } + eachTaskNodeMemberPoList = memberMap.get(task.getUuid()); + if (CollectionUtils.isNotEmpty(eachTaskNodeMemberPoList)) { + task.setPMembers(eachTaskNodeMemberPoList.stream().map(TaskNodeMemberPo::getName).collect(Collectors.joining(","))); + } + } + jsonObject.put("currentPage", req.getCurrent()); + jsonObject.put("pageSize", req.getSize()); + jsonObject.put("total", taskVoList.size()); + jsonObject.put("data", taskVoList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList()); + return SdmResponse.success(jsonObject); + } + + + @Override + public SdmResponse analysisRunList(SpdmAnalysisRunListReq req) { + SpdmAnalysisTaskListReq taskReq = new SpdmAnalysisTaskListReq(); + BeanUtils.copyProperties(req, taskReq); + taskReq.setCurrent(1); + taskReq.setSize(10000); + taskReq.setName(""); + taskReq.setBeginTime(""); + taskReq.setEndTime(""); + SdmResponse response = analysisTaskList(taskReq); + if (ObjectUtils.isEmpty(response)) { + log.error("指标查询中,未查询到任务1"); + return SdmResponse.success(new ArrayList<>()); + } + JSONObject data = (JSONObject) response.getData(); + List taskVoList = (List) data.get("data"); + if (CollectionUtils.isEmpty(taskVoList)) { + log.error("指标查询中,未查询到任务2"); + return SdmResponse.success(new ArrayList<>()); + } + List taskIdList = taskVoList.stream().map(SpdmAnalysisTaskVo::getUuid).toList(); + List runPoList = projectMapper.queryRunListByNodeIdList(taskIdList,req.getBeginTime(),req.getEndTime(),req.getName()); + if (CollectionUtils.isEmpty(runPoList)) { + log.error("算例查询中,未查询到算例1"); + return SdmResponse.success(new ArrayList<>()); + } + if (CollectionUtils.isEmpty(runPoList)) { + log.error("算例查询中,未查询到算例2"); + return SdmResponse.success(new ArrayList<>()); + } + Map taskMap = taskVoList.stream().collect(Collectors.groupingBy( + SpdmAnalysisTaskVo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + SpdmAnalysisTaskVo eachTaskVo; + for (TaskRunPo taskRunPo : runPoList) { + eachTaskVo = taskMap.get(taskRunPo.getTaskId()); + if (ObjectUtils.isEmpty(eachTaskVo)) { + continue; + } + taskRunPo.setProjectName(eachTaskVo.getProjectName()); + taskRunPo.setPhaseName(eachTaskVo.getPhaseName()); + taskRunPo.setDisciplineName(eachTaskVo.getDisciplineName()); + taskRunPo.setPMembers(eachTaskVo.getPMembers()); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("currentPage", req.getCurrent()); + jsonObject.put("pageSize", req.getSize()); + jsonObject.put("total", runPoList.size()); + jsonObject.put("data", runPoList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList()); + return SdmResponse.success(jsonObject); + } + + @Override + public SdmResponse attention(String taskId, List addUserIdList, List cancelUserIdList) { + if (StringUtils.isBlank(taskId) || (CollectionUtils.isEmpty(addUserIdList) && CollectionUtils.isEmpty(cancelUserIdList))) { + return SdmResponse.failed("参数不正确"); + } + SpdmTaskVo task = mapper.getTask(taskId); + if (ObjectUtils.isEmpty(task)) { + log.error("attention根据taskId:{},未查询到任务", taskId); + return SdmResponse.failed("未查询到任务"); + } + if (CollectionUtils.isNotEmpty(addUserIdList)) { + List attentionList = new ArrayList<>(); + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + Long jobNumber = ThreadLocalContext.getUserId(); + // 关注 + for (Long userId : addUserIdList) { + SpdmTaskAttentionReq spdmTaskAttentionReq = new SpdmTaskAttentionReq(); + spdmTaskAttentionReq.setTaskId(taskId); + spdmTaskAttentionReq.setUserId(userId); + spdmTaskAttentionReq.setCreateTime(curDateStr); + spdmTaskAttentionReq.setCreator(jobNumber); + attentionList.add(spdmTaskAttentionReq); + } + mapper.saveAttentionList(attentionList); + } else { + mapper.deleteAttentionByUserIdList(taskId, cancelUserIdList); + } + return SdmResponse.success(); + } + + @Override + public SdmResponse edit(ModifyTaskNode req) { + List taskEditNodeReqList = req.getEditNodeList(); + String nodeType; + Map> editNodeListMap = taskEditNodeReqList.stream().collect(Collectors.groupingBy(TaskEditNodeReq::getNodeType)); + for (Map.Entry> taskEntry : editNodeListMap.entrySet()) { + nodeType = taskEntry.getKey(); + log.info("nodeType为:{}", nodeType); + editTaskList(taskEntry.getValue()); + } + return SdmResponse.success(); + } + + private void editTaskList(List taskEditNodeReqList) { + List taskExtraNodeList; + List taskMemberNodeList; + for (TaskEditNodeReq taskEditNodeReq : taskEditNodeReqList) { + projectMapper.updateProjectNodeItem(taskEditNodeReq); + taskExtraNodeList = taskEditNodeReq.getTaskExtraNodeList(); + if (CollectionUtils.isNotEmpty(taskExtraNodeList)) { + for (TaskExtraNode taskExtraNode : taskExtraNodeList) { + projectMapper.updateProjectNodeItemExtra(taskExtraNode); + } + } + taskMemberNodeList = taskEditNodeReq.getMemberList(); + if (CollectionUtils.isNotEmpty(taskMemberNodeList)) { + for (TaskMemberNode taskMemberNode : taskMemberNodeList) { + projectMapper.updateProjectNodeItemMember(taskMemberNode); + } + } + } + } + + @Override + public SdmResponse getAllRunResultByTaskId(String taskId) { + GetAllRunResultByTaskIdResp result= new GetAllRunResultByTaskIdResp(); + // taskId不为null,runid为null,查询所有工况设定的标准指标 + List simulationTaskPerformances = simulationPerformanceService + .lambdaQuery() + .eq(SimulationPerformance::getTaskId, taskId) + .isNull(SimulationPerformance::getRunId) + .list(); + if(CollectionUtils.isEmpty(simulationTaskPerformances)) { + return SdmResponse.success(); + } + + simulationTaskPerformances.forEach(simulationPerformance -> { + TasKPerformanceResp taskPerformanceResp = new TasKPerformanceResp(); + BeanUtils.copyProperties(simulationPerformance, taskPerformanceResp); + result.getTasKPerformanceRespList().add(taskPerformanceResp); + }); + + + + // // taskId不为null,runid不为null,获取算列计算结果 + List simulationRunList = simulationRunService.lambdaQuery().eq(SimulationRun::getTaskId, taskId).list(); + + Map> simulationRunPerformanceMap = simulationPerformanceService + .lambdaQuery() + .eq(SimulationPerformance::getTaskId, taskId) + .isNotNull(SimulationPerformance::getRunId) + .list() + .stream() + .collect(Collectors.groupingBy(SimulationPerformance::getRunId)); + + List runResultRespList = new ArrayList<>(); + + if(CollectionUtils.isNotEmpty(simulationRunList)) { + for (SimulationRun simulationRun : simulationRunList) { + RunResultResp runResultResp = new RunResultResp(); + runResultResp.setSimulationRun(simulationRun); + List simulationPerformance = simulationRunPerformanceMap.get(simulationRun.getUuid()); + if (CollectionUtils.isNotEmpty(simulationPerformance)) { + runResultResp.setSimulationPerformance(simulationPerformance); + } + runResultRespList.add(runResultResp); + } + } + + result.setRunResultResp(runResultRespList); + + return SdmResponse.success(result); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public SdmResponse batchDeleteTask(SpdmTaskOpr taskOpr) { + List taskIds = taskOpr.getTaskIds(); + simulationTaskService.lambdaUpdate().in(SimulationTask::getUuid, taskIds).remove(); + simulationTaskMemberService.lambdaUpdate().in(SimulationTaskMember::getTaskId, taskIds).remove(); + simulationTaskExtraService.lambdaUpdate().in(SimulationTaskExtra::getTaskId, taskIds).remove(); + simulationTaskAttentionService.lambdaUpdate().in(SimulationTaskAttention::getTaskId, taskIds).remove(); + return SdmResponse.success(); + } + + @Override + public SdmResponse> listUserWorkloadsWithinTimeFrame(UserWorkloadReq req) { + List userWorkloadRespList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(req.getUserIds())) { + SdmResponse> cidUserResp= sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(req.getUserIds().stream().map(Long::valueOf).toList()).build()); + List userList = cidUserResp.getData(); + for (CIDUserResp userResp : userList) { + UserWorkloadResp workloadResp = new UserWorkloadResp(); + workloadResp.setUserId(String.valueOf(userResp.getUserId())); + workloadResp.setUserName(userResp.getNickname()); + req.setUserId(userResp.getUserId()); + List taskList = mapper.getUserExecTaskWithinTimeFrame(req); + workloadResp.setTaskNum(taskList.size()); + workloadResp.setWorkNum(taskList.stream().filter(i -> Arrays.asList(TaskExeStatusEnum.NO_STARTED.getCode(), TaskExeStatusEnum.IN_PROGRESS.getCode()).contains(i.getExeStatus())).toList().size()); + workloadResp.setWorkload(taskList.stream().filter(i -> i.getDays() != null).mapToDouble(SimulationTask::getDays).sum()); + workloadResp.setTaskList(taskList); + userWorkloadRespList.add(workloadResp); + } + } + return SdmResponse.success(userWorkloadRespList); + } + + @Override + public SdmResponse> listTaskWorkDays(UserWorkloadReq req) { + List taskList = simulationTaskService.lambdaQuery().in(SimulationTask::getUuid, req.getTaskIds()).list(); + List taskWorkDaysResps = taskList.stream().map(i -> { + TaskWorkDaysResp taskWorkDaysResp = new TaskWorkDaysResp(); + taskWorkDaysResp.setTaskName(i.getTaskName()); + taskWorkDaysResp.setTaskId(i.getUuid()); + taskWorkDaysResp.setDays(i.getDays()); + return taskWorkDaysResp; + }).toList(); + return SdmResponse.success(taskWorkDaysResps); + } + + @Override + public SdmResponse exportTask(TaskExportExcelFormat taskExportExcelFormat, HttpServletResponse httpServletResponse) { + SpdmTaskListReq req = new SpdmTaskListReq(); + TaskExportExcelParam params = taskExportExcelFormat.getParams(); + List originIdMap = params.getIdMap(); + if (ObjectUtils.isEmpty(params.getType())) { + log.error("type不能为空"); + return SdmResponse.failed("type不能为空"); + } + if (CollectionUtils.isEmpty(originIdMap)) { + log.error("idMap不能为空"); + return SdmResponse.failed("idMap不能为空"); + } + List currentIdMapList = new ArrayList<>(); + for (com.sdm.common.entity.bo.TaskNodeTag originTaskNodeTag : originIdMap) { + TaskNodeTag taskNodeTag = new TaskNodeTag(); + taskNodeTag.setKey(originTaskNodeTag.getKey()); + taskNodeTag.setValue(originTaskNodeTag.getValue()); + currentIdMapList.add(taskNodeTag); + } + req.setIdMap(currentIdMapList); + if (ObjectUtils.isNotEmpty(params)) { + BeanUtils.copyProperties(params,req); + } + req.setCurrent(1); + req.setSize(10000); + List exportExcelFormats = taskExportExcelFormat.getExcelHeaders(); + SdmResponse taskRespond = list(req); + SdmResponse response = new SdmResponse(); + if(taskRespond.isSuccess()) { + JSONObject dataObj = (JSONObject) taskRespond.getData(); + List taskVoList = (List) dataObj.get("data"); + List exportNewTaskVoList = new ArrayList<>(); + List pMemberList; + String pMemberName = ""; + List eMemberList; + String eMemberName = ""; + for (SpdmNewTaskVo spdmNewTaskVo : taskVoList) { + pMemberList = spdmNewTaskVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(pMemberList)) { + pMemberName = pMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + eMemberList = spdmNewTaskVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(eMemberList)) { + eMemberName = eMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + SpdmExportNewTaskVo spdmExportNewTaskVo = new SpdmExportNewTaskVo(); + BeanUtils.copyProperties(spdmNewTaskVo,spdmExportNewTaskVo); + spdmExportNewTaskVo.setPMemberList(pMemberName); + spdmExportNewTaskVo.setEMemberList(eMemberName); + exportNewTaskVoList.add(spdmExportNewTaskVo); + } + ExcelUtil.exportExcelNoMerge(JSONArray.from(exportNewTaskVoList),exportExcelFormats,httpServletResponse); + } else { + response = SdmResponse.failed(taskRespond.getMessage()); + } + return response; + } + +// @Override +// public SdmResponse synchronizeCidTask(SpdmSyncCidTaskReq req) { +// log.info("同步CID任务的参数为:{}", req); +// Long tenantId = ThreadLocalContext.getTenantId(); +// Long jobNumber = ThreadLocalContext.getUserId(); +// List taskNodeList = req.getTaskList(); +// if (CollectionUtils.isEmpty(taskNodeList)) { +// log.error("同步CID任务的参数为空"); +// return SdmResponse.failed("同步CID任务的参数为空"); +// } +// SdmResponse response = SdmResponse.success(); +// List projectNodeMemberList = new ArrayList<>(); +// List projectNodeExtraList = new ArrayList<>(); +// List allPerformanceList = new ArrayList<>(); +// List allPerformanceExtraList = new ArrayList<>(); +// for (CidTaskNode task : taskNodeList) { +// task.setUuid(RandomUtil.generateString(32)); +// task.setTenantId(tenantId); +// String pUserIdStr = task.getPMemberList(); +// String eUserIdStr = task.getEMemberList(); +// log.info("下发的仿真负责人为:{}", pUserIdStr); +// log.info("下发的仿真执行人为:{}", eUserIdStr); +// if (StringUtils.isNotBlank(pUserIdStr)) { +// String[] userIdArr = pUserIdStr.split(","); +// for (String userId : userIdArr) { +// TaskMemberNode taskMemberNode = new TaskMemberNode(); +// taskMemberNode.setTaskId(task.getUuid()); +// taskMemberNode.setNodeId(task.getUuid()); +// taskMemberNode.setUserId(userId); +// taskMemberNode.setType(MemberTypeEnum.PRINCIPAL.getCode()); +// projectNodeMemberList.add(taskMemberNode); +// } +// } +// if (StringUtils.isNotBlank(eUserIdStr)) { +// String[] userIdArr = eUserIdStr.split(","); +// for (String userId : userIdArr) { +// TaskMemberNode taskMemberNode = new TaskMemberNode(); +// taskMemberNode.setTaskId(task.getUuid()); +// taskMemberNode.setNodeId(task.getUuid()); +// taskMemberNode.setUserId(userId); +// taskMemberNode.setType(MemberTypeEnum.EXECUTOR.getCode()); +// projectNodeMemberList.add(taskMemberNode); +// } +// } +// List extraList = task.getTaskExtraNodeList(); +// if (CollectionUtils.isNotEmpty(extraList)) { +// for (TaskExtraNode extra : extraList) { +// TaskExtraNode taskExtraNode = new TaskExtraNode(); +// taskExtraNode.setTaskId(task.getUuid()); +// taskExtraNode.setNodeId(task.getUuid()); +// taskExtraNode.setPropertyName(extra.getPropertyName()); +// taskExtraNode.setPropertyValue(extra.getPropertyValue()); +// projectNodeExtraList.add(taskExtraNode); +// } +// } +// // 指标 +// List performanceList = task.getChildren(); +// for (CidTaskNode performance : performanceList) { +// performance.setTaskId(task.getUuid()); +// List performanceExtraList = performance.getTaskExtraNodeList(); +// if (CollectionUtils.isNotEmpty(performanceExtraList)) { +// for (TaskExtraNode extra : performanceExtraList) { +// extra.setPerformanceId(performance.getUuid()); +// extra.setTaskId(performance.getTaskId()); +// extra.setNodeId(performance.getNodeId()); +// allPerformanceExtraList.add(extra); +// } +// } +// allPerformanceList.add(performance); +// } +// } +// String createTime = DateUtil.now(); +// Map taskNodeMap = Map.of(); +// if (CollectionUtils.isNotEmpty(taskNodeList)) { +// taskNodeList.forEach(projectNode -> { +// projectNode.setCreator(jobNumber); +// projectNode.setCreateTime(createTime); +// }); +// if (projectMapper.batchAddSimulationCidTask(taskNodeList) <= 0) { +// response = SdmResponse.failed("新增任务失败"); +// return response; +// } +// taskNodeMap = taskNodeList.stream().collect(Collectors.groupingBy( +// CidTaskNode::getUuid, +// Collectors.collectingAndThen( +// Collectors.toList(), +// list -> list.get(0) +// ) +// )); +// for (CidTaskNode taskNode : taskNodeList) { +// createDir(taskNode.getUuid(), NodeTypeEnum.TASK.getValue(),null, taskNode.getTaskName()); +// } +// } +// if (CollectionUtils.isNotEmpty(projectNodeExtraList)) { +// projectNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationTaskExtra(projectNodeExtraList) <= 0) { +// response = SdmResponse.failed("新增任务附加属性失败"); +// } +// } +// if (CollectionUtils.isNotEmpty(projectNodeMemberList)) { +// projectNodeMemberList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationTaskMember(projectNodeMemberList) <= 0) { +// response = SdmResponse.failed("新增任务成员属性失败"); +// return response; +// } +// } +// // 指标 +// if (CollectionUtils.isNotEmpty(allPerformanceList)) { +// allPerformanceList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationCidPerformance(allPerformanceList) <= 0) { +// response = SdmResponse.failed("新增指标失败"); +// return response; +// } +// List newTaskNodeList = projectMapper.getTaskListByNodeIdList(allPerformanceList.stream().map(CidTaskNode::getTaskId).toList()); +// Map taskNodePoMap = Map.of(); +// if (CollectionUtils.isNotEmpty(newTaskNodeList)) { +// taskNodePoMap = newTaskNodeList.stream().collect(Collectors.groupingBy( +// TaskNodePo::getUuid, +// Collectors.collectingAndThen( +// Collectors.toList(), +// list -> list.get(0) +// ) +// )); +// } +// for (CidTaskNode taskNode : allPerformanceList) { +// if (ObjectUtils.isEmpty(taskNodePoMap.get(taskNode.getTaskId())) && ObjectUtils.isEmpty(taskNodeMap.get(taskNode.getTaskId()))) { +// log.error("taskNodeMap不空,根据taskId:{},未查询到任务", taskNode.getTaskId()); +// response = SdmResponse.failed("新增指标时,创建文件失败"); +// return response; +// } +// createDir(taskNode.getUuid(),NodeTypeEnum.PERFORMANCE.getValue(), +// ObjectUtils.isNotEmpty(taskNodePoMap.get(taskNode.getTaskId())) ? taskNodePoMap.get(taskNode.getTaskId()).getUuid() : taskNodeMap.get(taskNode.getTaskId()).getUuid(), +// taskNode.getTaskName()); +// } +// } +// if (CollectionUtils.isNotEmpty(allPerformanceExtraList)) { +// allPerformanceExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime)); +// if (projectMapper.batchAddSimulationPerformanceExtra(allPerformanceExtraList) <= 0) { +// response = SdmResponse.failed("新增任务指标附加属性失败"); +// return response; +// } +// } +// return response; +// } + + @Override + public SdmResponse getTaskDetail(GetTaskDetailReq req) { + log.info("getTaskDetail参数为:{}",req); + SpdmTaskVo taskVo = mapper.getTask(req.getRelatedResourceUuid()); + if (ObjectUtils.isEmpty(taskVo)) { + log.error("根据id:{},未查询到任务",req.getRelatedResourceUuid()); + return SdmResponse.failed("未查询到任务"); + } + SpdmTaskDetailVo spdmTaskDetailVo = new SpdmTaskDetailVo(); + BeanUtils.copyProperties(taskVo,spdmTaskDetailVo); + spdmTaskDetailVo.setId(taskVo.getId()); + List memberList = mapper.getMemberList(Collections.singletonList(taskVo.getUuid()), null); + if (CollectionUtils.isNotEmpty(memberList)) { + List userIdList = memberList.stream().map(SpdmTaskMemberVo::getUserId).toList(); + Map> userMap = Map.of(); + if (CollectionUtils.isNotEmpty(userIdList)) { + SdmResponse> cidUserResp= sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build()); + List userList = cidUserResp.getData(); + if (CollectionUtils.isNotEmpty(userList)) { + userMap = userList.stream().collect(Collectors.groupingBy(CIDUserResp::getUserId)); + } + } + List pMemberList = memberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).toList(); + if (CollectionUtils.isNotEmpty(pMemberList)) { + List spdmPUserVoList = new ArrayList<>(); + for (Long userId : pMemberList.stream().map(SpdmTaskMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmPUserVoList.addAll(userMap.get(userId)); + } + } + if (CollectionUtils.isNotEmpty(spdmPUserVoList)) { + spdmTaskDetailVo.setPMemberList(spdmPUserVoList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(","))); + } + } + List eMemberList = memberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).toList(); + if (CollectionUtils.isNotEmpty(eMemberList)) { + List spdmEUserVoList = new ArrayList<>(); + for (Long userId : eMemberList.stream().map(SpdmTaskMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmEUserVoList.addAll(userMap.get(userId)); + } + } + if (CollectionUtils.isNotEmpty(spdmEUserVoList)) { + spdmTaskDetailVo.setEMemberList(spdmEUserVoList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(","))); + } + } + } + return SdmResponse.success(spdmTaskDetailVo); + } + + private SdmResponse createDir(String uuid, String uuidOwnType,String parentUuid, String dirName) { + CreateDirReq createDirReq = new CreateDirReq(); + createDirReq.setUuId(uuid); + createDirReq.setUuIdOwnType(uuidOwnType); + createDirReq.setParentUuId(parentUuid); + createDirReq.setDirName(dirName); + createDirReq.setDirType(DirTypeEnum.PROJECT_NODE_DIR.getValue()); + log.info("同步CID任务调用创建文件夹的参数为:{}", createDirReq); + SdmResponse response = dataClientFeignClient.createDir(createDirReq); + log.info("同步CID调用创建文件夹的返回值为:{}", response); + return response; + } + + @Transactional + @Override + public BosimSaveProjectTaskRsp syncCidTask(SyncCidTaskReq req) { + Long userId = ThreadLocalContext.getUserId(); + log.info("syncCidTask中,userId为:{}",userId); + userId = ObjectUtils.isNotEmpty(userId) ? userId : 1999363561237610497L; + BosimSaveProjectTaskRsp resp = new BosimSaveProjectTaskRsp(); + String projectId = req.getProjectId(); + String projectName = req.getProjectName(); + if (StringUtils.isEmpty(projectId) || StringUtils.isEmpty(projectName)) { + log.error("同步cid任务时,projectId或projectName为空"); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + // 查询是否已同步过项目 + SpdmNodeVo spdmNodeVo = nodeMapper.getNodeByProjectIdAndName(projectId,projectName); + if (ObjectUtils.isEmpty(spdmNodeVo)) { + SpdmProjectNodeEditReq spdmProjectNodeEditReq = new SpdmProjectNodeEditReq(); + spdmProjectNodeEditReq.setNodeName(req.getProjectName()); + spdmProjectNodeEditReq.setNodeType(NodeTypeEnum.PROJECT.getValue()); + spdmProjectNodeEditReq.setUuid(req.getProjectId()); + spdmProjectNodeEditReq.setTag1(req.getProjectId()); + spdmProjectNodeEditReq.setCreateTime(curDateStr); + spdmProjectNodeEditReq.setPid(""); + spdmProjectNodeEditReq.setTenantId(ThreadLocalContext.getTenantId()); + if (nodeMapper.addNodeBatch(Collections.singletonList(spdmProjectNodeEditReq)) <= 0) { + log.error("同步CID项目:{}失败",req.getProjectId() + " " + req.getProjectName()); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + try { + // 创建项目节点的文件夹 + SdmResponse response = createDir(spdmProjectNodeEditReq.getUuid(), spdmProjectNodeEditReq.getNodeType(), null, spdmProjectNodeEditReq.getNodeName()); + if (ObjectUtils.isEmpty(response) || response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("同步CID项目:{}时,创建文件夹失败,原因为:{}",req.getProjectId() + " " + req.getProjectName(),response.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + // 更新文件权限 + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(userId); + updatePermissionReq.setUuid(spdmProjectNodeEditReq.getUuid()); + Map userPermissions = new HashMap<>(); + userPermissions.put(userId, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("同步CID项目时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataClientFeignClient.updatePermission(updatePermissionReq); + log.info("同步CID项目时,更新用户权限的返回值为:{}",updatePermissionResponse); + }catch (Exception ex) { + log.error("同步CID项目:{}时,创建文件夹异常,原因为:{}",req.getProjectId() + " " + req.getProjectName(),ex.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + } + + log.info("syncCidTask参数为:{}", req); + List taskInfoList = req.getTaskInfoList(); + if (CollectionUtils.isEmpty(taskInfoList)) { + log.error("同步cid任务时,任务为空"); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + List taskNameList = taskInfoList.stream().map(ProjectTaskInfo::getTaskName).distinct().toList(); + List taskVoList = mapper.getTaskListByName(taskNameList); + if (CollectionUtils.isNotEmpty(taskVoList)) { + List projectIdList = taskVoList.stream().map(SpdmTaskVo::getTag1).toList(); + if (projectIdList.contains(projectId)) { + String existTaskName = taskVoList.stream().map(SpdmTaskVo::getTaskName).collect(Collectors.joining(",")); + log.error("本次同步任务失败,以下任务:{}已存在",existTaskName); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage("本次同步任务失败,以下任务:"+existTaskName+"已存在"); + return resp; + } + } + List taskNodeList = new ArrayList<>(); + for (ProjectTaskInfo projectTaskInfo : taskInfoList) { + CidTaskNode taskNode = new CidTaskNode(); + taskNode.setUuid(projectTaskInfo.getTaskId()); + taskNode.setTag1(req.getProjectId()); + taskNode.setTaskName(projectTaskInfo.getTaskName()); + taskNode.setNodeId(req.getProjectId()); + taskNode.setCreateTime(curDateStr); + taskNode.setTenantId(ThreadLocalContext.getTenantId()); + taskNodeList.add(taskNode); + } + if (projectMapper.batchAddSimulationCidTask(taskNodeList) <= 0) { + log.error("同步CID任务失败"); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + try { + SdmResponse response; + // 创建任务节点的文件夹 + for (CidTaskNode taskNode : taskNodeList) { + response = createDir(taskNode.getUuid(), NodeTypeEnum.TASK.getValue(), req.getProjectId(), taskNode.getTaskName()); + if (ObjectUtils.isEmpty(response) || response.getCode() != ResultCode.SUCCESS.getCode()) { + log.error("同步CID任务时,创建任务:{}的文件夹失败,原因为:{}",taskNode.getUuid() + " " + taskNode.getTaskName(),response.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + } + for (CidTaskNode cidTaskNode : taskNodeList) { + // 更新文件权限 + UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq(); + updatePermissionReq.setUserId(userId); + updatePermissionReq.setUuid(cidTaskNode.getUuid()); + Map userPermissions = new HashMap<>(); + userPermissions.put(userId, FilePermissionEnum.ALL.getValue()); + updatePermissionReq.setUserPermissions(userPermissions); + log.info("同步CID任务时,更新用户权限的参数为:{}",updatePermissionReq); + SdmResponse updatePermissionResponse = dataClientFeignClient.updatePermission(updatePermissionReq); + log.info("同步CID任务时,更新用户权限的返回值为:{}",updatePermissionResponse); + } + + }catch (Exception ex) { + log.error("同步CID任务时,创建文件夹失败,原因为:{}",ex.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + resp.setCode(String.valueOf(ResultCode.FAILED.getCode())); + resp.setMessage(ResultCode.FAILED.getMessage()); + return resp; + } + resp.setCode(String.valueOf(ResultCode.SUCCESS.getCode())); + resp.setMessage("success"); + return resp; + } + + @Override + public SdmResponse getTaskCompleteStatistics(TaskCompleteStatisticsReq req) { + // 所有任务执行状态 + Set allExeStatus = new HashSet<>(); + List taskList = mapper.getTaskListByTag(req); + if (CollectionUtils.isEmpty(taskList)) { + log.error("根据参数:{},未查询到任务",req); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + String resultTagType = req.getResultTagType(); + List nodeIdList = new ArrayList<>(); + for (SpdmTaskVo taskVo : taskList) { + try { + String tagProperty = getTagProperty(taskVo, resultTagType); + if (StringUtils.isNotBlank(tagProperty)) { + nodeIdList.addAll(Arrays.stream(tagProperty.split(",")).toList()); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + if (CollectionUtils.isEmpty(nodeIdList)) { + log.error("根据任务:{},未查询到{}标签中的节点id",taskList,resultTagType); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + nodeIdList = nodeIdList.stream().distinct().toList(); + List nodeList = nodeMapper.getNodeListByIds(nodeIdList); + if (CollectionUtils.isEmpty(nodeList)) { + log.error("根据节点id:{},未查询节点",nodeIdList); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + Map nodeMap = nodeList.stream().collect(Collectors.toMap(SpdmNodeVo::getUuid, SpdmNodeVo::getNodeName)); + List commonCompleteStatisticsFromTask = new ArrayList<>(); + String resultTagId; + String[] resultTagIdArr; + for (SpdmTaskVo taskVo : taskList) { + try { + resultTagId = getTagProperty(taskVo,resultTagType); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (StringUtils.isBlank(resultTagId)) { + log.error("id:{}任务的:{}标签不存在",taskVo.getId(),resultTagType); + continue; + } + resultTagIdArr = resultTagId.split(","); + CommonGetCompleteFromTaskVo commonGetCompleteFromTaskVo = new CommonGetCompleteFromTaskVo(); + commonGetCompleteFromTaskVo.setTag(resultTagId); + commonGetCompleteFromTaskVo.setNodeName(nodeMap.get(resultTagIdArr[resultTagIdArr.length - 1])); + commonGetCompleteFromTaskVo.setExeStatus(taskVo.getExeStatus()); + commonCompleteStatisticsFromTask.add(commonGetCompleteFromTaskVo); + } + // 按tag分组统计任务状态 + Map taskStatisticsMap = new HashMap<>(); + // 统计每个tag的各种状态任务数量 + for (CommonGetCompleteFromTaskVo item : commonCompleteStatisticsFromTask) { + String name = item.getNodeName(); + + CommonStatisticsVo stat = taskStatisticsMap.getOrDefault(name, new CommonStatisticsVo()); + stat.setName(name); + + Map statusCount = stat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + stat.setStatusCount(statusCount); + } + String exeStatus = item.getExeStatus(); + allExeStatus.add(exeStatus); + statusCount.put(exeStatus, statusCount.getOrDefault(exeStatus, 0) + 1); + taskStatisticsMap.put(name, stat); + } + // 转换为列表返回 + List taskResult = new ArrayList<>(taskStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", taskResult); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse getPerformanceCompleteStatistics(PerformanceCompleteStatisticsReq req) { + // 所有指标执行状态 + Set allExeStatus = new HashSet<>(); + TaskCompleteStatisticsReq taskCompleteStatisticsReq = new TaskCompleteStatisticsReq(); + BeanUtils.copyProperties(req,taskCompleteStatisticsReq); + List taskList = mapper.getTaskListByTag(taskCompleteStatisticsReq); + if (CollectionUtils.isEmpty(taskList)) { + log.error("根据参数:{},未查询到任务",req); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + // 查询任务下所有指标 + List taskIdList = taskList.stream().map(SpdmTaskVo::getUuid).distinct().toList(); + List performanceList = nodeMapper.getPerformanceListByNodeIdList(taskIdList); + if (CollectionUtils.isEmpty(performanceList)) { + log.error("根据任务id:{},未查询到指标",taskIdList); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + Map taskMap = taskList.stream().collect(Collectors.groupingBy( + SpdmTaskVo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + String resultTagType = req.getResultTagType(); + List nodeIdList = new ArrayList<>(); + SpdmTaskVo eachTaskVo; + for (PerformanceNodePo performanceNodePo : performanceList) { + eachTaskVo = taskMap.get(performanceNodePo.getTaskId()); + if (ObjectUtils.isEmpty(eachTaskVo)) { + continue; + } + try { + String tagProperty = getTagProperty(eachTaskVo, resultTagType); + if (StringUtils.isNotBlank(tagProperty)) { + nodeIdList.addAll(Arrays.stream(tagProperty.split(",")).toList()); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + if (CollectionUtils.isEmpty(nodeIdList)) { + log.error("根据任务:{},未查询到{}标签中的节点id",taskList,resultTagType); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + nodeIdList = nodeIdList.stream().distinct().toList(); + List nodeList = nodeMapper.getNodeListByIds(nodeIdList); + if (CollectionUtils.isEmpty(nodeList)) { + log.error("根据节点id:{},未查询节点",nodeIdList); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", new ArrayList<>()); + return SdmResponse.success(resultResponse); + } + Map nodeMap = nodeList.stream().collect(Collectors.toMap(SpdmNodeVo::getUuid, SpdmNodeVo::getNodeName)); + List commonCompleteStatisticsFromPerformance = new ArrayList<>(); + String resultTagId; + String[] resultTagIdArr; + for (PerformanceNodePo performanceNodePo : performanceList) { + eachTaskVo = taskMap.get(performanceNodePo.getTaskId()); + try { + resultTagId = getTagProperty(eachTaskVo,resultTagType); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (StringUtils.isBlank(resultTagId)) { + log.error("id:{}任务的:{}标签不存在",eachTaskVo.getId(),resultTagType); + continue; + } + resultTagIdArr = resultTagId.split(","); + CommonGetCompleteFromPerformanceVo commonGetCompleteFromPerformanceVo = new CommonGetCompleteFromPerformanceVo(); + commonGetCompleteFromPerformanceVo.setTag(resultTagId); + commonGetCompleteFromPerformanceVo.setNodeName(nodeMap.get(resultTagIdArr[resultTagIdArr.length - 1])); + commonGetCompleteFromPerformanceVo.setCompleteStatus(StringUtils.isNotBlank(performanceNodePo.getCompleteStatus()) ? + performanceNodePo.getCompleteStatus() : RunPerformanceStatusEnum.UNCOMPLETED.getCode()); + commonCompleteStatisticsFromPerformance.add(commonGetCompleteFromPerformanceVo); + } + // 按tag分组统计指标状态 + Map performanceStatisticsMap = new HashMap<>(); + // 统计每个tag的各种状态指标数量 + for (CommonGetCompleteFromPerformanceVo item : commonCompleteStatisticsFromPerformance) { + String nodeName = item.getNodeName(); + CommonStatisticsVo stat = performanceStatisticsMap.getOrDefault(nodeName, new CommonStatisticsVo()); + stat.setName(nodeName); + Map statusCount = stat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + stat.setStatusCount(statusCount); + } + String completeStatus = item.getCompleteStatus(); + allExeStatus.add(completeStatus); + statusCount.put(completeStatus, statusCount.getOrDefault(completeStatus, 0) + 1); + performanceStatisticsMap.put(nodeName, stat); + } + // 转换为列表返回 + List performanceResult = new ArrayList<>(performanceStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", performanceResult); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse getUserTaskCompleteStatistics(UserTaskCompleteStatisticsReq req) { + String projectId = req.getTag1(); + if (StringUtils.isBlank(projectId)) { + log.error("项目id不能为空"); + return SdmResponse.failed("项目id不能为空"); + } + GetProjectListReq getProjectListReq = new GetProjectListReq(); + getProjectListReq.setCurrent(1); + getProjectListReq.setSize(10000); + getProjectListReq.setProjectNodeId(projectId); + SdmResponse sdmResponse = nodeService.getProjectMemberList(getProjectListReq); + if (!sdmResponse.isSuccess()) { + log.info("项目成员为空"); + return SdmResponse.success(); + } + List userList = (List)((JSONObject) sdmResponse.getData()).get("data"); + if (CollectionUtils.isEmpty(userList)) { + log.info("项目成员为空"); + return SdmResponse.success(); + } + List userIdList = userList.stream().map(CIDUserResp::getUserId).distinct().toList(); + Map userMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUserId, CIDUserResp::getNickname)); + req.setUserIds(userIdList); + List userGroupTaskCompleteStatistics = mapper.getUserTaskCompleteStatistics(req); + // 按用户分组统计任务状态 + Map userStatisticsMap = new HashMap<>(); + // 所有任务执行状态 + Set allExeStatus = new HashSet<>(); + // 统计每个用户的各种状态任务数量 + for (UserGroupTaskCompleteVo item : userGroupTaskCompleteStatistics) { + Long userId = item.getUserId(); + String exeStatus = item.getExeStatus(); + allExeStatus.add(exeStatus); + UserGroupTaskCompleteStatisticsVo userStat = userStatisticsMap.getOrDefault(userId, new UserGroupTaskCompleteStatisticsVo()); + userStat.setUserId(userId); + userStat.setUserName(userMap.getOrDefault(userId, "Unknown User")); + Map statusCount = userStat.getStatusCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + userStat.setStatusCount(statusCount); + } + statusCount.put(exeStatus, statusCount.getOrDefault(exeStatus, 0) + 1); + userStat.setTotalTasks(userStat.getTotalTasks() == null ? 1 : userStat.getTotalTasks() + 1); + userStatisticsMap.put(userId, userStat); + } + // 转换为列表返回 + List result = new ArrayList<>(userStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("allExeStatus", allExeStatus); + resultResponse.put("result", result); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse getUserDifficultyStatistics(UserDifficultCompleteStatisticsReq req) { + String projectId = req.getTag1(); + if (StringUtils.isBlank(projectId)) { + log.error("项目id不能为空"); + return SdmResponse.failed("项目id不能为空"); + } + GetProjectListReq getProjectListReq = new GetProjectListReq(); + getProjectListReq.setCurrent(1); + getProjectListReq.setSize(10000); + getProjectListReq.setProjectNodeId(projectId); + SdmResponse sdmResponse = nodeService.getProjectMemberList(getProjectListReq); + if (!sdmResponse.isSuccess()) { + log.info("项目成员为空"); + return SdmResponse.success(); + } + List userList = (List)((JSONObject) sdmResponse.getData()).get("data"); + if (CollectionUtils.isEmpty(userList)) { + log.info("项目成员为空"); + return SdmResponse.success(); + } + List userIdList = userList.stream().map(CIDUserResp::getUserId).distinct().toList(); + Map userMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUserId, CIDUserResp::getNickname)); + req.setUserIds(userIdList); + List userGroupDifficultyStatistics = mapper.getUserDifficultyStatistics(req); + // 按用户分组统计任务状态 + Map userStatisticsMap = new HashMap<>(); + // 所有难度值 + Set alldifficultyValue = new HashSet<>(); + // 统计每个用户的各种状态任务数量 + for (UserGroupDifficultyVo item : userGroupDifficultyStatistics) { + Long userId = item.getUserId(); + Float difficulty = item.getDifficult(); + alldifficultyValue.add(difficulty); + UserGroupDifficultyStatisticsVo userStat = userStatisticsMap.getOrDefault(userId, new UserGroupDifficultyStatisticsVo()); + userStat.setUserId(userId); + userStat.setUserName(userMap.getOrDefault(userId, "Unknown User")); + Map statusCount = userStat.getDifficultyCount(); + if (statusCount == null) { + statusCount = new HashMap<>(); + userStat.setDifficultyCount(statusCount); + } + statusCount.put(difficulty, statusCount.getOrDefault(difficulty, 0) + 1); + userStat.setTotalTasks(userStat.getTotalTasks() == null ? 1 : userStat.getTotalTasks() + 1); + userStatisticsMap.put(userId, userStat); + } + // 转换为列表返回 + List result = new ArrayList<>(userStatisticsMap.values()); + JSONObject resultResponse = new JSONObject(); + resultResponse.put("alldifficultyValue", alldifficultyValue); + resultResponse.put("result", result); + return SdmResponse.success(resultResponse); + } + + @Override + public SdmResponse getTaskListByDemandId(SpdmTaskListReq req) { + SdmResponse taskRespond = list(req); + if (!taskRespond.isSuccess()) { + return taskRespond; + } + JSONObject dataObj = (JSONObject) taskRespond.getData(); + List taskVoList = (List) dataObj.get("data"); + JSONObject jsonObject = new JSONObject(); + if (CollectionUtils.isEmpty(taskVoList)) { + jsonObject.put("data", new ArrayList<>()); + return SdmResponse.success(jsonObject); + } + List taskIdList = taskVoList.stream().map(SpdmNewTaskVo::getUuid).toList(); + List memberList = mapper.getMemberList(taskIdList, null); + List spdmTaskDetailVoList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(memberList)) { + for (SpdmNewTaskVo taskVo : taskVoList) { + List spdmPUserVoList = new ArrayList<>(); + List spdmEUserVoList = new ArrayList<>(); + SpdmTaskDetailVo spdmTaskDetailVo = new SpdmTaskDetailVo(); + BeanUtils.copyProperties(taskVo,spdmTaskDetailVo); + spdmTaskDetailVo.setId(taskVo.getId()); + List userIdList = memberList.stream().filter(member -> taskVo.getUuid().equals(member.getTaskId())).map(SpdmTaskMemberVo::getUserId).toList(); + if (CollectionUtils.isEmpty(userIdList)) { + spdmTaskDetailVoList.add(spdmTaskDetailVo); + continue; + } + List userList = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build()).getData(); + if (CollectionUtils.isEmpty(userList)) { + spdmTaskDetailVoList.add(spdmTaskDetailVo); + continue; + } + Map> userMap = userList.stream().collect(Collectors.groupingBy(CIDUserResp::getUserId)); + List pMemberList = memberList.stream().filter(member -> MemberTypeEnum.PRINCIPAL.getCode().equals(member.getType())).toList(); + if (CollectionUtils.isNotEmpty(pMemberList)) { + for (Long userId : pMemberList.stream().map(SpdmTaskMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmPUserVoList.addAll(userMap.get(userId)); + } + } + } + List eMemberList = memberList.stream().filter(member -> MemberTypeEnum.EXECUTOR.getCode().equals(member.getType())).toList(); + if (CollectionUtils.isNotEmpty(eMemberList)) { + for (Long userId : eMemberList.stream().map(SpdmTaskMemberVo::getUserId).toList()) { + if (ObjectUtils.isNotEmpty(userId) && CollectionUtils.isNotEmpty(userMap.get(userId))) { + spdmEUserVoList.addAll(userMap.get(userId)); + } + } + } + if (CollectionUtils.isNotEmpty(spdmPUserVoList)) { + spdmTaskDetailVo.setPMemberList(spdmPUserVoList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(","))); + } + if (CollectionUtils.isNotEmpty(spdmEUserVoList)) { + spdmTaskDetailVo.setEMemberList(spdmEUserVoList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(","))); + } + spdmTaskDetailVoList.add(spdmTaskDetailVo); + } + }else { + for (SpdmNewTaskVo taskVo : taskVoList) { + SpdmTaskDetailVo spdmTaskDetailVo = new SpdmTaskDetailVo(); + BeanUtils.copyProperties(taskVo,spdmTaskDetailVo); + spdmTaskDetailVo.setId(taskVo.getId()); + spdmTaskDetailVoList.add(spdmTaskDetailVo); + } + } + jsonObject.put("data", spdmTaskDetailVoList); + return SdmResponse.success(jsonObject); + } + + @Override + public SdmResponse newExportTaskTree(TaskTreeExportExcelFormat taskTreeExportExcelFormat, HttpServletResponse httpServletResponse) { + SpdmTaskListReq req = new SpdmTaskListReq(); + TaskTreeExportExcelParam params = taskTreeExportExcelFormat.getParams(); + List originIdMap = params.getIdMap(); + if (CollectionUtils.isEmpty(originIdMap)) { + log.error("idMap不能为空"); + return SdmResponse.failed("idMap不能为空"); + } + List currentIdMapList = new ArrayList<>(); + for (com.sdm.common.entity.bo.TaskNodeTag originTaskNodeTag : originIdMap) { + TaskNodeTag taskNodeTag = new TaskNodeTag(); + taskNodeTag.setKey(originTaskNodeTag.getKey()); + taskNodeTag.setValue(originTaskNodeTag.getValue()); + currentIdMapList.add(taskNodeTag); + } + req.setIdMap(currentIdMapList); + if (ObjectUtils.isNotEmpty(params)) { + BeanUtils.copyProperties(params,req); + } + req.setConvertTag(false); + req.setType(2); + req.setCurrent(1); + req.setSize(10000); + List exportExcelFormats = taskTreeExportExcelFormat.getExcelHeaders(); + + SdmResponse taskRespond = list(req); + SdmResponse response = new SdmResponse(); + List tagMap = params.getTagMap(); + List allNodeIdList = new ArrayList<>(); + if(taskRespond.isSuccess()) { + JSONObject dataObj = (JSONObject) taskRespond.getData(); + List taskVoList = (List) dataObj.get("data"); + if (CollectionUtils.isEmpty(taskVoList)) { + log.error("导出任务分析项树时,任务不能为空"); + return SdmResponse.failed("任务不能为空"); + } + List chooseTaskIdList = params.getTaskIdList(); + if (CollectionUtils.isNotEmpty(chooseTaskIdList)) { + taskVoList = taskVoList.stream().filter(task -> chooseTaskIdList.contains(task.getUuid())).toList(); + } + if (CollectionUtils.isEmpty(taskVoList)) { + log.error("导出任务分析项树时,根据任务id:{}过滤后,任务集合为空",chooseTaskIdList); + return SdmResponse.failed("任务不能为空"); + } + List fixedHeaderList = new ArrayList<>(); + Optional nodeNameOptional = exportExcelFormats.stream().filter(header -> "nodeName".equals(header.getKey())).findAny(); + Optional nodeCodeOptional = exportExcelFormats.stream().filter(header -> "nodeCode".equals(header.getKey())).findAny(); + if (nodeNameOptional.isPresent() && nodeCodeOptional.isPresent()) { + // 机台 + ExportExcelFormat machineNameExportExcelFormat = new ExportExcelFormat(); + machineNameExportExcelFormat.setKey(MACHINE_NAME_KEY); + machineNameExportExcelFormat.setTitle(MACHINE_NAME); + ExportExcelFormat machineCodeExportExcelFormat = new ExportExcelFormat(); + machineCodeExportExcelFormat.setKey(MACHINE_CODE_KEY); + machineCodeExportExcelFormat.setTitle(MACHINE_CODE); + + // 工位 + ExportExcelFormat workspaceNameExportExcelFormat = new ExportExcelFormat(); + workspaceNameExportExcelFormat.setKey(WORKSPACE_NAME_KEY); + workspaceNameExportExcelFormat.setTitle(WORKSPACE_NAME); + ExportExcelFormat workspaceCodeExportExcelFormat = new ExportExcelFormat(); + workspaceCodeExportExcelFormat.setKey(WORKSPACE_CODE_KEY); + workspaceCodeExportExcelFormat.setTitle(WORKSPACE_CODE); + + // 学科 + ExportExcelFormat disciplineNameExportExcelFormat = new ExportExcelFormat(); + disciplineNameExportExcelFormat.setKey(DISCIPLINE_NAME_KEY); + disciplineNameExportExcelFormat.setTitle(DISCIPLINE_NAME); + ExportExcelFormat disciplineCodeExportExcelFormat = new ExportExcelFormat(); + disciplineCodeExportExcelFormat.setKey(DISCIPLINE_CODE_KEY); + disciplineCodeExportExcelFormat.setTitle(DISCIPLINE_CODE); + + // 任务 + ExportExcelFormat taskNameExportExcelFormat = new ExportExcelFormat(); + taskNameExportExcelFormat.setKey(TASK_NAME_KEY); + taskNameExportExcelFormat.setTitle(TASK_NAME); + ExportExcelFormat taskCodeExportExcelFormat = new ExportExcelFormat(); + taskCodeExportExcelFormat.setKey(TASK_CODE_KEY); + taskCodeExportExcelFormat.setTitle(TASK_CODE); + + // 指标 + ExportExcelFormat performanceNameExportExcelFormat = new ExportExcelFormat(); + performanceNameExportExcelFormat.setKey(PERFORMANCE_NAME_KEY); + performanceNameExportExcelFormat.setTitle(PERFORMANCE_NAME); + ExportExcelFormat performanceCodeExportExcelFormat = new ExportExcelFormat(); + performanceCodeExportExcelFormat.setKey(PERFORMANCE_CODE_KEY); + performanceCodeExportExcelFormat.setTitle(PERFORMANCE_CODE); + fixedHeaderList.add(machineNameExportExcelFormat); + fixedHeaderList.add(machineCodeExportExcelFormat); + fixedHeaderList.add(workspaceNameExportExcelFormat); + fixedHeaderList.add(workspaceCodeExportExcelFormat); + fixedHeaderList.add(disciplineNameExportExcelFormat); + fixedHeaderList.add(disciplineCodeExportExcelFormat); + fixedHeaderList.add(taskNameExportExcelFormat); + fixedHeaderList.add(taskCodeExportExcelFormat); + fixedHeaderList.add(performanceNameExportExcelFormat); + fixedHeaderList.add(performanceCodeExportExcelFormat); + }else if (nodeNameOptional.isPresent()) { + // 机台 + ExportExcelFormat machineNameExportExcelFormat = new ExportExcelFormat(); + machineNameExportExcelFormat.setKey(MACHINE_NAME_KEY); + machineNameExportExcelFormat.setTitle(MACHINE_NAME); + + // 工位 + ExportExcelFormat workspaceNameExportExcelFormat = new ExportExcelFormat(); + workspaceNameExportExcelFormat.setKey(WORKSPACE_NAME_KEY); + workspaceNameExportExcelFormat.setTitle(WORKSPACE_NAME); + + // 学科 + ExportExcelFormat disciplineNameExportExcelFormat = new ExportExcelFormat(); + disciplineNameExportExcelFormat.setKey(DISCIPLINE_NAME_KEY); + disciplineNameExportExcelFormat.setTitle(DISCIPLINE_NAME); + + // 任务 + ExportExcelFormat taskNameExportExcelFormat = new ExportExcelFormat(); + taskNameExportExcelFormat.setKey(TASK_NAME_KEY); + taskNameExportExcelFormat.setTitle(TASK_NAME); + + // 指标 + ExportExcelFormat performanceNameExportExcelFormat = new ExportExcelFormat(); + performanceNameExportExcelFormat.setKey(PERFORMANCE_NAME_KEY); + performanceNameExportExcelFormat.setTitle(PERFORMANCE_NAME); + + fixedHeaderList.add(machineNameExportExcelFormat); + fixedHeaderList.add(workspaceNameExportExcelFormat); + fixedHeaderList.add(disciplineNameExportExcelFormat); + fixedHeaderList.add(taskNameExportExcelFormat); + fixedHeaderList.add(performanceNameExportExcelFormat); + }else if (nodeCodeOptional.isPresent()) { + // 机台 + ExportExcelFormat machineCodeExportExcelFormat = new ExportExcelFormat(); + machineCodeExportExcelFormat.setKey(MACHINE_CODE_KEY); + machineCodeExportExcelFormat.setTitle(MACHINE_CODE); + + // 工位 + ExportExcelFormat workspaceCodeExportExcelFormat = new ExportExcelFormat(); + workspaceCodeExportExcelFormat.setKey(WORKSPACE_CODE_KEY); + workspaceCodeExportExcelFormat.setTitle(WORKSPACE_CODE); + + // 学科 + ExportExcelFormat disciplineCodeExportExcelFormat = new ExportExcelFormat(); + disciplineCodeExportExcelFormat.setKey(DISCIPLINE_CODE_KEY); + disciplineCodeExportExcelFormat.setTitle(DISCIPLINE_CODE); + + // 任务 + ExportExcelFormat taskCodeExportExcelFormat = new ExportExcelFormat(); + taskCodeExportExcelFormat.setKey(TASK_CODE_KEY); + taskCodeExportExcelFormat.setTitle(TASK_CODE); + + // 指标 + ExportExcelFormat performanceCodeExportExcelFormat = new ExportExcelFormat(); + performanceCodeExportExcelFormat.setKey(PERFORMANCE_CODE_KEY); + performanceCodeExportExcelFormat.setTitle(PERFORMANCE_CODE); + + fixedHeaderList.add(machineCodeExportExcelFormat); + fixedHeaderList.add(workspaceCodeExportExcelFormat); + fixedHeaderList.add(disciplineCodeExportExcelFormat); + fixedHeaderList.add(taskCodeExportExcelFormat); + fixedHeaderList.add(performanceCodeExportExcelFormat); + } + + if (CollectionUtils.isNotEmpty(fixedHeaderList)) { + if (nodeNameOptional.isPresent()) { + exportExcelFormats.remove(0); + } + if (nodeCodeOptional.isPresent()) { + exportExcelFormats.remove(0); + } + fixedHeaderList.addAll(exportExcelFormats); + exportExcelFormats = fixedHeaderList; + } + + List allExportNewTaskVoList = new ArrayList<>(); + List exportNewTaskVoList = new ArrayList<>(); + List pMemberList; + String pMemberName = ""; + List eMemberList; + String eMemberName = ""; + for (SpdmNewTaskVo spdmNewTaskVo : taskVoList) { + pMemberList = spdmNewTaskVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(pMemberList)) { + pMemberName = pMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + eMemberList = spdmNewTaskVo.getPMemberList(); + if (CollectionUtils.isNotEmpty(eMemberList)) { + eMemberName = eMemberList.stream().map(CIDUserResp::getNickname).collect(Collectors.joining(",")); + } + SpdmExportNewTaskVo spdmExportNewTaskVo = new SpdmExportNewTaskVo(); + BeanUtils.copyProperties(spdmNewTaskVo,spdmExportNewTaskVo); + spdmExportNewTaskVo.setPMemberList(pMemberName); + spdmExportNewTaskVo.setEMemberList(eMemberName); + // 查询任务相应的前置节点和指标 + // 机台 + Optional machineOptional = tagMap.stream().filter(tag -> NodeTypeEnum.MACHINE.getValue().equals(tag.getKey())).findFirst(); + // 工位 + Optional workspaceOptional = tagMap.stream().filter(tag -> NodeTypeEnum.WORKSPACE.getValue().equals(tag.getKey())).findFirst(); + // 学科 + Optional disciplineOptional = tagMap.stream().filter(tag -> NodeTypeEnum.DISCIPLINE.getValue().equals(tag.getKey())).findFirst(); + String machineTags = ""; + if (machineOptional.isPresent()) { + String machineTag = machineOptional.get().getValue(); + try { + machineTags = getTagProperty(spdmExportNewTaskVo, machineTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + String workspaceTags = ""; + if (workspaceOptional.isPresent()) { + String workspaceTag = workspaceOptional.get().getValue(); + try { + workspaceTags = getTagProperty(spdmExportNewTaskVo, workspaceTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + String disciplineTags = ""; + if (disciplineOptional.isPresent()) { + String disciplineTag = disciplineOptional.get().getValue(); + try { + disciplineTags = getTagProperty(spdmExportNewTaskVo, disciplineTag); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + if (StringUtils.isNotBlank(machineTags)) { + allNodeIdList.addAll(Arrays.stream(machineTags.split(",")).toList()); + } + if (StringUtils.isNotBlank(workspaceTags)) { + allNodeIdList.addAll(Arrays.stream(workspaceTags.split(",")).toList()); + } + if (StringUtils.isNotBlank(disciplineTags)) { + allNodeIdList.addAll(Arrays.stream(disciplineTags.split(",")).toList()); + } + exportNewTaskVoList.add(spdmExportNewTaskVo); + } + // 查询任务下所有指标 + List taskIdList = exportNewTaskVoList.stream().map(SpdmExportNewTaskVo::getUuid).toList(); + List performanceList = projectMapper.getPerformanceListByNodeIdList(taskIdList); + Map> performanceMap = Map.of(); + if (CollectionUtils.isNotEmpty(performanceList)) { + performanceMap = performanceList.stream().collect(Collectors.groupingBy(PerformanceNodePo::getTaskId)); + } + if (CollectionUtils.isNotEmpty(allNodeIdList)) { + List nodeList = nodeMapper.getNodeListByIds(allNodeIdList.stream().distinct().toList()); + if (CollectionUtils.isNotEmpty(nodeList)) { + Map nodeMap = nodeList.stream().collect(Collectors.groupingBy( + SpdmNodeVo::getUuid, + Collectors.collectingAndThen( + Collectors.toList(), + list -> list.get(0) + ) + )); + for (SpdmExportNewTaskVo spdmExportNewTaskVo : exportNewTaskVoList) { + // 设置机台名称和机台编码 + Optional machineOptional = tagMap.stream().filter(tag -> NodeTypeEnum.MACHINE.getValue().equals(tag.getKey())).findFirst(); + if (machineOptional.isPresent()) { + String machineTag = machineOptional.get().getValue(); + try { + String machineTags = getTagProperty(spdmExportNewTaskVo, machineTag); + if (StringUtils.isNotBlank(machineTags)) { + for (String machineTagId : Arrays.stream(machineTags.split(",")).toList()) { + SpdmNodeVo spdmNodeVo = nodeMap.get(machineTagId); + if (ObjectUtils.isEmpty(spdmNodeVo)) { + continue; + } + spdmExportNewTaskVo.setMachineName(spdmNodeVo.getNodeName()); + spdmExportNewTaskVo.setMachineCode(spdmNodeVo.getNodeCode()); + } + } + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + // 设置机台名称和机台编码 + Optional workspaceOptional = tagMap.stream().filter(tag -> NodeTypeEnum.WORKSPACE.getValue().equals(tag.getKey())).findFirst(); + if (workspaceOptional.isPresent()) { + String workspaceTag = workspaceOptional.get().getValue(); + try { + String workspaceTags = getTagProperty(spdmExportNewTaskVo, workspaceTag); + if (StringUtils.isNotBlank(workspaceTags)) { + for (String workspaceTagId : Arrays.stream(workspaceTags.split(",")).toList()) { + SpdmNodeVo spdmNodeVo = nodeMap.get(workspaceTagId); + if (ObjectUtils.isEmpty(spdmNodeVo)) { + continue; + } + spdmExportNewTaskVo.setWorkspaceName(spdmNodeVo.getNodeName()); + spdmExportNewTaskVo.setWorkspaceCode(spdmNodeVo.getNodeCode()); + } + } + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + Optional disciplineOptional = tagMap.stream().filter(tag -> NodeTypeEnum.DISCIPLINE.getValue().equals(tag.getKey())).findFirst(); + if (disciplineOptional.isPresent()) { + String disciplineTag = disciplineOptional.get().getValue(); + try { + String disciplineTags = getTagProperty(spdmExportNewTaskVo, disciplineTag); + if (StringUtils.isNotBlank(disciplineTags)) { + for (String disciplineTagId : Arrays.stream(disciplineTags.split(",")).toList()) { + SpdmNodeVo spdmNodeVo = nodeMap.get(disciplineTagId); + if (ObjectUtils.isEmpty(spdmNodeVo)) { + continue; + } + spdmExportNewTaskVo.setDisciplineName(spdmNodeVo.getNodeName()); + spdmExportNewTaskVo.setDisciplineCode(spdmNodeVo.getNodeCode()); + } + } + + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + // 任务下指标 + List performanceNodePoList = performanceMap.get(spdmExportNewTaskVo.getUuid()); + List spdmExportNewTaskVoList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(performanceNodePoList)) { + for (PerformanceNodePo performanceNodePo : performanceNodePoList) { + SpdmExportNewTaskVo exportNewTaskVo = new SpdmExportNewTaskVo(); + BeanUtils.copyProperties(performanceNodePo,exportNewTaskVo); + exportNewTaskVo.setMachineName(spdmExportNewTaskVo.getMachineName()); + exportNewTaskVo.setMachineCode(spdmExportNewTaskVo.getMachineCode()); + exportNewTaskVo.setWorkspaceName(spdmExportNewTaskVo.getWorkspaceName()); + exportNewTaskVo.setWorkspaceCode(spdmExportNewTaskVo.getWorkspaceCode()); + exportNewTaskVo.setDisciplineName(spdmExportNewTaskVo.getDisciplineName()); + exportNewTaskVo.setDisciplineCode(spdmExportNewTaskVo.getDisciplineCode()); + exportNewTaskVo.setTaskCode(spdmExportNewTaskVo.getTaskCode()); + exportNewTaskVo.setPerformanceName(performanceNodePo.getNodeName()); + exportNewTaskVo.setPerformanceCode(performanceNodePo.getNodeCode()); + spdmExportNewTaskVoList.add(exportNewTaskVo); + } + } + allExportNewTaskVoList.add(spdmExportNewTaskVo); + if (CollectionUtils.isNotEmpty(spdmExportNewTaskVoList)) { + allExportNewTaskVoList.addAll(spdmExportNewTaskVoList); + } + } + } + } + ExcelUtil.exportExcelNoMerge(JSONArray.from(allExportNewTaskVoList),exportExcelFormats,httpServletResponse); + } else { + response = SdmResponse.failed(taskRespond.getMessage()); + } + return response; + } + +} + + + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.project.DelNodeReq; +import com.sdm.common.entity.req.project.ProjectExportExcelFormat; +import com.sdm.common.entity.req.project.RenameNodeReq; +import com.sdm.common.entity.req.project.SpdmNodeListReq; +import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; +import com.sdm.common.entity.resp.project.SimulationNodeResp; +import com.sdm.project.model.entity.SimulationNode; +import com.sdm.project.model.req.*; +import com.sdm.project.model.req.YA.SyncCidProjectReq; +import com.sdm.project.model.resp.YA.BosimSaveNodeInfoRsp; +import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +@Service +public interface INodeService extends IService { + + SdmResponse add(SpdmAddNodeReq req); + + SdmResponse edit(SpdmEditNodeReq req); + + SdmResponse delete(SpdmDeleteNodeReq req); + + SdmResponse list(SpdmNodeListReq req); + + SdmResponse getNodeDetail(GetProjectDetailReq req); + + SdmResponse getProjectMemberList(GetProjectListReq req); + + SdmResponse getChildrenNodeList(List projectNodeIdList, String nodeType); + + SdmResponse> getAllNodeByBodeType(String nodeType, Long nodeId); + + SdmResponse> getAllNodeByProjectIdAndType(String uuid, String nextNodeType); + + SdmResponse> getNodeTaskList(String uuid); + + SdmResponse> getTaskRunList(String uuid); + + SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId); + + SdmResponse getUserGroupTaskCompleteStatistics(GetUserGroupTaskCompleteStatisticsReq req); + + //用户组难度系数统计 + SdmResponse getUserGroupDifficultyStatistics(GetUserGroupTaskCompleteStatisticsReq req); + + SdmResponse getCommonCompleteStatistics(CommonGetCompleteStatisticsReq req); + + // 工位评审通过统计查询 + SdmResponse getWorkstationReviewStatistics(GetWorkstationApproveStatusReq req); + + // 重命名node/task/run的名称 + SdmResponse renameNode(RenameNodeReq req); + + // 删除node/task/run + SdmResponse delteNode(DelNodeReq req); + + SdmResponse uploadProjectFiles(UploadFilesReq req); + + SdmResponse addNodeForData(SpdmAddNodeReq req); + + SdmResponse addTaskForData(SpdmTaskReq req); + + SdmResponse> querySimulationNodeByUuids(List uuids); + + SdmResponse exportProject(ProjectExportExcelFormat projectExportExcelFormat, HttpServletResponse httpservletResponse); + + SdmResponse getNodeDetailForData(GetNodeDetailReq req); + + BosimSaveProjectTaskRsp syncProject(SyncCidProjectReq req); + + SdmResponse editNodeForData(SpdmEditNodeForDataReq req); + +} + + + +package com.sdm.project.service; + +import com.alibaba.fastjson2.JSONObject; +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.task.TaskTreeExportExcelFormat; +import com.sdm.project.model.bo.ModifyProjectNode; +import com.sdm.project.model.req.*; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface IProjectService { + + SdmResponse add(JSONObject jsonObject); + + + SdmResponse edit(List jsonObject); + + SdmResponse getTaskTree(ProjectTreeTagReq req); + + SdmResponse delete(SpdmDeleteProjectReq req); + + SdmResponse taskHandle(String taskId, Integer handleType); + + SdmResponse modify(ModifyProjectNode req); + + SdmResponse exportTaskTree(TaskTreeExportExcelFormat taskTreeExportExcelFormat, HttpServletResponse httpservletResponse); + +} + + + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationBaseQuantities; +import com.sdm.project.model.entity.SimulationBaseUnits; + +public interface ISimulationBaseQuantitiesService extends IService { + +} + + + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationBaseUnits; + +public interface ISimulationBaseUnitsService extends IService { + +} + + + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationRunKeyResult; + +public interface ISimulationKeyResultService extends IService { + +} + + + +package com.sdm.project.service; + +import com.sdm.common.entity.req.project.SimulationPerformance; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2025-11-03 + */ +public interface ISimulationPerformanceService extends IService { + +} +
+ + +package com.sdm.project.service; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.req.data.CreateDirReq; +import com.sdm.common.entity.req.data.QueryDirReq; +import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.common.entity.req.project.SpdmReportReq; +import com.sdm.common.entity.req.system.LaunchApproveReq; +import com.sdm.common.entity.resp.PageDataResp; +import com.sdm.common.entity.resp.data.BatchAddFileInfoResp; +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import com.sdm.project.model.entity.SimulationBaseQuantities; +import com.sdm.project.model.entity.SimulationBaseUnits; +import com.sdm.project.model.entity.SimulationRun; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationRunKeyResult; +import com.sdm.project.model.req.*; +import com.sdm.project.model.resp.FlowInfoDto; +import com.sdm.project.model.resp.KeyResultAndTaskInfoResp; +import com.sdm.project.model.resp.RunVersionInfoResp; +import jakarta.servlet.http.HttpServletResponse; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2025-11-03 + */ +public interface ISimulationRunService extends IService { + + SdmResponse getTaskRunTree(ProjectTreeTagReq req); + + SdmResponse addTaskRun(SpdmAddTaskRunReq req); + + SdmResponse deleteTaskRun(SpdmTaskRunReq req); + + SdmResponse> queryTaskRun(SpdmTaskRunReq req); + + SdmResponse createRunDir(CreateDirReq req); + + SdmResponse>> queryRunDir(QueryDirReq req); + + SdmResponse uploadRunFiles(UploadFilesReq req); + + SdmResponse> getTaskRunVersion(GetRunVersionReq req); + + SdmResponse getRunVersion(GetRunVersionReq req); + + SdmResponse addSimulationKeyResult(KeyResultReq req); + + SdmResponse editSimulationKeyResult(KeyResultReq req); + + SdmResponse> batchAddSimulationKeyResult(KeyResultReq req); + + SdmResponse deliverableApprove(DeliverableApproveReq req); + + SdmResponse deliverableApproveCallback(LaunchApproveReq req); + + SdmResponse>> listSimulationKeyResult(KeyResultReq req); + + SdmResponse> getSimulationKeyResultFileIds(String runId); + + SdmResponse>> queryKeyResultAndTaskInfo(KeyResultReq req); + + SdmResponse deleteSimulationKeyResult(KeyResultReq req); + + void generateReport(SpdmReportReq req, HttpServletResponse response); + + /** + * 内部调用生成报告 + * @param req 报告请求参数 + */ + SdmResponse generateReportInternal(SpdmReportReq req); + + SdmResponse startProcessInstance(SpdmTaskRunReq req); + + SdmResponse saveNodeParams(SpdmNodeParamReq req); + + SdmResponse listFlowNodes(SpdmTaskRunReq req); + + SdmResponse flowRelateReport(SpdmReportReq req); + + SdmResponse> listQuantities(); + + SdmResponse> listUnits(String quantityType); + +} +
+ + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationTaskAttention; + + +public interface ISimulationTaskAttentionService extends IService { + +} + + + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationTaskExtra; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2025-09-16 + */ +public interface ISimulationTaskExtraService extends IService { + +} +
+ + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.entity.SimulationTaskMember; + +import java.util.List; + +public interface ISimulationTaskMemberService extends IService { + + void deleteTaskMemberList(String taskId, Integer type); + + boolean saveTaskMemberList(String taskId, Integer type, List userIds); + +} + + + +package com.sdm.project.service; + +import com.sdm.common.common.SdmResponse; +import com.sdm.project.model.entity.SimulationTask; +import com.baomidou.mybatisplus.extension.service.IService; +import com.sdm.project.model.req.SpdmEditTaskForDataReq; +import com.sdm.project.model.req.SpdmTaskOprReq; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author author + * @since 2025-11-03 + */ +public interface ISimulationTaskService extends IService { + + boolean updateSimulationTask(SpdmTaskOprReq req); + + SdmResponse editTaskForData(SpdmEditTaskForDataReq req); + +} +
+ + +package com.sdm.project.service; + +import com.sdm.common.common.SdmResponse; +import com.sdm.common.entity.ExportExcelFormat; +import com.sdm.common.entity.req.task.TaskExportExcelFormat; +import com.sdm.common.entity.req.task.TaskTreeExportExcelFormat; +import com.sdm.project.model.bo.ModifyTaskNode; +import com.sdm.project.model.req.*; +import com.sdm.project.model.req.YA.SyncCidTaskReq; +import com.sdm.project.model.resp.GetAllRunResultByTaskIdResp; +import com.sdm.project.model.resp.TaskCountResp; +import com.sdm.project.model.resp.TaskWorkDaysResp; +import com.sdm.project.model.resp.UserWorkloadResp; +import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Service; + +import java.util.List; + + +@Service +public interface ITaskService { + + SdmResponse list(SpdmTaskListReq req); + + SdmResponse countByStatus(SpdmTaskCountReq req); + + SdmResponse operation(SpdmTaskOpr req); + + SdmResponse analysisTaskList(SpdmAnalysisTaskListReq req); + + SdmResponse analysisPerformanceList(SpdmAnalysisPerformanceListReq req); + + SdmResponse analysisRunList(SpdmAnalysisRunListReq req); + + SdmResponse attention(String taskId, List addUserIdList,List cancelUserIdList); + + SdmResponse edit(ModifyTaskNode req); + + SdmResponse getAllRunResultByTaskId(String taskId); + + SdmResponse batchDeleteTask(SpdmTaskOpr taskOpr); + + SdmResponse> listUserWorkloadsWithinTimeFrame(UserWorkloadReq req); + + SdmResponse> listTaskWorkDays(UserWorkloadReq req); + + /** + * 导出任务列表 + * @param taskExportExcelFormat + * @param httpservletResponse + * @return + */ + SdmResponse exportTask(TaskExportExcelFormat taskExportExcelFormat , HttpServletResponse httpservletResponse); + +// SdmResponse synchronizeCidTask(SpdmSyncCidTaskReq req); + + SdmResponse getTaskDetail(GetTaskDetailReq req); + + BosimSaveProjectTaskRsp syncCidTask(SyncCidTaskReq req); + + SdmResponse getTaskCompleteStatistics(TaskCompleteStatisticsReq req); + + SdmResponse getPerformanceCompleteStatistics(PerformanceCompleteStatisticsReq req); + + SdmResponse getUserTaskCompleteStatistics(UserTaskCompleteStatisticsReq req); + + SdmResponse getUserDifficultyStatistics(UserDifficultCompleteStatisticsReq req); + + SdmResponse getTaskListByDemandId(SpdmTaskListReq req); + + SdmResponse newExportTaskTree(TaskTreeExportExcelFormat taskTreeExportExcelFormat, HttpServletResponse httpservletResponse); + +} + + + +package com.sdm.project.service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.sdm.project.dao.SimulationBaseQuantitiesMapper; +import com.sdm.project.dao.SimulationBaseUnitsMapper; +import com.sdm.project.model.entity.SimulationBaseQuantities; +import com.sdm.project.model.entity.SimulationBaseUnits; +import org.springframework.stereotype.Service; + +@Service +public class SimulationBaseQuantitiesServiceImpl extends ServiceImpl implements ISimulationBaseQuantitiesService { + +} + + + +server: + port: 7101 + +spring: + application: + name: project + datasource: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + # 设置连接池能够容纳的最大连接数。建议值:CPU核心数 * 2 + 有效磁盘I/O数。一个常见的经验值是 10-20。 + maximum-pool-size: 20 + # 连接池在空闲时保持的最小连接数。 + minimum-idle: 5 + # 一个连接在被标记为空闲之前可以保持空闲状态的最长时间(毫秒)。当连接的空闲时间超过此值后,它可能会被连接池 evict(驱逐)。 + idle-timeout: 60000 # 1 min + # 一个连接从被创建开始,其生命周期的最大时长(毫秒)。HikariCP的默认值就是30分钟,这是一个非常合理的设置。 + max-lifetime: 1800000 # 30 min(Hikari 默认) + # 应用程序尝试从连接池获取一个连接时,等待的最长时间(毫秒)。建议值:30-60秒。 + connection-timeout: 30000 # 30s + master: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + slave: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + enable: true + cloud: + nacos: + discovery: + server-addr: 192.168.65.161:8848 + enabled: true + group: DEV_GROUP +# username: nacos +# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + data: + redis: + # Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0 + database: 0 + # redis服务器地址(填写自己的服务器地址) + host: 192.168.2.166 + # redis端口(默认6379) + port: 6379 + #redis连接超时等待,10秒 + timeout: PT10S + # redis访问密码(默认为空) + password: + lettuce: + pool: + # 连接池最大连接数(使用负值表示没有限制) 默认 8 + max-active: 50 + # 连接池中的最大空闲连接 默认 8 + max-idle: 20 + # 连接池中的最小空闲连接 默认 0 + min-idle: 1 + # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s + max-wait: PT10S +# password: +# sentinel: +# master: mymaster +# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379 + servlet: + multipart: + # 单个文件的最大值 + max-file-size: 500MB + # 上传文件总的最大值 + max-request-size: 10240MB + +management: + endpoints: + web: + exposure: + include: health,info + endpoint: + health: + show-details: always + group: + readiness: + include: discoveryComposite,ping,refreshScope + health: + redis: + enabled: false + db: + enabled: false + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full + cache-enabled: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mapper/**/*.xml + global-config: + # 逻辑删除配置 + db-config: + # 删除前 + logic-not-delete-value: 1 + # 删除后 + logic-delete-value: 0 + +#showSql +logging: + level: + com.sdm.dao: debug + +lombok: + anyConstructor: + addConstructorProperties: true + +file: + rootPath: /data/home/sdm + +security: + whitelist: + paths: + - /run/deliverableApproveCallback + - /run/getSimulationKeyResultFileIds + - /run/generateReportInternal +#logging: +# config: ./config/logback.xml + + + +server: + port: 7101 + +spring: + application: + name: project + datasource: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + # 设置连接池能够容纳的最大连接数。建议值:CPU核心数 * 2 + 有效磁盘I/O数。一个常见的经验值是 10-20。 + maximum-pool-size: 20 + # 连接池在空闲时保持的最小连接数。 + minimum-idle: 5 + # 一个连接在被标记为空闲之前可以保持空闲状态的最长时间(毫秒)。当连接的空闲时间超过此值后,它可能会被连接池 evict(驱逐)。 + idle-timeout: 60000 # 1 min + # 一个连接从被创建开始,其生命周期的最大时长(毫秒)。HikariCP的默认值就是30分钟,这是一个非常合理的设置。 + max-lifetime: 1800000 # 30 min(Hikari 默认) + # 应用程序尝试从连接池获取一个连接时,等待的最长时间(毫秒)。建议值:30-60秒。 + connection-timeout: 30000 # 30s + master: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + slave: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.65.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + enable: true + cloud: + nacos: + discovery: + server-addr: 192.168.65.161:8848 + enabled: true + group: LOCAL_GROUP +# username: nacos +# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + data: + redis: + # Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0 + database: 0 + # redis服务器地址(填写自己的服务器地址) + host: 192.168.2.166 + # redis端口(默认6379) + port: 6379 + #redis连接超时等待,10秒 + timeout: PT10S + # redis访问密码(默认为空) + password: + lettuce: + pool: + # 连接池最大连接数(使用负值表示没有限制) 默认 8 + max-active: 50 + # 连接池中的最大空闲连接 默认 8 + max-idle: 20 + # 连接池中的最小空闲连接 默认 0 + min-idle: 1 + # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s + max-wait: PT10S +# password: +# sentinel: +# master: mymaster +# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379 + servlet: + multipart: + # 单个文件的最大值 + max-file-size: 500MB + # 上传文件总的最大值 + max-request-size: 10240MB + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full + cache-enabled: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mapper/**/*.xml + global-config: + # 逻辑删除配置 + db-config: + # 删除前 + logic-not-delete-value: 1 + # 删除后 + logic-delete-value: 0 + +#showSql +# MyBatis SQL日志通过logback.xml配置控制 + +lombok: + anyConstructor: + addConstructorProperties: true + +file: + rootPath: /data/home/sdm + +#logging: +# config: ./config/logback.xml + +management: + endpoints: + web: + exposure: + include: health,info + endpoint: + health: + show-details: always + group: + readiness: + include: discoveryComposite,ping,refreshScope + health: + redis: + enabled: false + db: + enabled: false + +# 0单机处理,可以指向本地,1负载均衡轮询 +serverType: 0 +#serverIp: 192.168.65.161 +serverIp: 192.168.65.73 + +security: + whitelist: + paths: + - /run/deliverableApproveCallback + - /run/getSimulationKeyResultFileIds + - /run/generateReportInternal + + + +server: + port: 7101 + +spring: + application: + name: project + datasource: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.30.146:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + # 设置连接池能够容纳的最大连接数。建议值:CPU核心数 * 2 + 有效磁盘I/O数。一个常见的经验值是 10-20。 + maximum-pool-size: 20 + # 连接池在空闲时保持的最小连接数。 + minimum-idle: 5 + # 一个连接在被标记为空闲之前可以保持空闲状态的最长时间(毫秒)。当连接的空闲时间超过此值后,它可能会被连接池 evict(驱逐)。 + idle-timeout: 60000 # 1 min + # 一个连接从被创建开始,其生命周期的最大时长(毫秒)。HikariCP的默认值就是30分钟,这是一个非常合理的设置。 + max-lifetime: 1800000 # 30 min(Hikari 默认) + # 应用程序尝试从连接池获取一个连接时,等待的最长时间(毫秒)。建议值:30-60秒。 + connection-timeout: 30000 # 30s + master: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.30.146:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + slave: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.30.146:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + enable: true + cloud: + nacos: + discovery: + server-addr: 192.168.30.146:8848 + enabled: true + group: LYRIC_GROUP +# username: nacos +# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + data: + redis: + # Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0 + database: 0 + # redis服务器地址(填写自己的服务器地址) + host: 192.168.30.145 + # redis端口(默认6379) + port: 6379 + #redis连接超时等待,10秒 + timeout: PT10S + # redis访问密码(默认为空) + password: + lettuce: + pool: + # 连接池最大连接数(使用负值表示没有限制) 默认 8 + max-active: 50 + # 连接池中的最大空闲连接 默认 8 + max-idle: 20 + # 连接池中的最小空闲连接 默认 0 + min-idle: 1 + # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s + max-wait: PT10S +# password: +# sentinel: +# master: mymaster +# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379 + servlet: + multipart: + # 单个文件的最大值 + max-file-size: 500MB + # 上传文件总的最大值 + max-request-size: 10240MB + +management: + endpoints: + web: + exposure: + include: health,info + endpoint: + health: + show-details: always + group: + readiness: + include: discoveryComposite,ping,refreshScope + health: + redis: + enabled: false + db: + enabled: false + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full + cache-enabled: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mapper/**/*.xml + global-config: + # 逻辑删除配置 + db-config: + # 删除前 + logic-not-delete-value: 1 + # 删除后 + logic-delete-value: 0 + +#showSql +logging: + level: + com.sdm.dao: debug + +lombok: + anyConstructor: + addConstructorProperties: true + +file: + rootPath: /data/home/sdm + +security: + whitelist: + paths: + - /run/deliverableApproveCallback + - /run/getSimulationKeyResultFileIds + - /run/generateReportInternal +#logging: +# config: ./config/logback.xml + + + +server: + port: 7101 + +spring: + application: + name: project + datasource: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.30.146:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + hikari: + # 设置连接池能够容纳的最大连接数。建议值:CPU核心数 * 2 + 有效磁盘I/O数。一个常见的经验值是 10-20。 + maximum-pool-size: 20 + # 连接池在空闲时保持的最小连接数。 + minimum-idle: 5 + # 一个连接在被标记为空闲之前可以保持空闲状态的最长时间(毫秒)。当连接的空闲时间超过此值后,它可能会被连接池 evict(驱逐)。 + idle-timeout: 60000 # 1 min + # 一个连接从被创建开始,其生命周期的最大时长(毫秒)。HikariCP的默认值就是30分钟,这是一个非常合理的设置。 + max-lifetime: 1800000 # 30 min(Hikari 默认) + # 应用程序尝试从连接池获取一个连接时,等待的最长时间(毫秒)。建议值:30-60秒。 + connection-timeout: 30000 # 30s + master: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.30.146:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + slave: + username: root + password: mysql + jdbc-url: jdbc:mysql://192.168.30.146:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + enable: true + cloud: + nacos: + discovery: + server-addr: 192.168.30.146:8848 + enabled: true + group: PROD_GROUP + # username: nacos + # password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + data: + redis: + # Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0 + database: 0 + # redis服务器地址(填写自己的服务器地址) + host: 192.168.2.166 + # redis端口(默认6379) + port: 6379 + #redis连接超时等待,10秒 + timeout: PT10S + # redis访问密码(默认为空) + password: + lettuce: + pool: + # 连接池最大连接数(使用负值表示没有限制) 默认 8 + max-active: 50 + # 连接池中的最大空闲连接 默认 8 + max-idle: 20 + # 连接池中的最小空闲连接 默认 0 + min-idle: 1 + # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s + max-wait: PT10S + # password: + # sentinel: + # master: mymaster + # nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379 + servlet: + multipart: + # 单个文件的最大值 + max-file-size: 500MB + # 上传文件总的最大值 + max-request-size: 10240MB + +management: + endpoints: + web: + exposure: + include: health,info + endpoint: + health: + show-details: always + group: + readiness: + include: discoveryComposite,ping,refreshScope + health: + redis: + enabled: false + db: + enabled: false + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full + cache-enabled: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mapper/**/*.xml + global-config: + # 逻辑删除配置 + db-config: + # 删除前 + logic-not-delete-value: 1 + # 删除后 + logic-delete-value: 0 + +#showSql +logging: + level: + com.sdm.dao: debug + +lombok: + anyConstructor: + addConstructorProperties: true + +file: + rootPath: /data/home/sdm + +security: + whitelist: + paths: + - /run/deliverableApproveCallback + - /run/getSimulationKeyResultFileIds + - /run/generateReportInternal +#logging: +# config: ./config/logback.xml + + + +server: + port: 7007 + +spring: + application: + name: project + datasource: + hikari: + # 设置连接池能够容纳的最大连接数。建议值:CPU核心数 * 2 + 有效磁盘I/O数。一个常见的经验值是 10-20。 + maximum-pool-size: 20 + # 连接池在空闲时保持的最小连接数。 + minimum-idle: 5 + # 一个连接在被标记为空闲之前可以保持空闲状态的最长时间(毫秒)。当连接的空闲时间超过此值后,它可能会被连接池 evict(驱逐)。 + idle-timeout: 60000 # 1 min + # 一个连接从被创建开始,其生命周期的最大时长(毫秒)。HikariCP的默认值就是30分钟,这是一个非常合理的设置。 + max-lifetime: 1800000 # 30 min(Hikari 默认) + # 应用程序尝试从连接池获取一个连接时,等待的最长时间(毫秒)。建议值:30-60秒。 + connection-timeout: 30000 # 30s + master: + username: root + password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + jdbc-url: jdbc:mysql://172.27.2.235:3306/spdm?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai +# jdbc-url: jdbc:mysql://10.30.10.210:3306/spdm?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + slave: + username: root + password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + jdbc-url: jdbc:mysql://172.27.2.235:3306/spdm?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai +# jdbc-url: jdbc:mysql://10.30.10.210:3306/spdm?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + enable: true + cloud: + nacos: + discovery: + server-addr: 172.27.2.238:8848 + enabled: true + username: nacos + password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + data: + redis: + # Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0 + database: 0 + # redis服务器地址(填写自己的服务器地址) + host: 172.27.2.238 + # redis端口(默认6379) + port: 6379 + #redis连接超时等待,10秒 + timeout: PT10S + # redis访问密码(默认为空) + password: ENC(+QKYnI6gAYu1SbLaZQTkZA==) + lettuce: + pool: + # 连接池最大连接数(使用负值表示没有限制) 默认 8 + max-active: 50 + # 连接池中的最大空闲连接 默认 8 + max-idle: 20 + # 连接池中的最小空闲连接 默认 0 + min-idle: 1 + # 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s + max-wait: PT10S +# password: +# sentinel: +# master: mymaster +# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379 + servlet: + multipart: + # 单个文件的最大值 + max-file-size: 500MB + # 上传文件总的最大值 + max-request-size: 10240MB + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + auto-mapping-behavior: full +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + mapper-locations: classpath*:mapper/**/*.xml + global-config: + # 逻辑删除配置 + db-config: + # 删除前 + logic-not-delete-value: 1 + # 删除后 + logic-delete-value: 0 + +#showSql +#logging: +# level: +# com.sdm.dao: debug + +lombok: + anyConstructor: + addConstructorProperties: true + +file: + rootPath: /SPDM/server + viewDataPath: /SPDM/simright/viewdata + +hpc: + url: http://172.27.3.135/JSONAPI/JSONAPI.ashx + # 0单机,1执行和文件传输分开 + fileType: 0 + postName: root + postCode: '&bwM%Tgsn@cw' + postServer: 10.1.3.166 + #后处理执行模式,0本机,1ssh到其他机器 + postType: 0 + #最多同时执行的后处理数量 + postCount: 2 + +idme: + tenantId: 657153814494711808 + prefixUrl: https://10.30.8.192/rdm_d7cfc15006a04012934fcbb120ef3f18_app/services/ + # prefixUrl: https://idme-sit-runtime.gacrnd.com/rdm_d7cfc15006a04012934fcbb120ef3f18_app/services/ + privateKeyStr: MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC2Lt/AHP9kPCqQuGxpLEfsE9JmwdNe1DyvWQGC8l4oKOIIBuJRJr2DlVcdfIT1KO49mmP4ucS10OoxGgXclW24BBzvGtQFJ6aF9e7pHq3m/lq6zAVTV8smr23XBe6+n8rDaG0IEtFCnsyizA/idzcKs3KSnSXN9AU0fwI+nAJZ8896liK/A5H/YYnVxvJlgy4/fGdHzgEjzFbi54AqfZTfcFbYA5W0S1h6L4TE/BSVV6cgtL3bpIUQuaLKiPP/E//PwNU7aZ11WaopIkXxB15cZ7JOXHpyHs49sdShIDY+75L8QKykWX7xm/Kg+p2y1HmjpK0sYDZwgc2B3D/myTDlAgMBAAECggEAM5JhVIjg4wcFJaKPTdZzJakWzm/f3eBGrXyMqPzjGos4MP2B42cMDsuftYEiQiQsDNQ/qJEt1ioloXC0aBUE0iqX5je5/RuUUCemUeeVYuZt2KMYftdDctgGR/At/VhOlbJh6v8oras2Un9hn8IPmr/hlw9VPE/viUTK5d5T7BJUqYxiakEVYofnUWeOGvQJCsC8HT32kMsl3U3zCtut5t2v4afV+16yB8CasBYpgWZ9TBbh8FldxngEvHTJwNSIEm0KR2puFDIwctEvHxd8bxbNYMYfQL0KBW6f2GZQ061zoOQzwo4ZAH/foVq2WrUPp9KTzhawG8NqLOjpQHodAQKBgQD+T3VBda3gANhX3Ti5cmR+N9nOlYp9xifkaC0kcrFcFIVTbK/f1OobPmUQkXoGKqI+swc6Z3wvmM/BT8qGCLCQIjhL7oiIGks6ALZYFSO4rTaP16qL37utlnp3exinEhnq0Yb8u9VpVjC/5v7uOdKwWd0ZXjvbMudDc9bHukMxXQKBgQC3ZL0kF7hkHiVDud5Dg0NIY1jCc90ENfzj2J6I23jddodYprjVu1POpEvM1jb3rpmbZOYsCJb5En5QePTgsWq1rliPpD67Etsm5g2glJhPmRGcc/9RDr2AOArNip9U+IhICbhonKaWkJaUoKvD7k6WODJG2kAzPqiyrLkabn3dKQKBgF1T5bEvMa86QCsGmZGdBHo5nuosgRWlSfCNtrtgh+xF76PtCCI5rexvmoFZEhH/RWmDJAzv+2gwSVYlJSrJN5q9pDFhiaOBGshfiIuMvn5AuvxQ5lrMscCDr8/3UdXGU9KUMFjByhENO3jBmh7tA4AKipSLu6W26Z4cfd7wYUZVAoGBAJvfPXstxgUiMh4MHkNXj5o5BjnP7GwlztmBRc2gbGwe0A6jNbpDS4n4zow9Dd8aQWh4K8IFUvxDoaSYCdnoMYBVvOPpf3/VGPtI0RBI++O7f+JwHPMyChKuj0//oEjCLGK+EESp0FVscu/EV/lh1N2Myf66hZKIkS277F/wxX1xAoGBAIleLj+Yl4G/QAj4Cp99rEF7LvClooLsSa1s344xe5F6IWdd3jk5UlUywPeLD+x2aiPKYra/4W7msfAwLhhjaADPHtqp4q7Xm60kWkuTfWZe0hRvcH+lnar1gYksJOa2jaosYTAiUR59VOzGaQqgJ6oVHV4PlE5Cv5xO0Rvg2dQe + userId: PerformancePlanningV + userName: SPDMDevM + +ftp: + host: 172.27.3.135 + port: 6318 + +#hpc定时任务开关 +scheduled: + cleanZip: 0 0 4 * * ? + getProjectSize: 0 0/30 9-19 * * ? + syncHpcTaskStatus: 30 * * * * ? + taskResultSync: 0 0/1 * * * ? + + loadcaseNotice: 0 0 9 * * ? + updateExeStatus: 0 0 4 * * ? + syncUser: 0 0 4 * * ? + + + +spring: + profiles: + active: local + + +
From ba50748e195ac471c7c79c56e19af149fa5c0b22 Mon Sep 17 00:00:00 2001 From: gulongcheng <474084054@qq.com> Date: Mon, 15 Dec 2025 15:50:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=80=BB=E8=A7=88?= =?UTF-8?q?=E5=A4=9A=E7=BB=B4=E5=BA=A6=E5=90=88=E5=B9=B6=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/compiler.xml | 13 +- .../SimulationNodeFeignClientImpl.java | 20 +-- .../project/ISimulationNodeFeignClient.java | 9 +- data/pom.xml | 27 ++++ .../controller/DataOverviewController.java | 3 +- .../sdm/data/convert/FileMetadataConvert.java | 77 +++++++++ .../sdm/data/dao/FileMetadataInfoMapper.java | 2 +- .../model/dto/FileMetadataChildrenDTO.java | 20 +++ .../model/req/GetSimulationNodeTreeReq.java | 6 +- .../model/req/ListSimulationNodeTreeReq.java | 9 +- .../service/IDimensionTemplateService.java | 3 +- .../service/IFileMetadataInfoService.java | 2 +- .../service/impl/DataStorageAnalysisImpl.java | 2 +- .../impl/DimensionTemplateServiceImpl.java | 152 ++++++++++++------ .../impl/FileMetadataInfoServiceImpl.java | 4 +- .../mapper/FileMetadataInfoMapper.xml | 6 +- .../controller/SimulationNodeController.java | 14 +- .../com/sdm/project/service/INodeService.java | 8 +- .../project/service/impl/NodeServiceImpl.java | 36 ++--- 19 files changed, 303 insertions(+), 110 deletions(-) create mode 100644 data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java create mode 100644 data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 1a4a804a..f6f1da5f 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -14,11 +14,22 @@ - + + + + + + + + + + + + diff --git a/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java b/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java index 32925c5e..b943d6c8 100644 --- a/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java +++ b/common/src/main/java/com/sdm/common/feign/impl/project/SimulationNodeFeignClientImpl.java @@ -43,15 +43,15 @@ public class SimulationNodeFeignClientImpl implements ISimulationNodeFeignClient /** * 根据项目ID和节点类型获取所有节点信息 * - * @param uuid 项目ID + * @param uuids 项目ID * @param nextNodeType 下一级节点类型 * @return SdmResponse 节点信息 */ - public SdmResponse> getAllNodeByProjectIdAndType(String uuid, String nextNodeType) { + public SdmResponse> getAllNodeByProjectIdAndType(List uuids, String nextNodeType) { SdmResponse> response; try { - log.info("根据项目ID和节点类型获取所有节点信息请求参数:uuid={}, nextNodeType={}", uuid, nextNodeType); - response = ISimulationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, nextNodeType); + log.info("根据项目ID和节点类型获取所有节点信息请求参数:uuid={}, nextNodeType={}", uuids, nextNodeType); + response = ISimulationNodeFeignClient.getAllNodeByProjectIdAndType(uuids, nextNodeType); if (!response.isSuccess() || response.getData() == null || response.getData().isEmpty()) { return SdmResponse.failed("获取节点信息失败"); } @@ -65,11 +65,11 @@ public class SimulationNodeFeignClientImpl implements ISimulationNodeFeignClient @Override - public SdmResponse> getNodeTaskList(String uuid) { + public SdmResponse> getNodeTaskList(List uuids) { SdmResponse> response; try { - log.info("获取节点下的task列表请求参数:uuid={}", uuid); - response = ISimulationNodeFeignClient.getNodeTaskList(uuid); + log.info("获取节点下的task列表请求参数:uuid={}", uuids); + response = ISimulationNodeFeignClient.getNodeTaskList(uuids); if (!response.isSuccess() || response.getData() == null || response.getData().isEmpty()) { return SdmResponse.failed("获取节点下的task列表失败"); } @@ -81,11 +81,11 @@ public class SimulationNodeFeignClientImpl implements ISimulationNodeFeignClient } @Override - public SdmResponse> getTaskRunList(String uuid) { + public SdmResponse> getTaskRunList(List uuids) { SdmResponse> response; try { - log.info("获取task下的run请求参数:uuid={}", uuid); - response = ISimulationNodeFeignClient.getTaskRunList(uuid); + log.info("获取task下的run请求参数:uuid={}", uuids); + response = ISimulationNodeFeignClient.getTaskRunList(uuids); if (!response.isSuccess() || response.getData() == null || response.getData().isEmpty()) { return SdmResponse.failed("获取task下的run失败"); } diff --git a/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java b/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java index a49ab7b3..00fe8ea5 100644 --- a/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java +++ b/common/src/main/java/com/sdm/common/feign/inter/project/ISimulationNodeFeignClient.java @@ -5,7 +5,6 @@ import com.sdm.common.entity.req.project.DelNodeReq; import com.sdm.common.entity.req.project.SpdmNodeListReq; import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; import com.sdm.common.entity.resp.project.SimulationNodeResp; -import io.swagger.v3.oas.annotations.Operation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -27,24 +26,24 @@ public interface ISimulationNodeFeignClient { /** * 根据项目ID和节点类型获取所有节点信息 * - * @param uuid 项目ID + * @param uuids 项目ID * @param nextNodeType 下一级节点类型 * @return SdmResponse> 节点信息 */ @GetMapping("/node/getAllNodeByProjectIdAndType") - SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeId") String uuid, @RequestParam(value = "nextNodeType") String nextNodeType); + SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeIds") List uuids, @RequestParam(value = "nextNodeType") String nextNodeType); /** * 获取节点下的task列表 */ @GetMapping("/node/getNodeTaskList") - SdmResponse> getNodeTaskList(@RequestParam(value = "uuid") String uuid); + SdmResponse> getNodeTaskList(@RequestParam(value = "uuids") List uuids); /** * 获取task下的run */ @GetMapping("/node/getNodeTaskRunList") - SdmResponse> getTaskRunList(@RequestParam(value = "uuid") String uuid); + SdmResponse> getTaskRunList(@RequestParam(value = "uuids") List uuids); @PostMapping("node/delteNode") SdmResponse delteNode(@RequestBody DelNodeReq req); diff --git a/data/pom.xml b/data/pom.xml index 6722fa82..7cefee39 100644 --- a/data/pom.xml +++ b/data/pom.xml @@ -16,6 +16,9 @@ UTF-8 UTF-8 3.3.5 + 1.5.2.Final + 1.18.30 + 0.2.0 @@ -108,6 +111,13 @@ spring-boot-starter-websocket + + + org.mapstruct + mapstruct + ${org.mapstruct.version} + + @@ -134,6 +144,23 @@ -parameters + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + org.projectlombok + lombok + ${lombok.version} + + + org.projectlombok + lombok-mapstruct-binding + ${lombok-mapstruct-binding.version} + + diff --git a/data/src/main/java/com/sdm/data/controller/DataOverviewController.java b/data/src/main/java/com/sdm/data/controller/DataOverviewController.java index 8bbb2ec9..06c83111 100644 --- a/data/src/main/java/com/sdm/data/controller/DataOverviewController.java +++ b/data/src/main/java/com/sdm/data/controller/DataOverviewController.java @@ -4,6 +4,7 @@ package com.sdm.data.controller; import com.sdm.common.common.SdmResponse; import com.sdm.common.entity.req.data.CreateDirReq; import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; import com.sdm.data.model.entity.FileMetadataInfo; import com.sdm.data.model.req.*; import com.sdm.data.service.IDimensionTemplateService; @@ -40,7 +41,7 @@ public class DataOverviewController { */ @PostMapping("/getSimulationNodeTree") @Operation(summary = "根据数据显示维度展示左侧节点树") - public SdmResponse> getSimulationNodeTree(@RequestBody GetSimulationNodeTreeReq req) { + public SdmResponse> getSimulationNodeTree(@RequestBody GetSimulationNodeTreeReq req) { return dimensionTemplateService.getSimulationNodeTree(req); } diff --git a/data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java b/data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java new file mode 100644 index 00000000..aa2f0bb6 --- /dev/null +++ b/data/src/main/java/com/sdm/data/convert/FileMetadataConvert.java @@ -0,0 +1,77 @@ +package com.sdm.data.convert; + +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; +import com.sdm.data.model.entity.FileMetadataInfo; +import jdk.jfr.Name; +import org.mapstruct.*; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface FileMetadataConvert { + + FileMetadataConvert INSTANCE = Mappers.getMapper(FileMetadataConvert.class); + + @Named("baseResp") + @Mappings({ + @Mapping(target = "fileUrl", ignore = true), + @Mapping(target = "creatorName", ignore = true), + @Mapping(target = "updaterName", ignore = true), + @Mapping(target = "projectName", ignore = true), + @Mapping(target = "analysisDirectionName", ignore = true), + @Mapping(target = "poolInfos", ignore = true), + @Mapping(target = "approvalStatus", ignore = true), + @Mapping(target = "approveType", ignore = true), + @Mapping(target = "tempMetadata", ignore = true), + @Mapping(target = "cidFlowId", ignore = true), + @Mapping(target = "uploadTaskId", ignore = true), + @Mapping(target = "uploadStatus", ignore = true), + @Mapping(target = "cidFlowReviewer", ignore = true), + @Mapping(target = "tag1", ignore = true), + @Mapping(target = "tag2", ignore = true), + @Mapping(target = "tag3", ignore = true), + @Mapping(target = "tag4", ignore = true), + @Mapping(target = "tag5", ignore = true), + @Mapping(target = "tag6", ignore = true), + @Mapping(target = "tag7", ignore = true), + @Mapping(target = "tag8", ignore = true), + @Mapping(target = "tag9", ignore = true), + @Mapping(target = "tag10", ignore = true) + }) + FileMetadataInfoResp convertToFileMetadataInfoResp(FileMetadataInfo fileMetadataInfo); + + @IterableMapping(qualifiedByName = "baseResp") + List convertToFileMetadataInfoRespList(List fileMetadataInfoList); + + @Named("childrenResp") + @Mappings({ + @Mapping(target = "children", ignore = true), + @Mapping(target = "totalName", ignore = true), + @Mapping(target = "fileUrl", ignore = true), + @Mapping(target = "creatorName", ignore = true), + @Mapping(target = "updaterName", ignore = true), + @Mapping(target = "projectName", ignore = true), + @Mapping(target = "analysisDirectionName", ignore = true), + @Mapping(target = "poolInfos", ignore = true), + @Mapping(target = "approvalStatus", ignore = true), + @Mapping(target = "approveType", ignore = true), + @Mapping(target = "tempMetadata", ignore = true), + @Mapping(target = "cidFlowId", ignore = true), + @Mapping(target = "uploadTaskId", ignore = true), + @Mapping(target = "uploadStatus", ignore = true), + @Mapping(target = "cidFlowReviewer", ignore = true), + @Mapping(target = "tag1", ignore = true), + @Mapping(target = "tag2", ignore = true), + @Mapping(target = "tag3", ignore = true), + @Mapping(target = "tag4", ignore = true), + @Mapping(target = "tag5", ignore = true), + @Mapping(target = "tag6", ignore = true), + @Mapping(target = "tag7", ignore = true), + @Mapping(target = "tag8", ignore = true), + @Mapping(target = "tag9", ignore = true), + @Mapping(target = "tag10", ignore = true) + }) + FileMetadataChildrenDTO convertToFileMetadataChildrenDTO(FileMetadataInfo fileMetadataInfo); +} \ No newline at end of file diff --git a/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java b/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java index d7d2f8fc..9d33f282 100644 --- a/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java +++ b/data/src/main/java/com/sdm/data/dao/FileMetadataInfoMapper.java @@ -16,6 +16,6 @@ import java.util.List; */ public interface FileMetadataInfoMapper extends BaseMapper { List listSimulationNodeDir(@Param("dirIds") List dirIds, @Param("filterEmptyData") boolean filterEmptyData, @Param("tenantId") Long tenantId); - List listSimulationNodeFiles(@Param("parentId") Long parentId,@Param("fileIds") List fileIds, @Param("filterEmptyData") boolean isFilterEmptyData,@Param("tenantId") Long tenantId); + List listSimulationNodeFiles(@Param("parentIds") List parentIds, @Param("fileIds") List fileIds, @Param("filterEmptyData") boolean isFilterEmptyData, @Param("tenantId") Long tenantId); } diff --git a/data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java b/data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java new file mode 100644 index 00000000..c7ec079d --- /dev/null +++ b/data/src/main/java/com/sdm/data/model/dto/FileMetadataChildrenDTO.java @@ -0,0 +1,20 @@ +package com.sdm.data.model.dto; + +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(description = "带有子节点的文件元数据信息DTO") +public class FileMetadataChildrenDTO extends FileMetadataInfoResp { + + @Schema(description = "子节点列表") + private List children; + + @Schema(description = "总名称(去除projectNode/前缀的bucketName)") + private String totalName; +} \ No newline at end of file diff --git a/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java b/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java index 840cd791..fb71576f 100644 --- a/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java +++ b/data/src/main/java/com/sdm/data/model/req/GetSimulationNodeTreeReq.java @@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.NotEmpty; +import java.util.List; + @Data public class GetSimulationNodeTreeReq { /** @@ -14,7 +16,7 @@ public class GetSimulationNodeTreeReq { private Long dimensionTemplateId; /** - * 文件ID + * 聚合文件ID列表 */ - private Long fileId; + private List fileIds; } diff --git a/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java b/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java index 68c9ba2a..0b0a85fc 100644 --- a/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java +++ b/data/src/main/java/com/sdm/data/model/req/ListSimulationNodeTreeReq.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.NotEmpty; +import java.util.List; + @Data public class ListSimulationNodeTreeReq extends BaseReq { /** @@ -15,11 +17,16 @@ public class ListSimulationNodeTreeReq extends BaseReq { Long dimensionTemplateId; /** - * 文件夹ID + * 文件夹ID 只用来控制根目录 */ @Schema(description = "文件夹ID") Long fileId; + /** + * 聚合文件ID列表 + */ + private List fileIds; + /** * 是否过滤空数据 */ diff --git a/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java b/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java index 8e70a055..3e20867b 100644 --- a/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java +++ b/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java @@ -3,6 +3,7 @@ package com.sdm.data.service; import com.sdm.common.common.SdmResponse; import com.sdm.common.entity.req.data.CreateDirReq; import com.sdm.common.entity.req.data.UploadFilesReq; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; import com.sdm.data.model.entity.DimensionTemplate; import com.baomidou.mybatisplus.extension.service.IService; import com.sdm.data.model.entity.FileMetadataInfo; @@ -30,7 +31,7 @@ public interface IDimensionTemplateService extends IService { SdmResponse deleteTemplateWithHierarchies(Long id); - SdmResponse> getSimulationNodeTree(GetSimulationNodeTreeReq req); + SdmResponse> getSimulationNodeTree(GetSimulationNodeTreeReq req); /** * 根据数据显示维度展示左侧节点树 diff --git a/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java b/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java index 9be2115c..35ab5c3c 100644 --- a/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java +++ b/data/src/main/java/com/sdm/data/service/IFileMetadataInfoService.java @@ -19,5 +19,5 @@ public interface IFileMetadataInfoService extends IService { * @return */ List listSimulationNodeDir(List dirIds,boolean filterEmptyData,Long tenantId); - List listSimulationNodeFiles(Long parentId, List fileIds, boolean isFilterEmptyData,Long tenantId); + List listSimulationNodeFiles(List parentIds, List fileIds, boolean isFilterEmptyData, Long tenantId); } diff --git a/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java b/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java index e6c934a7..106d7a41 100644 --- a/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/DataStorageAnalysisImpl.java @@ -66,7 +66,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis { IFileStorageQuotaService fileStorageQuotaService; public SdmResponse> getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm) { - SdmResponse> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, queryNodeType); + SdmResponse> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(List.of(uuid), queryNodeType); Long tenantId = ThreadLocalContext.getTenantId(); if (!response.isSuccess()) { log.error("获取节点信息失败"); diff --git a/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java b/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java index 9b7de3cb..aa063265 100644 --- a/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java @@ -16,11 +16,14 @@ import com.sdm.common.entity.req.data.UploadFilesReq; import com.sdm.common.entity.req.project.DelNodeReq; import com.sdm.common.entity.req.system.UserQueryReq; import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; +import com.sdm.common.entity.resp.data.FileMetadataInfoResp; import com.sdm.common.entity.resp.system.CIDUserResp; import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl; import com.sdm.common.feign.impl.system.SysUserFeignClientImpl; import com.sdm.common.utils.CidSysUserUtil; import com.sdm.common.utils.PageUtils; +import com.sdm.data.convert.FileMetadataConvert; +import com.sdm.data.model.dto.FileMetadataChildrenDTO; import com.sdm.data.model.entity.DimensionTemplate; import com.sdm.data.dao.DimensionTemplateMapper; import com.sdm.data.model.entity.DimensionTemplateHierarchy; @@ -38,14 +41,12 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.*; -import java.util.stream.Stream; +import java.util.stream.Collectors; /** *

@@ -179,7 +180,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl> getSimulationNodeTree(GetSimulationNodeTreeReq req) { + public SdmResponse> getSimulationNodeTree(GetSimulationNodeTreeReq req) { Long tenantId = ThreadLocalContext.getTenantId(); // 根据展示维度获取展示节点类型顺序 Long dimensionTemplateId = req.getDimensionTemplateId(); @@ -189,26 +190,26 @@ public class DimensionTemplateServiceImpl extends ServiceImpl uuids = new ArrayList<>(); List resultDir = new ArrayList<>(); - if (ObjectUtils.isEmpty(req.getFileId())) { + if (ObjectUtils.isEmpty(req.getFileIds())) { // 选中维度了,没有选节点,按照模版,展示模版的第一层节点数据 String rootNodeType = dimensionNodeTyepOrderList.get(0); SdmResponse> allNodeByNodeTypeResponse = simuluationNodeFeignClient.getAllNodeByNodeType(null, rootNodeType); if (!allNodeByNodeTypeResponse.isSuccess()) { log.error("获取节点信息失败"); - return SdmResponse.success(); + return SdmResponse.success(Collections.emptyList()); } uuids.addAll(allNodeByNodeTypeResponse.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); } else { // 选中维度了,也选中了节点,按照模版,展示该节点下的普通文件夹、任务、算列、按照展示模版指定的下一层节点文件夹 - Long fileId = req.getFileId(); + List fileIds = req.getFileIds(); // 1、先获取普通文件夹 List dirInfos = fileMetadataInfoService .lambdaQuery() .eq(FileMetadataInfo::getTenantId, tenantId) - .eq(FileMetadataInfo::getParentId, fileId) + .in(FileMetadataInfo::getParentId, fileIds) .eq(FileMetadataInfo::getDataType, DataTypeEnum.DIRECTORY.getValue()) .isNull(FileMetadataInfo::getRelatedResourceUuid) .list(); @@ -216,46 +217,48 @@ public class DimensionTemplateServiceImpl extends ServiceImpl nodeDirInfos = fileMetadataInfoService.lambdaQuery().in(FileMetadataInfo::getId, fileIds).list(); + if(CollectionUtils.isNotEmpty(nodeDirInfos)) { + String chooseNodeType = nodeDirInfos.get(0).getRelatedResourceUuidOwnType(); + List chooseUuids = nodeDirInfos.stream().map(FileMetadataInfo::getRelatedResourceUuid).toList(); - // chooseUuid和chooseNodeType不为空,并且是node节点类型,才是节点文件夹,才需要查询子节点文件夹文件 - if (ObjectUtils.isNotEmpty(chooseUuid) && ObjectUtils.isNotEmpty(chooseNodeType) && NodeTypeEnum.isNodeType(chooseNodeType)) { - // 从dimensionNodeTyepOrderList中获取chooseNodeType下一个位置的数据,有可能chooseNodeType所在位置就是最后一层节点,SdmResponse返回空数据 - int index = dimensionNodeTyepOrderList.indexOf(chooseNodeType); - if (index == -1) { - return SdmResponse.failed("选中节点类型不在数据展示维度中"); - } - - // 判断是否是最后一层节点,如果是最后一层节点,则不需要查询子节点文件 - if (index != dimensionNodeTyepOrderList.size() - 1) { - // 获取dimensionNodeTyepOrderList的index+1位置的节点类型 - String nextNodeType = dimensionNodeTyepOrderList.get(index + 1); - SdmResponse> allNodeByProjectIdAndType = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(chooseUuid, nextNodeType); - if (allNodeByProjectIdAndType.isSuccess() && ObjectUtils.isNotEmpty(allNodeByProjectIdAndType.getData())) { - uuids.addAll(allNodeByProjectIdAndType.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + // chooseUuid和chooseNodeType不为空,并且是node节点类型,才是节点文件夹,才需要查询子节点文件夹文件 + if (ObjectUtils.isNotEmpty(chooseUuids) && ObjectUtils.isNotEmpty(chooseNodeType) && NodeTypeEnum.isNodeType(chooseNodeType)) { + // 从dimensionNodeTyepOrderList中获取chooseNodeType下一个位置的数据,有可能chooseNodeType所在位置就是最后一层节点,SdmResponse返回空数据 + int index = dimensionNodeTyepOrderList.indexOf(chooseNodeType); + if (index == -1) { + return SdmResponse.failed("选中节点类型不在数据展示维度中"); } + // 判断是否是最后一层节点,如果是最后一层节点,则不需要查询子节点文件 + if (index != dimensionNodeTyepOrderList.size() - 1) { + // 获取dimensionNodeTyepOrderList的index+1位置的节点类型 + String nextNodeType = dimensionNodeTyepOrderList.get(index + 1); + SdmResponse> allNodeByProjectIdAndType = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(chooseUuids, nextNodeType); + if (allNodeByProjectIdAndType.isSuccess() && ObjectUtils.isNotEmpty(allNodeByProjectIdAndType.getData())) { + uuids.addAll(allNodeByProjectIdAndType.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + } + + } } - } - // 3、获取当前节点下的任务、算列 - SdmResponse> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuid); - if (nodeTaskList.isSuccess()) { - uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); - log.info("获取节点下task的uudis:{}", uuids); - } + // 3、获取当前节点下的任务、算列 + SdmResponse> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuids); + if (nodeTaskList.isSuccess()) { + uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + log.info("获取节点下task的uudis:{}", uuids); + } - SdmResponse> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuid); - if (taskRunList.isSuccess()) { - uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); - log.info("获取节点下taskRun的uudis:{}", uuids); + SdmResponse> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuids); + if (taskRunList.isSuccess()) { + uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + log.info("获取节点下taskRun的uudis:{}", uuids); + } } } if (CollectionUtils.isEmpty(uuids)) { - return SdmResponse.success(resultDir); + return SdmResponse.success(Collections.emptyList()); } List nodeDirInfos = fileMetadataInfoService.lambdaQuery() @@ -263,9 +266,58 @@ public class DimensionTemplateServiceImpl extends ServiceImpl mergedResult = mergeNodeDirInfos(resultDir); + return SdmResponse.success(mergedResult); } + /** + * 根据originalName合并FileMetadataInfo列表,并处理bucketName生成totalName + * @param nodeDirInfos 需要合并的FileMetadataInfo列表 + * @return 合并后的结果 + */ + private List mergeNodeDirInfos(List nodeDirInfos) { + // 按originalName分组 + Map> groupedByOriginalName = nodeDirInfos.stream() + .collect(Collectors.groupingBy(FileMetadataInfo::getOriginalName)); + + List result = new ArrayList<>(); + + // 对每组进行处理 + for (Map.Entry> entry : groupedByOriginalName.entrySet()) { + List group = entry.getValue(); + + if (!group.isEmpty()) { + // 使用第一个作为基础对象 + FileMetadataInfo baseInfo = group.get(0); + + // 创建包含children的DTO对象 + FileMetadataChildrenDTO dto = FileMetadataConvert.INSTANCE.convertToFileMetadataChildrenDTO(baseInfo); + + // 转换children列表,并为每个child设置totalName + List children = new ArrayList<>(); + for (FileMetadataInfo fileInfo : group) { + FileMetadataChildrenDTO childDto = FileMetadataConvert.INSTANCE.convertToFileMetadataChildrenDTO(fileInfo); + + // 设置totalName(从bucketName中提取) + String objectKey = fileInfo.getObjectKey(); + String baseDirPath = DirTypeEnum.PROJECT_NODE_DIR.getDirName() + "/"; + if (objectKey != null && objectKey.startsWith(baseDirPath)) { + String totalName = objectKey.substring(baseDirPath.length()); + childDto.setTotalName(totalName); + } + + children.add(childDto); + } + + dto.setChildren(children); + result.add(dto); + } + } + + return result; + } @Override public SdmResponse listSimulationNodeFiles(ListSimulationNodeTreeReq req) { Long tenantId = ThreadLocalContext.getTenantId(); @@ -274,7 +326,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl dirInfos = null; - if(ObjectUtils.isEmpty(req.getFileId())){ + if(ObjectUtils.isEmpty(req.getFileId()) && ObjectUtils.isEmpty(req.getFileIds())){ // 第一次进入数据总览页面,右侧不展示文件和文件夹 return SdmResponse.success(); } @@ -283,10 +335,10 @@ public class DimensionTemplateServiceImpl extends ServiceImpl> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); + getSimulationNodeTreeReq.setFileIds(null); + SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) { - dirInfos = nodeDirInfos.getData().stream().map(FileMetadataInfo::getId).toList(); + dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList(); } PageHelper.startPage(req.getCurrent(), req.getSize()); @@ -297,24 +349,18 @@ public class DimensionTemplateServiceImpl extends ServiceImpl parentDirInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, parentDirId).eq(FileMetadataInfo::getTenantId, tenantId).oneOpt(); - if (!parentDirInfo.isPresent()) { - return SdmResponse.failed("父文件夹不存在"); - } - // relatedResourceUuid和relatedResourceUuidOwnType不为空才是节点文件夹,才需要查询子节点文件夹文件 GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq(); getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId()); - getSimulationNodeTreeReq.setFileId(parentDirId); - SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); + getSimulationNodeTreeReq.setFileIds(req.getFileIds()); + SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) { - dirInfos = nodeDirInfos.getData().stream().map(FileMetadataInfo::getId).toList(); + dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList(); } PageHelper.startPage(req.getCurrent(), req.getSize()); - List fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(parentDirId, dirInfos,req.isFilterEmptyData(),tenantId); + List fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(req.getFileIds(), dirInfos,req.isFilterEmptyData(),tenantId); setCreatorNames(fileMetadataInfos); PageInfo page = new PageInfo<>(fileMetadataInfos); diff --git a/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java b/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java index 6a08a4bf..463bf03b 100644 --- a/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/FileMetadataInfoServiceImpl.java @@ -24,7 +24,7 @@ public class FileMetadataInfoServiceImpl extends ServiceImpl listSimulationNodeFiles(Long parentId, List fileIds, boolean isFilterEmptyData,Long tenantId) { - return this.baseMapper.listSimulationNodeFiles(parentId, fileIds, isFilterEmptyData,tenantId); + public List listSimulationNodeFiles(List parentIds, List fileIds, boolean isFilterEmptyData, Long tenantId) { + return this.baseMapper.listSimulationNodeFiles(parentIds, fileIds, isFilterEmptyData,tenantId); } } diff --git a/data/src/main/resources/mapper/FileMetadataInfoMapper.xml b/data/src/main/resources/mapper/FileMetadataInfoMapper.xml index 18b91862..0767c00a 100644 --- a/data/src/main/resources/mapper/FileMetadataInfoMapper.xml +++ b/data/src/main/resources/mapper/FileMetadataInfoMapper.xml @@ -26,7 +26,11 @@ SELECT distinct file_metadata_info.* FROM file_metadata_info - WHERE parentId = #{parentId} + WHERE parentId IN ( + + #{parentId} + + ) and tenantId = #{tenantId} AND dataType = 2 AND isLatest = true diff --git a/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java b/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java index 6d07a6e8..6905fa9d 100644 --- a/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java +++ b/project/src/main/java/com/sdm/project/controller/SimulationNodeController.java @@ -144,14 +144,14 @@ public class SimulationNodeController implements ISimulationNodeFeignClient { /** * 根据项目ID和节点类型获取所有节点信息 * - * @param uuid 项目ID + * @param uuids 项目ID * @param nextNodeType 下一级节点类型 * @return SdmResponse> 节点信息 */ @GetMapping("/getAllNodeByProjectIdAndType") @Operation(summary = "根据项目ID和节点类型获取所有节点信息", description = "根据项目ID和节点类型获取所有节点信息") - public SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeId") String uuid, @RequestParam(value = "nextNodeType") String nextNodeType) { - return nodeService.getAllNodeByProjectIdAndType(uuid, nextNodeType); + public SdmResponse> getAllNodeByProjectIdAndType(@RequestParam(value = "chooseNodeIds") List uuids, @RequestParam(value = "nextNodeType") String nextNodeType) { + return nodeService.getAllNodeByProjectIdAndType(uuids, nextNodeType); } /** @@ -159,8 +159,8 @@ public class SimulationNodeController implements ISimulationNodeFeignClient { */ @GetMapping("/getNodeTaskList") @Operation(summary = "获取节点下的task列表", description = "获取节点下的task列表") - public SdmResponse> getNodeTaskList(@RequestParam(value = "uuid") String uuid) { - return nodeService.getNodeTaskList(uuid); + public SdmResponse> getNodeTaskList(@RequestParam(value = "uuids") List uuids) { + return nodeService.getNodeTaskList(uuids); } /** @@ -168,8 +168,8 @@ public class SimulationNodeController implements ISimulationNodeFeignClient { */ @GetMapping("/getNodeTaskRunList") @Operation(summary = "获取task下的run", description = "获取task下的run") - public SdmResponse> getTaskRunList(@RequestParam(value = "uuid") String uuid) { - return nodeService.getTaskRunList(uuid); + public SdmResponse> getTaskRunList(@RequestParam(value = "uuids") List uuids) { + return nodeService.getTaskRunList(uuids); } diff --git a/project/src/main/java/com/sdm/project/service/INodeService.java b/project/src/main/java/com/sdm/project/service/INodeService.java index d71617e5..eae5c0d1 100644 --- a/project/src/main/java/com/sdm/project/service/INodeService.java +++ b/project/src/main/java/com/sdm/project/service/INodeService.java @@ -12,11 +12,9 @@ import com.sdm.common.entity.resp.project.SimulationNodeResp; import com.sdm.project.model.entity.SimulationNode; import com.sdm.project.model.req.*; import com.sdm.project.model.req.YA.SyncCidProjectReq; -import com.sdm.project.model.resp.YA.BosimSaveNodeInfoRsp; import com.sdm.project.model.resp.YA.BosimSaveProjectTaskRsp; import jakarta.servlet.http.HttpServletResponse; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -39,11 +37,11 @@ public interface INodeService extends IService { SdmResponse> getAllNodeByBodeType(String nodeType, Long nodeId); - SdmResponse> getAllNodeByProjectIdAndType(String uuid, String nextNodeType); + SdmResponse> getAllNodeByProjectIdAndType(List uuids, String nextNodeType); - SdmResponse> getNodeTaskList(String uuid); + SdmResponse> getNodeTaskList(List uuids); - SdmResponse> getTaskRunList(String uuid); + SdmResponse> getTaskRunList(List uuids); SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId); diff --git a/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java b/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java index d7c0a465..9c33e06f 100644 --- a/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java +++ b/project/src/main/java/com/sdm/project/service/impl/NodeServiceImpl.java @@ -819,7 +819,7 @@ public class NodeServiceImpl extends ServiceImpl> getAllNodeByProjectIdAndType(String uuid, String nextNodeType) { + public SdmResponse> getAllNodeByProjectIdAndType(List uuids, String nextNodeType) { SdmResponse> tagMapList = sysConfigFeignClient.getDictionaryData(TagConstant.DICTIONARY_TAG_KEY); if (!tagMapList.isSuccess() || ObjectUtils.isEmpty(tagMapList.getData())) { log.error("字典信息查询失败"); @@ -828,7 +828,7 @@ public class NodeServiceImpl extends ServiceImpltag1 phase-->tag2 Map TagMap = tagMapList.getData().stream().collect(Collectors.toMap(DataDictionary::getDictValue, DataDictionary::getDictName)); - Optional simulationNodeOptional = this.lambdaQuery().eq(SimulationNode::getUuid, uuid).oneOpt(); + Optional simulationNodeOptional = this.lambdaQuery().in(SimulationNode::getUuid, uuids).list().stream().findFirst(); if (!simulationNodeOptional.isPresent()) { return SdmResponse.failed("未找到节点"); } @@ -838,16 +838,16 @@ public class NodeServiceImpl extends ServiceImpl simulationNodeList = this.lambdaQuery() - .eq(TagConstant.TAG1.equals(currentNodeTag), SimulationNode::getTag1, uuid) - .eq(TagConstant.TAG2.equals(currentNodeTag), SimulationNode::getTag2, uuid) - .eq(TagConstant.TAG3.equals(currentNodeTag), SimulationNode::getTag3, uuid) - .eq(TagConstant.TAG4.equals(currentNodeTag), SimulationNode::getTag4, uuid) - .eq(TagConstant.TAG5.equals(currentNodeTag), SimulationNode::getTag5, uuid) - .eq(TagConstant.TAG6.equals(currentNodeTag), SimulationNode::getTag6, uuid) - .eq(TagConstant.TAG7.equals(currentNodeTag), SimulationNode::getTag7, uuid) - .eq(TagConstant.TAG8.equals(currentNodeTag), SimulationNode::getTag8, uuid) - .eq(TagConstant.TAG9.equals(currentNodeTag), SimulationNode::getTag9, uuid) - .eq(TagConstant.TAG10.equals(currentNodeTag), SimulationNode::getTag10, uuid) + .in(TagConstant.TAG1.equals(currentNodeTag), SimulationNode::getTag1, uuids) + .in(TagConstant.TAG2.equals(currentNodeTag), SimulationNode::getTag2, uuids) + .in(TagConstant.TAG3.equals(currentNodeTag), SimulationNode::getTag3, uuids) + .in(TagConstant.TAG4.equals(currentNodeTag), SimulationNode::getTag4, uuids) + .in(TagConstant.TAG5.equals(currentNodeTag), SimulationNode::getTag5, uuids) + .in(TagConstant.TAG6.equals(currentNodeTag), SimulationNode::getTag6, uuids) + .in(TagConstant.TAG7.equals(currentNodeTag), SimulationNode::getTag7, uuids) + .in(TagConstant.TAG8.equals(currentNodeTag), SimulationNode::getTag8, uuids) + .in(TagConstant.TAG9.equals(currentNodeTag), SimulationNode::getTag9, uuids) + .in(TagConstant.TAG10.equals(currentNodeTag), SimulationNode::getTag10, uuids) .eq(SimulationNode::getNodeType, nextNodeType) .list(); @@ -866,11 +866,11 @@ public class NodeServiceImpl extends ServiceImpl> getNodeTaskList(String uuid) { - if(ObjectUtils.isEmpty(uuid)){ + public SdmResponse> getNodeTaskList(List uuids) { + if(CollectionUtils.isEmpty(uuids)){ return SdmResponse.success(); } - List simulationTasks = simulationTaskService.lambdaQuery().eq(SimulationTask::getNodeId, uuid).list(); + List simulationTasks = simulationTaskService.lambdaQuery().in(SimulationTask::getNodeId, uuids).list(); if(CollectionUtils.isEmpty(simulationTasks)){ return SdmResponse.success(); } @@ -888,11 +888,11 @@ public class NodeServiceImpl extends ServiceImpl> getTaskRunList(String uuid) { - if(ObjectUtils.isEmpty(uuid)){ + public SdmResponse> getTaskRunList(List uuids) { + if(ObjectUtils.isEmpty(uuids)){ return SdmResponse.success(); } - List simulationRunList = simulationRunService.lambdaQuery().eq(SimulationRun::getTaskId, uuid).list(); + List simulationRunList = simulationRunService.lambdaQuery().eq(SimulationRun::getTaskId, uuids).list(); if(CollectionUtils.isEmpty(simulationRunList)){ return SdmResponse.success(); } From c0c7a0144c1d080487a75dac65461619e05675bf Mon Sep 17 00:00:00 2001 From: gulongcheng <474084054@qq.com> Date: Mon, 15 Dec 2025 20:09:50 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=80=BB=E8=A7=88?= =?UTF-8?q?=E5=A4=9A=E7=BB=B4=E5=BA=A6=E5=90=88=E5=B9=B6=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/inspectionProfiles/Project_Default.xml | 8 ++ .vscode/settings.json | 3 + .../service/IDimensionTemplateService.java | 3 - .../impl/DimensionTemplateServiceImpl.java | 131 ++++++++++++------ 4 files changed, 102 insertions(+), 43 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .vscode/settings.json diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..7693510d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..7b016a89 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java b/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java index 3e20867b..51673ddd 100644 --- a/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java +++ b/data/src/main/java/com/sdm/data/service/IDimensionTemplateService.java @@ -35,9 +35,6 @@ public interface IDimensionTemplateService extends IService { /** * 根据数据显示维度展示左侧节点树 - * dimensionTemplateId+chooseUuid+chooseNodeType根据数据显示维度查询当前节点下的文件夹和文件, - * dimensionTemplateId+fileId支持进入普通文件夹和节点文件夹查询下一层, - * 支持分页查询 * * @param req 获取模拟节点树的请求参数 * @return SdmResponse 响应对象,包含模拟节点树数据或错误信息 diff --git a/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java b/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java index aa063265..f9d152b6 100644 --- a/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java +++ b/data/src/main/java/com/sdm/data/service/impl/DimensionTemplateServiceImpl.java @@ -16,6 +16,7 @@ import com.sdm.common.entity.req.data.UploadFilesReq; import com.sdm.common.entity.req.project.DelNodeReq; import com.sdm.common.entity.req.system.UserQueryReq; import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp; +import com.sdm.common.entity.resp.PageDataResp; import com.sdm.common.entity.resp.data.FileMetadataInfoResp; import com.sdm.common.entity.resp.system.CIDUserResp; import com.sdm.common.feign.impl.project.SimulationNodeFeignClientImpl; @@ -39,6 +40,7 @@ import com.sdm.data.service.IFileMetadataInfoService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -240,19 +242,19 @@ public class DimensionTemplateServiceImpl extends ServiceImpl> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuids); - if (nodeTaskList.isSuccess()) { - uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); - log.info("获取节点下task的uudis:{}", uuids); - } + // 3、获取当前节点下的任务、算列 + SdmResponse> nodeTaskList = simuluationNodeFeignClient.getNodeTaskList(chooseUuids); + if (nodeTaskList.isSuccess()) { + uuids.addAll(nodeTaskList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + log.info("获取节点下task的uudis:{}", uuids); + } - SdmResponse> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuids); - if (taskRunList.isSuccess()) { - uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); - log.info("获取节点下taskRun的uudis:{}", uuids); + SdmResponse> taskRunList = simuluationNodeFeignClient.getTaskRunList(chooseUuids); + if (taskRunList.isSuccess()) { + uuids.addAll(taskRunList.getData().stream().map(AllNodeByProjectIdAndTypeResp::getUuid).toList()); + log.info("获取节点下taskRun的uudis:{}", uuids); + } } } } @@ -318,55 +320,104 @@ public class DimensionTemplateServiceImpl extends ServiceImpl dirInfos = null; - if(ObjectUtils.isEmpty(req.getFileId()) && ObjectUtils.isEmpty(req.getFileIds())){ + + // 处理空参数情况 + if (ObjectUtils.isEmpty(req.getFileId()) && ObjectUtils.isEmpty(req.getFileIds())) { // 第一次进入数据总览页面,右侧不展示文件和文件夹 return SdmResponse.success(); } - if(0L==req.getFileId()){ + // 处理根目录情况 + if (0L == req.getFileId()) { // 和前端规定 0=触发根目录按钮,相当于获取左侧文件树的根节点文件夹 - GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq(); - getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId()); - getSimulationNodeTreeReq.setFileIds(null); - SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); - if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) { - dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList(); - } - - PageHelper.startPage(req.getCurrent(), req.getSize()); - List fileMetadataInfos = fileMetadataInfoService.listSimulationNodeDir(dirInfos, req.isFilterEmptyData(), tenantId); - - PageInfo page = new PageInfo<>(fileMetadataInfos); - return PageUtils.getJsonObjectSdmResponse(fileMetadataInfos, page); + return handleRootDirectory(req, tenantId); } - //fileId 不为空也不为0,是右侧点击进入文件夹下一层级查询 - // relatedResourceUuid和relatedResourceUuidOwnType不为空才是节点文件夹,才需要查询子节点文件夹文件 + // 处理普通目录情况 + return handleNormalDirectory(req, tenantId); + } + + private SdmResponse handleRootDirectory(ListSimulationNodeTreeReq req, Long tenantId) { + GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq(); + getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId()); + getSimulationNodeTreeReq.setFileIds(null); + + SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); + List dirInfos = extractDirIdsFromResponse(nodeDirInfos); + + // 获取所有数据 + List allFileMetadataInfos = fileMetadataInfoService.listSimulationNodeDir(dirInfos, req.isFilterEmptyData(), tenantId); + + return processAndPageResults(allFileMetadataInfos, req); + } + + private SdmResponse handleNormalDirectory(ListSimulationNodeTreeReq req, Long tenantId) { GetSimulationNodeTreeReq getSimulationNodeTreeReq = new GetSimulationNodeTreeReq(); getSimulationNodeTreeReq.setDimensionTemplateId(req.getDimensionTemplateId()); getSimulationNodeTreeReq.setFileIds(req.getFileIds()); + SdmResponse> nodeDirInfos = getSimulationNodeTree(getSimulationNodeTreeReq); - if (nodeDirInfos.isSuccess() && ObjectUtils.isNotEmpty(nodeDirInfos.getData())) { - dirInfos = nodeDirInfos.getData().stream().flatMap(fileMetadataChildrenDTO -> fileMetadataChildrenDTO.getChildren().stream()).map(FileMetadataInfoResp::getId).toList(); + List dirInfos = extractDirIdsFromResponse(nodeDirInfos); + + // 获取所有数据 + List allFileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles( + req.getFileIds(), + dirInfos, + req.isFilterEmptyData(), + tenantId); + + return processAndPageResults(allFileMetadataInfos, req); + } + + private List extractDirIdsFromResponse(SdmResponse> response) { + if (response.isSuccess() && ObjectUtils.isNotEmpty(response.getData())) { + return response.getData().stream() + .flatMap(dto -> dto.getChildren().stream()) + .map(FileMetadataInfoResp::getId) + .toList(); } + return Collections.emptyList(); + } - - PageHelper.startPage(req.getCurrent(), req.getSize()); - List fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(req.getFileIds(), dirInfos,req.isFilterEmptyData(),tenantId); + private SdmResponse processAndPageResults(List fileMetadataInfos, ListSimulationNodeTreeReq req) { + // 设置创建者名称 setCreatorNames(fileMetadataInfos); - PageInfo page = new PageInfo<>(fileMetadataInfos); - return PageUtils.getJsonObjectSdmResponse(fileMetadataInfos, page); + // 使用 mergeNodeDirInfos 处理所有数据 + List mergedResults = mergeNodeDirInfos(fileMetadataInfos); + + // 手动分页 + int pageSize = req.getSize(); + int currentPage = req.getCurrent(); + int fromIndex = (currentPage - 1) * pageSize; + int toIndex = Math.min(fromIndex + pageSize, mergedResults.size()); + + List pagedResults = new ArrayList<>(); + if (fromIndex < mergedResults.size()) { + pagedResults = mergedResults.subList(fromIndex, toIndex); + } + + PageInfo pageInfo = new PageInfo<>(pagedResults); + pageInfo.setTotal(mergedResults.size()); + pageInfo.setPageNum(currentPage); + pageInfo.setPageSize(pageSize); + + return PageUtils.getJsonObjectSdmResponse(pagedResults, pageInfo); } + private void setCreatorNames(List list) { try { if (ObjectUtils.isNotEmpty(list)) {