fix[project]: 仿真专项代表角色能看到所有项目

This commit is contained in:
2026-04-18 15:09:32 +08:00
parent 1dd1be3007
commit d9690a8a4e
4 changed files with 130 additions and 28 deletions

View File

@@ -23,4 +23,9 @@ public class CommonConstants {
*/ */
public static final String EXPERIMENT_DIR_NAME = "试验结果"; public static final String EXPERIMENT_DIR_NAME = "试验结果";
/**
* 仿真专项代表角色编码
*/
public static final String SIMULATION_REPRESENT = "SIMULATION_REPRESENT";
} }

View File

@@ -118,6 +118,11 @@ public interface SimulationNodeMapper extends BaseMapper<SimulationNode> {
List<TaskNodePo> getTaskListByPhaseNodeId(@Param("nodeId") String nodeId); List<TaskNodePo> getTaskListByPhaseNodeId(@Param("nodeId") String nodeId);
List<SpdmNodeVo> getAllNodeListByUserId(@Param("nodeType") String nodeType, @Param("nodeSubType") String nodeSubType, @Param("exeStatus") String exeStatus, @Param("nodeCode") String nodeCode,
@Param("manager") String manager, @Param("nodeName") String nodeName, @Param("tenantId") Long tenantId, @Param("pos") int pos, @Param("limit") int limit, @Param("userId") Long userId,@Param("type") Integer type);
int getAllNodeListCountByUserId(@Param("nodeType") String nodeType, @Param("nodeSubType") String nodeSubType, @Param("exeStatus") String exeStatus, @Param("nodeCode") String nodeCode,
@Param("manager") String manager, @Param("nodeName") String nodeName, @Param("tenantId") Long tenantId, @Param("userId") Long userId,@Param("type") Integer type);
List<SpdmNodeVo> getNodeListByUserId(@Param("nodeType") String nodeType, @Param("nodeSubType") String nodeSubType, @Param("exeStatus") String exeStatus, @Param("nodeCode") String nodeCode, List<SpdmNodeVo> getNodeListByUserId(@Param("nodeType") String nodeType, @Param("nodeSubType") String nodeSubType, @Param("exeStatus") String exeStatus, @Param("nodeCode") String nodeCode,
@Param("manager") String manager, @Param("nodeName") String nodeName, @Param("tenantId") Long tenantId, @Param("pos") int pos, @Param("limit") int limit, @Param("userId") Long userId,@Param("type") Integer type,@Param("projectIdList") List<String> projectIdList); @Param("manager") String manager, @Param("nodeName") String nodeName, @Param("tenantId") Long tenantId, @Param("pos") int pos, @Param("limit") int limit, @Param("userId") Long userId,@Param("type") Integer type,@Param("projectIdList") List<String> projectIdList);

View File

@@ -15,6 +15,7 @@ import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext; import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.entity.ExportExcelFormat; import com.sdm.common.entity.ExportExcelFormat;
import com.sdm.common.entity.bo.DataDictionary; import com.sdm.common.entity.bo.DataDictionary;
import com.sdm.common.entity.constants.CommonConstants;
import com.sdm.common.entity.constants.TagConstant; import com.sdm.common.entity.constants.TagConstant;
import com.sdm.common.entity.enums.*; import com.sdm.common.entity.enums.*;
import com.sdm.common.entity.req.data.*; import com.sdm.common.entity.req.data.*;
@@ -27,6 +28,7 @@ import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.data.BatchCreateNormalDirResp; import com.sdm.common.entity.resp.data.BatchCreateNormalDirResp;
import com.sdm.common.entity.resp.project.SimulationNodeResp; import com.sdm.common.entity.resp.project.SimulationNodeResp;
import com.sdm.common.entity.resp.project.SimulationRunResp; import com.sdm.common.entity.resp.project.SimulationRunResp;
import com.sdm.common.entity.resp.system.CIDRoleResp;
import com.sdm.common.entity.resp.system.CIDStaffResp; import com.sdm.common.entity.resp.system.CIDStaffResp;
import com.sdm.common.entity.resp.system.CIDUserResp; import com.sdm.common.entity.resp.system.CIDUserResp;
import com.sdm.common.entity.resp.system.SysUserGroupDetailResp; import com.sdm.common.entity.resp.system.SysUserGroupDetailResp;
@@ -652,6 +654,17 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
return deleteNode(childrenNodeList.stream().map(SpdmNodeVo::getUuid).toList()); return deleteNode(childrenNodeList.stream().map(SpdmNodeVo::getUuid).toList());
} }
/**
* 是否仿真专项代表
* @param userId 用户ID
* @return
*/
private boolean isSimulationRepresent(Long userId) {
SdmResponse<List<CIDRoleResp>> listSdmResponse = sysUserFeignClient.queryUserRole(userId);
if(!listSdmResponse.isSuccess()) return false;
return listSdmResponse.getData().stream().anyMatch(role -> role.getRoleCode().equals(CommonConstants.SIMULATION_REPRESENT));
}
@Override @Override
public SdmResponse list(SpdmNodeListReq req) { public SdmResponse list(SpdmNodeListReq req) {
int pos = (req.getCurrent() - 1) * req.getSize(); int pos = (req.getCurrent() - 1) * req.getSize();
@@ -664,33 +677,47 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
int total; int total;
// type=0查询所有使用原有查询逻辑 // type=0查询所有使用原有查询逻辑
if (type == null || type == 0) { if (type == null || type == 0) {
// 查询当前用户作为任务成员的项目id集合 // 利元亨定制逻辑:仿真专项代表角色能看到所有项目
List<String> projectIdList = Optional.ofNullable( boolean simulationRepresent = false;
simulationTaskMemberService.lambdaQuery() if (lyricFlag == 1) {
.eq(SimulationTaskMember::getUserId, userId) simulationRepresent = isSimulationRepresent(userId);
.list() }
)
.filter(CollectionUtils::isNotEmpty) if (simulationRepresent) {
.stream() nodeList = nodeMapper.getAllNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(),
.flatMap(List::stream) tenantId, pos, limit, userId, type);
.map(SimulationTaskMember::getTaskId) total = nodeMapper.getAllNodeListCountByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), tenantId, userId, type);
.distinct() }else {
.filter(StringUtils::isNotBlank) // 防止taskId为空 // 查询当前用户作为任务成员的项目id集合
.toList() List<String> projectIdList = Optional.ofNullable(
.stream() simulationTaskMemberService.lambdaQuery()
.filter(StringUtils::isNotBlank) .eq(SimulationTaskMember::getUserId, userId)
.map(taskIds -> taskService.lambdaQuery() .list()
.in(SimulationTask::getUuid, taskIds) )
.list() .filter(CollectionUtils::isNotEmpty)
) .stream()
.filter(CollectionUtils::isNotEmpty) .flatMap(List::stream)
.flatMap(List::stream) .map(SimulationTaskMember::getTaskId)
.map(SimulationTask::getTag1) .distinct()
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank) // 防止taskId为空
.distinct() .toList()
.toList(); .stream()
nodeList = nodeMapper.getNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), .filter(StringUtils::isNotBlank)
tenantId, pos, limit, userId, type, projectIdList); .map(taskIds -> taskService.lambdaQuery()
.in(SimulationTask::getUuid, taskIds)
.list()
)
.filter(CollectionUtils::isNotEmpty)
.flatMap(List::stream)
.map(SimulationTask::getTag1)
.filter(StringUtils::isNotBlank)
.distinct()
.toList();
nodeList = nodeMapper.getNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(),
tenantId, pos, limit, userId, type, projectIdList);
total = nodeMapper.getNodeListCountByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), tenantId, userId, type, projectIdList);
}
// 设置关注标签 // 设置关注标签
if (CollectionUtils.isNotEmpty(nodeList)) { if (CollectionUtils.isNotEmpty(nodeList)) {
List<String> nodeIdList = nodeList.stream().map(SpdmNodeVo::getUuid).toList(); List<String> nodeIdList = nodeList.stream().map(SpdmNodeVo::getUuid).toList();
@@ -705,7 +732,6 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
} }
} }
} }
total = nodeMapper.getNodeListCountByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), tenantId, userId, type, projectIdList);
} else if (type == 1) { } else if (type == 1) {
nodeList = nodeMapper.getNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), nodeList = nodeMapper.getNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(),
tenantId, pos, limit, userId, type, Collections.emptyList()); tenantId, pos, limit, userId, type, Collections.emptyList());

View File

@@ -1168,5 +1168,71 @@
ORDER BY n.create_time DESC ORDER BY n.create_time DESC
</select> </select>
<select id="getAllNodeListByUserId" resultType="com.sdm.project.model.vo.SpdmNodeVo">
SELECT distinct sn.*, IFNULL(pin.pinnedType, 0) as pinnedType, pin.pinnedTime
FROM simulation_node sn
LEFT JOIN (
SELECT nodeId, 1 as pinnedType, create_time as pinnedTime
FROM simulation_node_member
WHERE user_id = #{userId} AND type = 2
) pin ON sn.uuid = pin.nodeId
where sn.tenantId = #{tenantId}
<if test="nodeType != null and nodeType != ''">
and sn.nodeType = #{nodeType}
</if>
<if test="nodeSubType != null and nodeSubType != ''">
and sn.nodeSubType = #{nodeSubType}
</if>
<if test="exeStatus != null and exeStatus != ''">
and sn.exe_status = #{exeStatus}
</if>
<if test="nodeCode != null and nodeCode != ''">
<bind name="searchKey1" value="'%' + nodeCode + '%'"/>
and sn.nodeCode like #{searchKey1}
</if>
<if test="manager != null and manager != ''">
<bind name="searchKey2" value="'%' + manager + '%'"/>
and snm.name like #{searchKey2}
</if>
<if test="nodeName != null and nodeName != ''">
<bind name="searchKey3" value="'%' + nodeName + '%'"/>
and sn.nodeName like #{searchKey3}
</if>
order by IFNULL(pin.pinnedType, 0) desc, pin.pinnedTime desc, sn.create_time desc
limit #{pos},#{limit}
</select>
<select id="getAllNodeListCountByUserId" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT sn.id)
FROM simulation_node sn
LEFT JOIN (
SELECT nodeId, 1 as pinnedType, create_time as pinnedTime
FROM simulation_node_member
WHERE user_id = #{userId} AND type = 2
) pin ON sn.uuid = pin.nodeId
where sn.tenantId = #{tenantId}
<if test="nodeType != null and nodeType != ''">
and sn.nodeType = #{nodeType}
</if>
<if test="nodeSubType != null and nodeSubType != ''">
and sn.nodeSubType = #{nodeSubType}
</if>
<if test="exeStatus != null and exeStatus != ''">
and sn.exe_status = #{exeStatus}
</if>
<if test="nodeCode != null and nodeCode != ''">
<bind name="searchKey1" value="'%' + nodeCode + '%'"/>
and sn.nodeCode like #{searchKey1}
</if>
<if test="manager != null and manager != ''">
<bind name="searchKey2" value="'%' + manager + '%'"/>
and snm.name like #{searchKey2}
</if>
<if test="nodeName != null and nodeName != ''">
<bind name="searchKey3" value="'%' + nodeName + '%'"/>
and sn.nodeName like #{searchKey3}
</if>
</select>
</mapper> </mapper>