Browse Source

:sparkles:增加查找有实际占用但是没有起飞或者入站的飞机sql

Twelve615 1 year ago
parent
commit
2e70ab84ab

+ 35 - 1
airport/jeecg-boot-module-system/src/main/java/org/jeecg/modules/admin_dfdl_list/mapper/xml/AdminDfdlListMapper.xml

@@ -24,6 +24,39 @@
               FROM admin_dfdl_list
               WHERE position_code IS NOT NULL
                 AND position_code != ''
+        AND flio = 'A'
+        AND arrival = 0
+        AND rstr IS NOT NULL
+        AND rstr <= date_format(#{date,jdbcType=TIMESTAMP}, '%Y-%m-%d %H:%i:%s.%f')
+        AND IFNULL(IFNULL(rend, IFNULL(IF(alte = 0, frtt, drtt), IFNULL(IF(alte = 0, fett, dett), eend))), DATE_ADD(CURDATE(), INTERVAL 1 DAY)) >=
+            date_format(#{date,jdbcType=TIMESTAMP}, '%Y-%m-%d %H:%i:%s.%f')
+        AND (depe != 1 OR depe IS NULL)
+        AND del = 0
+        AND cane = 0
+          GROUP BY cfno, position_code
+          HAVING max(estr)
+          UNION
+          SELECT *
+          FROM admin_dfdl_list
+          WHERE position_code IS NOT NULL
+            AND position_code != ''
+            AND flio = 'D'
+            AND arrival = 0
+            AND depe = 0
+            AND rstr IS NOT NULL
+            AND rstr <= date_format(#{date,jdbcType=TIMESTAMP}, '%Y-%m-%d %H:%i:%s.%f')
+            AND IFNULL(IFNULL(rend, IFNULL(IF(alte = 0, frtt, drtt), IFNULL(IF(alte = 0, fett, dett), eend))), DATE_ADD(CURDATE(), INTERVAL 1 DAY)) >=
+              date_format(#{date,jdbcType=TIMESTAMP}, '%Y-%m-%d %H:%i:%s.%f')
+            AND (depe != 1 OR depe IS NULL)
+            AND del = 0
+            AND cane = 0
+          GROUP BY cfno, position_code
+          HAVING max(estr)
+    UNION
+    SELECT *
+      FROM admin_dfdl_list
+      WHERE position_code IS NOT NULL
+        AND position_code != ''
         AND arrival = 1
         AND flio = 'A'
         AND IFNULL(IFNULL(IF(alte = 0, frlt, drlt), IFNULL(IF(alte = 0, felt, delt), IFNULL(rstr, IFNULL(fplt, estr)))), DATE_ADD(CURDATE(), INTERVAL 1 DAY)) <=
@@ -92,9 +125,10 @@
               WHERE position_code IS NOT NULL
                 AND position_code != ''
                 AND flio = 'D'
+                AND rend IS NULL
                 AND IFNULL(IFNULL(IF(alte = 0, frlt, drlt), IFNULL(rstr, IFNULL(IF(alte = 0, felt, delt), IFNULL(fplt, estr)))), DATE_ADD(CURDATE(), INTERVAL 1 DAY)) <=
                   date_format(#{date,jdbcType=TIMESTAMP}, '%Y-%m-%d %H:%i:%s.%f')
-                AND IFNULL(IFNULL(rend, IFNULL(IF(alte = 0, frtt, drtt), IFNULL(IF(alte = 0, fett, dett), IFNULL(fptt, eend)))), DATE_ADD(CURDATE(), INTERVAL 1 DAY)) <=
+                AND IFNULL(IFNULL(IF(alte = 0, frtt, drtt), IFNULL(IF(alte = 0, fett, dett), IFNULL(fptt, eend))), DATE_ADD(CURDATE(), INTERVAL 1 DAY)) <=
                   date_format(#{date,jdbcType=TIMESTAMP}, '%Y-%m-%d %H:%i:%s.%f')
                 AND (depe != 1 OR depe IS NULL)
                 AND del = 0