<?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.kyBg.mapper.KyBgInfoMapper">
    
    <resultMap type="KyBgInfo" id="KyBgInfoResult">
        <result property="key"    column="key"    />
        <result property="id"    column="id"    />
        <result property="taskno"    column="taskno"    />
        <result property="taskname"    column="taskname"    />
        <result property="workcontent"    column="workcontent"    />
        <result property="workhour"    column="workhour"    />
        <result property="xhname"    column="xhname"    />
        <result property="yzsl"    column="yzsl"    />
        <result property="yzjdname"    column="yzjdname"    />
        <result property="tcdw"    column="tcdw"    />
        <result property="brief"    column="brief"    />
        <result property="status"    column="status"    />
        <result property="jhkssj"    column="jhkssj"    />
        <result property="jhwcsj"    column="jhwcsj"    />
        <result property="worktime"    column="worktime"    />
        <result property="createtime"    column="createtime"    />
        <result property="username"    column="username"    />
        <result property="userdept"    column="userdept"    />
        <result property="shr"    column="shr"    />
        <result property="spr"    column="spr"    />
        <result property="memo"    column="memo"    />
    </resultMap>

    <sql id="selectKyBgInfoVo">
        select key, id, taskno, taskname, workcontent, workhour, xhname, yzsl, yzjdname, tcdw, brief, status, jhkssj, jhwcsj, worktime, createtime, username, userdept, shr, spr, memo from ky_bg_info
    </sql>

    <select id="selectKyBgInfoList" parameterType="KyBgInfo" resultMap="KyBgInfoResult">
        <include refid="selectKyBgInfoVo"/>
        <where>  
            <if test="taskno != null  and taskno != ''"> and taskno = #{taskno}</if>
            <if test="taskname != null  and taskname != ''"> and taskname like concat('%', #{taskname}, '%')</if>
            <if test="workcontent != null  and workcontent != ''"> and workcontent = #{workcontent}</if>
            <if test="workhour != null "> and workhour = #{workhour}</if>
            <if test="xhname != null  and xhname != ''"> and xhname like concat('%', #{xhname}, '%')</if>
            <if test="yzsl != null "> and yzsl = #{yzsl}</if>
            <if test="yzjdname != null  and yzjdname != ''"> and yzjdname like concat('%', #{yzjdname}, '%')</if>
            <if test="tcdw != null  and tcdw != ''"> and tcdw = #{tcdw}</if>
            <if test="brief != null  and brief != ''"> and brief = #{brief}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="jhkssj != null "> and jhkssj = #{jhkssj}</if>
            <if test="jhwcsj != null "> and jhwcsj = #{jhwcsj}</if>
            <if test="worktime != null "> and worktime = #{worktime}</if>
            <if test="createtime != null "> and createtime = #{createtime}</if>
            <if test="username != null  and username != ''"> and username like concat('%', #{username}, '%')</if>
            <if test="userdept != null  and userdept != ''"> and userdept = #{userdept}</if>
            <if test="shr != null  and shr != ''"> and shr = #{shr}</if>
            <if test="spr != null  and spr != ''"> and spr = #{spr}</if>
            <if test="memo != null  and memo != ''"> and memo = #{memo}</if>
        </where>
    </select>
    
    <select id="selectKyBgInfoByKey" parameterType="Long" resultMap="KyBgInfoResult">
        <include refid="selectKyBgInfoVo"/>
        where key = #{key}
    </select>
    <select id="selectProjectCostFromKyBgInfoByTaskno" resultType="com.ruoyi.kyBg.domain.KyBgInfo">
        select xhname,yzjdname,
        from from ky_bg_info
    </select>
    <select id="selectKyBgInfoListByTaskno" resultType="com.ruoyi.kyBg.domain.KyBgInfo">
        select userdept,taskno,workhour from ky_bg_info where taskno = #{taskno};
    </select>

    <insert id="insertKyBgInfo" parameterType="KyBgInfo" useGeneratedKeys="true" keyProperty="key">
        insert into ky_bg_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="taskno != null">taskno,</if>
            <if test="taskname != null">taskname,</if>
            <if test="workcontent != null">workcontent,</if>
            <if test="workhour != null">workhour,</if>
            <if test="xhname != null">xhname,</if>
            <if test="yzsl != null">yzsl,</if>
            <if test="yzjdname != null">yzjdname,</if>
            <if test="tcdw != null">tcdw,</if>
            <if test="brief != null">brief,</if>
            <if test="status != null">status,</if>
            <if test="jhkssj != null">jhkssj,</if>
            <if test="jhwcsj != null">jhwcsj,</if>
            <if test="worktime != null">worktime,</if>
            <if test="createtime != null">createtime,</if>
            <if test="username != null">username,</if>
            <if test="userdept != null">userdept,</if>
            <if test="shr != null">shr,</if>
            <if test="spr != null">spr,</if>
            <if test="memo != null">memo,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="taskno != null">#{taskno},</if>
            <if test="taskname != null">#{taskname},</if>
            <if test="workcontent != null">#{workcontent},</if>
            <if test="workhour != null">#{workhour},</if>
            <if test="xhname != null">#{xhname},</if>
            <if test="yzsl != null">#{yzsl},</if>
            <if test="yzjdname != null">#{yzjdname},</if>
            <if test="tcdw != null">#{tcdw},</if>
            <if test="brief != null">#{brief},</if>
            <if test="status != null">#{status},</if>
            <if test="jhkssj != null">#{jhkssj},</if>
            <if test="jhwcsj != null">#{jhwcsj},</if>
            <if test="worktime != null">#{worktime},</if>
            <if test="createtime != null">#{createtime},</if>
            <if test="username != null">#{username},</if>
            <if test="userdept != null">#{userdept},</if>
            <if test="shr != null">#{shr},</if>
            <if test="spr != null">#{spr},</if>
            <if test="memo != null">#{memo},</if>
         </trim>
    </insert>

    <update id="updateKyBgInfo" parameterType="KyBgInfo">
        update ky_bg_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="id != null">id = #{id},</if>
            <if test="taskno != null">taskno = #{taskno},</if>
            <if test="taskname != null">taskname = #{taskname},</if>
            <if test="workcontent != null">workcontent = #{workcontent},</if>
            <if test="workhour != null">workhour = #{workhour},</if>
            <if test="xhname != null">xhname = #{xhname},</if>
            <if test="yzsl != null">yzsl = #{yzsl},</if>
            <if test="yzjdname != null">yzjdname = #{yzjdname},</if>
            <if test="tcdw != null">tcdw = #{tcdw},</if>
            <if test="brief != null">brief = #{brief},</if>
            <if test="status != null">status = #{status},</if>
            <if test="jhkssj != null">jhkssj = #{jhkssj},</if>
            <if test="jhwcsj != null">jhwcsj = #{jhwcsj},</if>
            <if test="worktime != null">worktime = #{worktime},</if>
            <if test="createtime != null">createtime = #{createtime},</if>
            <if test="username != null">username = #{username},</if>
            <if test="userdept != null">userdept = #{userdept},</if>
            <if test="shr != null">shr = #{shr},</if>
            <if test="spr != null">spr = #{spr},</if>
            <if test="memo != null">memo = #{memo},</if>
        </trim>
        where key = #{key}
    </update>

    <delete id="deleteKyBgInfoByKey" parameterType="Long">
        delete from ky_bg_info where key = #{key}
    </delete>

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