Merge branch 'main' of http://192.168.65.198:3000/toolchaintechnologycenter/spdm-backend
# Conflicts: # common/src/main/java/com/sdm/common/entity/enums/FilePermissionEnum.java # project/src/main/java/com/sdm/project/service/impl/ProjectServiceImpl.java # project/src/main/java/com/sdm/project/service/impl/TaskServiceImpl.java
This commit is contained in:
@@ -98,4 +98,6 @@ public interface SimulationNodeMapper extends BaseMapper<SimulationNode> {
|
||||
|
||||
List<PerformanceNodePo> getPerformanceListByIdList(@Param("taskIdList") List<String> taskIdList);
|
||||
|
||||
List<SimulationNode> queryNodeCodeByTags(@Param("list")List<String> tag1List, @Param("tagKey")String tagKey,@Param("tagValue") String tagValue);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sdm.project.dao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.resp.project.SpdmTaskVo;
|
||||
import com.sdm.outbridge.mode.SimulationTaskSyncExBo;
|
||||
import com.sdm.project.model.entity.SimulationTask;
|
||||
import com.sdm.common.entity.resp.project.TaskNodeExtraPo;
|
||||
import com.sdm.project.model.req.SpdmAnalysisTaskListReq;
|
||||
@@ -37,7 +38,7 @@ public interface SimulationTaskMapper extends BaseMapper<SimulationTask> {
|
||||
|
||||
int updateTask(@Param("task") SpdmTaskVo task);
|
||||
|
||||
List<SimulationTask> getUserExecTaskWithinTimeFrame(@Param("req") UserWorkloadReq req);
|
||||
List<SpdmTaskVo> getUserExecTaskWithinTimeFrame(@Param("req") UserWorkloadReq req);
|
||||
|
||||
SpdmTaskVo getTaskById(@Param("id") Long id);
|
||||
|
||||
@@ -63,4 +64,6 @@ public interface SimulationTaskMapper extends BaseMapper<SimulationTask> {
|
||||
|
||||
List<SpdmTaskVo> optimisedGtTaskList(@Param("tenantId") Long tenantId, @Param("req") SpdmTaskListReq req);
|
||||
|
||||
List<SimulationTaskSyncExBo> queryLyricHasNotSyncExceptionDatas();
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public class UserWorkloadReq {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private List<Long> userIdList;
|
||||
|
||||
/*
|
||||
* 用户组id
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sdm.project.model.resp;
|
||||
|
||||
import com.sdm.common.entity.resp.project.SpdmTaskVo;
|
||||
import com.sdm.project.model.entity.SimulationTask;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -31,6 +32,6 @@ public class UserWorkloadResp {
|
||||
/**
|
||||
* 任务列表
|
||||
*/
|
||||
private List<SimulationTask> taskList;
|
||||
private List<SpdmTaskVo> taskList;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.sdm.project.schedule.lyric;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.utils.MdcUtil;
|
||||
import com.sdm.project.service.ILyricInternalService;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class LyricEncExceptionSchedule {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ILyricInternalService lyricInternalService;
|
||||
|
||||
// xxljob平台配置定时任务
|
||||
@XxlJob("lyricEncExceptionHandler")
|
||||
public void lyricEncExceptionHandler() throws Exception {
|
||||
// 初始化traceId
|
||||
String traceId = MdcUtil.generateAndPutTraceId();
|
||||
XxlJobHelper.log("{} XXL-JOB:拉起lyric异常任务信息开始,param:{}", traceId);
|
||||
long startTime = System.currentTimeMillis();
|
||||
SdmResponse response = lyricInternalService.syncException();
|
||||
long endTime = System.currentTimeMillis();
|
||||
long second = (endTime - startTime) / 1000;
|
||||
log.info("{} lyricEncExceptionHandler cost [{}] s", traceId,second);
|
||||
log.info("{} lyricEncExceptionHandler result :{}", traceId,JSON.toJSONString(response));
|
||||
XxlJobHelper.log("{} XXL-JOB:拉起lyric异常任务信息结束:{},耗时:{} s", traceId,JSON.toJSONString(response),second);
|
||||
// 销毁
|
||||
MdcUtil.removeTraceId();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class LyricTodoListSchedule {
|
||||
|
||||
// xxljob平台配置定时任务
|
||||
@XxlJob("lyricTodoListHandler")
|
||||
public void hpcJobStatusHandler() throws Exception {
|
||||
public void lyricTodoListHandler() throws Exception {
|
||||
// 初始化traceId
|
||||
String traceId = MdcUtil.generateAndPutTraceId();
|
||||
String param = XxlJobHelper.getJobParam();
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
import com.sdm.project.model.req.PushReportReq;
|
||||
import com.sdm.project.model.req.ep.EpProjectQueryReq;
|
||||
import com.sdm.project.model.req.ep.EpSyncPhaseReq;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
public interface ILyricInternalService {
|
||||
|
||||
@@ -47,4 +46,7 @@ public interface ILyricInternalService {
|
||||
*/
|
||||
SdmResponse queryProjectMember(String projectId, Integer queryType,Integer current, Integer size);
|
||||
|
||||
/* 同步任务的异常状态 */
|
||||
SdmResponse syncException();
|
||||
|
||||
}
|
||||
|
||||
@@ -688,21 +688,11 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
||||
taskMemberNode.setUserId(userId);
|
||||
taskMemberNode.setType(MemberTypeEnum.PRINCIPAL.getCode());
|
||||
projectNodeMemberList.add(taskMemberNode);
|
||||
// 更新需求负责人对需求文件权限
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(task.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(Long.valueOf(userId), FilePermissionEnum.ALL.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
// 更新任务仿真负责人对任务文件夹的权限
|
||||
filePermissions.add(buildFilePermissionItem(task.getUuid(), Long.valueOf(userId), FilePermissionEnum.ALL));
|
||||
|
||||
// 更新需求负责人对任务文件夹的权限
|
||||
BatchUpdatePermissionReq.FilePermissionItem demandItem = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
demandItem.setUuid(task.getUuid());
|
||||
Map<Long, Byte> demandUserPermissions = new HashMap<>();
|
||||
demandUserPermissions.put(demandCreator, FilePermissionEnum.BASE.getValue());
|
||||
demandItem.setUserPermissions(demandUserPermissions);
|
||||
filePermissions.add(demandItem);
|
||||
// 更新任务仿真负责人对关联的需求文件夹权限
|
||||
filePermissions.add(buildFilePermissionItem(demandId, Long.valueOf(userId), FilePermissionEnum.BASE));
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(eUserIdStr)) {
|
||||
@@ -716,15 +706,22 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
||||
projectNodeMemberList.add(taskMemberNode);
|
||||
// 发送消息通知
|
||||
sendMessage(MessageTemplateEnum.TASK_ISSUE, task.getNodeName(), userId, task.getUuid());
|
||||
// 更新需求执行人对需求文件权限
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(task.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(Long.valueOf(userId), FilePermissionEnum.ALL.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
// 更新任务仿真执行人对任务文件夹权限
|
||||
filePermissions.add(buildFilePermissionItem(task.getUuid(), Long.valueOf(userId), FilePermissionEnum.ALL_EXCLUDE_DELETE));
|
||||
|
||||
// 更新任务仿真执行人对关联的需求文件夹权限
|
||||
filePermissions.add(buildFilePermissionItem(demandId, Long.valueOf(userId), FilePermissionEnum.BASE));
|
||||
}
|
||||
}
|
||||
// 更新需求创建人对任务文件夹的权限
|
||||
filePermissions.add(buildFilePermissionItem(task.getUuid(), demandCreator, FilePermissionEnum.BASE));
|
||||
|
||||
// 更新任务创建人对任务文件夹的权限
|
||||
filePermissions.add(buildFilePermissionItem(task.getUuid(), jobNumber, FilePermissionEnum.READ));
|
||||
|
||||
// 更新任务创建人对需求文件夹的权限
|
||||
filePermissions.add(buildFilePermissionItem(demandId, jobNumber, FilePermissionEnum.READ));
|
||||
|
||||
List<TaskExtraNode> extraList = task.getExtras();
|
||||
if (CollectionUtils.isNotEmpty(extraList)) {
|
||||
for (TaskExtraNode extra : extraList) {
|
||||
@@ -793,23 +790,6 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
||||
for (TaskNode taskNode : taskNodeList) {
|
||||
createDir(taskNode.getUuid(), parentUuid, taskNode.getNodeName());
|
||||
}
|
||||
for (TaskNode taskNode : taskNodeList) {
|
||||
// 更新需求创建人对需求文件夹权限
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(taskNode.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(jobNumber, FilePermissionEnum.ALL.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
|
||||
// 更新需求创建人对任务文件夹的权限
|
||||
BatchUpdatePermissionReq.FilePermissionItem demandItem = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
demandItem.setUuid(taskNode.getUuid());
|
||||
Map<Long, Byte> demandUserPermissions = new HashMap<>();
|
||||
demandUserPermissions.put(demandCreator, FilePermissionEnum.BASE.getValue());
|
||||
demandItem.setUserPermissions(demandUserPermissions);
|
||||
filePermissions.add(demandItem);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(projectNodeExtraList)) {
|
||||
projectNodeExtraList.forEach(projectNode -> projectNode.setCreateTime(createTime));
|
||||
@@ -894,6 +874,15 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
||||
return response;
|
||||
}
|
||||
|
||||
private BatchUpdatePermissionReq.FilePermissionItem buildFilePermissionItem(String uuid, Long userId, FilePermissionEnum filePermissionEnum) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(uuid);
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(userId, filePermissionEnum.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
return item;
|
||||
}
|
||||
|
||||
private void sendMessage(MessageTemplateEnum templateEnum, String taskName, String userId, String uuid) {
|
||||
SendMsgReq req = new SendMsgReq();
|
||||
req.setTitle(templateEnum.getTitle());
|
||||
|
||||
@@ -20,17 +20,19 @@ import com.sdm.common.utils.RandomUtil;
|
||||
import com.sdm.outbridge.entity.*;
|
||||
import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
import com.sdm.outbridge.mode.HkUploadFileReq;
|
||||
import com.sdm.outbridge.mode.LyricExceptionModel;
|
||||
import com.sdm.outbridge.mode.SimulationTaskSyncExBo;
|
||||
import com.sdm.outbridge.service.lyric.*;
|
||||
import com.sdm.project.common.ApprovalStatusEnum;
|
||||
import com.sdm.project.common.MemberTypeEnum;
|
||||
import com.sdm.project.common.generator.UniqueFileNameGenerator;
|
||||
import com.sdm.project.dao.SimulationDemandMapper;
|
||||
import com.sdm.project.dao.SimulationNodeMapper;
|
||||
import com.sdm.project.dao.SimulationProjectMapper;
|
||||
import com.sdm.project.dao.SimulationTaskExtraMapper;
|
||||
import com.sdm.project.dao.SimulationTaskMapper;
|
||||
import com.sdm.project.model.bo.TaskNodeTag;
|
||||
import com.sdm.project.model.entity.SimulationNode;
|
||||
import com.sdm.project.model.entity.SimulationDemand;
|
||||
import com.sdm.project.model.po.ProjectNodePo;
|
||||
import com.sdm.project.model.entity.SimulationNode;
|
||||
import com.sdm.project.model.req.*;
|
||||
import com.sdm.project.model.req.ep.EpProjectQueryReq;
|
||||
import com.sdm.project.model.req.ep.EpSyncPhaseReq;
|
||||
@@ -143,6 +145,18 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
@Value("${lyric.syncTodoDataWaitSeconds:3}")
|
||||
private Long syncTodoDataWaitSeconds;
|
||||
|
||||
@Autowired
|
||||
private SimulationTaskMapper simulationTaskMapper;
|
||||
|
||||
@Autowired
|
||||
private SimulationNodeMapper simulationNodeMapper;
|
||||
|
||||
@Autowired
|
||||
private LyricVProjectStationExcepTionToDMService lyricVProjectStationExcepTionToDMService;
|
||||
|
||||
@Autowired
|
||||
private SimulationTaskExtraMapper simulationTaskExtraMapper;
|
||||
|
||||
/**
|
||||
* 判断字符串是否可以安全转换为Long类型
|
||||
*
|
||||
@@ -362,8 +376,8 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
|
||||
return SdmResponse.success();
|
||||
} catch (Exception e) {
|
||||
log.error("syncTodoData 未知 error: {}", e.getMessage());
|
||||
return SdmResponse.failed();
|
||||
log.error("syncTodoData 未知 error: {}", e.getMessage());
|
||||
return SdmResponse.failed();
|
||||
}finally {
|
||||
syncTodoInfoLock.unlock();
|
||||
if(StringUtils.isNotBlank(traceId)){
|
||||
@@ -1722,6 +1736,57 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
return PageUtils.getJsonObjectSdmResponse(projectMemberList, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步异常任务信息方法
|
||||
*/
|
||||
@Override
|
||||
public SdmResponse syncException() {
|
||||
try {
|
||||
// 1. 查询未同步异常的任务
|
||||
List<SimulationTaskSyncExBo> unsyncedExceptionTasks = queryUnsyncedExceptionTasks();
|
||||
if (CollectionUtils.isEmpty(unsyncedExceptionTasks)) {
|
||||
log.warn("同步异常任务:暂无需要同步的任务");
|
||||
return SdmResponse.success("同步异常任务:暂无需要同步的任务");
|
||||
}
|
||||
|
||||
// 2. 构建标签对应的节点信息映射
|
||||
Map<String, SimulationNode> tag1NodeMap = buildTagNodeMap(unsyncedExceptionTasks, "tag1", "project");
|
||||
Map<String, SimulationNode> tag5NodeMap = buildTagNodeMap(unsyncedExceptionTasks, "tag5", "workspace");
|
||||
|
||||
if (MapUtils.isEmpty(tag1NodeMap) && MapUtils.isEmpty(tag5NodeMap)) {
|
||||
log.warn("同步异常任务:标签对应的节点信息为空");
|
||||
return SdmResponse.success("同步异常任务:标签对应的节点信息为空");
|
||||
}
|
||||
|
||||
// 3. 为任务赋值对应的节点编码
|
||||
assignNodeCodeToTasks(unsyncedExceptionTasks, tag1NodeMap, tag5NodeMap);
|
||||
|
||||
// 4. 过滤出编码完整的任务(tag1Code和tag5Code都不为空)
|
||||
List<SimulationTaskSyncExBo> validTasks = filterValidTasks(unsyncedExceptionTasks);
|
||||
if (CollectionUtils.isEmpty(validTasks)) {
|
||||
log.warn("同步异常任务:过滤后无有效任务(tag1Code/tag5Code为空)");
|
||||
return SdmResponse.success("同步异常任务:过滤后无有效任务");
|
||||
}
|
||||
|
||||
// 5. 查询异常数据并匹配任务
|
||||
List<LyricExceptionModel> newExceptionModels = queryAndMatchExceptions(validTasks);
|
||||
if (CollectionUtils.isEmpty(newExceptionModels)) {
|
||||
log.info("同步异常任务:无新增异常数据需要入库");
|
||||
return SdmResponse.success("同步异常任务:无新增异常数据需要入库");
|
||||
}
|
||||
|
||||
// 6. 批量入库异常数据
|
||||
int syncCount = batchSaveExceptionData(newExceptionModels);
|
||||
|
||||
log.info("同步异常任务完成,本次同步{}条数据", syncCount);
|
||||
return SdmResponse.success("同步成功,本次同步了" + syncCount + "条数据");
|
||||
} catch (Exception e) {
|
||||
log.error("同步异常任务失败", e);
|
||||
return SdmResponse.failed("同步异常任务失败:" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SdmResponse httpSyncTodoData( List<SimulationNode> projectNodeList,List<LyricVTodoEmulationInfoDM> todoInfoList){
|
||||
String traceId = MdcUtil.getTraceId();
|
||||
CompletableFuture<SdmResponse> syncTodoDataFeature = CompletableFuture.supplyAsync(() ->
|
||||
@@ -1744,5 +1809,192 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未同步异常的任务列表
|
||||
*/
|
||||
private List<SimulationTaskSyncExBo> queryUnsyncedExceptionTasks() {
|
||||
return simulationTaskMapper.queryLyricHasNotSyncExceptionDatas();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建标签对应的节点信息映射
|
||||
* @param tasks 任务列表
|
||||
* @param tagField 标签字段名(tag1/tag5)
|
||||
* @param nodeType 节点类型(project/workspace)
|
||||
*/
|
||||
private Map<String, SimulationNode> buildTagNodeMap(List<SimulationTaskSyncExBo> tasks,
|
||||
String tagField,
|
||||
String nodeType) {
|
||||
// 提取非空的标签值列表
|
||||
List<String> tagValues = tasks.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(task -> "tag1".equals(tagField) ? task.getTag1() : task.getTag5())
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.distinct() // 去重,减少查询次数
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(tagValues)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
// 查询标签对应的节点信息
|
||||
List<SimulationNode> nodes = simulationNodeMapper.queryNodeCodeByTags(tagValues, tagField, nodeType);
|
||||
if (CollectionUtils.isEmpty(nodes)) {
|
||||
log.warn("同步异常任务:{}类型节点查询结果为空,标签列表:{}", nodeType, tagValues);
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
// 转换为UUID->节点的映射(处理重复UUID,保留第一个)
|
||||
return nodes.stream()
|
||||
.filter(node -> node != null && StringUtils.isNotBlank(node.getUuid()))
|
||||
.collect(Collectors.toMap(
|
||||
SimulationNode::getUuid,
|
||||
node -> node,
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 为任务赋值对应的节点编码
|
||||
*/
|
||||
private void assignNodeCodeToTasks(List<SimulationTaskSyncExBo> tasks,
|
||||
Map<String, SimulationNode> tag1NodeMap,
|
||||
Map<String, SimulationNode> tag5NodeMap) {
|
||||
tasks.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(task -> {
|
||||
// 赋值tag1Code
|
||||
if (MapUtils.isNotEmpty(tag1NodeMap) && StringUtils.isNotBlank(task.getTag1())) {
|
||||
SimulationNode node = tag1NodeMap.get(task.getTag1());
|
||||
if (node != null) {
|
||||
task.setTag1Code(node.getNodeCode());
|
||||
}
|
||||
}
|
||||
// 赋值tag5Code
|
||||
if (MapUtils.isNotEmpty(tag5NodeMap) && StringUtils.isNotBlank(task.getTag5())) {
|
||||
SimulationNode node = tag5NodeMap.get(task.getTag5());
|
||||
if (node != null) {
|
||||
task.setTag5Code(node.getNodeCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤出tag1Code和tag5Code都不为空的有效任务
|
||||
*/
|
||||
private List<SimulationTaskSyncExBo> filterValidTasks(List<SimulationTaskSyncExBo> tasks) {
|
||||
return tasks.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(task -> StringUtils.isNotBlank(task.getTag1Code())
|
||||
&& StringUtils.isNotBlank(task.getTag5Code()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询异常数据并匹配任务
|
||||
*/
|
||||
private List<LyricExceptionModel> queryAndMatchExceptions(List<SimulationTaskSyncExBo> validTasks) {
|
||||
// 查询EP视图异常数据
|
||||
List<LyricVProjectStationExcepTionToDM> exceptionList = lyricVProjectStationExcepTionToDMService
|
||||
.queryExceptionsByProjectAndStation(validTasks);
|
||||
|
||||
// 匹配异常和任务,返回新增的异常数据
|
||||
return matchExceptionAndTask(exceptionList, validTasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存异常数据到扩展表
|
||||
*/
|
||||
private int batchSaveExceptionData(List<LyricExceptionModel> exceptionModels) {
|
||||
// 构建扩展表数据
|
||||
List<SpdmNodeExtraReq> abnormalExtraList = new ArrayList<>();
|
||||
List<SpdmNodeExtraReq> abnormalDetailExtraList = new ArrayList<>();
|
||||
for (LyricExceptionModel model : exceptionModels) {
|
||||
if (model == null || StringUtils.isBlank(model.getUuid())) {
|
||||
log.warn("同步异常任务:异常模型数据无效,跳过处理,model={}", model);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 构建异常标识扩展记录
|
||||
SpdmNodeExtraReq abnormalExtra = new SpdmNodeExtraReq();
|
||||
abnormalExtra.setNodeId(model.getUuid());
|
||||
abnormalExtra.setPropertyName("abnormal");
|
||||
abnormalExtra.setPropertyValue("1");
|
||||
abnormalExtraList.add(abnormalExtra);
|
||||
|
||||
// 构建异常详情扩展记录(修复原代码空指针问题)
|
||||
SpdmNodeExtraReq detailExtra = new SpdmNodeExtraReq();
|
||||
detailExtra.setNodeId(model.getUuid());
|
||||
detailExtra.setPropertyName("abnormalDetail");
|
||||
detailExtra.setPropertyValue(JSONObject.toJSONString(model));
|
||||
abnormalDetailExtraList.add(detailExtra);
|
||||
}
|
||||
|
||||
// 批量插入异常标识
|
||||
if (CollectionUtils.isNotEmpty(abnormalExtraList)) {
|
||||
int abnormalCount = simulationTaskExtraMapper.addTaskExtraBatch(abnormalExtraList);
|
||||
log.info("同步异常任务:批量插入异常标识{}条,成功{}条", abnormalExtraList.size(), abnormalCount);
|
||||
}
|
||||
|
||||
// 批量插入异常详情
|
||||
if (CollectionUtils.isNotEmpty(abnormalDetailExtraList)) {
|
||||
int detailCount = simulationTaskExtraMapper.addTaskExtraBatch(abnormalDetailExtraList);
|
||||
log.info("同步异常任务:批量插入异常详情{}条,成功{}条", abnormalDetailExtraList.size(), detailCount);
|
||||
}
|
||||
|
||||
return exceptionModels.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配两个集合,筛选符合条件的数据并封装为 LyricExceptionModel 列表
|
||||
* @param exceptionList 异常信息列表
|
||||
* @param noSyncLists 没有同步的有异常的任务同步列表
|
||||
* @return 匹配后的异常模型列表
|
||||
*/
|
||||
public List<LyricExceptionModel> matchExceptionAndTask(List<LyricVProjectStationExcepTionToDM> exceptionList,
|
||||
List<SimulationTaskSyncExBo> noSyncLists) {
|
||||
// 步骤1:预处理 noSyncLists,转换为 Map(key: tag1Code_tag5Code,value: SimulationTaskSyncExBo)
|
||||
// 先过滤掉 tag1Code/tag5Code 为空的无效数据
|
||||
Map<String, SimulationTaskSyncExBo> taskMap = noSyncLists.stream()
|
||||
.filter(bo -> bo != null
|
||||
&& bo.getTag1Code() != null && !bo.getTag1Code().trim().isEmpty()
|
||||
&& bo.getTag5Code() != null && !bo.getTag5Code().trim().isEmpty())
|
||||
.collect(Collectors.toMap(
|
||||
// 组合键:tag1Code + "_" + tag5Code(确保唯一性)
|
||||
bo -> bo.getTag1Code().trim() + "_" + bo.getTag5Code().trim(),
|
||||
// value 为当前 bo 对象
|
||||
bo -> bo,
|
||||
// 若存在重复组合键,保留第一个(避免报错)
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
|
||||
// 步骤2:遍历 exceptionList,匹配并封装结果
|
||||
List<LyricExceptionModel> resultList = exceptionList.stream()
|
||||
// 过滤掉异常列表中的无效数据(null 或关键字段为空)
|
||||
.filter(exception -> exception != null
|
||||
&& exception.getProjectNum() != null && !exception.getProjectNum().trim().isEmpty()
|
||||
&& exception.getStationNum() != null && !exception.getStationNum().trim().isEmpty())
|
||||
.map(exception -> {
|
||||
// 生成匹配键:projectNum + "_" + stationNum
|
||||
String matchKey = exception.getProjectNum().trim() + "_" + exception.getStationNum().trim();
|
||||
// 从 taskMap 中查找匹配的任务对象
|
||||
SimulationTaskSyncExBo matchTask = taskMap.get(matchKey);
|
||||
if (matchTask != null) {
|
||||
// 匹配成功,创建 LyricExceptionModel 对象
|
||||
LyricExceptionModel model = new LyricExceptionModel();
|
||||
model.setUuid(matchTask.getUuid()); // 设置任务的 uuid
|
||||
model.setExceptionModel(exception); // 设置异常信息对象
|
||||
return model;
|
||||
}
|
||||
// 匹配失败返回 null
|
||||
return null;
|
||||
})
|
||||
// 过滤掉匹配失败的 null 元素
|
||||
.filter(model -> model != null)
|
||||
.collect(Collectors.toList());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.entity.resp.project.SimulationNodeResp;
|
||||
import com.sdm.common.entity.resp.project.SimulationRunResp;
|
||||
import com.sdm.common.entity.resp.system.CIDStaffResp;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.entity.resp.system.SysUserGroupDetailResp;
|
||||
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
||||
@@ -1404,6 +1405,7 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
|
||||
@Override
|
||||
public SdmResponse getProjectMemberList(GetProjectListReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String projectNodeId = req.getProjectNodeId();
|
||||
SpdmNodeVo spdmNodeVo = nodeMapper.getNodeById(projectNodeId);
|
||||
@@ -1432,14 +1434,25 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
userIdList.addAll(taskMemberList.stream().map(SimulationTaskMember::getUserId).distinct().toList());
|
||||
}
|
||||
}
|
||||
SdmResponse<List<CIDUserResp>> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build());
|
||||
List<CIDUserResp> userList = cidUserResp.getData();
|
||||
userIdList = userIdList.stream().distinct().toList();
|
||||
|
||||
// SdmResponse<List<CIDUserResp>> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build());
|
||||
// List<CIDUserResp> userList = cidUserResp.getData();
|
||||
SdmResponse<List<CIDStaffResp>> cidStaffResp = sysUserFeignClient.listUserDetailByIds(UserQueryReq.builder()
|
||||
.userIds(userIdList)
|
||||
.tenantId(tenantId)
|
||||
.build());
|
||||
List<CIDStaffResp> userList = cidStaffResp.getData();
|
||||
|
||||
if (CollectionUtils.isEmpty(userList)) {
|
||||
log.error("getProjectMemberList未查询到用户");
|
||||
jsonObject.put("data", new ArrayList<CIDUserResp>());
|
||||
return SdmResponse.success(jsonObject);
|
||||
}
|
||||
jsonObject.put("data", userList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList());
|
||||
jsonObject.put("currentPage", req.getCurrent());
|
||||
jsonObject.put("pageSize", req.getSize());
|
||||
jsonObject.put("total", userList.size());
|
||||
return SdmResponse.success(jsonObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -354,6 +354,32 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
if (!MemberTypeEnum.ATTENTION.equals(memberType)) {
|
||||
// TODO 优化:替换为批量权限更新方法 updateBatchPermission(newMemberIdList, taskUuid)
|
||||
newMemberIdList.forEach(userId -> updatePermission(userId, taskUuid,filePermissionValue));
|
||||
UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq();
|
||||
updatePermissionReq.setUuid(taskUuid);
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
for (Long userId : newMemberIdList) {
|
||||
userPermissions.put(userId, MemberTypeEnum.EXECUTOR.equals(memberType) ? FilePermissionEnum.ALL_EXCLUDE_DELETE.getValue() : FilePermissionEnum.ALL.getValue());
|
||||
}
|
||||
updatePermissionReq.setUserPermissions(userPermissions);
|
||||
log.info("仿真策划时,更新用户权限的参数为:{}",updatePermissionReq);
|
||||
SdmResponse updatePermissionResponse = dataClientFeignClient.updatePermission(updatePermissionReq);
|
||||
log.info("仿真策划时,更新用户权限的返回值为:{}",updatePermissionResponse);
|
||||
// newMemberIdList.forEach(userId -> updatePermission(userId, taskUuid));
|
||||
}
|
||||
}
|
||||
|
||||
private void batchUpdatePermission(List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions) {
|
||||
if (CollectionUtils.isNotEmpty(filePermissions)) {
|
||||
BatchUpdatePermissionReq batchReq = new BatchUpdatePermissionReq();
|
||||
batchReq.setFilePermissions(filePermissions);
|
||||
|
||||
log.info("仿真策划新增任务时,批量更新权限,任务数量:{}", filePermissions.size());
|
||||
SdmResponse response = dataClientFeignClient.batchUpdatePermission(batchReq);
|
||||
log.info("仿真策划新增任务时,批量更新权限结果:{}", response);
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
log.error("批量更新算例权限失败:{}", response.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1465,6 +1491,7 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
TaskMemberNode taskMemberNode = new TaskMemberNode();
|
||||
taskMemberNode.setUserId(String.valueOf(userId));
|
||||
taskMemberNode.setTaskId(projectNode.getUuid());
|
||||
taskMemberNode.setType(MemberTypeEnum.EXECUTOR.getCode());
|
||||
projectNodeMemberList.add(taskMemberNode);
|
||||
}
|
||||
}
|
||||
@@ -1477,6 +1504,7 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
TaskMemberNode taskMemberNode = new TaskMemberNode();
|
||||
taskMemberNode.setUserId(String.valueOf(userId));
|
||||
taskMemberNode.setTaskId(projectNode.getUuid());
|
||||
taskMemberNode.setType(MemberTypeEnum.PRINCIPAL.getCode());
|
||||
projectNodeMemberList.add(taskMemberNode);
|
||||
}
|
||||
}
|
||||
@@ -2028,7 +2056,19 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
for (TaskMemberNode taskMemberNode : principalMemberList) {
|
||||
updatePermission(Long.valueOf(taskMemberNode.getUserId()),taskMemberNode.getTaskId(),FilePermissionEnum.ALL.getValue());
|
||||
}
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
|
||||
for (TaskMemberNode taskMemberNode : taskNodeMemberList) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(taskMemberNode.getTaskId());
|
||||
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(Long.valueOf(taskMemberNode.getUserId()), MemberTypeEnum.EXECUTOR.getCode().equals(taskMemberNode.getType()) ? FilePermissionEnum.ALL_EXCLUDE_DELETE.getValue() : FilePermissionEnum.ALL.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
|
||||
filePermissions.add(item);
|
||||
}
|
||||
batchUpdatePermission(filePermissions);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(projectNodePerformanceList)) {
|
||||
projectNodePerformanceList.forEach(projectNode -> {
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.CommonConstants;
|
||||
import com.sdm.common.entity.constants.NumberConstants;
|
||||
import com.sdm.common.entity.enums.*;
|
||||
import com.sdm.common.entity.flowable.dto.FlowElementDTO;
|
||||
@@ -641,6 +642,33 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
throw new RuntimeException("创建算例文件夹失败:" + runDirResponse.getMessage());
|
||||
}
|
||||
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
|
||||
// 1、任务执行人对任务下自己建的算例文件夹有所有权限
|
||||
BatchUpdatePermissionReq.FilePermissionItem currentUserRunItem = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
currentUserRunItem.setUuid(simulationRun.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(userId, FilePermissionEnum.ALL.getValue());
|
||||
currentUserRunItem.setUserPermissions(userPermissions);
|
||||
filePermissions.add(currentUserRunItem);
|
||||
|
||||
// 2、任务执行人对其他执行人建的算例有预览、下载权限
|
||||
// 查询当前任务下其他算例
|
||||
List<SimulationRun> otherRuns = this.lambdaQuery().eq(SimulationRun::getTaskId, simulationTask.getUuid())
|
||||
.ne(SimulationRun::getCreator, userId).list();
|
||||
if (CollectionUtils.isNotEmpty(otherRuns)) {
|
||||
for (SimulationRun otherRun : otherRuns) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(otherRun.getUuid());
|
||||
Map<Long, Byte> permissions = new HashMap<>();
|
||||
permissions.put(userId, FilePermissionEnum.BASE.getValue());
|
||||
item.setUserPermissions(permissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
batchUpdateRunPermission(filePermissions);
|
||||
|
||||
// 解析流程模板中的节点结构,初始化流程节点表
|
||||
SdmResponse<FlowTemplateResp> flowTemplateResp = flowFeignClient.queryFlowTemplateInfo(simulationRun.getFlowTemplate());
|
||||
if (flowTemplateResp.getData() != null) {
|
||||
@@ -702,6 +730,21 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
}
|
||||
}
|
||||
|
||||
private void batchUpdateRunPermission(List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions) {
|
||||
if (CollectionUtils.isNotEmpty(filePermissions)) {
|
||||
BatchUpdatePermissionReq batchReq = new BatchUpdatePermissionReq();
|
||||
batchReq.setFilePermissions(filePermissions);
|
||||
|
||||
log.info("创建算例时,批量更新权限,任务数量:{}", filePermissions.size());
|
||||
SdmResponse response = dataFeignClient.batchUpdatePermission(batchReq);
|
||||
log.info("创建算例时,批量更新权限结果:{}", response);
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
log.error("批量更新算例权限失败:{}", response.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SdmResponse createDir(String uuid, String parentUuid, String dirName, Integer dirType, String uuidOwnType) {
|
||||
CreateDirReq createDirReq = new CreateDirReq();
|
||||
createDirReq.setUuId(uuid);
|
||||
@@ -715,6 +758,19 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
return response;
|
||||
}
|
||||
|
||||
private SdmResponse createDir(String uuid, Long parentDirId, String dirName, Integer dirType, String uuidOwnType) {
|
||||
CreateDirReq createDirReq = new CreateDirReq();
|
||||
createDirReq.setUuId(uuid);
|
||||
createDirReq.setParDirId(parentDirId);
|
||||
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) {
|
||||
@@ -2051,9 +2107,12 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
req.getFileInfoList().add(req.getImageFileInfo());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(req.getFileInfoList())) {
|
||||
// 试验结果文件不直接放在task下面,要放在task的交付物文件夹的试验结果文件夹下面
|
||||
Long parentId = getParentDirId(req.getTaskId());
|
||||
|
||||
UploadFilesReq filesReq = new UploadFilesReq();
|
||||
BeanUtils.copyProperties(req, filesReq);
|
||||
filesReq.setUuid(req.getTaskId());
|
||||
filesReq.setDirId(parentId);
|
||||
filesReq.setSourceFiles(req.getFileInfoList().stream().map(i -> new UploadFilesReq(i.getFileName(), i.getFileSize(), i.getFileType())).toList());
|
||||
// 批量存储文件信息,返回数据供第二步分片上传使用
|
||||
SdmResponse<List<BatchAddFileInfoResp>> sdmResponse = dataFeignClient.batchAddFileInfo(filesReq);
|
||||
@@ -2074,6 +2133,43 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
return SdmResponse.success(experimentResult.getUuid());
|
||||
}
|
||||
|
||||
private Long getParentDirId(String taskId) {
|
||||
Long parentId = null;
|
||||
QueryDirReq queryDirReq = new QueryDirReq();
|
||||
queryDirReq.setUuid(taskId);
|
||||
queryDirReq.setQueryTarget(DataTypeEnum.DIRECTORY.getValue());
|
||||
queryDirReq.setFileName(CommonConstants.DELIVERABLE_DIR_NAME);
|
||||
queryDirReq.setCurrent(1);
|
||||
queryDirReq.setSize(10);
|
||||
SdmResponse<PageDataResp<List<FileMetadataInfoResp>>> response = dataFeignClient.queryDir(queryDirReq);
|
||||
// 建过交付物文件夹直接取id
|
||||
if (response.getData() != null && CollectionUtils.isNotEmpty(response.getData().getData())) {
|
||||
FileMetadataInfoResp dirFileMetadataInfo = response.getData().getData().get(0);
|
||||
Long parentDirId = dirFileMetadataInfo.getId();
|
||||
// 再查是否建过试验结果文件夹,没有则新建
|
||||
queryDirReq.setUuid(null);
|
||||
queryDirReq.setFileId(parentDirId);
|
||||
queryDirReq.setFileName(CommonConstants.EXPERIMENT_DIR_NAME);
|
||||
SdmResponse<PageDataResp<List<FileMetadataInfoResp>>> expResponse = dataFeignClient.queryDir(queryDirReq);
|
||||
if (expResponse.getData() != null && CollectionUtils.isNotEmpty(expResponse.getData().getData())) {
|
||||
FileMetadataInfoResp expFileMetadataInfo = expResponse.getData().getData().get(0);
|
||||
parentId = expFileMetadataInfo.getId();
|
||||
} else {
|
||||
// 再建试验结果文件夹
|
||||
SdmResponse expResultResponse = createDir(null, parentDirId, CommonConstants.EXPERIMENT_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
parentId = Long.parseLong(expResultResponse.getData().toString());
|
||||
}
|
||||
} else {
|
||||
// 没建过交付物文件夹则新建
|
||||
SdmResponse deliverableDirResponse = createDir(null, taskId, CommonConstants.DELIVERABLE_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
Long parentDirId = Long.parseLong(deliverableDirResponse.getData().toString());
|
||||
// 再建试验结果文件夹
|
||||
SdmResponse expResultResponse = createDir(null, parentDirId, CommonConstants.EXPERIMENT_DIR_NAME, DirTypeEnum.PROJECT_NODE_DIR.getValue(), null);
|
||||
parentId = Long.parseLong(expResultResponse.getData().toString());
|
||||
}
|
||||
return parentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<PageDataResp<List<SimulationExperimentResult>>> listExperimentResult(ExperimentResultReq req) {
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
@@ -2165,9 +2261,11 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
||||
|
||||
// 再处理新增的文件
|
||||
if (CollectionUtils.size(req.getAddFileInfoList()) > 0) {
|
||||
Long parentId = getParentDirId(req.getTaskId());
|
||||
|
||||
UploadFilesReq filesReq = new UploadFilesReq();
|
||||
BeanUtils.copyProperties(req, filesReq);
|
||||
filesReq.setUuid(req.getTaskId());
|
||||
filesReq.setDirId(parentId);
|
||||
filesReq.setSourceFiles(req.getAddFileInfoList().stream().map(i -> new UploadFilesReq(i.getFileName(), i.getFileSize(), i.getFileType())).toList());
|
||||
// 批量存储文件信息,返回数据供第二步分片上传使用
|
||||
batchAddResponse = dataFeignClient.batchAddFileInfo(filesReq);
|
||||
|
||||
@@ -165,7 +165,6 @@ public class SimulationTaskServiceImpl extends ServiceImpl<SimulationTaskMapper,
|
||||
List<Long> longUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList());
|
||||
simulationTaskMemberService.deleteTaskMemberList(req.getUuid(), MemberTypeEnum.EXECUTOR.getCode());
|
||||
simulationTaskMemberService.saveTaskMemberList(req.getUuid(), MemberTypeEnum.EXECUTOR.getCode(), longUserIdList);
|
||||
// 对关联的需求文件夹设置权限
|
||||
}
|
||||
// 设置仿真负责人
|
||||
if (StringUtils.isNotBlank(req.getPMemberList())) {
|
||||
|
||||
@@ -9,10 +9,7 @@ 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.*;
|
||||
import com.sdm.common.entity.req.data.CreateDirReq;
|
||||
import com.sdm.common.entity.req.data.DelDirReq;
|
||||
import com.sdm.common.entity.req.data.QueryFileReq;
|
||||
import com.sdm.common.entity.req.data.UpdatePermissionReq;
|
||||
import com.sdm.common.entity.req.data.*;
|
||||
import com.sdm.common.entity.req.export.PerformanceAnalysisExportExcelFormat;
|
||||
import com.sdm.common.entity.req.export.RunAnalysisExportExcelFormat;
|
||||
import com.sdm.common.entity.req.export.TaskAnalysisExportExcelFormat;
|
||||
@@ -1293,6 +1290,21 @@ public class TaskServiceImpl implements ITaskService {
|
||||
log.info("编辑任务时,更新用户权限的返回值为:{}",updatePermissionResponse);
|
||||
}
|
||||
|
||||
private void batchUpdatePermission(List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions) {
|
||||
if (CollectionUtils.isNotEmpty(filePermissions)) {
|
||||
BatchUpdatePermissionReq batchReq = new BatchUpdatePermissionReq();
|
||||
batchReq.setFilePermissions(filePermissions);
|
||||
|
||||
log.info("编辑任务时,批量更新权限,任务数量:{}", filePermissions.size());
|
||||
SdmResponse response = dataClientFeignClient.batchUpdatePermission(batchReq);
|
||||
log.info("编辑任务时,批量更新权限结果:{}", response);
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
log.error("批量更新算例权限失败:{}", response.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -1306,7 +1318,8 @@ public class TaskServiceImpl implements ITaskService {
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
for (String taskId : taskOpr.getTaskIds()) {
|
||||
req.setTaskId(taskId);
|
||||
if (simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, taskId).count() <= 0) {
|
||||
SimulationTask task = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, taskId).one();
|
||||
if (task == null) {
|
||||
log.error("根据taskId:{},未查询到任务", taskId);
|
||||
return SdmResponse.failed("未查询到任务");
|
||||
}
|
||||
@@ -1358,11 +1371,30 @@ public class TaskServiceImpl implements ITaskService {
|
||||
newUserIdList.forEach(i -> {
|
||||
sendMessage(MessageTemplateEnum.TASK_ISSUE, req.getNodeName(), String.valueOf(i), taskId);
|
||||
});
|
||||
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
// 保存当前的仿真执行人权限
|
||||
for (Long currentUserId : currentUserIdList) {
|
||||
updatePermission(currentUserId,taskId);
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(task.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(currentUserId, FilePermissionEnum.ALL_EXCLUDE_DELETE.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
// 对关联的需求文件夹设置权限
|
||||
// 设置任务执行人对关联的需求文件夹设置权限
|
||||
if (StringUtils.isNotEmpty(task.getDemandId())) {
|
||||
SpdmDemandVo demand = demandMapper.getDemandListById(Collections.singletonList(task.getDemandId())).get(0);
|
||||
for (Long currentUserId : currentUserIdList) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(demand.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(currentUserId, FilePermissionEnum.BASE.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
}
|
||||
batchUpdatePermission(filePermissions);
|
||||
|
||||
|
||||
// if (StringUtils.isNotBlank(req.getEMemberList())) {
|
||||
@@ -1877,6 +1909,8 @@ public class TaskServiceImpl implements ITaskService {
|
||||
@Override
|
||||
public SdmResponse<List<UserWorkloadResp>> listUserWorkloadsWithinTimeFrame(UserWorkloadReq req) {
|
||||
List<UserWorkloadResp> userWorkloadRespList = new ArrayList<>();
|
||||
List<CIDUserResp> userList = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isEmpty(req.getUserIds()) && StringUtils.isEmpty(req.getUserGroupId())) {
|
||||
UserListReq userListReq = new UserListReq();
|
||||
userListReq.setTenantId(ThreadLocalContext.getTenantId());
|
||||
@@ -1886,8 +1920,7 @@ public class TaskServiceImpl implements ITaskService {
|
||||
if (!pageDataRespSdmResponse.isSuccess()) {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
List<Long> userIds = pageDataRespSdmResponse.getData().getData().stream().map(CIDUserResp::getUserId).toList();
|
||||
req.setUserIds(userIds.stream().map(String::valueOf).toList());
|
||||
userList.addAll(pageDataRespSdmResponse.getData().getData());
|
||||
} else if (CollectionUtils.isEmpty(req.getUserIds()) && StringUtils.isNotEmpty(req.getUserGroupId())) {
|
||||
// 查询用户组下所有成员
|
||||
QueryGroupDetailReq groupDetailReq = new QueryGroupDetailReq();
|
||||
@@ -1899,26 +1932,31 @@ public class TaskServiceImpl implements ITaskService {
|
||||
if (response.isSuccess() && ObjectUtils.isNotEmpty(response.getData())
|
||||
&& ObjectUtils.isNotEmpty(response.getData().getUsers())
|
||||
&& ObjectUtils.isNotEmpty(response.getData().getUsers().getData())) {
|
||||
List<String> userIds = response.getData().getUsers().getData().stream()
|
||||
.map(u -> u.getUserId() == null ? null : String.valueOf(u.getUserId()))
|
||||
.toList();
|
||||
req.setUserIds(userIds);
|
||||
userList.addAll(response.getData().getUsers().getData());
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(req.getUserIds())) {
|
||||
SdmResponse<List<CIDUserResp>> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(req.getUserIds().stream().map(Long::valueOf).toList()).build());
|
||||
List<CIDUserResp> 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<SimulationTask> 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);
|
||||
if (CollectionUtils.isNotEmpty(userList)) {
|
||||
List<Long> userIds = userList.stream().map(CIDUserResp::getUserId).toList();
|
||||
Map<Long, String> userNameMap = userList.stream().collect(Collectors.toMap(
|
||||
CIDUserResp::getUserId,
|
||||
CIDUserResp::getNickname
|
||||
));
|
||||
req.setUserIdList(userIds);
|
||||
List<SpdmTaskVo> taskList = mapper.getUserExecTaskWithinTimeFrame(req);
|
||||
if (CollectionUtils.isNotEmpty(taskList)) {
|
||||
Map<String, List<SpdmTaskVo>> userTaskMap = taskList.stream().collect(Collectors.groupingBy(SpdmTaskVo::getEUserId));
|
||||
for(String eUserId : userTaskMap.keySet()){
|
||||
List<SpdmTaskVo> userTaskList = userTaskMap.get(eUserId);
|
||||
|
||||
UserWorkloadResp workloadResp = new UserWorkloadResp();
|
||||
workloadResp.setUserId(eUserId);
|
||||
workloadResp.setUserName(userNameMap.get(Long.valueOf(eUserId)));
|
||||
workloadResp.setTaskNum(userTaskList.size());
|
||||
workloadResp.setWorkNum(userTaskList.stream().filter(i -> Arrays.asList(TaskExeStatusEnum.NO_STARTED.getCode(), TaskExeStatusEnum.IN_PROGRESS.getCode()).contains(i.getExeStatus())).toList().size());
|
||||
workloadResp.setWorkload(userTaskList.stream().filter(i -> i.getDays() != null).mapToDouble(SpdmTaskVo::getDays).sum());
|
||||
workloadResp.setTaskList(userTaskList);
|
||||
userWorkloadRespList.add(workloadResp);
|
||||
}
|
||||
}
|
||||
}
|
||||
userWorkloadRespList = userWorkloadRespList.stream()
|
||||
@@ -3726,6 +3764,24 @@ public class TaskServiceImpl implements ITaskService {
|
||||
if (!simulationTaskService.updateById(simulationTask)) {
|
||||
throw new RuntimeException("编辑任务:" + simulationTask.getTaskName() + "失败");
|
||||
}
|
||||
public SdmResponse batchOperation(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%,请核查");
|
||||
}
|
||||
String curDateStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
for (String taskId : taskOpr.getTaskIds()) {
|
||||
req.setTaskId(taskId);
|
||||
SimulationTask task = simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, taskId).one();
|
||||
if (task == null) {
|
||||
log.error("根据taskId:{},未查询到任务", taskId);
|
||||
return SdmResponse.failed("未查询到任务");
|
||||
}
|
||||
if (!simulationTaskService.updateSimulationTask(req)) {
|
||||
return SdmResponse.failed("编辑任务失败");
|
||||
}
|
||||
|
||||
// 原来的仿真执行人
|
||||
List<SimulationTaskMember> oldEMemberList = simulationTaskMemberService.lambdaQuery()
|
||||
@@ -3778,6 +3834,80 @@ public class TaskServiceImpl implements ITaskService {
|
||||
// 新增拓展属性
|
||||
List<SimulationTaskExtra> extraList = req.getExtras();
|
||||
if (CollectionUtils.isNotEmpty(extraList)) {
|
||||
// 原来的仿真执行人
|
||||
List<SimulationTaskMember> oldEMemberList = simulationTaskMemberService.lambdaQuery()
|
||||
.eq(SimulationTaskMember::getTaskId, taskId)
|
||||
.eq(SimulationTaskMember::getType, MemberTypeEnum.EXECUTOR.getCode()).list();
|
||||
List<Long> oldEMemberIdList = new ArrayList<>();
|
||||
// eMemberList传空字符串代表要清空仿真执行人,传null代表不对仿真执行人做操作
|
||||
if (CollectionUtils.isNotEmpty(oldEMemberList) && Objects.equals(req.getEMemberList(), "")) {
|
||||
oldEMemberIdList = oldEMemberList.stream().map(SimulationTaskMember::getUserId).toList();
|
||||
// 删除原来的仿真执行人信息
|
||||
simulationTaskMemberService.deleteTaskMemberList(taskId, MemberTypeEnum.EXECUTOR.getCode());
|
||||
// 删除原来的仿真执行人权限
|
||||
for (SimulationTaskMember simulationTaskMember : oldEMemberList) {
|
||||
deletePermission(simulationTaskMember.getUserId(),simulationTaskMember.getTaskId());
|
||||
}
|
||||
}
|
||||
// 找出新的仿真执行人
|
||||
List<Long> currentUserIdList = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(req.getEMemberList())) {
|
||||
String[] userIdArr = req.getEMemberList().split(",");
|
||||
currentUserIdList = Arrays.stream(userIdArr).filter(s -> !s.isEmpty()).map(Long::valueOf).collect(Collectors.toList());
|
||||
}
|
||||
List<Long> newUserIdList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(currentUserIdList)) {
|
||||
if (CollectionUtils.isEmpty(oldEMemberIdList)) {
|
||||
newUserIdList = currentUserIdList;
|
||||
}else {
|
||||
for (Long currentUserId : currentUserIdList) {
|
||||
if (!oldEMemberIdList.contains(currentUserId)) {
|
||||
newUserIdList.add(currentUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("老用户id为:{}",oldEMemberIdList);
|
||||
log.info("新用户id为:{}",newUserIdList);
|
||||
if (CollectionUtils.isNotEmpty(currentUserIdList)) {
|
||||
if (!simulationTaskMemberService.saveTaskMemberList(taskId, MemberTypeEnum.EXECUTOR.getCode(), currentUserIdList)) {
|
||||
return SdmResponse.failed("编辑仿真执行人失败");
|
||||
}
|
||||
}
|
||||
// 发送消息通知
|
||||
newUserIdList.forEach(i -> {
|
||||
sendMessage(MessageTemplateEnum.TASK_ISSUE, req.getNodeName(), String.valueOf(i), taskId);
|
||||
});
|
||||
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
// 保存当前的仿真执行人权限
|
||||
for (Long currentUserId : currentUserIdList) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(task.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(currentUserId, FilePermissionEnum.ALL_EXCLUDE_DELETE.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
// 设置任务执行人对关联的需求文件夹设置权限
|
||||
if (StringUtils.isNotEmpty(task.getDemandId())) {
|
||||
SpdmDemandVo demand = demandMapper.getDemandListById(Collections.singletonList(task.getDemandId())).get(0);
|
||||
for (Long currentUserId : currentUserIdList) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(demand.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(currentUserId, FilePermissionEnum.BASE.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
}
|
||||
batchUpdatePermission(filePermissions);
|
||||
|
||||
// 新增拓展属性
|
||||
List<SimulationTaskExtra> extraList = req.getExtras();
|
||||
if (CollectionUtils.isEmpty(extraList)) {
|
||||
continue;
|
||||
}
|
||||
List<SimulationTaskExtra> saveExtraList = extraList.stream().filter(extra -> ObjectUtils.isEmpty(extra.getId())).toList();
|
||||
if (CollectionUtils.isNotEmpty(saveExtraList)) {
|
||||
saveExtraList.forEach(extra -> {
|
||||
@@ -3867,7 +3997,7 @@ public class TaskServiceImpl implements ITaskService {
|
||||
// 所有tag都相同
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 工具方法:比较两个String,处理null值
|
||||
|
||||
@@ -168,9 +168,9 @@ xxl:
|
||||
# 执行器应用名称 服务名-job-executor
|
||||
appname: project-job-executor
|
||||
# 执行器注册地址:默认使用address注册,若为null则使用ip:port注册
|
||||
address: ${XXL_JOB_EXECUTOR_IP:}
|
||||
address:
|
||||
# 执行器IP
|
||||
ip:
|
||||
ip: ${XXL_JOB_EXECUTOR_IP:}
|
||||
# 执行器端口,为了好记,web服务端口+1000
|
||||
port: 8101
|
||||
# 执行器日志路径
|
||||
|
||||
@@ -168,9 +168,9 @@ xxl:
|
||||
# 执行器应用名称 服务名-job-executor
|
||||
appname: project-job-executor
|
||||
# 执行器注册地址:默认使用address注册,若为null则使用ip:port注册
|
||||
address: ${XXL_JOB_EXECUTOR_IP:}
|
||||
address:
|
||||
# 执行器IP
|
||||
ip:
|
||||
ip: ${XXL_JOB_EXECUTOR_IP:}
|
||||
# 执行器端口,为了好记,web服务端口+1000
|
||||
port: 8101
|
||||
# 执行器日志路径
|
||||
|
||||
@@ -172,9 +172,9 @@ xxl:
|
||||
# 执行器应用名称 服务名-job-executor
|
||||
appname: project-job-executor
|
||||
# 执行器注册地址:默认使用address注册,若为null则使用ip:port注册
|
||||
address: ${XXL_JOB_EXECUTOR_IP:}
|
||||
address:
|
||||
# 执行器IP
|
||||
ip:
|
||||
ip: ${XXL_JOB_EXECUTOR_IP:}
|
||||
# 执行器端口,为了好记,web服务端口+1000
|
||||
port: 8101
|
||||
# 执行器日志路径
|
||||
|
||||
@@ -169,9 +169,9 @@ xxl:
|
||||
# 执行器应用名称 服务名-job-executor
|
||||
appname: project-job-executor
|
||||
# 执行器注册地址:默认使用address注册,若为null则使用ip:port注册
|
||||
address: ${XXL_JOB_EXECUTOR_IP:}
|
||||
address:
|
||||
# 执行器IP
|
||||
ip:
|
||||
ip: ${XXL_JOB_EXECUTOR_IP:}
|
||||
# 执行器端口,为了好记,web服务端口+1000
|
||||
port: 8101
|
||||
# 执行器日志路径
|
||||
|
||||
@@ -705,4 +705,18 @@
|
||||
select * from simulation_node where uuid = #{projectId} and nodeName = #{projectName} and nodeType = 'project' limit 1
|
||||
</select>
|
||||
|
||||
<select id="queryNodeCodeByTags" resultType="com.sdm.project.model.entity.SimulationNode">
|
||||
SELECT nodeCode,uuid
|
||||
FROM spdm_baseline.simulation_node
|
||||
WHERE nodeType = #{tagValue}
|
||||
<!-- 处理 List<String> 的 IN 条件,防止空列表导致 SQL 报错 -->
|
||||
<if test="list != null and list.size() > 0">
|
||||
AND ${tagKey} IN
|
||||
<foreach collection="list" item="tag" open="(" separator="," close=")">
|
||||
#{tag}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -216,15 +216,21 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getUserExecTaskWithinTimeFrame" resultType="com.sdm.project.model.entity.SimulationTask">
|
||||
<select id="getUserExecTaskWithinTimeFrame" resultType="com.sdm.common.entity.resp.project.SpdmTaskVo">
|
||||
select
|
||||
distinct st.*
|
||||
distinct st.*,
|
||||
stm.user_id as eUserId
|
||||
from
|
||||
simulation_task st
|
||||
inner join simulation_task_member stm on st.uuid = stm.task_id
|
||||
where
|
||||
stm.type = 1
|
||||
and stm.user_id = #{req.userId}
|
||||
and stm.user_id in (
|
||||
<foreach collection='req.userIdList' item='userId' index='index' separator=','>
|
||||
#{userId}
|
||||
</foreach>
|
||||
)
|
||||
|
||||
<if test="req.beginTime != null and req.beginTime != ''">
|
||||
<![CDATA[
|
||||
and STR_TO_DATE(st.begin_time,'%Y-%m-%d') >= #{req.beginTime}
|
||||
@@ -682,5 +688,11 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="queryLyricHasNotSyncExceptionDatas" resultType="com.sdm.outbridge.mode.SimulationTaskSyncExBo">
|
||||
select id,uuid,tag1,tag5 from simulation_task
|
||||
where uuid not in(select task_id from simulation_task_extra where property_name='abnormal')
|
||||
and tag1 is not null and tag5 is not null
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user