<?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.fbs.mapper.FbsProjectTaskMapper">

    <resultMap type="com.ruoyi.fbs.domain.FbsProjectTask" id="FbsProjectTaskResult">
        <result property="id" column="id"/>
        <result property="projectId" column="project_id"/>
        <result property="sectionId" column="section_id"/>
        <result property="subId" column="sub_id"/>
        <result property="taskName" column="task_name"/>
        <result property="taskAddress" column="task_address"/>
        <result property="taskAmount" column="task_amount"/>
        <result property="taskStaffNum" column="task_staff_num"/>
        <result property="taskBeginTime" column="task_begin_time"/>
        <result property="taskContactPerson" column="task_contact_person"/>
        <result property="taskContactPhone" column="task_contact_phone"/>
        <result property="taskDescribe" column="task_describe"/>
        <result property="taskImg" column="task_img"/>
        <result property="qualification" column="qualification"/>
        <result property="userId" column="user_id"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>


    <select id="appQueryPageList" resultType="com.ruoyi.fbs.domain.vo.AppTaskVO">
        select  fpt.id,
                fpt.task_name,
                fpt.task_staff_num,
                fpt.task_amount,
                zp.project_name,
                fpt.task_describe,
                fpt.task_address,
                fpt.create_time,
                (select count(task_id) from fbs_project_task_apply where task_id = fpt.id) as applyNum,
                (select sum(applicant_amount) from bgt_wage_application where audit_status = '2'and task_id = fpt.id) as taskReceiveAmount
        from fbs_project_task fpt
            left join zbf_project zp on fpt.project_id = zp.id
        <where>
        <if test="dto.taskIds != null and dto.taskIds.size() > 0">
            and fpt.id IN
            <foreach item="item" index="index" collection="dto.taskIds"
                     open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="dto.taskName != null and dto.taskName != '' ">
            and fpt.task_name like concat('%', #{dto.taskName}, '%')
        </if>
        <if test="dto.userId != null ">
            and fpt.user_id = #{dto.userId}
        </if>
        <if test="dto.status != null and dto.status != '' ">
            and fpt.status = #{dto.status}
        </if>
        </where>
    </select>

</mapper>
