Files
klp-oa/klp-system/src/main/resources/mapper/system/SysOperLogMapper.xml

197 lines
9.2 KiB
XML
Raw Normal View History

2021-12-21 10:15:12 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2025-07-17 18:07:48 +08:00
<mapper namespace="com.klp.system.mapper.SysOperLogMapper">
2021-12-21 10:15:12 +08:00
<resultMap type="SysOperLog" id="SysOperLogResult">
<id property="operId" column="oper_id"/>
<result property="title" column="title"/>
<result property="businessType" column="business_type"/>
<result property="method" column="method"/>
<result property="requestMethod" column="request_method"/>
<result property="operatorType" column="operator_type"/>
<result property="operName" column="oper_name"/>
<result property="deptName" column="dept_name"/>
<result property="operUrl" column="oper_url"/>
<result property="operPage" column="oper_page"/>
2021-12-21 10:15:12 +08:00
<result property="operIp" column="oper_ip"/>
<result property="operLocation" column="oper_location"/>
<result property="operParam" column="oper_param"/>
<result property="jsonResult" column="json_result"/>
<result property="status" column="status"/>
<result property="errorMsg" column="error_msg"/>
<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 &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND l.oper_time &lt;= #{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 &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND l.oper_time &lt;= #{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 &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND l.oper_time &lt;= #{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 &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != ''">
AND l.oper_time &lt;= #{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>
2025-07-17 18:07:48 +08:00
</mapper>