From dfed9c07aa8da5791d568736716bc4b44d59ebaf Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 16 Apr 2021 13:33:53 +0800
Subject: [PATCH] jfreechart+easyExcel 方式导出报表

---
 blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/mapper/healthcodeMapper.xml |  202 ++++++++++++++++++++------------------------------
 1 files changed, 81 insertions(+), 121 deletions(-)

diff --git a/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/mapper/healthcodeMapper.xml b/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/mapper/healthcodeMapper.xml
index 35ff49c..d85c502 100644
--- a/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/mapper/healthcodeMapper.xml
+++ b/blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/mapper/healthcodeMapper.xml
@@ -57,6 +57,71 @@
             </if>
         </trim>
     </sql>
+
+    <sql id="detailCondition">
+        <if test="healthcodeVO.status==0">
+            and to_days(dtime)=to_days(now())
+        </if>
+        <if test="healthcodeVO.status==1">
+            and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
+        </if>
+        <if test="healthcodeVO.status==2">
+            and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m')
+        </if>
+        <if test="healthcodeVO.province!=null">
+            and province like concat('%',#{healthcodeVO.province},'%')
+        </if>
+        <if test="healthcodeVO.city!=null">
+            and city like concat('%',#{healthcodeVO.city},'%')
+        </if>
+        <if test="healthcodeVO.district!=null">
+            and district like concat('%',#{healthcodeVO.district},'%')
+        </if>
+        <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.begTime!='undefined'  and healthcodeVO.endTime!='undefined'
+        and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' ">
+            and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime}
+        </if>
+        <if test="healthcodeVO.timeDesc!=null and healthcodeVO.timeDesc!='' and healthcodeVO.timeDesc!='undefined' ">
+            <if test="healthcodeVO.timeDesc=='0-2'">
+                and hour(dtime)>=0 and hour(dtime) &lt;2
+            </if>
+            <if test="healthcodeVO.timeDesc=='2-4'">
+                and hour(dtime)>=2 and hour(dtime) &lt;4
+            </if>
+            <if test="healthcodeVO.timeDesc=='4-6'">
+                and hour(dtime)>=4 and hour(dtime) &lt;6
+            </if>
+            <if test="healthcodeVO.timeDesc=='6-8'">
+                and hour(dtime)>=6 and hour(dtime) &lt;8
+            </if>
+            <if test="healthcodeVO.timeDesc=='8-10'">
+                and hour(dtime)>=8 and hour(dtime) &lt;10
+            </if>
+            <if test="healthcodeVO.timeDesc=='10-12'">
+                and hour(dtime)>=10 and hour(dtime) &lt;12
+            </if>
+            <if test="healthcodeVO.timeDesc=='12-14'">
+                and hour(dtime)>=12 and hour(dtime) &lt;14
+            </if>
+            <if test="healthcodeVO.timeDesc=='14-16'">
+                and hour(dtime)>=14 and hour(dtime) &lt;16
+            </if>
+            <if test="healthcodeVO.timeDesc=='16-18'">
+                and hour(dtime)>=16 and hour(dtime) &lt;18
+            </if>
+            <if test="healthcodeVO.timeDesc=='18-20'">
+                and hour(dtime)>=18 and hour(dtime) &lt;20
+            </if>
+            <if test="healthcodeVO.timeDesc=='20-22'">
+                and hour(dtime)>=20 and hour(dtime) &lt;22
+            </if>
+            <if test="healthcodeVO.timeDesc=='22-24'">
+                and hour(dtime)>=22 and hour(dtime) &lt;24
+            </if>
+        </if>
+    </sql>
+
+
     <insert id="insert">
         insert into healthcode(<include refid="key"/>) values(<include refid="value"/>)
     </insert>
@@ -126,68 +191,10 @@
     <select id="selectHealthcodeListPage" resultType="org.springblade.jfpt.healthcode.entity.Healthcode">
         SELECT * FROM healthcode
         where 1=1
-        <if test="healthcodeVO.status==0">
-            and to_days(dtime)=to_days(now())
-        </if>
-        <if test="healthcodeVO.status==1">
-            and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
-        </if>
-        <if test="healthcodeVO.status==2">
-            and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m')
-        </if>
-        <if test="healthcodeVO.type!=null">
+        <if test="healthcodeVO.type!=null and healthcodeVO.type!='undefined' ">
             and type=#{healthcodeVO.type}
         </if>
-        <if test="healthcodeVO.province!=null">
-            and province like concat('%',#{healthcodeVO.province},'%')
-        </if>
-        <if test="healthcodeVO.city!=null">
-            and city like concat('%',#{healthcodeVO.city},'%')
-        </if>
-        <if test="healthcodeVO.district!=null">
-            and district like concat('%',#{healthcodeVO.district},'%')
-        </if>
-        <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' ">
-            and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime}
-        </if>
-        <if test="healthcodeVO.timeDesc!=null and healthcodeVO.timeDesc!=''">
-            <if test="healthcodeVO.timeDesc=='0-2'">
-                and hour(dtime)>=0 and hour(dtime) &lt;2
-            </if>
-            <if test="healthcodeVO.timeDesc=='2-4'">
-                and hour(dtime)>=2 and hour(dtime) &lt;4
-            </if>
-            <if test="healthcodeVO.timeDesc=='4-6'">
-                and hour(dtime)>=4 and hour(dtime) &lt;6
-            </if>
-            <if test="healthcodeVO.timeDesc=='6-8'">
-                and hour(dtime)>=6 and hour(dtime) &lt;8
-            </if>
-            <if test="healthcodeVO.timeDesc=='8-10'">
-                and hour(dtime)>=8 and hour(dtime) &lt;10
-            </if>
-            <if test="healthcodeVO.timeDesc=='10-12'">
-                and hour(dtime)>=10 and hour(dtime) &lt;12
-            </if>
-            <if test="healthcodeVO.timeDesc=='12-14'">
-                and hour(dtime)>=12 and hour(dtime) &lt;14
-            </if>
-            <if test="healthcodeVO.timeDesc=='14-16'">
-                and hour(dtime)>=14 and hour(dtime) &lt;16
-            </if>
-            <if test="healthcodeVO.timeDesc=='16-18'">
-                and hour(dtime)>=16 and hour(dtime) &lt;18
-            </if>
-            <if test="healthcodeVO.timeDesc=='18-20'">
-                and hour(dtime)>=18 and hour(dtime) &lt;20
-            </if>
-            <if test="healthcodeVO.timeDesc=='20-22'">
-                and hour(dtime)>=20 and hour(dtime) &lt;22
-            </if>
-            <if test="healthcodeVO.timeDesc=='22-24'">
-                and hour(dtime)>=22 and hour(dtime) &lt;24
-            </if>
-        </if>
+        <include refid="detailCondition"></include>
         ORDER BY dtime desc
     </select>
 
@@ -230,70 +237,23 @@
     <!--导出健康码数据表格-->
     <select id="exportHealthcode" resultType="org.springblade.common.entity.HealthcodeExcel">
         SELECT * FROM healthcode
-        where 1=1
-        <if test="healthcodeVO.status==0">
-            and to_days(dtime)=to_days(now())
-        </if>
-        <if test="healthcodeVO.status==1">
-            and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
-        </if>
-        <if test="healthcodeVO.status==2">
-            and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m')
-        </if>
         <if test="healthcodeVO.type!=null and healthcodeVO.type!='undefined' ">
             and type=#{healthcodeVO.type}
         </if>
-        <if test="healthcodeVO.province!=null">
-            and province like concat('%',#{healthcodeVO.province},'%')
-        </if>
-        <if test="healthcodeVO.city!=null">
-            and city like concat('%',#{healthcodeVO.city},'%')
-        </if>
-        <if test="healthcodeVO.district!=null">
-            and district like concat('%',#{healthcodeVO.district},'%')
-        </if>
-        <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.begTime!='undefined'  and healthcodeVO.endTime!='undefined'
-        and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' ">
-            and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime}
-        </if>
-        <if test="healthcodeVO.timeDesc!=null and healthcodeVO.timeDesc!='' and healthcodeVO.timeDesc!='undefined' ">
-            <if test="healthcodeVO.timeDesc=='0-2'">
-                and hour(dtime)>=0 and hour(dtime) &lt;2
-            </if>
-            <if test="healthcodeVO.timeDesc=='2-4'">
-                and hour(dtime)>=2 and hour(dtime) &lt;4
-            </if>
-            <if test="healthcodeVO.timeDesc=='4-6'">
-                and hour(dtime)>=4 and hour(dtime) &lt;6
-            </if>
-            <if test="healthcodeVO.timeDesc=='6-8'">
-                and hour(dtime)>=6 and hour(dtime) &lt;8
-            </if>
-            <if test="healthcodeVO.timeDesc=='8-10'">
-                and hour(dtime)>=8 and hour(dtime) &lt;10
-            </if>
-            <if test="healthcodeVO.timeDesc=='10-12'">
-                and hour(dtime)>=10 and hour(dtime) &lt;12
-            </if>
-            <if test="healthcodeVO.timeDesc=='12-14'">
-                and hour(dtime)>=12 and hour(dtime) &lt;14
-            </if>
-            <if test="healthcodeVO.timeDesc=='14-16'">
-                and hour(dtime)>=14 and hour(dtime) &lt;16
-            </if>
-            <if test="healthcodeVO.timeDesc=='16-18'">
-                and hour(dtime)>=16 and hour(dtime) &lt;18
-            </if>
-            <if test="healthcodeVO.timeDesc=='18-20'">
-                and hour(dtime)>=18 and hour(dtime) &lt;20
-            </if>
-            <if test="healthcodeVO.timeDesc=='20-22'">
-                and hour(dtime)>=20 and hour(dtime) &lt;22
-            </if>
-            <if test="healthcodeVO.timeDesc=='22-24'">
-                and hour(dtime)>=22 and hour(dtime) &lt;24
-            </if>
-        </if>
+        where 1=1
+            <include refid="detailCondition"></include>
         ORDER BY dtime desc
     </select>
+
+    <!--导出健康码数据报表-->
+    <select id="getHealthcodePie" resultType="org.springblade.common.entity.ReportReturnData">
+        select if(1=1,'绿色健康码',0) type,ifnull(count(*),0) count from healthcode where type=1
+            <include refid="detailCondition"></include>
+        union all
+        select if(1=1,'黄色健康码',0) type,ifnull(count(*),0) count from healthcode where type=2
+            <include refid="detailCondition"></include>
+        union all
+        select if(1=1,'红色健康码',0) type,ifnull(count(*),0) count from healthcode where type=3
+            <include refid="detailCondition"></include>
+    </select>
 </mapper>

--
Gitblit v1.9.3