Merge remote-tracking branch 'origin/main'
This commit is contained in:
1
1-sql/2026-02-02/simulation_node_member.sql
Normal file
1
1-sql/2026-02-02/simulation_node_member.sql
Normal file
@@ -0,0 +1 @@
|
||||
CREATE INDEX idx_snm_userid_nodeId ON simulation_node_member (user_id, nodeId);
|
||||
2
1-sql/2026-02-02/simulation_task.sql
Normal file
2
1-sql/2026-02-02/simulation_task.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
CREATE INDEX idx_st_uuid_tenantid ON simulation_task (uuid, tenant_id);
|
||||
CREATE INDEX idx_st_tenantid_tag1 ON simulation_task (tenant_id, tag1);
|
||||
1
1-sql/2026-02-02/simulation_task_member.sql
Normal file
1
1-sql/2026-02-02/simulation_task_member.sql
Normal file
@@ -0,0 +1 @@
|
||||
CREATE INDEX idx_stm_userid_taskid ON simulation_task_member (user_id, task_id);
|
||||
@@ -289,4 +289,15 @@ public class SimulationTaskController implements ISimulationTaskFeignClient {
|
||||
return taskService.queryProjectUserLoads(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量操作任务
|
||||
* @param taskOpr
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/batchOperation")
|
||||
@Operation(summary = "批量操作任务", description = "批量操作任务")
|
||||
public SdmResponse batchOperation(@RequestBody SpdmTaskOpr taskOpr) {
|
||||
return taskService.batchOperation(taskOpr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,4 +76,15 @@ public class SpdmTaskOprReq {
|
||||
*/
|
||||
private String confidence;
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -104,4 +104,9 @@ public class SpdmNodeVo extends BaseEntity {
|
||||
* 军令状时间
|
||||
*/
|
||||
private String commitmentDeadline;
|
||||
|
||||
/**
|
||||
* 当前阶段
|
||||
*/
|
||||
private String currentPhase;
|
||||
}
|
||||
|
||||
@@ -102,4 +102,6 @@ public interface ITaskService {
|
||||
*/
|
||||
SdmResponse<List<ProjectUserLoadResp>> queryProjectUserLoads(ProjectUserLoadReq req);
|
||||
|
||||
SdmResponse batchOperation(SpdmTaskOpr taskOpr);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.sdm.outbridge.entity.*;
|
||||
import com.sdm.outbridge.mode.GetProcessDataReq;
|
||||
import com.sdm.outbridge.mode.HkUploadFileReq;
|
||||
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;
|
||||
@@ -607,19 +608,29 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
}
|
||||
}
|
||||
|
||||
// 批量更新权限(异步)
|
||||
// 批量更新权限
|
||||
if (CollectionUtils.isNotEmpty(updatePermissionList)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
for (UpdatePermissionReq permissionReq : updatePermissionList) {
|
||||
try {
|
||||
SdmResponse permissionResp = dataFeignClient.updatePermission(permissionReq);
|
||||
log.info("更新需求[{}]权限响应: {}", permissionReq.getUuid(), permissionResp);
|
||||
} catch (Exception e) {
|
||||
log.error("更新需求[{}]权限异常: ", permissionReq.getUuid(), e);
|
||||
}
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
for (UpdatePermissionReq updatePermissionReq : updatePermissionList) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(updatePermissionReq.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(updatePermissionReq.getUserId(), FilePermissionEnum.ALL.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
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());
|
||||
}
|
||||
},projectTaskThreadPoolExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1353,20 +1364,27 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
uploadFileReq.setXmh(req.getProjectCode());
|
||||
uploadFileReq.setGwh(req.getWorkspaceCode());
|
||||
uploadFileReq.setFiles(Collections.singletonList(zipFilePath));
|
||||
try {
|
||||
lyricIntegrateService.uploadHkFile(jobNumber, uploadFileReq);
|
||||
} catch (Exception e) {
|
||||
log.error("推送zip异常:{}", e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
// 删除临时路径
|
||||
log.info("删除临时路径:{},中。。。。。。", tempPath);
|
||||
String finalJobNumber = jobNumber;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
FilesUtil.deleteFolderNonRecursive(tempPath);
|
||||
} catch (IOException e) {
|
||||
lyricIntegrateService.uploadHkFile(finalJobNumber, uploadFileReq);
|
||||
} catch (Exception e) {
|
||||
log.error("推送zip异常:{}", e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
// 删除临时路径
|
||||
log.info("删除临时路径:{},中。。。。。。", tempPath);
|
||||
try {
|
||||
FilesUtil.deleteFolderNonRecursive(tempPath);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
},projectTaskThreadPoolExecutor);
|
||||
nodeService.lambdaUpdate().set(SimulationNode::getApprovalStatus, String.valueOf(ApprovalStatusEnum.ING.getCode()))
|
||||
.eq(SimulationNode::getNodeCode, req.getWorkspaceCode())
|
||||
.eq(SimulationNode::getNodeType, NodeTypeEnum.WORKSPACE.getValue())
|
||||
.update();
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -202,19 +202,28 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return SdmResponse.failed("操作节点失败,原因:新增节点时失败!");
|
||||
}
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
// 批量更新权限
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
for (SpdmProjectNodeEditReq addNode : addNodeList) {
|
||||
// 更新文件权限
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq();
|
||||
updatePermissionReq.setUserId(userId);
|
||||
updatePermissionReq.setUuid(addNode.getUuid());
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(addNode.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(userId, FilePermissionEnum.ALL.getValue());
|
||||
updatePermissionReq.setUserPermissions(userPermissions);
|
||||
log.info("创建项目阶段时,更新用户权限的参数为:{}",updatePermissionReq);
|
||||
SdmResponse updatePermissionResponse = dataFeignClient.updatePermission(updatePermissionReq);
|
||||
log.info("创建项目阶段时,更新用户权限的返回值为:{}",updatePermissionResponse);
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
for (SpdmProjectNodeEditReq addNode : addNodeList) {
|
||||
String projectSource = addNode.getProjectSource();
|
||||
String nodeType = addNode.getNodeType();
|
||||
@@ -454,12 +463,162 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
spdmNodeVo.setCreatorObj(userMap.get(creator));
|
||||
}
|
||||
}
|
||||
// 将当前阶段放到项目对象中返回
|
||||
setCurrentPhase(nodeList);
|
||||
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data", nodeList);
|
||||
jsonObject.put("total", total);
|
||||
return SdmResponse.success(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置项目当前阶段信息
|
||||
* @param nodeList
|
||||
*/
|
||||
public void setCurrentPhase(List<SpdmNodeVo> nodeList) {
|
||||
// 过滤出自建和EP的项目
|
||||
// EP类型项目
|
||||
List<SpdmNodeVo> epProjectNodeList = nodeList.stream().filter(node -> SYNC_PROJECT_SOURCE.equals(node.getProjectSource())).toList();
|
||||
// 自建类型项目
|
||||
List<SpdmNodeVo> dmProjectNodeList = nodeList.stream().filter(node -> !SYNC_PROJECT_SOURCE.equals(node.getProjectSource())).toList();
|
||||
if (CollectionUtils.isNotEmpty(epProjectNodeList)) {
|
||||
// 设置EP类型项目
|
||||
setEpCurrentPhase(dmProjectNodeList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(dmProjectNodeList)) {
|
||||
// 设置自建类型项目
|
||||
setDmCurrentPhase(dmProjectNodeList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置EP类型项目当前阶段信息
|
||||
* @param dmProjectNodeList
|
||||
*/
|
||||
private void setEpCurrentPhase(List<SpdmNodeVo> dmProjectNodeList) {
|
||||
// 1. 提取节点编码
|
||||
List<String> nodeCodeList = dmProjectNodeList.stream()
|
||||
.map(SpdmNodeVo::getNodeCode)
|
||||
// 过滤空的nodeCode,避免无效查询和后续匹配问题
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(nodeCodeList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 查询视图数据
|
||||
Map<String, String> projectStageMap;
|
||||
try {
|
||||
List<LyricVProjectToDM> lyricVProjectList = lyricVProjectToDmService.lambdaQuery()
|
||||
.in(LyricVProjectToDM::getProjectNum, nodeCodeList)
|
||||
.list();
|
||||
// 3. 转换为Map
|
||||
projectStageMap = lyricVProjectList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
LyricVProjectToDM::getProjectNum, // key:项目编号(nodeCode)
|
||||
LyricVProjectToDM::getStage, // value:当前阶段
|
||||
// 解决重复key问题:保留第一个值
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
} catch (MyBatisSystemException ex) {
|
||||
log.warn("查询EP项目信息并设置当前阶段发生异常,项目编号:{}", nodeCodeList, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 设置当前阶段
|
||||
dmProjectNodeList.forEach(spdmNodeVo -> {
|
||||
String nodeCode = spdmNodeVo.getNodeCode();
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(nodeCode)) {
|
||||
spdmNodeVo.setCurrentPhase(projectStageMap.get(nodeCode));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具方法:将时间字符串解析为时间戳,解析失败抛运行时异常
|
||||
* @param timeStr 时间字符串(yyyy-MM-dd HH:mm:ss)
|
||||
* @param sdf 时间格式化器
|
||||
* @return 时间戳
|
||||
*/
|
||||
private long parseTimeToMillis(String timeStr, SimpleDateFormat sdf) {
|
||||
try {
|
||||
return sdf.parse(timeStr).getTime();
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException("时间解析失败,时间字符串:" + timeStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具方法:判断当前时间是否落在阶段节点的[开始时间, 结束时间]范围内
|
||||
* @param phaseNode 阶段节点
|
||||
* @param currentTime 当前时间戳
|
||||
* @param sdf 时间格式化器
|
||||
* @return true-在范围内,false-不在/解析失败
|
||||
*/
|
||||
private boolean isCurrentTimeInRange(SimulationNode phaseNode, long currentTime, SimpleDateFormat sdf) {
|
||||
try {
|
||||
long beginTime = sdf.parse(phaseNode.getBeginTime()).getTime();
|
||||
long endTime = sdf.parse(phaseNode.getEndTime()).getTime();
|
||||
return currentTime >= beginTime && currentTime <= endTime;
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException("阶段节点时间解析失败,节点ID:" + phaseNode.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自建项目当前阶段信息
|
||||
* @param nodeList
|
||||
*/
|
||||
private void setDmCurrentPhase(List<SpdmNodeVo> nodeList) {
|
||||
List<String> nodeUuidList = nodeList.stream()
|
||||
.map(SpdmNodeVo::getUuid)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 1. 初始化时间格式化器
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// 2. 查询所有父节点为目标节点的阶段类型节点
|
||||
List<SimulationNode> allPhaseNodeList = this.lambdaQuery()
|
||||
.in(SimulationNode::getParentId, nodeUuidList)
|
||||
.eq(SimulationNode::getNodeType, NodeTypeEnum.PHASE.getValue())
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(allPhaseNodeList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 按项目节点ID(tag1)分组,预处理:过滤时间为空的节点
|
||||
Map<String, List<SimulationNode>> phaseNodeByProjectIdMap = allPhaseNodeList.stream()
|
||||
.filter(phaseNode -> StringUtils.isNotBlank(phaseNode.getBeginTime())
|
||||
&& StringUtils.isNotBlank(phaseNode.getEndTime()))
|
||||
.collect(Collectors.groupingBy(SimulationNode::getTag1));
|
||||
|
||||
// 4. 获取当前时间戳
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
// 5. 遍历每个项目节点的阶段列表,判断当前生效阶段
|
||||
phaseNodeByProjectIdMap.forEach((projectNodeId, phaseNodeList) -> {
|
||||
// 按开始时间升序排序
|
||||
List<SimulationNode> sortedPhaseNodeList = phaseNodeList.stream()
|
||||
.sorted(Comparator.comparingLong(phaseNode -> parseTimeToMillis(phaseNode.getBeginTime(), sdf)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查找当前时间落在【开始时间, 结束时间】内的阶段节点
|
||||
SimulationNode currentPhaseNode = sortedPhaseNodeList.stream()
|
||||
.filter(phaseNode -> isCurrentTimeInRange(phaseNode, currentTime, sdf))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// 找到当前阶段,回写至对应的SpdmNodeVo
|
||||
if (Objects.nonNull(currentPhaseNode)) {
|
||||
nodeList.stream()
|
||||
.filter(node -> projectNodeId.equals(node.getUuid()))
|
||||
.findFirst()
|
||||
.ifPresent(node -> node.setCurrentPhase(currentPhaseNode.getNodeName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private List<SpdmProjectNodeEditReq> addNode(List<SpdmProjectNodeEditReq> addNodeList, List<TaskNodeTag> tagMap, Long tenantId, Long jobNumber) {
|
||||
log.info("addNode参数为:{}", addNodeList);
|
||||
@@ -3192,22 +3351,45 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
return;
|
||||
}
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
log.info("开始异步更新{}条权限记录", permissionReqList.size());
|
||||
for (UpdatePermissionReq permissionReq : permissionReqList) {
|
||||
try {
|
||||
SdmResponse updateResponse = dataFeignClient.updatePermission(permissionReq);
|
||||
if (!updateResponse.isSuccess()) {
|
||||
log.warn("更新权限失败,需求ID:{},用户ID:{},响应:{}",
|
||||
permissionReq.getUuid(), permissionReq.getUserId(), updateResponse);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("更新权限异常,需求ID:{},用户ID:{}",
|
||||
permissionReq.getUuid(), permissionReq.getUserId(), e);
|
||||
// 批量更新需求权限
|
||||
if (CollectionUtils.isNotEmpty(permissionReqList)) {
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
for (UpdatePermissionReq updatePermissionReq : permissionReqList) {
|
||||
BatchUpdatePermissionReq.FilePermissionItem item = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
item.setUuid(updatePermissionReq.getUuid());
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
userPermissions.put(updatePermissionReq.getUserId(), FilePermissionEnum.ALL.getValue());
|
||||
item.setUserPermissions(userPermissions);
|
||||
filePermissions.add(item);
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
log.info("异步更新权限完成");
|
||||
}, projectTaskThreadPoolExecutor);
|
||||
}
|
||||
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
// log.info("开始异步更新{}条权限记录", permissionReqList.size());
|
||||
// for (UpdatePermissionReq permissionReq : permissionReqList) {
|
||||
// try {
|
||||
// SdmResponse updateResponse = dataFeignClient.updatePermission(permissionReq);
|
||||
// if (!updateResponse.isSuccess()) {
|
||||
// log.warn("更新权限失败,需求ID:{},用户ID:{},响应:{}",
|
||||
// permissionReq.getUuid(), permissionReq.getUserId(), updateResponse);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("更新权限异常,需求ID:{},用户ID:{}",
|
||||
// permissionReq.getUuid(), permissionReq.getUserId(), e);
|
||||
// }
|
||||
// }
|
||||
// log.info("异步更新权限完成");
|
||||
// }, projectTaskThreadPoolExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -568,8 +568,8 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
String tag6 = eachNode.getTag6();
|
||||
String tag7 = eachNode.getTag7();
|
||||
String tag8 = eachNode.getTag8();
|
||||
String tag9 = eachNode.getTag9();
|
||||
String tag10 = eachNode.getTag10();
|
||||
// String tag9 = eachNode.getTag9();
|
||||
// String tag10 = eachNode.getTag10();
|
||||
int currentNodeDepth = 0;
|
||||
if (StringUtils.isNotBlank(tag1) && !tag1.equals("null")) {
|
||||
currentNodeDepth += tag1.split(",").length;
|
||||
@@ -595,12 +595,12 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
|
||||
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;
|
||||
}
|
||||
// if (StringUtils.isNotBlank(tag9) && !tag9.equals("null")) {
|
||||
// currentNodeDepth += tag9.split(",").length;
|
||||
// }
|
||||
// if (StringUtils.isNotBlank(tag10) && !tag10.equals("null")) {
|
||||
// currentNodeDepth += tag10.split(",").length;
|
||||
// }
|
||||
return currentNodeDepth;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,36 @@ public class SimulationTaskServiceImpl extends ServiceImpl<SimulationTaskMapper,
|
||||
if (req.getExpStatus() != null) {
|
||||
wrapper.set(SimulationTask::getExpStatus, req.getExpStatus());
|
||||
}
|
||||
if (req.getTag1() != null) {
|
||||
wrapper.set(SimulationTask::getTag1, req.getTag1());
|
||||
}
|
||||
if (req.getTag2() != null) {
|
||||
wrapper.set(SimulationTask::getTag2, req.getTag2());
|
||||
}
|
||||
if (req.getTag3() != null) {
|
||||
wrapper.set(SimulationTask::getTag3, req.getTag3());
|
||||
}
|
||||
if (req.getTag4() != null) {
|
||||
wrapper.set(SimulationTask::getTag4, req.getTag4());
|
||||
}
|
||||
if (req.getTag5() != null) {
|
||||
wrapper.set(SimulationTask::getTag5, req.getTag5());
|
||||
}
|
||||
if (req.getTag6() != null) {
|
||||
wrapper.set(SimulationTask::getTag6, req.getTag6());
|
||||
}
|
||||
if (req.getTag7() != null) {
|
||||
wrapper.set(SimulationTask::getTag7, req.getTag7());
|
||||
}
|
||||
if (req.getTag8() != null) {
|
||||
wrapper.set(SimulationTask::getTag8, req.getTag8());
|
||||
}
|
||||
if (req.getTag9() != null) {
|
||||
wrapper.set(SimulationTask::getTag9, req.getTag9());
|
||||
}
|
||||
if (req.getTag10() != null) {
|
||||
wrapper.set(SimulationTask::getTag10, req.getTag10());
|
||||
}
|
||||
wrapper.set(SimulationTask::getCreator, ThreadLocalContext.getUserId());
|
||||
wrapper.set(SimulationTask::getUpdateTime, DateUtil.now());
|
||||
return this.update(wrapper);
|
||||
|
||||
@@ -3667,6 +3667,101 @@ public class TaskServiceImpl implements ITaskService {
|
||||
return SdmResponse.success(buildProjectUserLoadResponse(projectNodeList, taskData, projectNodeReferenceItemMap,tenantId,req.getBeginTime(),req.getEndTime()));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
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);
|
||||
if (simulationTaskService.lambdaQuery().eq(SimulationTask::getUuid, taskId).count() <= 0) {
|
||||
log.error("根据taskId:{},未查询到任务", taskId);
|
||||
return SdmResponse.failed("未查询到任务");
|
||||
}
|
||||
if (!simulationTaskService.updateSimulationTask(req)) {
|
||||
return SdmResponse.failed("编辑任务失败");
|
||||
}
|
||||
|
||||
// 原来的仿真执行人
|
||||
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);
|
||||
});
|
||||
// 保存当前的仿真执行人权限
|
||||
for (Long currentUserId : currentUserIdList) {
|
||||
updatePermission(currentUserId,taskId);
|
||||
}
|
||||
// 新增拓展属性
|
||||
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 -> {
|
||||
extra.setTaskId(taskId);
|
||||
extra.setCreateTime(curDateStr);
|
||||
extra.setCreator(userId);
|
||||
});
|
||||
simulationTaskExtraService.saveBatch(saveExtraList);
|
||||
}
|
||||
List<SimulationTaskExtra> updateExtraList = extraList.stream().filter(extra -> ObjectUtils.isNotEmpty(extra.getId())).toList();
|
||||
if (CollectionUtils.isEmpty(updateExtraList)) {
|
||||
continue;
|
||||
}
|
||||
for (SimulationTaskExtra simulationTaskExtra : updateExtraList) {
|
||||
simulationTaskExtraService.lambdaUpdate().set(SimulationTaskExtra::getPropertyValue, simulationTaskExtra.getPropertyValue())
|
||||
.eq(SimulationTaskExtra::getId, simulationTaskExtra.getId())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user