1、修改listNoPermission接口

This commit is contained in:
2026-03-11 16:50:28 +08:00
parent 39bcdfb20e
commit c416fa81d5

View File

@@ -70,6 +70,7 @@ import java.lang.reflect.Field;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -208,6 +209,10 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
2017166413785972755L, 2017166413785972758L, 2017166413785972774L, 2017166413785972780L, 2017166417586012738L,
2017166417586012737L);
// 通过标识判断是否走查询现场视图逻辑0不查询1查询
@Value("${lyricFlag:1}")
private int lyricFlag;
/**
* 判断字符串是否可以安全转换为Long类型
*
@@ -2161,12 +2166,161 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
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(epProjectNodeList);
}
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. 查询视图数据
if (lyricFlag == 1) {
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 (StringUtils.isNotBlank(nodeCode)) {
spdmNodeVo.setCurrentPhase(projectStageMap.get(nodeCode));
}
});
}
}
/**
* 设置自建项目当前阶段信息
* @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 = nodeService.lambdaQuery()
.in(SimulationNode::getParentId, nodeUuidList)
.eq(SimulationNode::getNodeType, NodeTypeEnum.PHASE.getValue())
.list();
if (CollectionUtils.isEmpty(allPhaseNodeList)) {
return;
}
// 3. 按项目节点IDtag1分组预处理过滤时间为空的节点
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()));
}
});
}
/**
* 工具方法:将时间字符串解析为时间戳,解析失败抛运行时异常
* @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);
}
}
/**
* 查询固定时间内的待办数据
*/