<?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.project.patrol.patrol.mapper.TPatrolMainMapper">

    <resultMap type="TPatrolMain" id="TPatrolMainResult">
        <result property="id"    column="id"    />
        <result property="devName"    column="dev_name"    />
        <result property="devNum"    column="dev_num"    />
        <result property="checkCycle"    column="check_cycle"    />
        <result property="year"    column="year"    />
        <result property="jan"    column="jan"    />
        <result property="feb"    column="feb"    />
        <result property="mar"    column="mar"    />
        <result property="apr"    column="apr"    />
        <result property="may"    column="may"    />
        <result property="jun"    column="jun"    />
        <result property="jul"    column="jul"    />
        <result property="aug"    column="aug"    />
        <result property="sep"    column="sep"    />
        <result property="oct"    column="oct"    />
        <result property="nov"    column="nov"    />
        <result property="dec"    column="dec"    />
        <result property="personLiable"    column="person_liable"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="remarks"    column="remarks"    />
        <result property="deptId"    column="dept_id"    />
        <result property="devLink"    column="dev_link"    />
        <result property="patrolType"    column="patrol_type"    />
    </resultMap>

    <sql id="selectTPatrolMainVo">
        select id, dev_name, dev_num, check_cycle, year, jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec,patrol_type, person_liable, del_flag, creater_code, createdate, updater_code, updatedate, remarks, dept_id,dev_link from t_patrol_main
    </sql>

    <select id="selectTPatrolMainList" parameterType="TPatrolMain" resultMap="TPatrolMainResult">
        <include refid="selectTPatrolMainVo"/>
        <where>
            <if test="devName != null  and devName != ''"> and dev_name like concat(concat('%', #{devName}), '%')</if>
            <if test="devNum != null  and devNum != ''"> and dev_num = #{devNum}</if>
            <if test="checkCycle != null  and checkCycle != ''"> and check_cycle = #{checkCycle}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="jan != null  and jan != ''"> and jan = #{jan}</if>
            <if test="feb != null  and feb != ''"> and feb = #{feb}</if>
            <if test="mar != null  and mar != ''"> and mar = #{mar}</if>
            <if test="apr != null  and apr != ''"> and apr = #{apr}</if>
            <if test="may != null  and may != ''"> and may = #{may}</if>
            <if test="jun != null  and jun != ''"> and jun = #{jun}</if>
            <if test="jul != null  and jul != ''"> and jul = #{jul}</if>
            <if test="aug != null  and aug != ''"> and aug = #{aug}</if>
            <if test="sep != null  and sep != ''"> and sep = #{sep}</if>
            <if test="oct != null  and oct != ''"> and oct = #{oct}</if>
            <if test="nov != null  and nov != ''"> and nov = #{nov}</if>
            <if test="dec != null  and dec != ''"> and dec = #{dec}</if>
            <if test="patrolType != null  and patrolType != ''"> and patrol_type = #{patrolType}</if>
            <if test="personLiable != null  and personLiable != ''"> and person_liable = #{personLiable}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="devLink != null "> and dev_link = #{devLink}</if>
            and del_flag=0
        </where>
        order by createdate
    </select>

    <select id="selectTPatrolMainById" parameterType="Long" resultMap="TPatrolMainResult">
        <include refid="selectTPatrolMainVo"/>
        where id = #{id}
    </select>

    <insert id="insertTPatrolMain" parameterType="TPatrolMain">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_patrol_main.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_patrol_main
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="devName != null">dev_name,</if>
            <if test="devNum != null">dev_num,</if>
            <if test="checkCycle != null">check_cycle,</if>
            <if test="year != null">year,</if>
            <if test="jan != null">jan,</if>
            <if test="feb != null">feb,</if>
            <if test="mar != null">mar,</if>
            <if test="apr != null">apr,</if>
            <if test="may != null">may,</if>
            <if test="jun != null">jun,</if>
            <if test="jul != null">jul,</if>
            <if test="aug != null">aug,</if>
            <if test="sep != null">sep,</if>
            <if test="oct != null">oct,</if>
            <if test="nov != null">nov,</if>
            <if test="dec != null">dec,</if>
            <if test="personLiable != null">person_liable,</if>
            <if test="patrolType != null">patrol_type,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="remarks != null">remarks,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="devLink != null">dev_link,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="devName != null">#{devName},</if>
            <if test="devNum != null">#{devNum},</if>
            <if test="checkCycle != null">#{checkCycle},</if>
            <if test="year != null">#{year},</if>
            <if test="jan != null">#{jan},</if>
            <if test="feb != null">#{feb},</if>
            <if test="mar != null">#{mar},</if>
            <if test="apr != null">#{apr},</if>
            <if test="may != null">#{may},</if>
            <if test="jun != null">#{jun},</if>
            <if test="jul != null">#{jul},</if>
            <if test="aug != null">#{aug},</if>
            <if test="sep != null">#{sep},</if>
            <if test="oct != null">#{oct},</if>
            <if test="nov != null">#{nov},</if>
            <if test="dec != null">#{dec},</if>
            <if test="personLiable != null">#{personLiable},</if>
            <if test="patrolType != null">#{patrolType},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="devLink != null">#{devLink},</if>
         </trim>
    </insert>

    <update id="updateTPatrolMain" parameterType="TPatrolMain">
        update t_patrol_main
        <trim prefix="SET" suffixOverrides=",">
            <if test="devName != null">dev_name = #{devName},</if>
            <if test="devNum != null">dev_num = #{devNum},</if>
            <if test="checkCycle != null">check_cycle = #{checkCycle},</if>
            <if test="year != null">year = #{year},</if>
            <if test="jan != null">jan = #{jan},</if>
            <if test="feb != null">feb = #{feb},</if>
            <if test="mar != null">mar = #{mar},</if>
            <if test="apr != null">apr = #{apr},</if>
            <if test="may != null">may = #{may},</if>
            <if test="jun != null">jun = #{jun},</if>
            <if test="jul != null">jul = #{jul},</if>
            <if test="aug != null">aug = #{aug},</if>
            <if test="sep != null">sep = #{sep},</if>
            <if test="oct != null">oct = #{oct},</if>
            <if test="nov != null">nov = #{nov},</if>
            <if test="dec != null">dec = #{dec},</if>
            <if test="personLiable != null">person_liable = #{personLiable},</if>
            <if test="patrolType != null">patrol_type = #{patrolType},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="devLink != null">dev_link = #{devLink},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateTPatrolMainByType" parameterType="TPatrolMain">
        update t_patrol_main
        <trim prefix="SET" suffixOverrides=",">
            <if test="devNum != null">dev_num = #{devNum},</if>
            <if test="year != null">year = #{year},</if>
            <if test="jan != null">jan = #{jan},</if>
            <if test="feb != null">feb = #{feb},</if>
            <if test="mar != null">mar = #{mar},</if>
            <if test="apr != null">apr = #{apr},</if>
            <if test="may != null">may = #{may},</if>
            <if test="jun != null">jun = #{jun},</if>
            <if test="jul != null">jul = #{jul},</if>
            <if test="aug != null">aug = #{aug},</if>
            <if test="sep != null">sep = #{sep},</if>
            <if test="oct != null">oct = #{oct},</if>
            <if test="nov != null">nov = #{nov},</if>
            <if test="dec != null">dec = #{dec},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where patrol_type = #{patrolType}
    </update>

    <delete id="deleteTPatrolMainById" parameterType="Long">
        delete from t_patrol_main where id = #{id}
    </delete>

    <delete id="deleteTPatrolMainByIds" parameterType="String">
        delete from t_patrol_main where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
