<?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.ozs.pm.mapper.PmDemandMapper">

    <select id="selectByDemandIdList" parameterType="java.util.List" resultType="com.ozs.pm.doman.PmDemand">
        select * from pm_demand where project_status &gt; 12 and demand_id in
        <foreach item="item" collection="demandIdList" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
    </select>

    <select id="selectExtractionExpert" parameterType="com.ozs.base.domain.vo.BaseExpertVo"
            resultType="com.ozs.pm.doman.PmDemand">
        select * from pm_demand where demand_id in (select demand_id from pm_demand_expert_ref group by demand_id)
        <if test="projectName != null and projectName != ''">
            and project_name like '%' + #{projectName} + '%'
        </if>
        <if test="startTime != null  "><!-- 开始时间检索 -->
            and date_format(plan_demand_sub_time,'%y%m%d') &gt; date_format(#{startTime},'%y%m%d')
        </if>
        <if test="endTime != null  "><!-- 结束时间检索 -->
            and date_format(plan_demand_sub_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
        </if>
    </select>

    <select id="purchaseProjectStatistical" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0) countId
        from pm_demand
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>

    <select id="purchaseProjectStatisticalYWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select count(d.demand_id) countYWC, ifnull(sum(c.contract_amount), 0) evaluationYWC
        from pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) countYWC ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status =21 ) de
        where d.demand_id = c.demand_id
        AND d.purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status =21
    </select>

    <select id="purchaseProjectStatisticalXCJ" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0) countXCJ, ifnull(sum(evaluation), 0) evaluationXCJ
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status !=17
        and year(create_time) = year(NOW())
    </select>

    <select id="purchaseProjectStatisticalQNWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select de.countYWC, ifnull(sum(c.contract_amount), 0) evaluationQNWC
        from pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) countYWC ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status =21 and year(create_time) = year(NOW())-1) de
        WHERE d.demand_id = c.demand_id
        AND d.purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status =21 and year(d.create_time) = year(NOW())-1
    </select>

    <select id="countByProjectAttr" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT project_attr columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        <if test="vo.deptList != null and vo.deptList.size != 0 ">
            WHERE purchase_dept_id
            in
            <foreach collection="vo.deptList" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY project_attr
    </select>

    <select id="countByPurchaseMode" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT purchase_mode columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        GROUP BY purchase_mode
    </select>

    <select id="countByEvaluationLt" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND evaluation &lt; #{vo.evaluation}
    </select>

    <select id="countByEvaluationBet" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND evaluation BETWEEN #{vo.evaluation} and #{vo.evaluationEnd}
    </select>
    <select id="countByEvaluationGt" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND evaluation &gt; #{vo.evaluation}
    </select>

    <select id="countProjectExceedThisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND ( real_purchase_finish_time > plan_purchase_finish_time )
        and YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="countProjectExceedThisQua" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND ( real_purchase_finish_time > plan_purchase_finish_time )
        and quarter(create_time) = quarter(NOW())
    </select>

    <select id="countProjectExceedThisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND ( real_purchase_finish_time > plan_purchase_finish_time )
        and MONTH(create_time) = MONTH(NOW())
    </select>

    <select id="countProjectExceedAllNum" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND ( real_purchase_finish_time > plan_purchase_finish_time)
    </select>

    <select id="countProjectExceedTZ" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>

    </select>

    <select id="countThisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.lang.Integer">
        SELECT ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="countProjectExceedYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT DATE_FORMAT(create_time, '%Y') columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND (real_demand_commit_time > plan_demand_sub_time
        or real_purchase_finish_time > plan_purchase_finish_time
        or real_deliver_time > plan_deliver_time)
        GROUP BY DATE_FORMAT(create_time, '%Y')
        order by create_time asc
    </select>

    <select id="countProjectExceedMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND (real_demand_commit_time > plan_demand_sub_time
        or real_purchase_finish_time > plan_purchase_finish_time
        or real_deliver_time > plan_deliver_time)
        and MONTH(
        create_time) = #{vo.month}
        AND DATE_FORMAT(create_time
        , '%Y') = #{vo.year}
        GROUP BY DATE_FORMAT(create_time, '%Y-%m')
    </select>

    <select id="countProjectExceedQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT DATE_FORMAT(create_time, '%Y-${quarter}季度') columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND (real_demand_commit_time > plan_demand_sub_time
        or real_purchase_finish_time > plan_purchase_finish_time
        or real_deliver_time > plan_deliver_time)
        and QUARTER(create_time) = #{vo.quarter}
        AND DATE_FORMAT(create_time, '%Y') = #{vo.year}
    </select>

    <select id="countProjectExceedAll" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.PmDemand">
        SELECT *
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND (real_demand_commit_time > plan_demand_sub_time
        or real_purchase_finish_time > plan_purchase_finish_time
        or real_deliver_time > plan_deliver_time)

    </select>

    <sql id="majorProjectByStatus">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND find_in_set('1', project_attr)
    </sql>

    <select id="majorProjectByStatusThisMonthNew" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND MONTH(create_time ) = MONTH(now())
        AND project_status &gt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisQuaNew" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND QUARTER(create_time ) = QUARTER(now())
        AND project_status &gt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisYearNew" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND YEAR(create_time ) = YEAR(now())
        AND project_status &gt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisMonthFi" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND MONTH(create_time ) = MONTH(now())
        AND project_status &lt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisQuaFi" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND QUARTER(create_time ) = QUARTER(now())
        AND project_status &lt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisYearFi" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND YEAR(create_time ) = YEAR(now())
        AND project_status &lt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisMonthFiCGB" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND MONTH(create_time ) = MONTH(now())
        AND project_status &gt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisQuaFiCGB" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND QUARTER(create_time ) = QUARTER(now())
        AND project_status &gt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusThisYearFiCGB" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND YEAR(create_time ) = YEAR(now())
        AND project_status &gt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusLastYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND YEAR(create_time ) = YEAR(now())-1
        <if test="vo.projectStatusList!=null">
            AND project_status in
            <foreach collection="vo.projectStatusList" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
    </select>
    <select id="majorProjectByStatusToThisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND project_status &lt; #{vo.projectStatus}
    </select>
    <select id="majorProjectByStatusWei" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND real_purchase_finish_time &lt;plan_purchase_finish_time
    </select>
    <select id="majorProjectByStatusChao" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        <include refid="majorProjectByStatus"></include>
        AND real_purchase_finish_time &gt;plan_purchase_finish_time
    </select>

    <select id="countMajorProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND (real_demand_commit_time > plan_demand_sub_time
        or real_purchase_finish_time > plan_purchase_finish_time
        or real_deliver_time > plan_deliver_time)
        AND find_in_set('1', project_attr)
        and YEAR(create_time ) = YEAR(NOW())
    </select>

    <select id="taskQuantityYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT YEAR(NOW()) columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE find_in_set('1'
            , project_attr)
          AND `project_status` = #{code}
          and YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="taskQuantityLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="java.lang.String">
        SELECT YEAR(NOW()) - 1 columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE find_in_set('1'
            , project_attr)
          AND `project_status` = #{code}
          and YEAR(create_time) = YEAR(NOW()) - 1
    </select>

    <select id="countEveryStatusNum" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT project_status columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND `project_status` IN (9, 10, 11, 12, 13, 14,15,16,17)
        and YEAR(create_time) = YEAR(NOW())
        GROUP BY project_status
    </select>


    <select id="selectByPlanId" parameterType="java.lang.Long" resultType="com.ozs.pm.doman.PmDemand">
        select *
        from pm_demand
        where plan_id = #{planId}
        limit 1
    </select>

    <select id="countMajorProjectLastYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        # AND find_in_set('1', project_attr)
        SELECT YEAR(NOW()) - 1 columnName, de.num, ifnull(sum(c.contract_amount), 0) evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND find_in_set('1', project_attr) AND YEAR(create_time) =YEAR(NOW()) - 1 ) de
        WHERE d.demand_id = c.demand_id
        AND find_in_set('1', d.project_attr)
        AND d.purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND YEAR(d.create_time) = YEAR(NOW()) - 1
    </select>

    <select id="countProjectMajorByYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT YEAR(create_time) columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND find_in_set('1', project_attr)
        GROUP BY YEAR(create_time)
        order by create_time asc
    </select>

    <select id="countProjectMajorByMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND find_in_set('1', project_attr)
        GROUP BY DATE_FORMAT(create_time, '%Y-%m')
    </select>

    <select id="countProjectMajorByQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT create_time columnName, ifnull(COUNT(demand_id), 0) num
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND find_in_set('1', project_attr)
        and QUARTER(create_time) = #{vo.quarter}
        AND YEAR(create_time) = #{vo.year}
    </select>

    <!-- 正常推进项目 -->
    <select id="purchaseProjectExecuteNormalPropulsion" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        select ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status !=21
        and (real_demand_commit_time &lt; plan_demand_sub_time
        or real_purchase_finish_time &lt; plan_purchase_finish_time
        or real_deliver_time &lt; plan_deliver_time)
    </select>

    <select id="purchaseProjectExecuteIncomplete" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        select ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status !=21
    </select>

    <select id="selectMinYear" resultType="java.lang.Integer">
        select min(year(create_time))
        from pm_demand
    </select>

    <select id="selectpurchaseProjectCompleteNumberYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select count(a.demand_id) countNum,
        ifnull(sum(a.evaluation), 0) evaluation,
        year(a.create_time) yy,
        ifnull(sum(b.contract_amount), 0) contractAmount
        from (
        select evaluation, create_time, demand_id
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status = '21'
        ) a
        left join (
        select contract_amount, demand_id
        from pm_contract_info
        ) b on a.demand_id = b.demand_id

        group by year(create_time)
    </select>

    <select id="selectpurchaseProjectCompleteNumberQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(sum(a.evaluation), 0) evaluation,
        quarter(a.create_time) yy,
        ifnull(sum(b.contract_amount), 0) contractAmount
        from (
        select evaluation, create_time, demand_id
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status = '21'
        and year(create_time) = year(NOW())
        ) a
        left join (
        select contract_amount, demand_id
        from pm_contract_info
        ) b on a.demand_id = b.demand_id
        group by concat(Year(a.create_time), quarter(a.create_time))
    </select>

    <select id="selectpurchaseProjectCompleteNumberMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(sum(a.evaluation), 0) evaluation,
        date_format(create_time, '%m') yy,
        ifnull(sum(b.contract_amount), 0) contractAmount
        from (
        select evaluation, create_time, demand_id
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status = '21'
        and year(create_time) = year(NOW())
        ) a
        left join (
        select contract_amount, demand_id
        from pm_contract_info
        ) b on a.demand_id = b.demand_id
        group by date_format(a.create_time, '%y%m')
    </select>

    <select id="selectPurchaseTaskFinishYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select count(a.demand_id) countNum,
        ifnull(sum(a.evaluation), 0) evaluation,
        year(a.create_time) yy,
        ifnull(sum(b.contract_amount), 0) contractAmount
        from (
        select evaluation, create_time, demand_id
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status in (15, 16, 17)
        ) a
        left join (
        select contract_amount, demand_id
        from pm_contract_info
        ) b on a.demand_id = b.demand_id
        group by year(a.create_time)
    </select>

    <select id="selectPurchaseTaskFinishQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(sum(a.evaluation), 0) evaluation,
        quarter(a.create_time) yy,
        ifnull(sum(b.contract_amount), 0) contractAmount
        from (
        select evaluation, create_time, demand_id
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status in (15, 16, 17)
        and year(create_time) = year(NOW())
        ) a
        left join (
        select contract_amount, demand_id
        from pm_contract_info
        ) b on a.demand_id = b.demand_id
        group by concat(Year(a.create_time), quarter(a.create_time))
    </select>

    <select id="selectPurchaseTaskFinishMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(sum(a.evaluation), 0) evaluation,
        date_format(create_time, '%m') yy,
        ifnull(sum(b.contract_amount), 0) contractAmount
        from (
        select evaluation, create_time, demand_id
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status in (15, 16, 17)
        and year(create_time) = year(NOW())
        ) a
        left join (
        select contract_amount, demand_id
        from pm_contract_info
        ) b on a.demand_id = b.demand_id
        group by date_format(a.create_time, '%y%m')
    </select>

    <select id="countProjectExceedAndMajor" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE (real_demand_commit_time > plan_demand_sub_time
            or real_purchase_finish_time > plan_purchase_finish_time
            or real_deliver_time > plan_deliver_time)
          AND find_in_set('1', project_attr)
          and YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="purchaseProjectDistribution" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(count(demand_id), 0) countNumber,ifnull(sum(evaluation), 0) evaluationTotal
        from pm_demand where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        <if test="vo.projectStatusList!=null">
            AND project_status in
            <foreach collection="vo.projectStatusList" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="purchaseProjectDistributionTo" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(count(demand_id), 0) countNumber,ifnull(sum(evaluation), 0) evaluationTotal
        from pm_demand where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        <if test="vo.projectStatusList!=null">
            AND project_status in
            <foreach collection="vo.projectStatusList" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="purchaseProjectNumberAnalysisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0) countNum, ifnull(sum(evaluation), 0) evaluationSum, year(create_time) yy
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        group by year(create_time)
    </select>

    <select id="purchaseProjectNumberAnalysisQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(create_time) yy
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND year(create_time) = year(NOW())
        group by concat(Year(create_time), quarter(create_time))
    </select>

    <select id="purchaseProjectNumberAnalysisOldYearQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(create_time) yy
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND year(create_time) = year(NOW() - 1)
        group by concat(Year(create_time), quarter(create_time))
    </select>

    <select id="purchaseProjectNumberAnalysisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0) countNum,
        ifnull(sum(evaluation), 0) evaluationSum,
        date_format(create_time, '%m') yy
        from pm_demand
        where purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND year(create_time) = year(NOW())
        group by date_format(create_time, '%y%m')
    </select>

    <select id="purchaseProjectNumberAnalysisOldYearMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
            resultType="java.util.Map">
        select ifnull(COUNT(demand_id), 0)    countNum,
               ifnull(sum(evaluation), 0)     evaluationSum,
               date_format(create_time, '%m') yy
        from pm_demand
        where purchase_dept_id = #{purchaseDeptId}
          AND year(create_time) = YEAR(NOW()) - 1
        group by date_format(create_time, '%y%m')
    </select>

    <select id="selectSTSLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND `project_status` IN (6,7,8,9,10,11,12,13,14,15, 16, 17)
        and YEAR(create_time) = YEAR(NOW())-1
    </select>

    <select id="selectSTSThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND `project_status` &gt; 4
        and YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="selectmeiJiDu" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND (real_demand_commit_time &gt; plan_demand_sub_time)
    </select>

    <select id="selectByProjectType" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT project_type columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        GROUP BY project_type
    </select>

    <select id="selectSTS" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
        FROM `pm_demand`
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND `project_status` &gt; 4
        and YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="selectCGThisMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT MONTH(NOW()) columnName, de.num, de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d,pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status &gt; 16 AND MONTH(create_time) =MONTH(NOW()) ) de
        where d.demand_id = c.demand_id and purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status &gt; 16
        AND MONTH(d.create_time) = MONTH(NOW())
    </select>

    <select id="selectCGThisQua" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT QUARTER(NOW()) columnName, de.num, de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d,pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status &gt; 17 AND QUARTER(create_time) =QUARTER(NOW()) ) de
        WHERE d.demand_id = c.demand_id and purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status &gt; 17
        AND QUARTER(d.create_time) = QUARTER(NOW())
    </select>

    <select id="selectZJLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT YEAR(NOW())-1 columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status IN (17,18) AND YEAR(create_time) = YEAR(NOW())-1 ) de
        WHERE d.demand_id = c.demand_id and purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status IN (17,18)
        AND YEAR(d.create_time) = YEAR(NOW())-1
    </select>

    <select id="selectTBThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT YEAR(NOW()) columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status &gt; 17 AND YEAR(create_time) = YEAR(NOW()) ) de
        WHERE d.demand_id = c.demand_id and purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status &gt; 17
        AND YEAR(d.create_time) = YEAR(NOW())
    </select>

    <select id="selectFInishAll" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT YEAR(NOW()) columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status &gt; 17 ) de
        WHERE d.demand_id = c.demand_id and purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.project_status &gt; 17
    </select>

    <select id="selectCCThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT YEAR(NOW()) columnName,ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
        FROM pm_demand
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND real_purchase_finish_time &lt;=plan_purchase_finish_time
        AND YEAR(create_time) = YEAR(NOW())
    </select>

    <sql id="countProjectExceedAndStatus">
        SELECT ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
        FROM pm_demand
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        <if test="vo.projectStatusList!=null">
            AND project_status in
            <foreach collection="vo.projectStatusList" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        AND real_purchase_finish_time &gt;plan_purchase_finish_time
    </sql>

    <select id="countProjectExceedAndStatus" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        <include refid="countProjectExceedAndStatus"></include>
        <if test="vo.demandIdAll !=null ">
            AND demand_id in
            <foreach collection="vo.demandIdAll" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
    </select>

    <select id="countBaseAgencyWithWhite" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
        SELECT ifnull(COUNT(id), 0) num
        FROM base_agency
        WHERE status = 0
    </select>

    <select id="JZCGnum" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT YEAR(NOW()) columnName,ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
        FROM pm_demand
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND project_status &gt; 8
        # AND YEAR(create_time) = YEAR(NOW())
    </select>

    <select id="countProjecReaAndStatus" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
        FROM pm_demand
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        <if test="vo.projectStatusList!=null">
            AND project_status in
            <foreach collection="vo.projectStatusList" item="item" index="index"
                     separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        and YEAR(create_time) = YEAR(NOW())-1
    </select>


    <select id="countProjectACT_Year" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT #{vo.year} columnName, de.num, de.evaluationTotal, ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND real_purchase_finish_time > plan_purchase_finish_time AND YEAR(create_time)=#{vo.year} ) de
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.demand_id = c.demand_id AND d.real_purchase_finish_time > d.plan_purchase_finish_time AND
        YEAR(d.create_time)=#{vo.year}
    </select>

    <select id="countProjectACT_Qua" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
        SELECT #{vo.year} columnName, de.num, de.evaluationTotal, ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND real_purchase_finish_time > plan_purchase_finish_time AND YEAR(create_time)=#{vo.year} AND
        QUARTER(create_time)=#{vo.quarter}) de
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND d.demand_id = c.demand_id AND d.real_purchase_finish_time > d.plan_purchase_finish_time AND
        YEAR(d.create_time)=#{vo.year} AND QUARTER(d.create_time)=#{vo.quarter}
    </select>

    <select id="countProjectACT_Mon" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
            parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">SELECT #{vo.year} columnName, de.num,
        de.evaluationTotal, ifnull(sum(c.contract_amount), 0)
        evaluationContractTotal
        FROM pm_demand d, pm_contract_info c,
        (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
        purchase_dept_id
        in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>
        AND real_purchase_finish_time > plan_purchase_finish_time AND
        YEAR(create_time)=#{vo.year} AND month(create_time)=#{vo.month}) de
        WHERE purchase_dept_id in
        <foreach collection="vo.deptList" item="item" index="index"
                 separator="," open="(" close=")">
            #{item}
        </foreach>

        AND d.demand_id = c.demand_id AND d.real_purchase_finish_time > d.plan_purchase_finish_time AND
        YEAR(d.create_time)=#{vo.year} AND month(d.create_time)=#{vo.month}
    </select>


</mapper>
