This commit is contained in:
2025-10-17 15:08:55 +08:00
10 changed files with 253 additions and 4 deletions

View File

@@ -169,10 +169,19 @@ public class SimulationNodeController implements ISimuluationNodeFeignClient {
* 用户组难度系数统计
*
*/
@GetMapping("/getUserGroupDifficultyStatistics")
@PostMapping("/getUserGroupDifficultyStatistics")
@Operation(summary = "用户组难度系数统计", description = "用户组难度系数统计")
public SdmResponse getUserGroupDifficultyStatistics(@RequestBody @Validated GetUserGroupTaskCompleteStatisticsReq req) {
return nodeService.getUserGroupDifficultyStatistics(req);
}
/**
* 通用完成统计查询
*/
@PostMapping("/getCommonCompleteStatistics")
@Operation(summary = "任务/指标 完成情况统计请求参数(工位、学科)", description = "任务/指标 完成情况统计请求参数(工位、学科)")
public SdmResponse getCommonCompleteStatistics(@RequestBody @Validated CommonGetCompleteStatisticsReq req) {
return nodeService.getCommonCompleteStatistics(req);
}
}

View File

@@ -79,4 +79,8 @@ public interface SimulationNodeMapper extends BaseMapper<SimulationNode> {
List<UserGroupDifficultyVo> getUserGroupDifficultyStatistics(@Param("req") GetUserGroupTaskCompleteStatisticsReq req);
List<CommonGetCompleteFromTaskVo> getCommonCompleteStatisticsFromTask(@Param("req") CommonGetCompleteStatisticsReq req);
List<CommonGetCompleteFromPerformanceVo> getCommonCompleteStatisticsFromPerformance(@Param("req")CommonGetCompleteStatisticsReq req);
}

View File

@@ -0,0 +1,50 @@
package com.sdm.project.model.req;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* 任务/指标 完成情况统计请求参数(工位、学科)
*/
@Data
@Schema(description = "任务/指标 完成情况统计请求参数(工位、学科)")
public class CommonGetCompleteStatisticsReq {
@Schema(description = "查询统计类型 task/performance")
@NotNull
private String queryType;
@Schema(description = "数据返回Tag类型: tag1、tag2,tag3,tag4,tag5,tag6,tag7,tag8,tag9,tag10")
@NotNull
private String resultTagType;
@Schema(description = "标签1")
private String tag1;
@Schema(description = "标签2")
private String tag2;
@Schema(description = "标签3")
private String tag3;
@Schema(description = "标签4")
private String tag4;
@Schema(description = "标签5")
private String tag5;
@Schema(description = "标签6")
private String tag6;
@Schema(description = "标签7")
private String tag7;
@Schema(description = "标签8")
private String tag8;
@Schema(description = "标签9")
private String tag9;
@Schema(description = "标签10")
private String tag10;
}

View File

@@ -0,0 +1,12 @@
package com.sdm.project.model.vo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
public class CommonCompleteStatisticsVo {
private String name;
private Map<String, Integer> statusCount = new HashMap<>();
}

View File

@@ -0,0 +1,10 @@
package com.sdm.project.model.vo;
import lombok.Data;
@Data
public class CommonGetCompleteFromPerformanceVo {
private String tag;
private String nodeName;
private String completeStatus;
}

View File

@@ -0,0 +1,10 @@
package com.sdm.project.model.vo;
import lombok.Data;
@Data
public class CommonGetCompleteFromTaskVo {
private String tag;
private String nodeName;
private String exeStatus;
}

View File

@@ -37,4 +37,6 @@ public interface INodeService extends IService<SimulationNode> {
//用户组难度系数统计
SdmResponse getUserGroupDifficultyStatistics(GetUserGroupTaskCompleteStatisticsReq req);
SdmResponse getCommonCompleteStatistics(CommonGetCompleteStatisticsReq req);
}

View File

@@ -787,4 +787,67 @@ public class NodeServiceImpl extends ServiceImpl<SimulationNodeMapper, Simulatio
return SdmResponse.success(result);
}
@Override
public SdmResponse getCommonCompleteStatistics(CommonGetCompleteStatisticsReq req) {
if ("task".equals(req.getQueryType())) {
// 处理任务完成情况统计
List<CommonGetCompleteFromTaskVo> commonCompleteStatisticsFromTask = this.baseMapper.getCommonCompleteStatisticsFromTask(req);
// 按tag分组统计任务状态
Map<String, CommonCompleteStatisticsVo> taskStatisticsMap = new HashMap<>();
// 统计每个tag的各种状态任务数量
for (CommonGetCompleteFromTaskVo item : commonCompleteStatisticsFromTask) {
String name = item.getNodeName();
CommonCompleteStatisticsVo stat = taskStatisticsMap.getOrDefault(name, new CommonCompleteStatisticsVo());
stat.setName(name);
Map<String, Integer> statusCount = stat.getStatusCount();
if (statusCount == null) {
statusCount = new HashMap<>();
stat.setStatusCount(statusCount);
}
String exeStatus = item.getExeStatus();
statusCount.put(exeStatus, statusCount.getOrDefault(exeStatus, 0) + 1);
taskStatisticsMap.put(name, stat);
}
// 转换为列表返回
List<CommonCompleteStatisticsVo> taskResult = new ArrayList<>(taskStatisticsMap.values());
return SdmResponse.success(taskResult);
} else if ("performance".equals(req.getQueryType())) {
// 处理指标完成情况统计
List<CommonGetCompleteFromPerformanceVo> commonCompleteStatisticsFromPerformance = this.baseMapper.getCommonCompleteStatisticsFromPerformance(req);
// 按tag分组统计指标状态
Map<String, CommonCompleteStatisticsVo> performanceStatisticsMap = new HashMap<>();
// 统计每个tag的各种状态指标数量
for (CommonGetCompleteFromPerformanceVo item : commonCompleteStatisticsFromPerformance) {
String nodeName = item.getNodeName();
CommonCompleteStatisticsVo stat = performanceStatisticsMap.getOrDefault(nodeName, new CommonCompleteStatisticsVo());
stat.setName(nodeName);
Map<String, Integer> statusCount = stat.getStatusCount();
if (statusCount == null) {
statusCount = new HashMap<>();
stat.setStatusCount(statusCount);
}
String completeStatus = item.getCompleteStatus();
statusCount.put(completeStatus, statusCount.getOrDefault(completeStatus, 0) + 1);
performanceStatisticsMap.put(nodeName, stat);
}
// 转换为列表返回
List<CommonCompleteStatisticsVo> performanceResult = new ArrayList<>(performanceStatisticsMap.values());
return SdmResponse.success(performanceResult);
}
return SdmResponse.success(new ArrayList<>());
}
}

View File

@@ -39,7 +39,7 @@
</appender>
<!-- 日志输出级别 -->
<root level="INFO">
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>

View File

@@ -347,7 +347,7 @@
<select id="getUserGroupTaskCompleteStatistics"
parameterType="com.sdm.project.model.req.GetUserGroupTaskCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.UserGroupTaskCompleteVo">
select exe_status as exeStatus,
select task.exe_status as exeStatus,
task_member.user_id as userId,
su.nickname,
sur.groupId
@@ -400,7 +400,7 @@
parameterType="com.sdm.project.model.req.GetUserGroupTaskCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.UserGroupDifficultyVo">
select
task.difficulty,
task.difficult,
task_member.user_id as userId,
su.nickname,
sur.groupId
@@ -449,4 +449,93 @@
</where>
</select>
<select id="getCommonCompleteStatisticsFromTask"
parameterType="com.sdm.project.model.req.CommonGetCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.CommonGetCompleteFromTaskVo">
select
task.${req.resultTagType} as tag,
node.nodeName,
task.exe_status as exeStatus
from simulation_task task
left join simulation_node node on task.${req.resultTagType} = node.uuid
<where>
1=1 and task.exe_status is not null
<if test="req.tag1 != null and req.tag1 !='' ">
and task.tag1 = #{req.tag1}
</if>
<if test="req.tag2 != null">
and task.tag2 = #{req.tag2}
</if>
<if test="req.tag3 != null">
and task.tag3 = #{req.tag3}
</if>
<if test="req.tag4 != null">
and task.tag4 = #{req.tag4}
</if>
<if test="req.tag5 != null">
and task.tag5 = #{req.tag5}
</if>
<if test="req.tag6 != null">
and task.tag6 = #{req.tag6}
</if>
<if test="req.tag7 != null">
and task.tag7 = #{req.tag7}
</if>
<if test="req.tag8 != null">
and task.tag8 = #{req.tag8}
</if>
<if test="req.tag9 != null">
and task.tag9 = #{req.tag9}
</if>
<if test="req.tag10 != null">
and task.tag10 = #{req.tag10}
</if>
</where>
</select>
<select id="getCommonCompleteStatisticsFromPerformance"
parameterType="com.sdm.project.model.req.CommonGetCompleteStatisticsReq"
resultType="com.sdm.project.model.vo.CommonGetCompleteFromPerformanceVo">
select
task.${req.resultTagType} as tag,
node.nodeName,
performance.completeStatus
from simulation_performance performance
left join simulation_task task on performance.taskId = task.uuid
left join simulation_node node on task.${req.resultTagType} = node.uuid
<where>
performance.completeStatus is not null
<if test="req.tag1 != null and req.tag1 !='' ">
and task.tag1 = #{req.tag1}
</if>
<if test="req.tag2 != null">
and task.tag2 = #{req.tag2}
</if>
<if test="req.tag3 != null">
and task.tag3 = #{req.tag3}
</if>
<if test="req.tag4 != null">
and task.tag4 = #{req.tag4}
</if>
<if test="req.tag5 != null">
and task.tag5 = #{req.tag5}
</if>
<if test="req.tag6 != null">
and task.tag6 = #{req.tag6}
</if>
<if test="req.tag7 != null">
and task.tag7 = #{req.tag7}
</if>
<if test="req.tag8 != null">
and task.tag8 = #{req.tag8}
</if>
<if test="req.tag9 != null">
and task.tag9 = #{req.tag9}
</if>
<if test="req.tag10 != null">
and task.tag10 = #{req.tag10}
</if>
</where>
</select>
</mapper>