hanfucheng 10 月之前
父節點
當前提交
9f581cce68

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

@@ -243,18 +243,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from centerdata_t_housingconstruction_storagetank a
         left join centerdata_t_housingconstruction_storagetank_log b on b.storagetank_id = a.id
         left join onest_system.sys_dept d on a.dept_id = d.dept_id
+        JOIN (
+            SELECT storagetank_id,MAX(create_time) AS max_time
+            FROM centerdata_t_housingconstruction_storagetank_log
         <if test="state != null  and state != ''">
-            JOIN (
-                SELECT storagetank_id,MAX(create_time) AS max_time
-                FROM centerdata_t_housingconstruction_storagetank_log
-                where
-                DATE_FORMAT(create_time, '%Y_%m_%d') = CURDATE()
-                GROUP BY storagetank_id
-                ) c ON b.storagetank_id = c.storagetank_id AND b.create_time = c.max_time
+            where
+            DATE_FORMAT(create_time, '%Y_%m_%d') = CURDATE()
         </if>
+            GROUP BY storagetank_id
+            ) c ON b.storagetank_id = c.storagetank_id AND b.create_time = c.max_time
         <where>
             <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
-            <if test="state != null  and state != ''"> and a.security_state !=''</if>
+            <if test="state != null  and state != ''"> and b.security_state !=''</if>
             ${params.dataScope}
         </where>
         GROUP BY a.id