<?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="cn.ezhizao.project.business.processCompletion.mapper.CompleteStatisticsMapper">

    <resultMap type="cn.ezhizao.project.business.processCompletion.domain.CompleteStatistics" id="CompleteStatisticsResult">
    </resultMap>


    <select id="getList" parameterType="cn.ezhizao.project.business.processCompletion.domain.CompleteStatistics" resultMap="CompleteStatisticsResult">
        SELECT year, month, (select count(1) from biz_process_completion t where t.deleted = 0 and t.year = biz_process_completion.year and t.month = biz_process_completion.month and (t.is_overdue = 1 or t.is_overdue = 2)) as finished_num, (select count(1) from biz_process_completion t where t.deleted = 0 and t.year = biz_process_completion.year and t.month = biz_process_completion.month and t.is_overdue = 1) as finished_in_time_num FROM biz_process_completion
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="year != null  and year != ''"> AND year = #{year}</if>
        </trim>
        group by year,month
        order by year,month desc
    </select>

</mapper>
