fix[project]: 从EP拉项目时,若专项代表为空则默认给到钟镇涛,需要给系统和即时通发消息
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.sdm.project.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -13,6 +15,7 @@ import com.sdm.common.entity.req.data.*;
|
||||
import com.sdm.common.entity.req.lyric.SpdmAcceptTodoInfoReq;
|
||||
import com.sdm.common.entity.req.project.SpdmNodeListReq;
|
||||
import com.sdm.common.entity.req.system.DeptQueryReq;
|
||||
import com.sdm.common.entity.req.system.SendMsgReq;
|
||||
import com.sdm.common.entity.req.system.UserListReq;
|
||||
import com.sdm.common.entity.req.system.UserQueryReq;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
@@ -21,6 +24,7 @@ import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.entity.resp.system.SysDeptUserResp;
|
||||
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.MessageFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.SysDeptFeignClientImpl;
|
||||
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
|
||||
import com.sdm.common.log.CoreLogger;
|
||||
@@ -47,6 +51,7 @@ import com.sdm.project.dao.SimulationTaskMapper;
|
||||
import com.sdm.project.model.bo.TaskNodeTag;
|
||||
import com.sdm.project.model.entity.SimulationDemand;
|
||||
import com.sdm.project.model.entity.SimulationNode;
|
||||
import com.sdm.project.model.entity.SimulationNodeMember;
|
||||
import com.sdm.project.model.entity.SimulationTask;
|
||||
import com.sdm.project.model.req.*;
|
||||
import com.sdm.project.model.req.ep.EpProjectQueryReq;
|
||||
@@ -54,6 +59,7 @@ import com.sdm.project.model.req.ep.EpSyncPhaseReq;
|
||||
import com.sdm.project.model.vo.*;
|
||||
import com.sdm.project.service.ILyricInternalService;
|
||||
import com.sdm.project.service.INodeService;
|
||||
import com.sdm.project.service.ISimulationNodeMemberService;
|
||||
import com.sdm.project.service.ISimulationTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -159,6 +165,9 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
@Resource
|
||||
private INodeService nodeService;
|
||||
|
||||
@Autowired
|
||||
private ISimulationNodeMemberService simulationNodeMemberService;
|
||||
|
||||
@Autowired
|
||||
private LyricVProjectStationToDmService lyricVProjectStationToDmService;
|
||||
|
||||
@@ -225,6 +234,9 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
2017166413785972755L, 2017166413785972758L, 2017166413785972774L, 2017166413785972780L, 2017166417586012738L,
|
||||
2017166417586012737L);
|
||||
|
||||
// 仿真专项代表为空时,将钟ZT设置为专项代表
|
||||
Long exFixManagerUserId = 2003641538857771009L;
|
||||
|
||||
// 通过标识判断是否走查询现场视图逻辑(0不查询,1查询)
|
||||
@Value("${lyricFlag:1}")
|
||||
private int lyricFlag;
|
||||
@@ -239,6 +251,9 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
@Resource
|
||||
private SimulationRunServiceImpl simulationRunService;
|
||||
|
||||
@Autowired
|
||||
private MessageFeignClientImpl messageFeignClient;
|
||||
|
||||
/**
|
||||
* 判断字符串是否可以安全转换为Long类型
|
||||
*
|
||||
@@ -2705,6 +2720,15 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMessage(MessageTemplateEnum templateEnum, String projectName, String userId) {
|
||||
SendMsgReq req = new SendMsgReq();
|
||||
req.setTitle(templateEnum.getTitle());
|
||||
req.setContent(templateEnum.getContent(projectName));
|
||||
req.setTenantId(ThreadLocalContext.getTenantId().toString());
|
||||
req.setUserId(userId);
|
||||
messageFeignClient.sendMessage(req);
|
||||
}
|
||||
|
||||
private List<SpdmProjectNodeEditReq> handleNoRelatedProjectTodo(List<LyricVTodoEmulationInfoDM> noRelatedProjectVTodoEmulationInfoDMList, Long tenantId, Long userId, String jobNumber, String userName, Map<String, Long> usernameToUserIdMap) {
|
||||
// 尝试获取锁(立即返回,不等待)
|
||||
if (!syncTodoInfoProjectLock.tryLock()) {
|
||||
@@ -2748,20 +2772,29 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
spdmProjectNodeEditReqList.add(spdmProjectNodeEditReq);
|
||||
if (CollectionUtils.isEmpty(eachPdtToDMList)) {
|
||||
log.info("项目:{},没有仿真代表", spdmProjectNodeEditReq.getNodeName());
|
||||
continue;
|
||||
}
|
||||
for (LyricVPdtToDM lyricVPdtToDM : eachPdtToDMList) {
|
||||
Long pdtUserId = usernameToUserIdMap.get(lyricVPdtToDM.getUser());
|
||||
if (pdtUserId == null) {
|
||||
continue;
|
||||
}
|
||||
SpdmNodeRelateMemberReq simulationNodeMember = new SpdmNodeRelateMemberReq();
|
||||
simulationNodeMember.setNodeId(spdmProjectNodeEditReq.getUuid());
|
||||
simulationNodeMember.setUserId(pdtUserId);
|
||||
simulationNodeMember.setUserId(exFixManagerUserId);
|
||||
simulationNodeMember.setCreator(userId);
|
||||
simulationNodeMember.setCreateTime(curDateStr);
|
||||
simulationNodeMember.setType(NodeMemberTypeEnum.MANAGER.getCode());
|
||||
allNodeManagerList.add(simulationNodeMember);
|
||||
// 给钟ZT发送消息通知
|
||||
sendMessage(MessageTemplateEnum.PROJECT_MANAGER_EMPTY, spdmProjectNodeEditReq.getNodeName(), String.valueOf(exFixManagerUserId));
|
||||
}else {
|
||||
for (LyricVPdtToDM lyricVPdtToDM : eachPdtToDMList) {
|
||||
Long pdtUserId = usernameToUserIdMap.get(lyricVPdtToDM.getUser());
|
||||
if (pdtUserId == null) {
|
||||
continue;
|
||||
}
|
||||
SpdmNodeRelateMemberReq simulationNodeMember = new SpdmNodeRelateMemberReq();
|
||||
simulationNodeMember.setNodeId(spdmProjectNodeEditReq.getUuid());
|
||||
simulationNodeMember.setUserId(pdtUserId);
|
||||
simulationNodeMember.setCreator(userId);
|
||||
simulationNodeMember.setCreateTime(curDateStr);
|
||||
simulationNodeMember.setType(NodeMemberTypeEnum.MANAGER.getCode());
|
||||
allNodeManagerList.add(simulationNodeMember);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3359,7 +3392,9 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
Map<Long, Byte> userPermissions = new HashMap<>();
|
||||
|
||||
List<LyricVPdtToDM> pdtToDMList = pdtMap.get(lyricVProjectToDM.getProjectNum());
|
||||
if (CollectionUtils.isNotEmpty(pdtToDMList)) {
|
||||
if (CollectionUtils.isEmpty(pdtToDMList)) {
|
||||
userPermissions.put(exFixManagerUserId, FilePermissionEnum.ALL.getValue());
|
||||
}else {
|
||||
for (LyricVPdtToDM lyricVPdtToDM : pdtToDMList) {
|
||||
Long pdtUserId = usernameToUserIdMap.get(lyricVPdtToDM.getUser());
|
||||
if (pdtUserId == null) {
|
||||
@@ -4525,6 +4560,71 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
}
|
||||
// 更新待办信息
|
||||
demandMapper.updateById(needToUpdateDemandList);
|
||||
|
||||
// 将没有专项代表的项目,设置钟ZT为专项代表
|
||||
// 查询所有项目节点
|
||||
List<SimulationNode> nodeList = nodeService.lambdaQuery().eq(SimulationNode::getProjectSource, SYNC_PROJECT_SOURCE).list();
|
||||
if (CollectionUtils.isEmpty(nodeList)) {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
// 提取所有项目节点的 UUID 集合
|
||||
List<String> nodeIdList = nodeList.stream().map(SimulationNode::getUuid).toList();
|
||||
|
||||
// 查询所有专项代表信息
|
||||
List<SimulationNodeMember> nodeMemberList = simulationNodeMemberService.lambdaQuery().in(SimulationNodeMember::getNodeId, nodeIdList)
|
||||
.eq(SimulationNodeMember::getType,NodeMemberTypeEnum.MANAGER.getCode()).list();
|
||||
|
||||
// 有专项代表的项目id集合
|
||||
Set<String> hasManagerNodeIdSet = nodeMemberList.stream()
|
||||
.map(SimulationNodeMember::getNodeId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 没有有专项代表的项目
|
||||
List<SimulationNode> noManagerNodeList = nodeList.stream()
|
||||
.filter(node -> !hasManagerNodeIdSet.contains(node.getUuid()))
|
||||
.toList();
|
||||
|
||||
if (CollectionUtils.isEmpty(noManagerNodeList)) {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
Long currentUserId = ThreadLocalContext.getUserId();
|
||||
String currentDataStr = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN);
|
||||
|
||||
// 构建专项代表对象集合
|
||||
List<SimulationNodeMember> simulationNodeMemberList = new ArrayList<>();
|
||||
// 设置权限
|
||||
List<BatchUpdatePermissionReq.FilePermissionItem> filePermissions = new ArrayList<>();
|
||||
|
||||
for (SimulationNode simulationNode : noManagerNodeList) {
|
||||
SimulationNodeMember member = new SimulationNodeMember();
|
||||
member.setNodeId(simulationNode.getUuid());
|
||||
member.setUserId(exFixManagerUserId);
|
||||
member.setType(NodeMemberTypeEnum.MANAGER.getCode());
|
||||
member.setCreateTime(currentDataStr);
|
||||
member.setCreator(currentUserId);
|
||||
simulationNodeMemberList.add(member);
|
||||
BatchUpdatePermissionReq.FilePermissionItem managerItem = new BatchUpdatePermissionReq.FilePermissionItem();
|
||||
managerItem.setUuid(simulationNode.getUuid());
|
||||
Map<Long, Byte> managerPermissions = new HashMap<>();
|
||||
managerPermissions.put(exFixManagerUserId, FilePermissionEnum.ALL.getValue());
|
||||
managerItem.setUserPermissions(managerPermissions);
|
||||
filePermissions.add(managerItem);
|
||||
}
|
||||
|
||||
// 批量更新权限
|
||||
BatchUpdatePermissionReq batchReq = new BatchUpdatePermissionReq();
|
||||
batchReq.setFilePermissions(filePermissions);
|
||||
log.info("手动更新待办数据,批量更新权限,任务数量:{}", filePermissions.size());
|
||||
CompletableFuture.runAsync(() -> {
|
||||
SdmResponse response = dataFeignClient.batchUpdatePermission(batchReq);
|
||||
log.info("手动更新待办数据,批量更新权限结果:{}", response);
|
||||
if (!response.isSuccess()) {
|
||||
log.error("手动更新待办数据,批量更新权限失败:{}", response.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
@@ -4621,6 +4721,14 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
simulationNodeMember.setType(NodeMemberTypeEnum.MANAGER.getCode());
|
||||
allNodeManagerList.add(simulationNodeMember);
|
||||
}
|
||||
}else {
|
||||
SpdmNodeRelateMemberReq simulationNodeMember = new SpdmNodeRelateMemberReq();
|
||||
simulationNodeMember.setNodeId(spdmProjectNodeEditReq.getUuid());
|
||||
simulationNodeMember.setUserId(exFixManagerUserId);
|
||||
simulationNodeMember.setCreator(userId);
|
||||
simulationNodeMember.setCreateTime(curDateStr);
|
||||
simulationNodeMember.setType(NodeMemberTypeEnum.MANAGER.getCode());
|
||||
allNodeManagerList.add(simulationNodeMember);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(allNodeManagerList)) {
|
||||
|
||||
Reference in New Issue
Block a user