From bd3916f68a3f8971bfe8c78b0b71e87fba643e11 Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期四, 10 八月 2023 09:24:58 +0800
Subject: [PATCH] 巡检日历及查询优化

---
 ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml b/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
index a471902..5f3d1ed 100644
--- a/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
+++ b/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
@@ -28,6 +28,13 @@
         <result property="createTime" column="create_time"/>
         <result property="updateBy" column="update_by"/>
         <result property="updateTime" column="update_time"/>
+        <result property="cameraId" column="camera_id"/>
+    </resultMap>
+
+    <resultMap type="ArdAlarmpointsWell" id="wellResult">
+        <result property="id" column="id"/>
+        <result property="wellId" column="well_id"/>
+        <result property="type" column="type"/>
     </resultMap>
 
     <sql id="selectArdAlarmpointsWellVo">
@@ -53,7 +60,8 @@
                c.create_by,
                c.create_time,
                c.update_by,
-               c.update_time
+               c.update_time,
+               c.camera_id
         from ard_alarmpoints_well c
                  left join sys_dept d on d.dept_id = c.dept_id
                  left join sys_user u on u.user_id = c.user_id
@@ -64,18 +72,21 @@
         <where>
             <if test="wellId != null  and wellId != ''">and c.well_id = #{wellId}</if>
             <if test="wellNumber != null  and wellNumber != ''">and c.well_number = #{wellNumber}</if>
-            <if test="userId != null  and userId != ''"> and c.user_id = #{userId}</if>
-            <if test="deptId != null ">  and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) ))</if>
+            <if test="userId != null  and userId != ''">and c.user_id = #{userId}</if>
+            <if test="deptId != null ">and (c.dept_id = #{deptId} OR c.dept_id IN ( SELECT t.dept_id FROM sys_dept t
+                WHERE cast(#{deptId} as varchar) = any(string_to_array(ancestors,',')) ))
+            </if>
             <!-- 鏁版嵁鑼冨洿杩囨护 -->
             ${params.dataScope}
         </where>
     </select>
 
-    <select id="selectArdAlarmpointsWellByWellIdLike" parameterType="ArdAlarmpointsWell" resultMap="ArdAlarmpointsWellResult">
+    <select id="selectArdAlarmpointsWellByWellIdLike" parameterType="ArdAlarmpointsWell"
+            resultMap="ArdAlarmpointsWellResult">
         <include refid="selectArdAlarmpointsWellVo"/>
         <where>
             <if test="id != null  and id != ''">and c.id = #{id}</if>
-            <if test="wellId != null  and wellId != ''"> and well_id like  ('%${wellId}%')</if>
+            <if test="wellId != null  and wellId != ''">and well_id like ('%${wellId}%')</if>
             <!-- 鏁版嵁鑼冨洿杩囨护 -->
             ${params.dataScope}
         </where>
@@ -115,6 +126,7 @@
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
+            <if test="cameraId != null">camera_id,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -140,6 +152,7 @@
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
+            <if test="cameraId != null">#{cameraId},</if>
         </trim>
     </insert>
 
@@ -168,8 +181,9 @@
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="cameraId != null">camera_id = #{cameraId},</if>
         </trim>
-         where well_id = #{wellId}
+        where id = #{id}
     </update>
 
     <delete id="deleteArdAlarmpointsWellById" parameterType="String">
@@ -184,4 +198,14 @@
             #{id}
         </foreach>
     </delete>
+    <select id="checkWellIdExists" resultType="boolean">
+        SELECT COUNT(*)
+        FROM ard_alarmpoints_well
+        WHERE well_id = #{wellId}
+    </select>
+
+    <select id="wellByPlanId" parameterType="String" resultMap="wellResult">
+        select ard_app_patrolpoint.alarmpoints_id as id,ard_alarmpoints_well.well_id, ard_app_patrolpoint."type" from ard_alarmpoints_well LEFT JOIN ard_app_patrolpoint on ard_app_patrolpoint.alarmpoints_id = ard_alarmpoints_well.id where ard_alarmpoints_well.id in (select alarmpoints_id from ard_app_patrolpoint where patrolplan_id = #{id})
+        GROUP BY ard_app_patrolpoint.alarmpoints_id,ard_alarmpoints_well.well_id,ard_app_patrolpoint."type"
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3