<?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.RzgClassifiedStatisticsInfoMapper">

    <select id="listByReport" resultType="map">
        select ff.*  from (
        select  appli_type
        
        <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>
        
        ,sum(case when hv_seis_press='1' then 1 else 0 end ) hv_seis_press
        ,sum(case when hv_keep10_press='1' then 1 else 0 end ) hv_keep10_press
        ,sum(case when hv_have_overseas_press='1' then 1 else 0 end ) hv_have_overseas_press
        ,sum(case when hv_high_pledge_press='1' then 1 else 0 end ) hv_high_pledge_press
        ,sum(case when hv_technology_award_press='1' then 1 else 0 end ) hv_technology_award_press
        from d_height_value_patent_detail where 1=1 and status='10' 
         
         <if test="applicantTypesList != null and applicantTypesList.size > 0">
		  and appli_type in  <foreach item="type" collection="applicantTypesList" open="(" separator="," close=")">#{type}</foreach>
		  </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>
	    )
        
        <if test="year != null  and year != ''">and year_batch = #{year}</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="cityName != null  and cityName != ''">and modify_appli_city = #{cityName}</if>
        group by  appli_type,
        <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>
        ) ff
    </select>


    <select id="listByReport_bak2" parameterType="com.ruoyi.hv.domain.RzgClassifiedStatisticsInfo" resultType="map">
        select ff.*  from (
        select appli_province,appli_type
        <if test="cityName != null  and cityName != ''">,modify_appli_county</if>
        <if test="cityName == null  or cityName == ''">,modify_appli_city area_name</if>
        ,sum(case when hv_seis_press='1' then 1 else 0 end ) hv_seis_press
        ,sum(case when hv_keep10_press='1' then 1 else 0 end ) hv_keep10_press
        ,sum(case when hv_have_overseas_press='1' then 1 else 0 end ) hv_have_overseas_press
        ,sum(case when hv_high_pledge_press='1' then 1 else 0 end ) hv_high_pledge_press
        ,sum(case when hv_technology_award_press='1' then 1 else 0 end ) hv_technology_award_press
        from d_height_value_patent_detail where 1=1
        <if test="year != null  and year != ''">and year_batch = #{year}</if>
        <if test="month != null  and month != ''">and month_batch = #{month}</if>
        <if test="cityName != null  and cityName != ''">and modify_appli_city_code = #{cityName}</if>
        group by appli_province,appli_type
        ) ff
    </select>


</mapper>