fix[project]: 仿真专项代表角色能看到所有项目
This commit is contained in:
@@ -23,4 +23,9 @@ public class CommonConstants {
|
||||
*/
|
||||
public static final String EXPERIMENT_DIR_NAME = "试验结果";
|
||||
|
||||
/**
|
||||
* 仿真专项代表角色编码
|
||||
*/
|
||||
public static final String SIMULATION_REPRESENT = "SIMULATION_REPRESENT";
|
||||
|
||||
}
|
||||
|
||||
@@ -118,6 +118,11 @@ public interface SimulationNodeMapper extends BaseMapper<SimulationNode> {
|
||||
|
||||
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,
|
||||
@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);
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.ExportExcelFormat;
|
||||
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.enums.*;
|
||||
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.project.SimulationNodeResp;
|
||||
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.CIDUserResp;
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否仿真专项代表
|
||||
* @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
|
||||
public SdmResponse list(SpdmNodeListReq req) {
|
||||
int pos = (req.getCurrent() - 1) * req.getSize();
|
||||
@@ -664,33 +677,47 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
|
||||
int total;
|
||||
// type=0,查询所有,使用原有查询逻辑
|
||||
if (type == null || type == 0) {
|
||||
// 查询当前用户作为任务成员的项目id集合
|
||||
List<String> projectIdList = Optional.ofNullable(
|
||||
simulationTaskMemberService.lambdaQuery()
|
||||
.eq(SimulationTaskMember::getUserId, userId)
|
||||
.list()
|
||||
)
|
||||
.filter(CollectionUtils::isNotEmpty)
|
||||
.stream()
|
||||
.flatMap(List::stream)
|
||||
.map(SimulationTaskMember::getTaskId)
|
||||
.distinct()
|
||||
.filter(StringUtils::isNotBlank) // 防止taskId为空
|
||||
.toList()
|
||||
.stream()
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.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);
|
||||
// 利元亨定制逻辑:仿真专项代表角色能看到所有项目
|
||||
boolean simulationRepresent = false;
|
||||
if (lyricFlag == 1) {
|
||||
simulationRepresent = isSimulationRepresent(userId);
|
||||
}
|
||||
|
||||
if (simulationRepresent) {
|
||||
nodeList = nodeMapper.getAllNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(),
|
||||
tenantId, pos, limit, userId, type);
|
||||
total = nodeMapper.getAllNodeListCountByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(), tenantId, userId, type);
|
||||
}else {
|
||||
// 查询当前用户作为任务成员的项目id集合
|
||||
List<String> projectIdList = Optional.ofNullable(
|
||||
simulationTaskMemberService.lambdaQuery()
|
||||
.eq(SimulationTaskMember::getUserId, userId)
|
||||
.list()
|
||||
)
|
||||
.filter(CollectionUtils::isNotEmpty)
|
||||
.stream()
|
||||
.flatMap(List::stream)
|
||||
.map(SimulationTaskMember::getTaskId)
|
||||
.distinct()
|
||||
.filter(StringUtils::isNotBlank) // 防止taskId为空
|
||||
.toList()
|
||||
.stream()
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.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)) {
|
||||
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) {
|
||||
nodeList = nodeMapper.getNodeListByUserId(req.getNodeType(), req.getNodeSubType(), req.getExeStatus(), req.getNodeCode(), req.getManager(), req.getNodeName(),
|
||||
tenantId, pos, limit, userId, type, Collections.emptyList());
|
||||
|
||||
@@ -1168,5 +1168,71 @@
|
||||
ORDER BY n.create_time DESC
|
||||
</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>
|
||||
Reference in New Issue
Block a user