<?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.engine.organization.mapper.jclorgmap.JclOrgMapper">

    <insert id="insertMap">
        insert into jcl_org_map
        (id, ftype, fobjid, fecid, uuid, fclass, fclassname, fnumber, fname, fleader, fleaderimg,
         fleadername, fleaderjobid, fleaderjob, fleaderlv, fleaderst, fparentid, fobjparentid,
         fplan, fonjob, fisvitual, fdatebegin, fdateend)
        values (#{id}, #{fType}, #{fObjId}, #{fEcId}, #{uuid}, #{fClass}, #{fClassName}, #{fNumber}, #{fName},
                #{fLeader}, #{fLeaderImg},
                #{fLeaderName}, #{fLeaderJobId}, #{fLeaderJob}, #{fLeaderLv}, #{fLeaderSt}, #{fParentId},
                #{fObjParentId},
                #{fPlan}, #{fOnJob}, #{fIsVitual}, #{fDateBegin}, #{fDateEnd})
    </insert>
    <update id="updateMap">
        update jcl_org_map
        <set>
            fdateend=#{yesterday},
        </set>
        where ftype=#{ftype} and fobjid=#{fobjid} and fdateend &gt; #{currentDate}
    </update>
    <delete id="deleteMap">
        delete
        from jcl_org_map
        where ftype = #{ftype}
          and fobjid = #{fobjid}
          and fdatebegin = #{currentDate}
    </delete>
    <select id="getJclOrgMapByObjID" resultType="com.engine.organization.entity.map.JclOrgMap">
        select *
        from jcl_org_map
        where fobjid = #{objId}
          and ftype = #{fType}
          AND FDATEBEGIN &lt;= #{currentDate}
          AND FDATEEND &gt;= #{currentDate}
    </select>
    <select id="getJclOrgMapByFParentId" resultType="com.engine.organization.entity.map.JclOrgMap">
        select *
        from jcl_org_map
        where fparentid = #{fparentid}
          AND FDATEBEGIN &lt;= #{currentDate}
          AND FDATEEND &gt;= #{currentDate}
    </select>
    <select id="getJclOrgMapById" resultType="com.engine.organization.entity.map.JclOrgMap">
        select *
        from jcl_org_map
        where id = #{id}
          AND FDATEBEGIN &lt;= #{currentDate}
          AND FDATEEND &gt;= #{currentDate}
    </select>
    <select id="getSumPlanAndJobByFParentId" resultType="com.engine.organization.entity.map.JclOrgMap">
        select sum(fplan) fplan,sum(fonjob) fonjob
        from jcl_org_map
        where fparentid = #{fparentid}
          AND FDATEBEGIN &lt;= #{currentDate}
          AND FDATEEND &gt;= #{currentDate}
    </select>
    <update id="updateMapById">
        update jcl_org_map
        <set>
            fplan=#{fplan},
            fonjob=#{fonjob},
        </set>
        where id=#{id}
        AND FDATEBEGIN &lt;= #{currentDate}
        AND FDATEEND &gt;= #{currentDate}
    </update>
</mapper>