高雄 1 rok pred
rodič
commit
ee551703fb

+ 29 - 21
soc-modules/soc-modules-core/src/main/resources/mapper/board/CockpitMapper.xml

@@ -282,7 +282,7 @@
                      sum(if(m.ga382015 is null or m.ga382015 = 0, 0, 1))                 as ga382015,
                      sum(if(m.ga382015current is null or m.ga382015current = 0, 0, 1))   as ga382015current
                  from
-                     (select *FROM
+                     (select * FROM
                          (
                          <if test="type == 3">
                              SELECT id ,if(breviary is null,short_name,breviary) as org_name,path,sort as tj_sort FROM sys_org WHERE type = 4 AND deleted = 0 and path LIKE CONCAT(#{orgPath},'%') ) a
@@ -297,26 +297,34 @@
                          </if>
 
                              LEFT JOIN (
-                             SELECT
-                                 org_id,
-                                 sum( standard = 1 ) AS ga382021,
-                                 sum(
-                                         IF
-                                             ( standard = 1 AND   date_of_compliance >= '2022-01-01', 1, 0 )) AS ga382021current,
-                                 sum( standard = 2 ) AS ga382015,
-                                 sum(standard =1 or standard = 2) as ga38,
-                                 sum(
-                                         IF
-                                             ( standard = 2 AND date_of_compliance >= '2022-01-01', 1, 0 )) AS ga382015current
-                             FROM
-                                 sys_org_physical_defense_construction
-                             WHERE
-                                 type = 1
-                               and standard != 3
-                             GROUP BY
-                                 org_id
-                         ) b ON a.id = b.org_id
+                                select
+                                t.org_id,
+                                if((t.ga382021 - t.ga382015) &gt;= 0,1,0) as ga382021,
+                                if((t.ga382021 - t.ga382015) &lt; 0,1,0) as ga382015,
+                                if((t.ga382015 + t.ga382021) &gt; 0 ,1,0 ) as ga38,
+                                if((t.ga382021current - t.ga382015current) &gt;= 0,1,0) as ga382021current,
+                                if((t.ga382021current - t.ga382015current) &lt; 0,1,0) as ga382015current
+                                from (
+                                SELECT
+                                org_id,
+                                sum( standard = 1 ) AS ga382021,
+                                sum(
+                                IF
+                                ( standard = 1 AND date_of_compliance &gt;= #{date}, 1, 0 )) AS ga382021current,
+                                sum( standard = 2 ) AS ga382015,
+                                sum(
+                                IF
+                                ( standard = 2 AND date_of_compliance &gt;= #{date}, 1, 0 )) AS ga382015current
+                                FROM
+                                sys_org_physical_defense_construction
+                                WHERE
+                                type = 1
+                                AND standard != 3
+                                GROUP BY
+                                org_id
+                                ) t
+        ) b ON a.id = b.org_id
                      ) m GROUP BY m.org_name,m.tj_sort
-             ) t ORDER BY t.tj_sort;
+             ) t ORDER BY t.tj_sort
     </select>
 </mapper>