feat(employee-big-brother): 新增建联率统计与柱状图接口

- Controller 增加 /self_complete、/employeeCompleteBarChart 两个端点
- Mapper 新增 selectEmployeeBrotherCompleteBarChart、selectEmployeeBrotherWithOperationStatus 查询
- Service 层实现个人及多用户建联率统计逻辑
- XML 补充对应 SQL,支持按天数与用户列表过滤
This commit is contained in:
2025-11-12 19:15:42 +08:00
parent 10c5b04c32
commit 4c42809d3b
5 changed files with 103 additions and 0 deletions

View File

@@ -228,4 +228,39 @@
</when>
</choose>
</select>
<select id="selectEmployeeBrotherCompleteBarChart"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
COUNT(DISTINCT
CASE WHEN operation_status = 1 THEN display_id END) AS finishedNum
FROM server_employee_big_brother
WHERE deleted = 0
AND operation_status = 1
<!-- 日期范围:今天或过去 7 天(含今天) -->
AND update_time >= DATE_SUB(CURDATE(), INTERVAL #{days,jdbcType=INTEGER} - 1 DAY)
<if test="list != null and list.size() > 0">
AND user_id IN
<foreach collection="list" item="user_id" open="(" separator="," close=")">
#{user_id}
</foreach>
</if>
GROUP BY user_id
</select>
<select id="selectEmployeeBrotherWithOperationStatus"
resultType="cn.iocoder.yudao.module.tkdata.controller.admin.employeehosts.vo.CompletedRateVO">
SELECT
user_id AS userId,
SUM(CASE WHEN operation_status = 1 THEN 1 ELSE 0 END) AS finishedNum,
SUM(CASE WHEN operation_status = 0 THEN 1 ELSE 0 END) AS unfinishedNum,
COUNT(*) AS totalNum
FROM server_employee_big_brother
WHERE deleted = 0
<if test="userId != null">
AND user_id = #{userId}
</if>
GROUP BY user_id
</select>
</mapper>