hanfucheng 9 months ago
parent
commit
03a399c0f8

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

@@ -426,7 +426,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ${params.dataScope}-->
     <select id="getJoinHouseUserList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">
         SELECT
-            SUBSTRING_INDEX( GROUP_CONCAT( l.steelcylinder_name ORDER BY sign_time DESC ), ',', 1 ) steelcylinderName,
+            l.steelcylinderName steelcylinderName,
+            l.steelcylinder_id,
             u.longitude,
             u.latitude,
             u.gas_address gasAddress,
@@ -436,18 +437,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             u.dept_name as name,
             l.sign_time deliveryTime,
             l.delivery_name deliveryName
-        FROM
-        centerdata_t_housingconstruction_steelcylinder_log l
+        FROM centerdata_t_housingconstruction_steelcylinder a
+        left join ( SELECT
+                    SUBSTRING_INDEX( GROUP_CONCAT( l.steelcylinder_name ORDER BY sign_time DESC ), ',', 1 ) steelcylinderName,
+                    SUBSTRING_INDEX( GROUP_CONCAT( l.steelcylinder_id ORDER BY sign_time DESC ), ',', 1 ) steelcylinder_id,
+                    SUBSTRING_INDEX( GROUP_CONCAT( l.join_house_id ORDER BY sign_time DESC ), ',', 1 ) join_house_id,
+                    SUBSTRING_INDEX( GROUP_CONCAT( l.join_house_name ORDER BY sign_time DESC ), ',', 1 ) join_house_name,
+                    SUBSTRING_INDEX( GROUP_CONCAT( l.sign_time ORDER BY sign_time DESC ), ',', 1 ) sign_time,
+                    SUBSTRING_INDEX( GROUP_CONCAT( l.delivery_name ORDER BY sign_time DESC ), ',', 1 ) delivery_name
+                    FROM
+                    centerdata_t_housingconstruction_steelcylinder_log l
+                    where
+                    l.recycling_time is null
+                    GROUP BY l.steelcylinder_id
+                    ) l on a.id = l.steelcylinder_id
         LEFT JOIN centerdata_t_housingconstruction_realnameuser u ON u.id = l.join_house_id
-        LEFT JOIN ${database_system}.sys_dept d ON d.dept_id = u.dept_id
         <where>
+            a.state = 'state_4'
             <if test="state != null  and state != ''">
                 and DATE(l.sign_time) = CURDATE()
             </if>
-            <if test="enterpriseId != null  and enterpriseId != ''"> and u.enterprise_id = #{enterpriseId}</if>
-            <if test="name != null  and name != ''"> and l.steelcylinder_name like concat('%', #{name}, '%')</if>
+            <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
+            <if test="name != null  and name != ''"> and a.steelcylinder_name like concat('%', #{name}, '%')</if>
         </where>
-        GROUP BY join_house_id
     </select>
 
     <select id="getGassourceList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">