hanfucheng 1 年之前
父节点
当前提交
ae266d3b90
共有 1 个文件被更改,包括 11 次插入11 次删除
  1. 11 11
      src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionViewMapper.xml

+ 11 - 11
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionViewMapper.xml

@@ -180,19 +180,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
             a.id,
             a.enterprise_name enterpriseName,
-            count(DISTINCT b.id) cgNum,
-            count(DISTINCT c.id) gpNum,
-            count(DISTINCT e.id) aqNum,
-            count(DISTINCT f.id) yxNum,
-            b.storage_capacity storageCapacity
+            IFNULL(b.num,0) cgNum,
+            IFNULL(c.num,0) gpNum,
+            IFNULL(e.num,0) aqNum,
+            IFNULL(f.num,0) yxNum,
+            IFNULL(b.storage_capacity,0)  storageCapacity
         FROM
             centerdata_t_housingconstruction_enterprise a
-            LEFT JOIN (select id, enterprise_id,sum(storage_capacity) storage_capacity from centerdata_t_housingconstruction_storagetank GROUP BY enterprise_id) b ON a.id = b.enterprise_id
-            left join centerdata_t_housingconstruction_steelcylinder c on a.id = c.enterprise_id
-            left join  (SELECT id,storagetank_id, security_state FROM centerdata_t_housingconstruction_storagetank_log
-                    WHERE create_time = (SELECT MAX(create_time) FROM centerdata_t_housingconstruction_storagetank_log) and security_state is null) e on b.id = e.storagetank_id and security_state is null
-            left join  centerdata_t_housingconstruction_storagetank_log f on b.id = f.storagetank_id and run_state = 1
-                LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
+            LEFT JOIN  (select count(id) num, enterprise_id, sum(storage_capacity) storage_capacity from centerdata_t_housingconstruction_storagetank GROUP BY enterprise_id) b ON a.id = b.enterprise_id
+            left join (select count(id) num, enterprise_id from centerdata_t_housingconstruction_steelcylinder GROUP BY enterprise_id) c on a.id = c.enterprise_id
+            left join  (SELECT count(id) num,dept_id FROM centerdata_t_housingconstruction_storagetank_log
+            WHERE create_time = (SELECT MAX(create_time) FROM centerdata_t_housingconstruction_storagetank_log) and security_state ='' GROUP BY dept_id) e on a.id = e.dept_id
+            left join  (select count(id) num,dept_id from centerdata_t_housingconstruction_storagetank_log where run_state = 1 GROUP BY dept_id) f on a.id = f.dept_id
+            LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
         <where>
             ${params.dataScope}
         </where>