소스 검색

修改任务查询语句

yusm 2 달 전
부모
커밋
943e4822fa
1개의 변경된 파일48개의 추가작업 그리고 2개의 파일을 삭제
  1. 48 2
      fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/TaskMapper.xml

+ 48 - 2
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/TaskMapper.xml

@@ -193,11 +193,34 @@
             <if test=" executorName!= null and executorName != '' ">
                 AND te.executor_name LIKE CONCAT('%', #{executorName}, '%')
             </if>
-            <if test=" startDate!= null">
+            <!--<if test=" startDate!= null">
                 AND task.start_date &gt; #{startDate}
             </if>
             <if test=" endDate!= null">
                 AND task.end_date &lt; #{endDate}
+            </if>-->
+            <if test=" startDate!= null and endDate!= null">
+                AND
+                (
+                    (
+                        (task.start_date IS NULL OR task.start_date &lt;= #{startDate}) AND (task.end_date &gt;= #{startDate} AND task.end_date &lt;= #{endDate})
+                    )
+                    OR
+                    (
+                        (task.end_date IS NULL OR task.end_date &gt;= #{endDate}) AND (task.start_date &gt;= #{startDate} AND task.start_date &lt;= #{endDate})
+                    )
+                    OR
+                    (
+                        task.start_date IS NOT NULL AND task.end_date IS NOT NULL AND task.start_date &gt;= #{startDate}
+                        AND task.start_date &lt;= #{endDate} AND task.end_date &gt;= #{startDate} AND task.end_date &lt;= #{endDate}
+                    )
+                )
+            </if>
+            <if test=" startDate != null and endDate == null">
+                AND (task.end_date IS NOT NULL and task.end_date &gt;= #{startDate})
+            </if>
+            <if test=" startDate == null and endDate != null">
+                AND (task.start_date IS NOT NULL and task.start_date &lt;= #{endDate})
             </if>
             <if test=" companyId!= null ">
                 AND task.company_id = #{companyId}
@@ -275,11 +298,34 @@
             <if test=" executorName!= null and executorName != '' ">
                 AND te.executor_name LIKE CONCAT('%', #{executorName}, '%')
             </if>
-            <if test=" startDate!= null  ">
+            <!--<if test=" startDate!= null  ">
                 AND task.start_date &gt; #{startDate}
             </if>
             <if test=" endDate!= null  ">
                 AND task.end_date &lt; #{endDate}
+            </if>-->
+            <if test=" startDate!= null and endDate!= null">
+                AND
+                (
+                    (
+                        (task.start_date IS NULL OR task.start_date &lt;= #{startDate}) AND (task.end_date &gt;= #{startDate} AND task.end_date &lt;= #{endDate})
+                    )
+                OR
+                    (
+                        (task.end_date IS NULL OR task.end_date &gt;= #{endDate}) AND (task.start_date &gt;= #{startDate} AND task.start_date &lt;= #{endDate})
+                    )
+                OR
+                    (
+                        task.start_date IS NOT NULL AND task.end_date IS NOT NULL AND task.start_date &gt;= #{startDate}
+                        AND task.start_date &lt;= #{endDate} AND task.end_date &gt;= #{startDate} AND task.end_date &lt;= #{endDate}
+                    )
+                )
+            </if>
+            <if test=" startDate != null and endDate == null">
+                AND (task.end_date IS NOT NULL and task.end_date &gt;= #{startDate})
+            </if>
+            <if test=" startDate == null and endDate != null">
+                AND (task.start_date IS NOT NULL and task.start_date &lt;= #{endDate})
             </if>
             <if test=" companyId!= null ">
                 AND task.company_id = #{companyId}