Selaa lähdekoodia

修改 大屏项目申报列表添加筛选条件

huZhiHao 6 vuotta sitten
vanhempi
commit
98075c844d

+ 30 - 0
src/main/java/platform/common/util/DateUtil.java

@@ -333,4 +333,34 @@ public class DateUtil {
         cal.set(Calendar.HOUR_OF_DAY, 24);
         return cal.getTime();
     }
+
+    /**
+     * 获取两个日期相差的月数
+     */
+    public static int getMonthDiff(Date d1, Date d2) {
+        Calendar c1 = Calendar.getInstance();
+        Calendar c2 = Calendar.getInstance();
+        c1.setTime(d1);
+        c2.setTime(d2);
+        int year1 = c1.get(Calendar.YEAR);
+        int year2 = c2.get(Calendar.YEAR);
+        int month1 = c1.get(Calendar.MONTH);
+        int month2 = c2.get(Calendar.MONTH);
+        int day1 = c1.get(Calendar.DAY_OF_MONTH);
+        int day2 = c2.get(Calendar.DAY_OF_MONTH);
+        // 获取年的差值 
+        int yearInterval = year1 - year2;
+        // 如果 d1的 月-日 小于 d2的 月-日 那么 yearInterval-- 这样就得到了相差的年数
+        if (month1 < month2 || month1 == month2 && day1 < day2) {
+            yearInterval--;
+        }
+        // 获取月数差值
+        int monthInterval = (month1 + 12) - month2;
+        if (day1 < day2) {
+            monthInterval--;
+        }
+        monthInterval %= 12;
+        int monthsDiff = Math.abs(yearInterval * 12 + monthInterval);
+        return monthsDiff;
+    }
 }

+ 4 - 0
src/main/java/platform/modules/home/request/FindRequest.java

@@ -29,6 +29,10 @@ public class FindRequest {
     private String isinvalid;           //活动是否失效 0:有效、1:失效
     private Boolean isActive;
 
+    private String startTime;
+
+    private String endTime;
+
     /**
      * 获取页索引。如果当前索引小于1,则回1.
      *

+ 36 - 27
src/main/resources/mapper/government/ProjectDeclarationDao.xml

@@ -39,12 +39,12 @@
 
         select * from project_declaration where id = #{id}
     </select>
-    
+
     <select id="findByCondition" resultType="platform.modules.government.entity.ProjectDeclaration">
         SELECT distinct
-        	p.* FROM 
-        	project_declaration p 
-        	LEFT JOIN notices_accept n on n.recorde_id = p.id
+        p.* FROM
+        project_declaration p
+        LEFT JOIN notices_accept n on n.recorde_id = p.id
         where 1=1
         <if test="projectName != null and projectName != '' ">
             and p.project_name LIKE CONCAT ('%',#{projectName},'%')
@@ -62,26 +62,27 @@
             and p.apply_endDate <![CDATA[<=]]> left(#{endTime2},10)
         </if>
         <if test="request.company_id != null and request.company_id != '' ">
-        	and n.user_id = #{request.company_id}
+            and n.user_id = #{request.company_id}
         </if>
         <if test="request.isActive != null and request.isActive != '' ">
-        	and p.apply_startDate <![CDATA[<=]]> left(now(),10)
-        	and p.apply_endDate <![CDATA[>=]]> left(now(),10)
-        	and p.status != 0
+            and p.apply_startDate <![CDATA[<=]]> left(now(),10)
+            and p.apply_endDate <![CDATA[>=]]> left(now(),10)
+            and p.status != 0
         </if>
         <if test="searchCondition.is_online_application != null ">
-        	and p.is_online_application =#{searchCondition.is_online_application} 
+            and p.is_online_application =#{searchCondition.is_online_application}
         </if>
         order by p.create_time desc
     </select>
 
-	<select id="findUnionProjectsOnHome" resultType="platform.modules.government.entity.ProjectDeclaration">
+    <select id="findUnionProjectsOnHome" resultType="platform.modules.government.entity.ProjectDeclaration">
         <if test="request.type != null and request.type != '' and request.type =='4'.toString()">
             select * from
             (
             SELECT
-            a.id,a.project_name,a.create_time,a.project_source,a.apply_enddate,0 as isFilling,a.project_content AS content
-            FROM  project_declaration a
+            a.id,a.project_name,a.create_time,a.project_source,a.apply_enddate,0 as isFilling,a.project_content AS
+            content
+            FROM project_declaration a
             where
             a.del_flag=0
             and a.is_open = 1
@@ -105,8 +106,9 @@
             select * from
             (
             SELECT
-            a.id,a.project_name,a.create_time,a.project_source,a.apply_enddate,0 as isFilling,a.project_content AS content
-            FROM  project_declaration a
+            a.id,a.project_name,a.create_time,a.project_source,a.apply_enddate,0 as isFilling,a.project_content AS
+            content
+            FROM project_declaration a
             where
             a.del_flag=0
             and a.is_open = 1
@@ -122,21 +124,28 @@
             from project_intelligent_declaration b
             where b.del_flag = 0 and b.status=1
             ) temp
+            where 1=1
+            <if test="request.startTime !='' and request.startTime !=null ">
+                and temp.create_time <![CDATA[>=]]> #{request.startTime}
+            </if>
+            <if test="request.endTime !='' and request.endTime !=null ">
+                and temp.create_time <![CDATA[<=]]> #{request.endTime}
+            </if>
             order by temp.create_time desc
         </if>
 
-	</select>
-	<select id="findProjectsOnHome" resultType="platform.modules.government.entity.ProjectDeclaration">
+    </select>
+    <select id="findProjectsOnHome" resultType="platform.modules.government.entity.ProjectDeclaration">
         SELECT
         a.project_name,a.id,a.create_time,a.project_source,a.apply_enddate
-        FROM  project_declaration a
-        where 
-        	a.del_flag=0
-        	and a.is_open = 1
-        	and a.status = 1
+        FROM project_declaration a
+        where
+        a.del_flag=0
+        and a.is_open = 1
+        and a.status = 1
         <if test="request.keyword!=null and request.keyword!=''">
             and a.project_name LIKE CONCAT ('%',#{ request.keyword},'%')
-             
+
         </if>
         <if test="request.type!=null and request.type!=''">
             and a.project_source = #{ request.type}
@@ -144,18 +153,18 @@
         order by a.create_time desc
         limit #{request.start},#{request.page_size}
     </select>
-    
+
     <select id="findProjectsCountOnHome" resultType="integer">
         SELECT
         count(0)
-        FROM project_declaration a 
+        FROM project_declaration a
         where a.del_flag = 0
-        	and a.is_open = 1
-        	and a.status = 1
+        and a.is_open = 1
+        and a.status = 1
         <if test="request.keyword!=null and request.keyword!=''">
             and a.project_name LIKE CONCAT ('%',#{ request.keyword},'%')
         </if>
-		<if test="request.type!=null and request.type!=''">
+        <if test="request.type!=null and request.type!=''">
             and a.project_source = #{ request.type}
         </if>
     </select>