From b204ec191d0473df7c7ca276a7f0be48bac4cb82 Mon Sep 17 00:00:00 2001
From: sinake <sinake1@qq.com>
Date: 星期四, 17 九月 2026 15:33:39 +0800
Subject: [PATCH] 案例趋势相关统计

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceTotalsController.java |    3 +
 ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceTotalsMapper.java           |    2 +
 ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceTotalsServiceImp.java |   11 +++++
 ruoyi-project/src/main/java/com/ruoyi/project/service/iServiceTotalsService.java        |    6 +++
 ruoyi-project/src/main/resources/mapper/project/ServiceTotalsMapper.xml                 |   47 +++++++++++++++++------
 5 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceTotalsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceTotalsController.java
index 9cb71ac..22d1fd5 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceTotalsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/ServiceTotalsController.java
@@ -109,6 +109,7 @@
         public Result<List<trendList>> trendList(@RequestBody ServiceTotals totals)
         {
             List<trendList> list = service.trendList(totals);
-            return Result.success(list);
+            Long count=service.trendCount(totals);
+            return Result.success(count,list);
         }
 }
diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceTotalsMapper.java b/ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceTotalsMapper.java
index dc1df0a..00c4463 100644
--- a/ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceTotalsMapper.java
+++ b/ruoyi-project/src/main/java/com/ruoyi/project/mapper/ServiceTotalsMapper.java
@@ -79,5 +79,7 @@
      */
     public List<trendList> trendList(ServiceTotals totals);
 
+    public Long trendCount(ServiceTotals totals);
+
 
 }
diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/iServiceTotalsService.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/iServiceTotalsService.java
index 24c54f0..e659ded 100644
--- a/ruoyi-project/src/main/java/com/ruoyi/project/service/iServiceTotalsService.java
+++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/iServiceTotalsService.java
@@ -69,5 +69,11 @@
      *
      */
     List<trendList> trendList(ServiceTotals totals);
+
+    /**
+     * 妗堜緥鏄庣粏鏁伴噺
+     *
+     */
+    Long trendCount(ServiceTotals totals);
 }
 
diff --git a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceTotalsServiceImp.java b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceTotalsServiceImp.java
index e792726..3c24c1a 100644
--- a/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceTotalsServiceImp.java
+++ b/ruoyi-project/src/main/java/com/ruoyi/project/service/impl/ServiceTotalsServiceImp.java
@@ -115,7 +115,7 @@
     }
 
     /**
-     * 鎬у埆涓庤鍨嬪垎甯�
+     * 妗堜緥鏄庣粏鍒楄〃
      *
      */
     @Override
@@ -123,4 +123,13 @@
         return mapper.trendList(totals);
     }
 
+    /**
+     * 妗堜緥鏄庣粏鏁伴噺
+     *
+     */
+    @Override
+    public Long trendCount(ServiceTotals totals) {
+        return mapper.trendCount(totals);
+    }
+
 }
diff --git a/ruoyi-project/src/main/resources/mapper/project/ServiceTotalsMapper.xml b/ruoyi-project/src/main/resources/mapper/project/ServiceTotalsMapper.xml
index 68d91bf..d7258bb 100644
--- a/ruoyi-project/src/main/resources/mapper/project/ServiceTotalsMapper.xml
+++ b/ruoyi-project/src/main/resources/mapper/project/ServiceTotalsMapper.xml
@@ -7,8 +7,9 @@
     <select id="caseTrend" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotalsTrend">
         SELECT DATE_FORMAT(a.donatetime, '%Y-%m') donateTime, RegisterCountyName area,  COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo a
-        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id where a.del_flag=0
+        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id
         <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
             <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
             <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
@@ -19,8 +20,9 @@
     <select id="caseTrendMoon" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotalsTrend">
         SELECT DATE_FORMAT(a.donatetime, '%Y-%m') donateTime, COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo a
-        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id where a.del_flag=0
+        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id
         <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
             <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
             <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
@@ -31,8 +33,9 @@
     <select id="caseTrendArea" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotalsTrend">
         SELECT RegisterCountyName area, COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo a
-        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id where a.del_flag=0
+        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id
         <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
             <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
             <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
@@ -44,8 +47,9 @@
             resultType="ServiceTotalsOrgan">
         SELECT DATE_FORMAT(a.OrganGetTime, '%Y-%m') donateTime,a.OrganName organName, COUNT(*) getCount,
         COUNT(IF(transplantstate=3, true, NULL)) useCount   FROM  service_donationwitnessorgan a
-        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName  where a.del_flag=0
+        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName
         <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">
                 and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
             </if>
@@ -60,8 +64,9 @@
             resultType="ServiceTotalsOrgan">
         SELECT DATE_FORMAT(a.OrganGetTime, '%Y-%m') donateTime, COUNT(*) getCount,
         COUNT(IF(transplantstate=3, true, NULL)) useCount   FROM  service_donationwitnessorgan a
-        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName  where a.del_flag=0
+        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName
         <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">
                 and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
             </if>
@@ -76,8 +81,9 @@
             resultType="ServiceTotalsOrgan">
         SELECT a.OrganName organName, COUNT(*) getCount,
         COUNT(IF(transplantstate=3, true, NULL)) useCount   FROM  service_donationwitnessorgan a
-        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName  where a.del_flag=0
+        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName
         <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">
                 and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
             </if>
@@ -91,8 +97,9 @@
     <select id="caseSex" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotalsSex">
         SELECT COUNT(sex) totalCount, COUNT(IF(sex=1, true, NULL)) manCount ,COUNT(IF(sex=2, true, NULL)) womanCount
-        FROM service_donatebaseinfo where del_flag=0
+        FROM service_donatebaseinfo
         <where>
+            del_flag=0
             <if test="area != null  and area != ''">
                 and  RegisterCountyName>=#{area}
             </if>
@@ -113,8 +120,9 @@
 
     <select id="caseAvgAge" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotals">
-        SELECT AVG(age) avgAge FROM  service_donatebaseinfo where del_flag=0
+        SELECT AVG(age) avgAge FROM  service_donatebaseinfo
         <where>
+            del_flag=0
             <if test="area != null  and area != ''">
                 and  RegisterCountyName>=#{area}
             </if>
@@ -135,8 +143,9 @@
     <select id="caseBloodType" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotalsBood">
         SELECT COUNT(BloodType) boodTypeCount,BloodType bloodType
-        FROM service_donatebaseinfo where del_flag=0
+        FROM service_donatebaseinfo
         <where>
+            del_flag=0
             <if test="area != null  and area != ''">
                 and  RegisterCountyName>=#{area}
             </if>
@@ -157,8 +166,8 @@
 
     <select id="totals" parameterType="com.ruoyi.project.domain.ServiceTotals"
             resultType="ServiceTotalsTotal">
-        SELECT ( SELECT COUNT(*) FROM service_donatebaseinfo_report WHERE del_flag=0) totalPotential,
-        (SELECT COUNT(*) FROM service_donatecompletioninfo WHERE del_flag=0) totalCompletion
+        SELECT ( SELECT COUNT(*) FROM service_donatebaseinfo WHERE del_flag=0) totalPotential,
+               (SELECT COUNT(*) FROM service_donatecompletioninfo WHERE del_flag=0 and complete_state=3) totalCompletion
     </select>
 
     <select id="trendList" parameterType="com.ruoyi.project.domain.ServiceTotals"
@@ -167,8 +176,22 @@
         (SELECT  GROUP_CONCAT(c.OrganName) FROM service_donateorgan c WHERE c.InfoId=a.id AND c.del_flag=0) OrganName
         FROM service_donatebaseinfo a
         LEFT JOIN service_deathinfo d ON d.InfoID=a.id
-        where a.del_flag=0
         <where>
+            a.del_flag=0
+            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
+            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
+            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
+        </where>
+
+    </select>
+
+    <select id="trendCount" parameterType="com.ruoyi.project.domain.ServiceTotals"
+            resultType="Long">
+        SELECT count(*)
+        FROM service_donatebaseinfo a
+        LEFT JOIN service_deathinfo d ON d.InfoID=a.id
+        <where>
+            a.del_flag=0
             <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
             <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
             <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>

--
Gitblit v1.9.3