| <?xml version="1.0" encoding="UTF-8" ?> | 
| <!DOCTYPE mapper | 
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | 
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
| <mapper namespace="com.ruoyi.app.patrolplan.mapper.ArdAppPatrolplanMapper"> | 
|      | 
|     <resultMap type="ArdAppPatrolplan" id="ArdAppPatrolplanResult"> | 
|         <result property="patroEndTime"    column="patro_end_time"    /> | 
|         <result property="userId"    column="user_id"    /> | 
|         <result property="cycle"    column="cycle"    /> | 
|         <result property="createTime"    column="create_time"    /> | 
|         <result property="id"    column="id"    /> | 
|         <result property="planName"    column="plan_name"    /> | 
|         <result property="patroBeginTime"    column="patro_begin_time"    /> | 
|         <result property="nickName"    column="nick_name"    /> | 
|     </resultMap> | 
|   | 
|     <sql id="selectArdAppPatrolplanVo"> | 
|         select | 
|             ard_app_patrolplan.id, | 
|             sys_user.nick_name, | 
|             ard_app_patrolplan.patro_end_time, | 
|             ard_app_patrolplan.user_id, | 
|             ard_app_patrolplan.cycle, | 
|             ard_app_patrolplan.create_time, | 
|             ard_app_patrolplan.plan_name, | 
|             ard_app_patrolplan.patro_begin_time | 
|         from | 
|             ard_app_patrolplan | 
|     </sql> | 
|   | 
|     <select id="selectArdAppPatrolplanList" parameterType="ArdAppPatrolplan" resultMap="ArdAppPatrolplanResult"> | 
|         <include refid="selectArdAppPatrolplanVo"/> | 
|         left join ard_app_patrolpoint as well on ard_app_patrolplan.id = well.patrolplan_id | 
|         left join ard_app_patroluser as users on ard_app_patrolplan.id = users.patrolplan_id | 
|         left join sys_user on ard_app_patrolplan.user_id = sys_user.user_id | 
|         <where>   | 
|             <if test="userId != null  and userId != ''"> and ard_app_patrolplan.user_id = #{userId}</if> | 
|             <if test="cycle != null  and cycle != ''"> and cycle = #{cycle}</if> | 
|             <if test="planName != null  and planName != ''"> and plan_name like '%'||#{planName}||'%'</if> | 
|             <if test="patroBeginTime != null  and patroBeginTime != ''"> and patro_begin_time >= #{patroBeginTime}</if> | 
|             <if test="patroEndTime != null  and patroEndTime != ''"> and patro_end_time <= #{patroEndTime}</if> | 
|             <if test="wellId != null  and wellId != ''"> | 
|                 and well.alarmpoints_id = (select ard_alarmpoints_well.id from ard_alarmpoints_well where well_id = #{wellId}) | 
|             </if> | 
|             <if test="pUser != null  and pUser != ''"> | 
|                 and users.app_user_id = (select sys_user.user_id from sys_user where nick_name = #{pUser}) | 
|             </if> | 
|         </where> | 
|             group by ard_app_patrolplan.id,sys_user.nick_name | 
|     </select> | 
|      | 
|     <select id="selectArdAppPatrolplanByPatroEndTime" parameterType="String" resultMap="ArdAppPatrolplanResult"> | 
|         <include refid="selectArdAppPatrolplanVo"/> | 
|         where patro_end_time = #{patroEndTime} | 
|     </select> | 
|          | 
|     <insert id="insertArdAppPatrolplan" parameterType="ArdAppPatrolplan"> | 
|         insert into ard_app_patrolplan | 
|         <trim prefix="(" suffix=")" suffixOverrides=","> | 
|             <if test="patroEndTime != null">patro_end_time,</if> | 
|             <if test="userId != null">user_id,</if> | 
|             <if test="cycle != null">cycle,</if> | 
|             <if test="createTime != null">create_time,</if> | 
|             <if test="id != null">id,</if> | 
|             <if test="planName != null">plan_name,</if> | 
|             <if test="patroBeginTime != null">patro_begin_time,</if> | 
|          </trim> | 
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | 
|             <if test="patroEndTime != null">#{patroEndTime},</if> | 
|             <if test="userId != null">#{userId},</if> | 
|             <if test="cycle != null">#{cycle},</if> | 
|             <if test="createTime != null">#{createTime},</if> | 
|             <if test="id != null">#{id},</if> | 
|             <if test="planName != null">#{planName},</if> | 
|             <if test="patroBeginTime != null">#{patroBeginTime},</if> | 
|          </trim> | 
|     </insert> | 
|   | 
|     <update id="updateArdAppPatrolplan" parameterType="ArdAppPatrolplan"> | 
|         update ard_app_patrolplan | 
|         <trim prefix="SET" suffixOverrides=","> | 
|             <if test="userId != null">user_id = #{userId},</if> | 
|             <if test="cycle != null">cycle = #{cycle},</if> | 
|             <if test="createTime != null">create_time = #{createTime},</if> | 
|             <if test="id != null">id = #{id},</if> | 
|             <if test="planName != null">plan_name = #{planName},</if> | 
|             <if test="patroBeginTime != null">patro_begin_time = #{patroBeginTime},</if> | 
|         </trim> | 
|         where patro_end_time = #{patroEndTime} | 
|     </update> | 
|   | 
|     <delete id="deleteArdAppPatrolplanByPatroEndTime" parameterType="String"> | 
|         delete from ard_app_patrolplan where ard_app_patrolplan.id = #{id}; | 
|     </delete> | 
|   | 
|     <delete id="deleteArdAppPatrolplanByPatroEndTimes" parameterType="String"> | 
|         delete from ard_app_patrolplan | 
|         left join ard_app_patrolpoint as well on ard_app_patrolplan.id = well.patrolplan_id | 
|         left join ard_app_patroluser as users on ard_app_patrolplan.id = users.patrolplan_id | 
|         where ard_app_patrolplan.id in | 
|         <foreach item="patroEndTime" collection="array" open="(" separator="," close=")"> | 
|             #{id} | 
|         </foreach> | 
|     </delete> | 
|   | 
|     <delete id="deleteArdAppPatrolplanById" parameterType="String"> | 
|         delete from ard_app_patrolplan aap where aap.id = #{id}; | 
|     </delete> | 
| </mapper> |