fix:数据统计用户需要分租户

This commit is contained in:
2026-01-23 10:35:26 +08:00
parent 9a2c8d8795
commit 8787d10e4b
7 changed files with 21 additions and 9 deletions

View File

@@ -178,6 +178,7 @@ public class SimulationNodeController implements ISimulationNodeFeignClient {
@PostMapping("/getAllUserTaskCompleteStatistics")
@Operation(summary = "所有项目的人员任务完成情况统计", description = "所有项目的人员任务完成情况统计")
public SdmResponse getAllUserTaskCompleteStatistics(@RequestBody @Validated GetAllUserTaskCompleteStatisticsReq req) {
req.setTenantId(ThreadLocalContext.getTenantId());
return nodeService.getAllUserTaskCompleteStatistics(req);
}
@@ -188,7 +189,7 @@ public class SimulationNodeController implements ISimulationNodeFeignClient {
@GetMapping("/getUserGroupProjectStatistics")
@Operation(summary = "用户组项目统计", description = "用户组项目统计")
public SdmResponse getUserGroupProjectStatistics(@Parameter(description = "用户组ID")@RequestParam( value = "userGroupId" )@NotNull(message = "用户组IDuserGroupId为必传参数请补充后重试") Long userGroupId, @Parameter(description = "用户ID")@RequestParam( value = "userId", required = false) Long userId) {
return nodeService.getUserGroupProjectStatistics(userGroupId,userId);
return nodeService.getUserGroupProjectStatistics(userGroupId,userId,ThreadLocalContext.getTenantId());
}
/**
@@ -201,6 +202,7 @@ public class SimulationNodeController implements ISimulationNodeFeignClient {
@PostMapping("/getUserGroupTaskCompleteStatistics")
@Operation(summary = "用户组任务完成情况统计", description = "用户组任务完成情况统计")
public SdmResponse getUserGroupTaskCompleteStatistics(@RequestBody @Validated GetUserGroupTaskCompleteStatisticsReq req) {
req.setTenantId(ThreadLocalContext.getTenantId());
return nodeService.getUserGroupTaskCompleteStatistics(req);
}

View File

@@ -74,7 +74,7 @@ public interface SimulationNodeMapper extends BaseMapper<SimulationNode> {
List<SpdmNodeVo> getNodeListByIds(@Param("nodeIdList") List<String> nodeIdList);
List<UserGroupProjectVo> getUserGroupProjectStatistics(@Param("userIds")Set<Long> userIds );
List<UserGroupProjectVo> getUserGroupProjectStatistics(@Param("userIds")Set<Long> userIds, @Param("tenantId")Long tenantId);
List<UserGroupTaskCompleteVo> getUserGroupTaskCompleteStatistics(@Param("req") GetUserGroupTaskCompleteStatisticsReq req);

View File

@@ -11,6 +11,8 @@ import java.util.List;
@Data
@Schema(description = "所有项目的人员任务完成情况统计")
public class GetAllUserTaskCompleteStatisticsReq {
@Schema(description = "租户ID")
private Long tenantId;
@Schema(description = "用户列表")
private List<Long> userIds;

View File

@@ -20,6 +20,9 @@ public class GetUserGroupTaskCompleteStatisticsReq {
@Schema(description = "用户ID")
private Long userId;
@Schema(description = "租户ID")
private Long tenantId;
@Schema(description = "用户")
private Set<Long> userIds;

View File

@@ -41,7 +41,7 @@ public interface INodeService extends IService<SimulationNode> {
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> getTaskRunList(List<String> uuids);
SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId);
SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId,Long tenantId);
SdmResponse getUserGroupTaskCompleteStatistics(GetUserGroupTaskCompleteStatisticsReq req);

View File

@@ -8,7 +8,6 @@ import com.sdm.common.common.ResultCode;
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.TagConstant;
import com.sdm.common.entity.enums.DirTypeEnum;
import com.sdm.common.entity.enums.FilePermissionEnum;
@@ -22,7 +21,6 @@ import com.sdm.common.entity.resp.AllNodeByProjectIdAndTypeResp;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.project.SimulationNodeResp;
import com.sdm.common.entity.resp.project.SimulationRunResp;
import com.sdm.common.entity.resp.system.CIDStaffResp;
import com.sdm.common.entity.resp.system.CIDUserResp;
import com.sdm.common.entity.resp.system.SysUserGroupDetailResp;
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
@@ -1240,7 +1238,7 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
}
@Override
public SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId) {
public SdmResponse getUserGroupProjectStatistics(Long userGroupId, Long userId,Long tenantId) {
Map<Long, String> userId2Nickname = getUserIdToNicknameMap(userGroupId);
if (MapUtils.isEmpty(userId2Nickname)) {
return SdmResponse.success();
@@ -1253,7 +1251,7 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
userIds.add(userId);
}
List<UserGroupProjectVo> userGroupProjectStatistics = this.baseMapper.getUserGroupProjectStatistics(userIds);
List<UserGroupProjectVo> userGroupProjectStatistics = this.baseMapper.getUserGroupProjectStatistics(userIds,tenantId );
if (CollectionUtils.isEmpty(userGroupProjectStatistics)) {
return SdmResponse.success(new ArrayList<>());
}

View File

@@ -339,7 +339,11 @@
nodeId,
user_id as userId
from simulation_node_member
where user_id in (
left join simulation_node on simulation_node_member.nodeId = simulation_node.uuid
where
simulation_node.tenantId = #{tenantId}
and
user_id in (
<foreach collection='userIds' item='userId' index='index' separator=','>
#{userId}
</foreach>
@@ -354,6 +358,8 @@
from simulation_task task
left join simulation_task_member task_member on task.uuid = task_member.task_id
<where>
task.tenant_Id = #{req.tenantId}
and
task_member.user_id in
(
<foreach collection='req.userIds' item='userId' index='index' separator=','>
@@ -406,7 +412,8 @@
from simulation_task task
left join simulation_task_member task_member on task.uuid = task_member.task_id
<where>
task_member.user_id in
task.tenant_Id = #{req.tenantId}
and task_member.user_id in
(
<foreach collection='req.userIds' item='userId' index='index' separator=','>
#{userId}