<?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.qy.worksheetsystem.model.mapper.ProjectMapper">

    <insert id="addProjectPerson">
        insert
        CT_PRO_MemberManagement(fid,CFEmployeeID,CFProjectManagementID,CFProjectRoleID,FCreatorID,FLastUpdateUserID,
               FCreateTime,FLastUpdateTime,FControlUnitID,CFState,CFProjectCode,CFProjectName,CFProjectManagemen,FHROrgUnitID)
               values (
        #{id},
        #{personID},
        #{projectID},
        #{projectRoleID},
        #{currentUser},
        #{currentUser},
        #{dateTime},
        #{dateTime},
        #{controUnit},
        #{state},
        #{projectName},
        #{projectNumber},
        #{projectID},
        #{hrOrgUnit}
        )
    </insert>

    <select id="getProjectManagementByState"  resultType="java.util.Map">

        select
        projectManagement.fid as  id,
        projectManagement.CFProjectName as projectName,
        projectManagement.CFExpectedStartTime as expectedStartTime,
        projectManagement.CFExpectedEndTime as expectedEndTime,
        person.fid  as personId,
        person.Fname_l2  as personName,
        person.Fnumber as personNumber,
        CFTotalPersonDays as totalPersonDays,
        CFCostAmount as costAmount,
        CFNotes as notes,
        FWorkerDaysReported as workerDaysReported,
        FProDayConsumption as  proDayConsumption,
        projectManagement.fnumber as number,
        projectManagement.FBillState as billState,
        CFProjectLevel as projectLevel ,
        CFProjectState as projectState,
        CFBeingChanged as beingChanged ,
        CFChangedManDays as changedManDays
        from CT_PRO_ProjectManagement projectManagement
        left join T_BD_Person person on person.fid = projectManagement.CFProjectManagerID
        left join T_org_admin adminOrg on adminOrg.fid = projectManagement.FAdminOrgUnitId

        where CFExpectedEndTime
        <if test="state==1">
            &gt;=
        </if>
        <if test="state==2">
            &lt;=
        </if>
        #{dateTime}
    </select>
    <select id="getProjectListByState"  resultType="java.util.Map">
        select fid as id ,fnumber as number ,CFProjectName as name from CT_PRO_ProjectManagement where CFExpectedEndTime
        <if test="state==1">
            &gt;=
        </if>
        <if test="state==2">
            &lt;=
        </if>
        #{dateTime}
    </select>

</mapper>
