hanfucheng 8 kuukautta sitten
vanhempi
commit
0908333459

+ 19 - 1
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionViewMapper.xml

@@ -272,7 +272,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             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,sum(storage_capacity) storageCapacity,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  (
+                    SELECT
+                        count( a.id ) num,
+                        sum( a.storageCapacity ) storageCapacity,
+                        a.dept_id
+                    FROM
+                    (
+                        SELECT
+                        id,
+                        SUBSTRING_INDEX( GROUP_CONCAT( storage_capacity ORDER BY create_time DESC ), ',', 1 ) storageCapacity,
+                        dept_id
+                        FROM
+                        centerdata_t_housingconstruction_storagetank_log
+                        WHERE run_state = 1
+                        GROUP BY storagetank_id
+                    ) a
+                    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}