<?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.njcn.process.mapper.SupvReportMMapper">
    <update id="updateId">
        update supv_report_m set is_upload_head= #{isUploadHead} where month_Report_Id=#{id}
    </update>

    <select id="statisticPlanReport" resultType="ProcessPublicDTO">
        select count(1) value,supv_Org_Id id from supv_plan
        where
        (delete_Flag = 0 or delete_Flag is null ) and
        supv_Type = #{statisticType}
        <if test="startTime!=null and endTime!=null">
            and effect_End_Time between #{startTime} and #{endTime}
        </if>
        <if test="objType !=null and objType!=''">
            and obj_type = #{objType}
        </if>
        <if test="effectStatus !=null">
            and effect_Status in
            <foreach collection="effectStatus" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        group by supv_Org_Id
    </select>

    <select id="statisticQueReport" resultType="ProcessPublicDTO">
        select count(1) value,a.duty_Org_Id id from supv_problem a
        inner join supv_plan b on a.plan_Id = b.plan_id
        where
        (b.delete_Flag = 0 or b.delete_Flag is null ) and
        b.supv_Type = #{statisticType}
        <if test="startTime!=null and endTime!=null">
            and a.discovery_Time between #{startTime} and #{endTime}
        </if>
        <if test="rectificationStatus !=null and rectificationStatus!=''">
            and a.rectification_Status = #{rectificationStatus}
        </if>
        <if test="objType !=null and objType!=''">
            and b.obj_type = #{objType}
        </if>
        group by a.duty_Org_Id
    </select>

    <select id="statisticQueReportRectify" resultType="com.njcn.process.pojo.dto.ProcessPublicDTO">
        select count(1) value,a.duty_Org_Id id from supv_problem a
        inner join supv_plan b on a.plan_Id = b.plan_id
        where
        (b.delete_Flag = 0 or b.delete_Flag is null ) and
        b.supv_Type = #{statisticType}
        <if test="startTime!=null and endTime!=null">
            and a.rectification_Time between #{startTime} and #{endTime}
        </if>
        <if test="rectificationStatus !=null and rectificationStatus!=''">
            and a.rectification_Status = #{rectificationStatus}
        </if>
        <if test="objType !=null and objType!=''">
            and b.obj_type = #{objType}
        </if>
        group by a.duty_Org_Id
    </select>
    <select id="statisticPlanReportYear" resultType="com.njcn.process.pojo.dto.ProcessPublicDTO">
        select count(1) value,supv_Org_Id id from supv_plan
        where
        (delete_Flag = 0 or delete_Flag is null ) and
        supv_Type = #{statisticType}
        <if test="startTime!=null and endTime!=null">
            and plan_Supv_Date between #{startTime} and #{endTime}
        </if>
        <if test="objType !=null and objType!=''">
            and obj_type = #{objType}
        </if>
        <if test="effectStatus !=null">
            and effect_Status in
            <foreach collection="effectStatus" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        group by supv_Org_Id
    </select>
</mapper>
