feat(monitor): 添加操作日志绩效统计功能
- 在SysOperLogService中新增绩效概览、人员绩效和模块排行接口 - 在SysOperLogMapper中添加模块统计、人员统计和全局概览查询方法 - 在SysOperLogMapper.xml中实现绩效相关的SQL查询和ResultMap - 在SysOperLogServiceImpl中实现绩效统计业务逻辑和评分算法 - 创建OperModuleStatVO、OperPersonVO和OperSummaryVO数据传输对象 - 新增OperPerformanceController提供绩效统计API接口 - 添加前端performance页面实现数据可视化展示和图表渲染
This commit is contained in:
@@ -23,4 +23,173 @@
|
||||
<result property="operTime" column="oper_time"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 绩效相关 ResultMap -->
|
||||
<resultMap type="com.klp.system.domain.vo.OperPersonVO" id="OperPersonResult">
|
||||
<result property="operName" column="oper_name"/>
|
||||
<result property="deptName" column="dept_name"/>
|
||||
<result property="totalCount" column="total_count"/>
|
||||
<result property="successCount" column="success_count"/>
|
||||
<result property="failCount" column="fail_count"/>
|
||||
<result property="successRate" column="success_rate"/>
|
||||
<result property="addCount" column="add_count"/>
|
||||
<result property="editCount" column="edit_count"/>
|
||||
<result property="deleteCount" column="delete_count"/>
|
||||
<result property="otherCount" column="other_count"/>
|
||||
<result property="lastOperTime" column="last_oper_time"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.klp.system.domain.vo.OperModuleStatVO" id="OperModuleStatResult">
|
||||
<result property="operName" column="oper_name"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="totalCount" column="total_count"/>
|
||||
<result property="addCount" column="add_count"/>
|
||||
<result property="editCount" column="edit_count"/>
|
||||
<result property="deleteCount" column="delete_count"/>
|
||||
<result property="otherCount" column="other_count"/>
|
||||
<result property="successRate" column="success_rate"/>
|
||||
<result property="personCount" column="person_count"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.klp.system.domain.vo.OperSummaryVO" id="OperSummaryResult">
|
||||
<result property="totalOperations" column="total_operations"/>
|
||||
<result property="successCount" column="success_count"/>
|
||||
<result property="failCount" column="fail_count"/>
|
||||
<result property="activePersonCount" column="active_person_count"/>
|
||||
<result property="activeModuleCount" column="active_module_count"/>
|
||||
<result property="avgPerPerson" column="avg_per_person"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- ========== 绩效聚合查询 ========== -->
|
||||
|
||||
<!-- 按模块全局统计 -->
|
||||
<select id="selectModuleSummary" parameterType="com.klp.system.domain.bo.OperPerformanceQuery" resultMap="OperModuleStatResult">
|
||||
SELECT
|
||||
l.title,
|
||||
COUNT(1) AS total_count,
|
||||
SUM(CASE WHEN l.business_type = 1 THEN 1 ELSE 0 END) AS add_count,
|
||||
SUM(CASE WHEN l.business_type = 2 THEN 1 ELSE 0 END) AS edit_count,
|
||||
SUM(CASE WHEN l.business_type = 3 THEN 1 ELSE 0 END) AS delete_count,
|
||||
SUM(CASE WHEN l.business_type = 0 THEN 1 ELSE 0 END) AS other_count,
|
||||
ROUND(SUM(CASE WHEN l.status = 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(1), 2) AS success_rate,
|
||||
COUNT(DISTINCT l.oper_name) AS person_count
|
||||
FROM sys_oper_log l
|
||||
<where>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND l.oper_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND l.oper_time <= #{endTime}
|
||||
</if>
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND l.dept_name LIKE CONCAT('%', #{deptName}, '%')
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND l.oper_name LIKE CONCAT('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND l.title LIKE CONCAT('%', #{title}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY l.title
|
||||
ORDER BY total_count DESC
|
||||
</select>
|
||||
|
||||
<!-- 按人员统计 -->
|
||||
<select id="selectPersonSummary" parameterType="com.klp.system.domain.bo.OperPerformanceQuery" resultMap="OperPersonResult">
|
||||
SELECT
|
||||
l.oper_name,
|
||||
l.dept_name,
|
||||
COUNT(1) AS total_count,
|
||||
SUM(CASE WHEN l.status = 0 THEN 1 ELSE 0 END) AS success_count,
|
||||
SUM(CASE WHEN l.status = 1 THEN 1 ELSE 0 END) AS fail_count,
|
||||
ROUND(SUM(CASE WHEN l.status = 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(1), 2) AS success_rate,
|
||||
SUM(CASE WHEN l.business_type = 1 THEN 1 ELSE 0 END) AS add_count,
|
||||
SUM(CASE WHEN l.business_type = 2 THEN 1 ELSE 0 END) AS edit_count,
|
||||
SUM(CASE WHEN l.business_type = 3 THEN 1 ELSE 0 END) AS delete_count,
|
||||
SUM(CASE WHEN l.business_type = 0 THEN 1 ELSE 0 END) AS other_count,
|
||||
MAX(l.oper_time) AS last_oper_time
|
||||
FROM sys_oper_log l
|
||||
<where>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND l.oper_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND l.oper_time <= #{endTime}
|
||||
</if>
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND l.dept_name LIKE CONCAT('%', #{deptName}, '%')
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND l.oper_name LIKE CONCAT('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND l.title LIKE CONCAT('%', #{title}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY l.oper_name, l.dept_name
|
||||
ORDER BY total_count DESC
|
||||
</select>
|
||||
|
||||
<!-- 按人员-模块明细统计 -->
|
||||
<select id="selectPersonModuleDetail" parameterType="com.klp.system.domain.bo.OperPerformanceQuery" resultMap="OperModuleStatResult">
|
||||
SELECT
|
||||
l.oper_name,
|
||||
l.title,
|
||||
COUNT(1) AS total_count,
|
||||
SUM(CASE WHEN l.business_type = 1 THEN 1 ELSE 0 END) AS add_count,
|
||||
SUM(CASE WHEN l.business_type = 2 THEN 1 ELSE 0 END) AS edit_count,
|
||||
SUM(CASE WHEN l.business_type = 3 THEN 1 ELSE 0 END) AS delete_count,
|
||||
SUM(CASE WHEN l.business_type = 0 THEN 1 ELSE 0 END) AS other_count,
|
||||
ROUND(SUM(CASE WHEN l.status = 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(1), 2) AS success_rate
|
||||
FROM sys_oper_log l
|
||||
<where>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND l.oper_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND l.oper_time <= #{endTime}
|
||||
</if>
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND l.dept_name LIKE CONCAT('%', #{deptName}, '%')
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND l.oper_name LIKE CONCAT('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND l.title LIKE CONCAT('%', #{title}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY l.oper_name, l.title
|
||||
ORDER BY l.oper_name, total_count DESC
|
||||
</select>
|
||||
|
||||
<!-- 全局概览统计 -->
|
||||
<select id="selectGlobalSummary" parameterType="com.klp.system.domain.bo.OperPerformanceQuery" resultMap="OperSummaryResult">
|
||||
SELECT
|
||||
COUNT(1) AS total_operations,
|
||||
SUM(CASE WHEN l.status = 0 THEN 1 ELSE 0 END) AS success_count,
|
||||
SUM(CASE WHEN l.status = 1 THEN 1 ELSE 0 END) AS fail_count,
|
||||
COUNT(DISTINCT l.oper_name) AS active_person_count,
|
||||
COUNT(DISTINCT l.title) AS active_module_count,
|
||||
ROUND(COUNT(1) * 1.0 / NULLIF(COUNT(DISTINCT l.oper_name), 0), 2) AS avg_per_person
|
||||
FROM sys_oper_log l
|
||||
<where>
|
||||
<if test="beginTime != null and beginTime != ''">
|
||||
AND l.oper_time >= #{beginTime}
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND l.oper_time <= #{endTime}
|
||||
</if>
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND l.dept_name LIKE CONCAT('%', #{deptName}, '%')
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND l.oper_name LIKE CONCAT('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="title != null and title != ''">
|
||||
AND l.title LIKE CONCAT('%', #{title}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user