1、项目详情,项目成员任务进度统计接口

2、项目详情,项目成员难度系数统计接口
This commit is contained in:
2025-12-04 17:02:27 +08:00
parent 653593c655
commit de412d6fc5
8 changed files with 224 additions and 5 deletions

View File

@@ -157,4 +157,23 @@ public class SimulationTaskController {
return taskService.getPerformanceCompleteStatistics(req);
}
/**
* 项目成员任务进度统计
*/
@PostMapping("/getUserTaskCompleteStatistics")
@Operation(summary = "项目成员任务进度统计", description = "项目成员任务进度统计")
public SdmResponse getUserTaskCompleteStatistics(@RequestBody @Validated UserTaskCompleteStatisticsReq req) {
return taskService.getUserTaskCompleteStatistics(req);
}
/**
* 项目成员难度系数统计
*
*/
@PostMapping("/getUserDifficultyStatistics")
@Operation(summary = "项目成员难度系数统计", description = "项目成员难度系数统计")
public SdmResponse getUserDifficultyStatistics(@RequestBody @Validated UserDifficultCompleteStatisticsReq req) {
return taskService.getUserDifficultyStatistics(req);
}
}

View File

@@ -43,4 +43,8 @@ public interface SimulationTaskMapper extends BaseMapper<SimulationTask> {
List<CommonGetCompleteFromPerformanceVo> getPerformanceCompleteStatistics(@Param("req") PerformanceCompleteStatisticsReq req);
List<UserGroupTaskCompleteVo> getUserTaskCompleteStatistics(@Param("req") UserTaskCompleteStatisticsReq req);
List<UserGroupDifficultyVo> getUserDifficultyStatistics(@Param("req") UserDifficultCompleteStatisticsReq req);
}

View File

@@ -0,0 +1,21 @@
package com.sdm.project.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* 项目成员任务进度统计请求参数
*/
@Data
@Schema(description = "项目成员任务进度统计请求参数")
public class UserDifficultCompleteStatisticsReq {
@Schema(description = "标签1")
private String tag1;
@Schema(description = "用户")
private List<Long> userIds;
}

View File

@@ -0,0 +1,23 @@
package com.sdm.project.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
import java.util.Set;
/**
* 项目成员任务进度统计请求参数
*/
@Data
@Schema(description = "项目成员任务进度统计请求参数")
public class UserTaskCompleteStatisticsReq {
@Schema(description = "标签1")
private String tag1;
@Schema(description = "用户")
private List<Long> userIds;
}

View File

@@ -58,4 +58,8 @@ public interface ITaskService {
SdmResponse getCommonCompleteStatistics(TaskCompleteStatisticsReq req);
SdmResponse getPerformanceCompleteStatistics(PerformanceCompleteStatisticsReq req);
SdmResponse getUserTaskCompleteStatistics(UserTaskCompleteStatisticsReq req);
SdmResponse getUserDifficultyStatistics(UserDifficultCompleteStatisticsReq req);
}

View File

@@ -695,11 +695,13 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
@Override
public SdmResponse getProjectMemberList(GetProjectListReq req) {
JSONObject jsonObject = new JSONObject();
String projectNodeId = req.getProjectNodeId();
SpdmNodeVo spdmNodeVo = nodeMapper.getNodeById(projectNodeId);
if (ObjectUtils.isEmpty(spdmNodeVo)) {
log.error("根据projectNodeId{},未查询到团队成员", projectNodeId);
return SdmResponse.success(new ArrayList<>());
jsonObject.put("data", new ArrayList<CIDUserResp>());
return SdmResponse.success(jsonObject);
}
List<String> allNodeIdList = new ArrayList<>();
allNodeIdList.add(spdmNodeVo.getUuid());
@@ -707,7 +709,8 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
List<SpdmNodeMemberVo> spdmNodeMemberVoList = nodeMapper.getNodeMemberListByNodeIdList(allNodeIdList);
if (CollectionUtils.isEmpty(spdmNodeMemberVoList)) {
log.error("allNodeIdList{},未查询到团队成员", allNodeIdList);
return SdmResponse.success(new ArrayList<>());
jsonObject.put("data", new ArrayList<CIDUserResp>());
return SdmResponse.success(jsonObject);
}
List<Long> userIdList = spdmNodeMemberVoList.stream().map(SpdmNodeMemberVo::getUserId).distinct().collect(Collectors.toList());
;
@@ -722,12 +725,11 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
}
SdmResponse<List<CIDUserResp>> cidUserResp = sysUserFeignClient.listUserByIds(UserQueryReq.builder().userIds(userIdList).build());
List<CIDUserResp> userList = cidUserResp.getData();
if (CollectionUtils.isEmpty(userList)) {
log.error("getProjectMemberList未查询到用户");
return SdmResponse.success(new ArrayList<>());
jsonObject.put("data", new ArrayList<CIDUserResp>());
return SdmResponse.success(jsonObject);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", userList.stream().skip((long) (req.getCurrent() - 1) * req.getSize()).limit(req.getSize()).toList());
return SdmResponse.success(jsonObject);
}

View File

@@ -38,6 +38,7 @@ import com.sdm.project.service.*;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@@ -92,6 +93,9 @@ public class TaskServiceImpl implements ITaskService {
@Autowired
private DataClientFeignClientImpl dataClientFeignClient;
@Resource
private INodeService nodeService;
@Override
public SdmResponse list(SpdmTaskListReq req) {
Long tenantId = ThreadLocalContext.getTenantId();
@@ -1418,4 +1422,112 @@ public class TaskServiceImpl implements ITaskService {
return SdmResponse.success(resultResponse);
}
@Override
public SdmResponse getUserTaskCompleteStatistics(UserTaskCompleteStatisticsReq req) {
String projectId = req.getTag1();
if (StringUtils.isBlank(projectId)) {
log.error("项目id不能为空");
return SdmResponse.failed("项目id不能为空");
}
GetProjectListReq getProjectListReq = new GetProjectListReq();
getProjectListReq.setCurrent(1);
getProjectListReq.setSize(10000);
getProjectListReq.setProjectNodeId(projectId);
SdmResponse sdmResponse = nodeService.getProjectMemberList(getProjectListReq);
if (!sdmResponse.isSuccess()) {
log.info("项目成员为空");
return SdmResponse.success();
}
List<CIDUserResp> userList = (List<CIDUserResp>)((JSONObject) sdmResponse.getData()).get("data");
if (CollectionUtils.isEmpty(userList)) {
log.info("项目成员为空");
return SdmResponse.success();
}
List<Long> userIdList = userList.stream().map(CIDUserResp::getUserId).distinct().toList();
Map<Long, String> userMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUserId, CIDUserResp::getNickname));
req.setUserIds(userIdList);
List<UserGroupTaskCompleteVo> userGroupTaskCompleteStatistics = mapper.getUserTaskCompleteStatistics(req);
// 按用户分组统计任务状态
Map<Long, UserGroupTaskCompleteStatisticsVo> userStatisticsMap = new HashMap<>();
// 所有任务执行状态
Set<String> allExeStatus = new HashSet<>();
// 统计每个用户的各种状态任务数量
for (UserGroupTaskCompleteVo item : userGroupTaskCompleteStatistics) {
Long userId = item.getUserId();
String exeStatus = item.getExeStatus();
allExeStatus.add(exeStatus);
UserGroupTaskCompleteStatisticsVo userStat = userStatisticsMap.getOrDefault(userId, new UserGroupTaskCompleteStatisticsVo());
userStat.setUserId(userId);
userStat.setUserName(userMap.getOrDefault(userId, "Unknown User"));
Map<String, Integer> statusCount = userStat.getStatusCount();
if (statusCount == null) {
statusCount = new HashMap<>();
userStat.setStatusCount(statusCount);
}
statusCount.put(exeStatus, statusCount.getOrDefault(exeStatus, 0) + 1);
userStat.setTotalTasks(userStat.getTotalTasks() == null ? 1 : userStat.getTotalTasks() + 1);
userStatisticsMap.put(userId, userStat);
}
// 转换为列表返回
List<UserGroupTaskCompleteStatisticsVo> result = new ArrayList<>(userStatisticsMap.values());
JSONObject resultResponse = new JSONObject();
resultResponse.put("allExeStatus", allExeStatus);
resultResponse.put("result", result);
return SdmResponse.success(resultResponse);
}
@Override
public SdmResponse getUserDifficultyStatistics(UserDifficultCompleteStatisticsReq req) {
String projectId = req.getTag1();
if (StringUtils.isBlank(projectId)) {
log.error("项目id不能为空");
return SdmResponse.failed("项目id不能为空");
}
GetProjectListReq getProjectListReq = new GetProjectListReq();
getProjectListReq.setCurrent(1);
getProjectListReq.setSize(10000);
getProjectListReq.setProjectNodeId(projectId);
SdmResponse sdmResponse = nodeService.getProjectMemberList(getProjectListReq);
if (!sdmResponse.isSuccess()) {
log.info("项目成员为空");
return SdmResponse.success();
}
List<CIDUserResp> userList = (List<CIDUserResp>)((JSONObject) sdmResponse.getData()).get("data");
if (CollectionUtils.isEmpty(userList)) {
log.info("项目成员为空");
return SdmResponse.success();
}
List<Long> userIdList = userList.stream().map(CIDUserResp::getUserId).distinct().toList();
Map<Long, String> userMap = userList.stream().collect(Collectors.toMap(CIDUserResp::getUserId, CIDUserResp::getNickname));
req.setUserIds(userIdList);
List<UserGroupDifficultyVo> userGroupDifficultyStatistics = mapper.getUserDifficultyStatistics(req);
// 按用户分组统计任务状态
Map<Long, UserGroupDifficultyStatisticsVo> userStatisticsMap = new HashMap<>();
// 所有难度值
Set<Float> alldifficultyValue = new HashSet<>();
// 统计每个用户的各种状态任务数量
for (UserGroupDifficultyVo item : userGroupDifficultyStatistics) {
Long userId = item.getUserId();
Float difficulty = item.getDifficult();
alldifficultyValue.add(difficulty);
UserGroupDifficultyStatisticsVo userStat = userStatisticsMap.getOrDefault(userId, new UserGroupDifficultyStatisticsVo());
userStat.setUserId(userId);
userStat.setUserName(userMap.getOrDefault(userId, "Unknown User"));
Map<Float, Integer> statusCount = userStat.getDifficultyCount();
if (statusCount == null) {
statusCount = new HashMap<>();
userStat.setDifficultyCount(statusCount);
}
statusCount.put(difficulty, statusCount.getOrDefault(difficulty, 0) + 1);
userStat.setTotalTasks(userStat.getTotalTasks() == null ? 1 : userStat.getTotalTasks() + 1);
userStatisticsMap.put(userId, userStat);
}
// 转换为列表返回
List<UserGroupDifficultyStatisticsVo> result = new ArrayList<>(userStatisticsMap.values());
JSONObject resultResponse = new JSONObject();
resultResponse.put("alldifficultyValue", alldifficultyValue);
resultResponse.put("result", result);
return SdmResponse.success(resultResponse);
}
}

View File

@@ -275,5 +275,39 @@
</where>
</select>
<select id="getUserTaskCompleteStatistics"
resultType="com.sdm.project.model.vo.UserGroupTaskCompleteVo">
select task.exe_status as exeStatus,
task_member.user_id as userId
from simulation_task task
left join simulation_task_member task_member on task.uuid = task_member.task_id
<where>
task_member.user_id in
(
<foreach collection='req.userIds' item='userId' index='index' separator=','>
#{userId}
</foreach>
)
and task.tag1 = #{req.tag1}
</where>
</select>
<select id="getUserDifficultyStatistics" resultType="com.sdm.project.model.vo.UserGroupDifficultyVo">
select
task.difficult,
task_member.user_id as userId
from simulation_task task
left join simulation_task_member task_member on task.uuid = task_member.task_id
<where>
task_member.user_id in
(
<foreach collection='req.userIds' item='userId' index='index' separator=','>
#{userId}
</foreach>
)
and task.tag1 = #{req.tag1}
</where>
</select>
</mapper>