<?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.growthrate.mapper.PatentGrowthrateMapper">
	<!-- <resultMap type="PatentGrowthrateDO" id="PatentGrowthrateResult">
		<result property="areaName" column="area_name" />
		<result property="inventionCnt" column="invention_cnt" />
		<result property="modelUtilityCnt" column="model_utility_cnt" />
		<result property="appearanceCnt" column="appearance_cnt" />
		<result property="higherSchool" column="higher_school" />
		<result property="researchInstitute" column="research_institute" />
		<result property="enterprise" column="enterprise" />
		<result property="institutions" column="institutions" />
		<result property="individual" column="individual" />
		<result property="hvSeisPress" column="hv_seis_press" />
		<result property="hvHaveOverseasPress" column="hv_have_overseas_press" />
		<result property="hvKeep10Press" column="hv_keep10_press" />
		<result property="hvHighPledgePress" column="hv_high_pledge_press" />
		<result property="hvTechnologyAwardPress" column="hv_technology_award_press" />
	</resultMap>
 -->
<select id="listForActAll" resultType="map" >
	select <if test="sumType == 'province'">modify_province_name area_name </if>
	<if test="sumType == 'city'">modify_city_name area_name </if>
	<if test="sumType == 'area'">modify_area_name area_name,modify_area_code area_code,modify_city_code city_code </if>
	,patent_type,count(*) total_cnt
	,sum(case when modify_patentee_type='大专院校' then 1 else 0 end ) higher_school
	,sum(case when modify_patentee_type='科研机构' then 1 else 0 end ) research_institute 
	,sum(case when modify_patentee_type='企业' then 1 else 0 end ) enterprise
	,sum(case when modify_patentee_type='机关团体' then 1 else 0 end ) institutions
	,sum(case when modify_patentee_type='个人' then 1 else 0 end ) individual
	from d_patent_effective_info
	 where 1=1 
	 <!-- 
	 <if test="sumType == 'area'">and modify_area_name is not null and modify_area_name!=''</if>
	  -->
	and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime} 
	<if test="sumType == 'city' and appliCity != 'all'">and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area' and appliCounty != 'null' and appliCounty != 'all'">and modify_area_code=#{appliCounty} and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_province_name </if>
	<if test="sumType == 'city'">modify_city_name </if><if test="sumType == 'area'">modify_area_name,modify_area_code,modify_city_code </if>,  patent_type
</select>

<select id="listForActPatent" resultType="map" >
	select  <if test="sumType == 'province'">modify_province_name area_name </if>
	<if test="sumType == 'city'">modify_city_name area_name </if>
	<if test="sumType == 'area'">modify_area_name area_name ,modify_area_code area_code,modify_city_code city_code</if>
	,count(*) total_cnt
	,sum(case when patent_type='发明' then 1 else 0 end ) invention_cnt
	,sum(case when patent_type='实用新型' then 1 else 0 end ) model_utility_cnt 
	,sum(case when patent_type='外观设计' then 1 else 0 end ) appearance_cnt
	from d_patent_effective_info
	where 1=1 
	<!-- 
	<if test="sumType == 'area'">and modify_area_name is not null and modify_area_name!=''</if>   -->
	and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime}
	<if test="sumType == 'city' and appliCity != 'all'">and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and appliCounty != 'null' and appliCounty != 'all' ">and modify_area_code=#{appliCounty} and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_province_name </if>
	<if test="sumType == 'city'">modify_city_name </if><if test="sumType == 'area'">modify_area_name,modify_area_code,modify_city_code </if> 
</select>

<select id="listForActAppli" resultType="map" >
	select  <if test="sumType == 'province'">modify_province_name area_name </if>
	<if test="sumType == 'city'">modify_city_name area_name </if>
	<if test="sumType == 'area'">modify_area_name area_name,modify_area_code area_code,modify_city_code city_code </if> 
	,count(*) total_cnt
	,sum(case when modify_patentee_type='大专院校' then 1 else 0 end ) higher_school
	,sum(case when modify_patentee_type='科研机构' then 1 else 0 end ) research_institute 
	,sum(case when modify_patentee_type='企业' then 1 else 0 end ) enterprise
	,sum(case when modify_patentee_type='机关团体' then 1 else 0 end ) institutions
	,sum(case when modify_patentee_type='个人' then 1 else 0 end ) individual
	from d_patent_effective_info
	where 1=1 
	<!-- 
	<if test="sumType == 'area'">and modify_area_name is not null and modify_area_name!=''</if>
	 -->
	and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime}
	<if test="sumType == 'city' and appliCity != 'all'">and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and appliCounty != 'null' and appliCounty != 'all' ">and modify_area_code=#{appliCounty} and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_province_name </if>
	<if test="sumType == 'city'">modify_city_name </if><if test="sumType == 'area'">modify_area_name,modify_area_code,modify_city_code </if>  
</select>



<select id="listForAuthAll" resultType="map" >
	select <if test="sumType == 'province'">modify_province_name area_name </if>
	<if test="sumType == 'city'">modify_city_name area_name </if>
	<if test="sumType == 'area'">modify_area_name area_name ,modify_area_code area_code,modify_city_code city_code</if>
	,patent_type,count(*) total_cnt
	,sum(case when modify_patentee_type='大专院校' then 1 else 0 end ) higher_school
	,sum(case when modify_patentee_type='科研机构' then 1 else 0 end ) research_institute 
	,sum(case when modify_patentee_type='企业' then 1 else 0 end ) enterprise
	,sum(case when modify_patentee_type='机关团体' then 1 else 0 end ) institutions
	,sum(case when modify_patentee_type='个人' then 1 else 0 end ) individual
	from d_patent_auth_info
	where 1=1 
	<!-- 
	<if test="sumType == 'area'">and modify_area_name is not null and modify_area_name!=''</if>   
	 -->
	and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime} 
	<if test="sumType == 'city' and appliCity != 'all'">and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and appliCounty != 'null' and appliCounty != 'all'">and modify_area_code=#{appliCounty} and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_province_name </if>
	<if test="sumType == 'city'">modify_city_name </if><if test="sumType == 'area'">modify_area_name ,modify_area_code,modify_city_code</if>,  patent_type
</select>

<select id="listForAuthPatent" resultType="map" >
	select  <if test="sumType == 'province'">modify_province_name area_name </if>
	<if test="sumType == 'city'">modify_city_name area_name </if>
	<if test="sumType == 'area'">modify_area_name area_name,modify_area_code area_code,modify_city_code city_code </if>
	,count(*) total_cnt
	,sum(case when patent_type='发明' then 1 else 0 end ) invention_cnt
	,sum(case when patent_type='实用新型' then 1 else 0 end ) model_utility_cnt 
	,sum(case when patent_type='外观设计' then 1 else 0 end ) appearance_cnt
	from d_patent_auth_info
	where 1=1 
	<!-- 
	<if test="sumType == 'area'">and modify_area_name is not null and modify_area_name!=''</if>  
	 -->
	and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime}
	<if test="sumType == 'city' and appliCity != 'all'">and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and appliCounty != 'null' and appliCounty != 'all' ">and modify_area_code=#{appliCounty} and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_province_name </if>
	<if test="sumType == 'city'">modify_city_name </if><if test="sumType == 'area'">modify_area_name,modify_area_code,modify_city_code </if> 
</select>

<select id="listForAuthAppli" resultType="map" >
	select  <if test="sumType == 'province'">modify_province_name area_name </if>
	<if test="sumType == 'city'">modify_city_name area_name </if>
	<if test="sumType == 'area'">modify_area_name area_name ,modify_area_code area_code,modify_city_code city_code</if> 
	,count(*) total_cnt
	,sum(case when modify_patentee_type='大专院校' then 1 else 0 end ) higher_school
	,sum(case when modify_patentee_type='科研机构' then 1 else 0 end ) research_institute 
	,sum(case when modify_patentee_type='企业' then 1 else 0 end ) enterprise
	,sum(case when modify_patentee_type='机关团体' then 1 else 0 end ) institutions
	,sum(case when modify_patentee_type='个人' then 1 else 0 end ) individual
	from d_patent_auth_info
	where 1=1 
	<!-- 
	<if test="sumType == 'area'">and modify_area_name is not null and modify_area_name!=''</if>   
	 -->
	 and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime}
	<if test="sumType == 'city' and appliCity != 'all'">and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and appliCounty != 'null' and appliCounty != 'all'">and modify_area_code=#{appliCounty} and modify_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_province_name </if>
	<if test="sumType == 'city'">modify_city_name </if><if test="sumType == 'area'">modify_area_name,modify_area_code,modify_city_code </if>  
</select>



<select id="listForHv" resultType="map" >
	select <if test="sumType == 'province'">modify_appli_province area_name </if>
	<if test="sumType == 'city'">modify_appli_city area_name </if>
	<if test="sumType == 'area'">modify_appli_county area_name,modify_appli_county_code area_code,modify_appli_city_code city_code </if> ,modify_appli_type patent_type
	,(sum(case when hv_seis_press='1' then 1 else 0 end ) +sum(case when hv_have_overseas_press='1' then 1 else 0 end ) 
	+sum(case when hv_keep10_press='1' then 1 else 0 end ) + sum(case when hv_high_pledge_press='1' then 1 else 0 end ) 
	+ sum(case when hv_technology_award_press='1' then 1 else 0 end )) total_cnt
	,sum(case when hv_seis_press='1' then 1 else 0 end ) hv_seis_press
	,sum(case when hv_have_overseas_press='1' then 1 else 0 end ) hv_have_overseas_press
	,sum(case when hv_keep10_press='1' then 1 else 0 end ) hv_keep10_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="sumType == 'area'">and modify_appli_county is not null and modify_appli_county!=''</if>  
	 -->
	  and STATUS = '10' 
	and imp_batch>=#{beginTime} and imp_batch<![CDATA[<=]]>#{endTime}
	<if test="sumType == 'city' and appliCity != 'all'">and modify_appli_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and appliCounty != 'null' and appliCounty != 'all'">and modify_appli_county_code=#{appliCounty} and modify_appli_city_code=#{appliCity}</if>
	<if test="sumType == 'area'  and (appliCounty == 'null' or appliCounty == 'all') ">and modify_appli_city_code=#{appliCity}</if>
	group by <if test="sumType == 'province'">modify_appli_province </if>
	<if test="sumType == 'city'">modify_appli_city </if><if test="sumType == 'area'">modify_appli_county,modify_appli_county_code,modify_appli_city_code </if>  ,modify_appli_type
</select>
				 
</mapper>




