<?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.hv.mapper.RzgHighValueIewStatisticsInfoMapper">

    <select id="listByReport2" resultType="map">

        select
        <if test="cityCode != null  and cityCode != ''">modify_appli_county_code area_code ,</if>
        <if test="cityCode == null  or cityCode == ''">modify_appli_city_code area_code ,</if>
        year_batch,count(*) total_cnt
        ,sum(case when hv_seis_press='1' then 1 else 0 end ) seis
        ,sum(case when hv_have_overseas_press='1' then 1 else 0 end ) have_overseas
        ,sum(case when hv_keep10_press='1' then 1 else 0 end ) keep_10_years
        ,sum(case when hv_high_pledge_press='1' then 1 else 0 end ) high_pledge
        ,sum(case when hv_technology_award_press='1' then 1 else 0 end ) technology_award
        from d_height_value_patent_detail where 1=1
        <if test="status != null  ">and status = #{status}</if>
        <if test="year != null  and year != ''">and year_batch = #{year}</if>
        <if test="minYear != null  and minYear != ''">and year_batch >= #{minYear}</if>
        <if test="maxYear != null  and maxYear != ''">and year_batch<![CDATA[ <= ]]>#{maxYear}</if>
        <if test="month != null  and month != ''">and month_batch = #{month}</if>
        <if test="cityCode != null  and cityCode != ''">and modify_appli_city_code =#{cityCode}</if>
        group by
        <if test="cityCode != null  and cityCode != ''"> modify_appli_county_code,</if>
        <if test="cityCode == null  or cityCode == ''"> modify_appli_city_code,</if>
        year_batch

    </select>
    <select id="listByReport" resultType="map">

        select
        <if test="cityCode != null  and cityCode != ''">modify_appli_county area_name ,modify_appli_county_code area_code ,</if>
        <if test="cityCode == null  or cityCode == ''">modify_appli_city area_name ,modify_appli_city_code area_code ,</if>
        year_batch,month_batch,count(*) total_cnt
        ,sum(case when hv_seis_press='1' then 1 else 0 end ) seis
        ,sum(case when hv_have_overseas_press='1' then 1 else 0 end ) have_overseas
        ,sum(case when hv_keep10_press='1' then 1 else 0 end ) keep_10_years
        ,sum(case when hv_high_pledge_press='1' then 1 else 0 end ) high_pledge
        ,sum(case when hv_technology_award_press='1' then 1 else 0 end ) technology_award
        from d_height_value_patent_detail where 1=1
        <if test="yearBatch != null and yearBatch !='' ">and year_batch >= #{yearBatch}</if>
        <if test="year != null  and year != ''">and year_batch = #{year}</if>
        <if test="minYear != null  and minYear != ''">and year_batch >= #{minYear}</if>
        <if test="maxYear != null  and maxYear != ''">and year_batch<![CDATA[ <= ]]>#{maxYear}</if>
        
         <if test="minDay != null  and minDay != ''">and app_date >= #{minDay}</if>
        <if test="maxDay != null  and maxDay != ''">and app_date<![CDATA[ <= ]]>#{maxDay}</if>
        
        <if test="month != null  and month != ''">and month_batch = #{month}</if>
        <if test="cityCode != null  and cityCode != ''">and modify_appli_city_code =#{cityCode}</if>
        <if test="heightValueDept != null and heightValueDept !='' " > and height_value_dept=#{heightValueDept} </if>
        <if test="heightValuePress != null and heightValuePress !='' " > and height_value_press=#{heightValuePress} </if>
        
        <if test="status != null  ">and status = #{status}</if>
        
        and (1=2 
        <if test="industryEmergIndustryQ != null  and industryEmergIndustryQ != ''">or hv_seis_press='1'</if>
        <if test="overseasCongenerPatentQ != null  and overseasCongenerPatentQ != ''">or hv_have_overseas_press='1'</if>
        <if test="maintenanceTenYearQ != null  and maintenanceTenYearQ != ''">or hv_keep10_press='1'</if>
        <if test="pledgeRecordQ != null  and pledgeRecordQ != ''">or hv_high_pledge_press='1'</if>
        <if test="nationalScienceAwardQ != null  and nationalScienceAwardQ != ''">or hv_technology_award_press='1'</if>
	    )
        
        
        group by
        <if test="cityCode != null  and cityCode != ''">modify_appli_county ,modify_appli_county_code ,</if>
        <if test="cityCode == null  or cityCode == ''">modify_appli_city ,modify_appli_city_code ,</if>
        year_batch,month_batch

    </select>


</mapper>