From 1b77c2724e38d087f3eab4a2f27b3b165f4265dc Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 25 五月 2026 14:37:34 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_tide' into dev_tide
---
src/main/resources/mapper/safety/SafetyInspectionRecordMapper.xml | 68 ++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/src/main/resources/mapper/safety/SafetyInspectionRecordMapper.xml b/src/main/resources/mapper/safety/SafetyInspectionRecordMapper.xml
new file mode 100644
index 0000000..ea5ff49
--- /dev/null
+++ b/src/main/resources/mapper/safety/SafetyInspectionRecordMapper.xml
@@ -0,0 +1,68 @@
+<?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">
+<mapper namespace="com.ruoyi.safety.mapper.SafetyInspectionRecordMapper">
+
+ <select id="selectTodayStatistics" resultType="com.ruoyi.safety.dto.SafetyInspectionTodayStatistics">
+ SELECT
+ COUNT(1) AS totalCount,
+ IFNULL(SUM(CASE WHEN status <> 3 THEN 1 ELSE 0 END), 0) AS completedCount,
+ IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS abnormalCount,
+ IFNULL(SUM(CASE WHEN status = 2 OR is_missed = 1 THEN 1 ELSE 0 END), 0) AS missedCount,
+ IFNULL(SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END), 0) AS unexecutedCount,
+ CASE
+ WHEN COUNT(1) = 0 THEN 0
+ ELSE ROUND(IFNULL(SUM(CASE WHEN status <> 3 THEN 1 ELSE 0 END), 0) / COUNT(1) * 100, 2)
+ END AS completionRate,
+ COUNT(DISTINCT inspector_id) AS inspectorCount
+ FROM safety_inspection_record
+ WHERE del_flag = 0
+ AND DATE(inspection_time) = #{statDate}
+ </select>
+
+ <select id="selectTrendStatistics" resultType="com.ruoyi.safety.dto.SafetyInspectionTrendStat">
+ SELECT
+ DATE(inspection_time) AS statDate,
+ COUNT(1) AS totalCount,
+ IFNULL(SUM(CASE WHEN status <> 3 THEN 1 ELSE 0 END), 0) AS completedCount,
+ IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS abnormalCount,
+ IFNULL(SUM(CASE WHEN status = 2 OR is_missed = 1 THEN 1 ELSE 0 END), 0) AS missedCount,
+ IFNULL(SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END), 0) AS unexecutedCount
+ FROM safety_inspection_record
+ WHERE del_flag = 0
+ AND DATE(inspection_time) BETWEEN #{startDate} AND #{endDate}
+ GROUP BY DATE(inspection_time)
+ ORDER BY statDate ASC
+ </select>
+
+ <select id="selectTypeStatistics" resultType="com.ruoyi.safety.dto.SafetyInspectionTypeStat">
+ SELECT
+ IFNULL(type, 'unknown') AS type,
+ COUNT(1) AS count
+ FROM safety_inspection_record
+ WHERE del_flag = 0
+ AND DATE(inspection_time) BETWEEN #{startDate} AND #{endDate}
+ GROUP BY IFNULL(type, 'unknown')
+ ORDER BY count DESC
+ </select>
+
+ <select id="selectInspectorStatistics" resultType="com.ruoyi.safety.dto.SafetyInspectorStat">
+ SELECT
+ inspector_id AS inspectorId,
+ inspector AS inspector,
+ COUNT(1) AS totalCount,
+ IFNULL(SUM(CASE WHEN status <> 3 THEN 1 ELSE 0 END), 0) AS completedCount,
+ IFNULL(SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END), 0) AS abnormalCount,
+ IFNULL(SUM(CASE WHEN status = 2 OR is_missed = 1 THEN 1 ELSE 0 END), 0) AS missedCount,
+ IFNULL(SUM(CASE WHEN status = 3 THEN 1 ELSE 0 END), 0) AS unexecutedCount,
+ CASE
+ WHEN COUNT(1) = 0 THEN 0
+ ELSE ROUND(IFNULL(SUM(CASE WHEN status <> 3 THEN 1 ELSE 0 END), 0) / COUNT(1) * 100, 2)
+ END AS completionRate
+ FROM safety_inspection_record
+ WHERE del_flag = 0
+ AND DATE(inspection_time) BETWEEN #{startDate} AND #{endDate}
+ GROUP BY inspector_id, inspector
+ ORDER BY totalCount DESC
+ </select>
+</mapper>
--
Gitblit v1.9.3