<?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.shiftmgr.mapper.TShiftLogMapper">

    <resultMap type="TShiftLog" id="TShiftLogResult">
        <result property="id"    column="id"    />
        <result property="shiftTeam"    column="shift_team"    />
        <result property="takeOverTime"    column="take_over_time"    />
        <result property="giveOverTime"    column="give_over_time"    />
        <result property="tocp"    column="tocp"    />
        <result property="ehs5sBriefing"    column="ehs_5s_briefing"    />
        <result property="soa"    column="soa"    />
        <result property="sh"    column="sh"    />
        <result property="bdoc"    column="bdoc"    />
        <result property="thfd"    column="thfd"    />
        <result property="pthfUnit"    column="pthf_unit"    />
        <result property="dbpd"    column="dbpd"    />
        <result property="truss"    column="truss"    />
        <result property="pthfCus"    column="pthf_cus"    />
        <result property="bipus"    column="bipus"    />
        <result property="lpgH2"    column="lpg_h2"    />
        <result property="q125601"    column="q125601"    />
        <result property="q125602"    column="q125602"    />
        <result property="q312018Q1"    column="q312018_q1"    />
        <result property="q312018Q2"    column="q312018_q2"    />
        <result property="q312018Q3"    column="q312018_q3"    />
        <result property="q312018Q4"    column="q312018_q4"    />
        <result property="q312000"    column="q312000"    />
        <result property="q312001"    column="q312001"    />
        <result property="epdOther"    column="epd_other"    />
        <result property="ehsOther"    column="ehs_other"    />
        <result property="qar"    column="qar"    />
        <result property="maEi"    column="ma_ei"    />
        <result property="maMechanical"    column="ma_mechanical"    />
        <result property="thirdPartyCommunication"    column="third_party_communication"    />
        <result property="fampEi"    column="famp_ei"    />
        <result property="fampMechanical"    column="famp_mechanical"    />
        <result property="faop"    column="faop"    />
        <result property="comments"    column="comments"    />
        <result property="hoShiftSup"    column="ho_shift_sup"    />
        <result property="toShiftSup"    column="to_shift_sup"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="status"    column="status"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTShiftLogVo">
        select id, shift_team, take_over_time,give_over_time, tocp, ehs_5s_briefing, soa, sh, bdoc, thfd, pthf_unit, dbpd, truss, pthf_cus, bipus, lpg_h2, q125601, q125602, q312018_q1, q312018_q2, q312018_q3, q312018_q4, q312000, q312001, epd_other, ehs_other, qar, ma_ei, ma_mechanical, third_party_communication, famp_ei, famp_mechanical, faop, comments, ho_shift_sup, to_shift_sup, del_flag, status, creater_code, createdate, updater_code, updatedate, dept_id, remarks from t_shift_log
    </sql>

    <select id="selectTShiftLogList" parameterType="TShiftLog" resultMap="TShiftLogResult">
        <include refid="selectTShiftLogVo"/>
        <where>
            <if test="shiftTeam != null  and shiftTeam != ''"> and shift_team like concat('%',#{shiftTeam},'%')</if>
            <if test="takeOverTime != null "> and take_over_time = #{takeOverTime}</if>
            <if test="giveOverTime != null "> and give_over_time = #{giveOverTime}</if>
            <if test="tocp != null  and tocp != ''"> and tocp = #{tocp}</if>
            <if test="ehs5sBriefing != null  and ehs5sBriefing != ''"> and ehs_5s_briefing = #{ehs5sBriefing}</if>
            <if test="soa != null  and soa != ''"> and soa = #{soa}</if>
            <if test="sh != null  and sh != ''"> and sh = #{sh}</if>
            <if test="bdoc != null  and bdoc != ''"> and bdoc = #{bdoc}</if>
            <if test="thfd != null  and thfd != ''"> and thfd = #{thfd}</if>
            <if test="pthfUnit != null  and pthfUnit != ''"> and pthf_unit = #{pthfUnit}</if>
            <if test="dbpd != null  and dbpd != ''"> and dbpd = #{dbpd}</if>
            <if test="truss != null  and truss != ''"> and truss = #{truss}</if>
            <if test="pthfCus != null  and pthfCus != ''"> and pthf_cus = #{pthfCus}</if>
            <if test="bipus != null  and bipus != ''"> and bipus = #{bipus}</if>
            <if test="lpgH2 != null  and lpgH2 != ''"> and lpg_h2 = #{lpgH2}</if>
            <if test="q125601 != null  and q125601 != ''"> and q125601 = #{q125601}</if>
            <if test="q125602 != null  and q125602 != ''"> and q125602 = #{q125602}</if>
            <if test="q312018Q1 != null  and q312018Q1 != ''"> and q312018_q1 = #{q312018Q1}</if>
            <if test="q312018Q2 != null  and q312018Q2 != ''"> and q312018_q2 = #{q312018Q2}</if>
            <if test="q312018Q3 != null  and q312018Q3 != ''"> and q312018_q3 = #{q312018Q3}</if>
            <if test="q312018Q4 != null  and q312018Q4 != ''"> and q312018_q4 = #{q312018Q4}</if>
            <if test="q312000 != null  and q312000 != ''"> and q312000 = #{q312000}</if>
            <if test="q312001 != null  and q312001 != ''"> and q312001 = #{q312001}</if>
            <if test="epdOther != null  and epdOther != ''"> and epd_other = #{epdOther}</if>
            <if test="ehsOther != null  and ehsOther != ''"> and ehs_other = #{ehsOther}</if>
            <if test="qar != null  and qar != ''"> and qar = #{qar}</if>
            <if test="maEi != null  and maEi != ''"> and ma_ei = #{maEi}</if>
            <if test="maMechanical != null  and maMechanical != ''"> and ma_mechanical = #{maMechanical}</if>
            <if test="thirdPartyCommunication != null  and thirdPartyCommunication != ''"> and third_party_communication = #{thirdPartyCommunication}</if>
            <if test="fampEi != null  and fampEi != ''"> and famp_ei = #{fampEi}</if>
            <if test="fampMechanical != null  and fampMechanical != ''"> and famp_mechanical = #{fampMechanical}</if>
            <if test="faop != null  and faop != ''"> and faop = #{faop}</if>
            <if test="comments != null  and comments != ''"> and comments = #{comments}</if>
            <if test="hoShiftSup != null  and hoShiftSup != ''"> and ho_shift_sup = #{hoShiftSup}</if>
            <if test="toShiftSup != null  and toShiftSup != ''"> and to_shift_sup = #{toShiftSup}</if>
            <if test="status != null "> and status = #{status}</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="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        and del_flag = 0
        </where>
        order by createdate desc,take_over_time desc
    </select>

    <select id="selectTShiftLogById" parameterType="Long" resultMap="TShiftLogResult">
        <include refid="selectTShiftLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertTShiftLog" parameterType="TShiftLog" useGeneratedKeys="true" keyProperty="id">
        insert into t_shift_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="shiftTeam != null and shiftTeam != ''">shift_team,</if>
            <if test="takeOverTime != null">take_over_time,</if>
            <if test="giveOverTime != null">give_over_time,</if>
            <if test="tocp != null and tocp != ''">tocp,</if>
            <if test="ehs5sBriefing != null and ehs5sBriefing != ''">ehs_5s_briefing,</if>
            <if test="soa != null and soa != ''">soa,</if>
            <if test="sh != null and sh != ''">sh,</if>
            <if test="bdoc != null and bdoc != ''">bdoc,</if>
            <if test="thfd != null and thfd != ''">thfd,</if>
            <if test="pthfUnit != null and pthfUnit != ''">pthf_unit,</if>
            <if test="dbpd != null and dbpd != ''">dbpd,</if>
            <if test="truss != null and truss != ''">truss,</if>
            <if test="pthfCus != null and pthfCus != ''">pthf_cus,</if>
            <if test="bipus != null and bipus != ''">bipus,</if>
            <if test="lpgH2 != null and lpgH2 != ''">lpg_h2,</if>
            <if test="q125601 != null and q125601 != ''">q125601,</if>
            <if test="q125602 != null and q125602 != ''">q125602,</if>
            <if test="q312018Q1 != null and q312018Q1 != ''">q312018_q1,</if>
            <if test="q312018Q2 != null and q312018Q2 != ''">q312018_q2,</if>
            <if test="q312018Q3 != null and q312018Q3 != ''">q312018_q3,</if>
            <if test="q312018Q4 != null and q312018Q4 != ''">q312018_q4,</if>
            <if test="q312000 != null and q312000 != ''">q312000,</if>
            <if test="q312001 != null and q312001 != ''">q312001,</if>
            <if test="epdOther != null and epdOther != ''">epd_other,</if>
            <if test="ehsOther != null and ehsOther != ''">ehs_other,</if>
            <if test="qar != null and qar != ''">qar,</if>
            <if test="maEi != null and maEi != ''">ma_ei,</if>
            <if test="maMechanical != null and maMechanical != ''">ma_mechanical,</if>
            <if test="thirdPartyCommunication != null and thirdPartyCommunication != ''">third_party_communication,</if>
            <if test="fampEi != null and fampEi != ''">famp_ei,</if>
            <if test="fampMechanical != null and fampMechanical != ''">famp_mechanical,</if>
            <if test="faop != null and faop != ''">faop,</if>
            <if test="comments != null and comments != ''">comments,</if>
            <if test="hoShiftSup != null and hoShiftSup != ''">ho_shift_sup,</if>
            <if test="toShiftSup != null and toShiftSup != ''">to_shift_sup,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="status != null">status,</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="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="shiftTeam != null and shiftTeam != ''">#{shiftTeam},</if>
            <if test="takeOverTime != null">#{takeOverTime},</if>
            <if test="giveOverTime != null">#{giveOverTime},</if>
            <if test="tocp != null and tocp != ''">#{tocp},</if>
            <if test="ehs5sBriefing != null and ehs5sBriefing != ''">#{ehs5sBriefing},</if>
            <if test="soa != null and soa != ''">#{soa},</if>
            <if test="sh != null and sh != ''">#{sh},</if>
            <if test="bdoc != null and bdoc != ''">#{bdoc},</if>
            <if test="thfd != null and thfd != ''">#{thfd},</if>
            <if test="pthfUnit != null and pthfUnit != ''">#{pthfUnit},</if>
            <if test="dbpd != null and dbpd != ''">#{dbpd},</if>
            <if test="truss != null and truss != ''">#{truss},</if>
            <if test="pthfCus != null and pthfCus != ''">#{pthfCus},</if>
            <if test="bipus != null and bipus != ''">#{bipus},</if>
            <if test="lpgH2 != null and lpgH2 != ''">#{lpgH2},</if>
            <if test="q125601 != null and q125601 != ''">#{q125601},</if>
            <if test="q125602 != null and q125602 != ''">#{q125602},</if>
            <if test="q312018Q1 != null and q312018Q1 != ''">#{q312018Q1},</if>
            <if test="q312018Q2 != null and q312018Q2 != ''">#{q312018Q2},</if>
            <if test="q312018Q3 != null and q312018Q3 != ''">#{q312018Q3},</if>
            <if test="q312018Q4 != null and q312018Q4 != ''">#{q312018Q4},</if>
            <if test="q312000 != null and q312000 != ''">#{q312000},</if>
            <if test="q312001 != null and q312001 != ''">#{q312001},</if>
            <if test="epdOther != null and epdOther != ''">#{epdOther},</if>
            <if test="ehsOther != null and ehsOther != ''">#{ehsOther},</if>
            <if test="qar != null and qar != ''">#{qar},</if>
            <if test="maEi != null and maEi != ''">#{maEi},</if>
            <if test="maMechanical != null and maMechanical != ''">#{maMechanical},</if>
            <if test="thirdPartyCommunication != null and thirdPartyCommunication != ''">#{thirdPartyCommunication},</if>
            <if test="fampEi != null and fampEi != ''">#{fampEi},</if>
            <if test="fampMechanical != null and fampMechanical != ''">#{fampMechanical},</if>
            <if test="faop != null and faop != ''">#{faop},</if>
            <if test="comments != null and comments != ''">#{comments},</if>
            <if test="hoShiftSup != null and hoShiftSup != ''">#{hoShiftSup},</if>
            <if test="toShiftSup != null and toShiftSup != ''">#{toShiftSup},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="status != null">#{status},</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="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTShiftLog" parameterType="TShiftLog">
        update t_shift_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="shiftTeam != null and shiftTeam != ''">shift_team = #{shiftTeam},</if>
            <if test="takeOverTime != null">take_over_time = #{takeOverTime},</if>
            <if test="giveOverTime != null">give_over_time = #{giveOverTime},</if>
            <if test="tocp != null and tocp != ''">tocp = #{tocp},</if>
            <if test="ehs5sBriefing != null and ehs5sBriefing != ''">ehs_5s_briefing = #{ehs5sBriefing},</if>
            <if test="soa != null and soa != ''">soa = #{soa},</if>
            <if test="sh != null and sh != ''">sh = #{sh},</if>
            <if test="bdoc != null and bdoc != ''">bdoc = #{bdoc},</if>
            <if test="thfd != null and thfd != ''">thfd = #{thfd},</if>
            <if test="pthfUnit != null and pthfUnit != ''">pthf_unit = #{pthfUnit},</if>
            <if test="dbpd != null and dbpd != ''">dbpd = #{dbpd},</if>
            <if test="truss != null and truss != ''">truss = #{truss},</if>
            <if test="pthfCus != null and pthfCus != ''">pthf_cus = #{pthfCus},</if>
            <if test="bipus != null and bipus != ''">bipus = #{bipus},</if>
            <if test="lpgH2 != null and lpgH2 != ''">lpg_h2 = #{lpgH2},</if>
            <if test="q125601 != null and q125601 != ''">q125601 = #{q125601},</if>
            <if test="q125602 != null and q125602 != ''">q125602 = #{q125602},</if>
            <if test="q312018Q1 != null and q312018Q1 != ''">q312018_q1 = #{q312018Q1},</if>
            <if test="q312018Q2 != null and q312018Q2 != ''">q312018_q2 = #{q312018Q2},</if>
            <if test="q312018Q3 != null and q312018Q3 != ''">q312018_q3 = #{q312018Q3},</if>
            <if test="q312018Q4 != null and q312018Q4 != ''">q312018_q4 = #{q312018Q4},</if>
            <if test="q312000 != null and q312000 != ''">q312000 = #{q312000},</if>
            <if test="q312001 != null and q312001 != ''">q312001 = #{q312001},</if>
            <if test="epdOther != null and epdOther != ''">epd_other = #{epdOther},</if>
            <if test="ehsOther != null and ehsOther != ''">ehs_other = #{ehsOther},</if>
            <if test="qar != null and qar != ''">qar = #{qar},</if>
            <if test="maEi != null and maEi != ''">ma_ei = #{maEi},</if>
            <if test="maMechanical != null and maMechanical != ''">ma_mechanical = #{maMechanical},</if>
            <if test="thirdPartyCommunication != null and thirdPartyCommunication != ''">third_party_communication = #{thirdPartyCommunication},</if>
            <if test="fampEi != null and fampEi != ''">famp_ei = #{fampEi},</if>
            <if test="fampMechanical != null and fampMechanical != ''">famp_mechanical = #{fampMechanical},</if>
            <if test="faop != null and faop != ''">faop = #{faop},</if>
            <if test="comments != null and comments != ''">comments = #{comments},</if>
            <if test="hoShiftSup != null and hoShiftSup != ''">ho_shift_sup = #{hoShiftSup},</if>
            <if test="toShiftSup != null and toShiftSup != ''">to_shift_sup = #{toShiftSup},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="status != null">status = #{status},</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="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTShiftLogById" parameterType="Long">
        update t_shift_log set del_flag=1 where id = #{id}
    </delete>

    <delete id="deleteTShiftLogByIds" parameterType="String">
        update t_shift_log set del_flag=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
