<?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.adjust.mapper.DPatentDataCollationInfoMapper">

	
	<delete id="deleteForSyncMarkReg"    >
	truncate table c_trademark_reg  
	</delete>
	<insert id="insertForSyncMarkReg"  >
	insert into  c_trademark_reg (modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,total_cnt )
	select modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,count(*) total_cnt 
	from c_trademark where modify_city is not null and modify_city<![CDATA[<>]]>'' 
	and modify_county is not null and modify_county<![CDATA[<>]]>''  
	and reg_date is not null and reg_date<![CDATA[<>]]>'' and modify_province='云南省' 
	group by modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year
	</insert>
	
	<delete id="deleteForSyncMarkApl"   >
	truncate table c_trademark_apl  
	</delete>
	<insert id="insertForSyncMarkApl"  >
	insert into  c_trademark_apl (modify_city_code,modify_city,modify_county,modify_county_code,apl_date,apl_year,total_cnt )
	select modify_city_code,modify_city,modify_county,modify_county_code,apl_date,apl_year,count(*) total_cnt 
	from c_trademark where modify_city is not null and modify_city<![CDATA[<>]]>'' 
	and modify_county is not null and modify_county<![CDATA[<>]]>''  and apl_date is not null and apl_date<![CDATA[<>]]>''  and modify_province='云南省' 
	group by modify_city_code,modify_city,modify_county,modify_county_code,apl_date,apl_year
	</insert>
	
	<delete id="deleteForSyncMarkAct"    >
	truncate table c_trademark_act  
	</delete>
	<insert id="insertForSyncMarkAct"  >
	insert into  c_trademark_act(modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,property_end_date, total_cnt)
	select modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,property_end_date,count(*) total_cnt 
	from c_trademark where modify_city is not null and modify_city<![CDATA[<>]]>'' and modify_county is not null and modify_county<![CDATA[<>]]>''  
	and reg_date is not null and reg_date<![CDATA[<>]]>'' and property_end_date is not null and property_end_date<![CDATA[<>]]>'' and modify_province='云南省' 
	group by modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,property_end_date
	</insert>
	
	<delete id="deleteForSyncMarkRegNc"    >
	truncate table c_trademark_reg_nc  
	</delete>
	<insert id="insertForSyncMarkRegNc"  >
	insert into c_trademark_reg_nc(nc,modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,total_cnt )
	select nc,modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,count(*) total_cnt 
	from c_trademark where modify_city is not null and modify_city<![CDATA[<>]]>'' 
	and modify_county is not null and modify_county<![CDATA[<>]]>''  
	and reg_date is not null and reg_date<![CDATA[<>]]>''  and nc is not null and nc<![CDATA[<>]]>'' and modify_province='云南省' 
	group by nc,modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year
	</insert>
	
	<delete id="deleteForSyncMarkAplNc"   >
	truncate table c_trademark_apl_nc  
	</delete>
	<insert id="insertForSyncMarkAplNc">
	insert into c_trademark_apl_nc(nc,modify_city_code,modify_city,modify_county,modify_county_code,apl_date,apl_year,total_cnt )
	select nc,modify_city_code,modify_city,modify_county,modify_county_code,apl_date,apl_year,count(*) total_cnt 
	from c_trademark where modify_city is not null and modify_city<![CDATA[<>]]>'' 
	and modify_county is not null and modify_county<![CDATA[<>]]>''  and apl_date is not null and apl_date<![CDATA[<>]]>'' and nc is not null and nc<![CDATA[<>]]>'' 
	and modify_province='云南省' 
	group by nc,modify_city_code,modify_city,modify_county,modify_county_code,apl_date,apl_year
	</insert>
	
	<delete id="deleteForSyncMarkActNc"  >
	truncate table c_trademark_act_nc  
	</delete>
	<insert id="insertForSyncMarkActNc"  >
	insert into c_trademark_act_nc(nc,modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,property_end_date,total_cnt )
	select nc,modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,property_end_date,count(*) total_cnt 
	from c_trademark where modify_city is not null and modify_city<![CDATA[<>]]>'' and modify_county is not null and modify_county<![CDATA[<>]]>''   and nc is not null and nc<![CDATA[<>]]>'' 
	and reg_date is not null and reg_date<![CDATA[<>]]>'' and property_end_date is not null and property_end_date<![CDATA[<>]]>'' 
	and modify_province='云南省' 
	group by nc,modify_city_code,modify_city,modify_county,modify_county_code,reg_date,reg_year,property_end_date
	</insert>
	
	
	
	
	
	
	
<delete id="deleteForSyncActType" parameterType="String"  >
	truncate table rzl_class_statistics_info  
	</delete>
	<insert id="insertForSyncActType"  >
	 insert into rzl_class_statistics_info(modify_area_name ,modify_area_code  ,modify_city_name  ,modify_city_code,modify_patentee_type  ,patent_type,
        year_batch ,month_batch,pub_date_pub,
				higher_school,research_institute,total_cnt,enterprise,institutions,individual)
		select  modify_area_name ,modify_area_code  ,modify_city_name  ,modify_city_code,modify_patentee_type  ,patent_type,
        year_batch ,month_batch,pub_date_pub 
        ,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 ,count(*) total_cnt
        ,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 
       group by  modify_area_name ,modify_area_code  ,modify_city_name  ,modify_city_code,modify_patentee_type  ,patent_type,
        year_batch ,month_batch,pub_date_pub,modify_patentee_type 
	</insert>
	
	
<delete id="deleteForSyncAuthType" parameterType="String"  >
	truncate table rzs_class_statistics_info  
	</delete>
	
	<insert id="insertForSyncAuthType"  >
	 insert into rzs_class_statistics_info(modify_area_name ,modify_area_code  ,modify_city_name  ,modify_city_code,modify_patentee_type  ,patent_type,
        year_batch ,month_batch,auth_inbound_date,
				higher_school,research_institute,total_cnt,enterprise,institutions,individual) 
	select  modify_area_name ,modify_area_code  ,modify_city_name  ,modify_city_code,modify_patentee_type  ,patent_type,
        year_batch ,month_batch,auth_inbound_date  
        ,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 ,count(*) total_cnt
        ,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 
       group by  modify_area_name ,modify_area_code  ,modify_city_name  ,modify_city_code,modify_patentee_type  ,patent_type,
        year_batch ,month_batch,auth_inbound_date,modify_patentee_type 
	</insert>
	

<delete id="deleteForSyncPubType" parameterType="String"  >
	truncate table rzg_class_statistics_info  
	</delete>
	
	<insert id="insertForSyncPubType"  >
	         insert into rzg_class_statistics_info(yunnan_modify_appli_province,
	 yunnan_modify_appli_county ,yunnan_modify_appli_county_code,  
	yunnan_modify_appli_city , yunnan_modify_appli_city_code, pub_date,modify_appli_type, 
	year_batch,month_batch,patent_type,higher_school,research_institute,enterprise,institutions,individual,total_cnt )
	select yunnan_modify_appli_province,
	 yunnan_modify_appli_county ,yunnan_modify_appli_county_code,  
	yunnan_modify_appli_city , yunnan_modify_appli_city_code, pub_date,modify_appli_type, 
	SUBSTRING(pub_date,1,4) year_batch,SUBSTRING(pub_date,5,2) month_batch
	,(case  when patent_type='1' then '发明' when patent_type='2' then '实用新型' when patent_type='3' then '外观设计'  else '' end )  patent_type
	,sum(case  when modify_appli_type='UC' then 1 else 0 end ) higher_school  
	,sum(case  when modify_appli_type='SRI' then 1 else 0 end ) research_institute 
	,sum(case  when modify_appli_type='IME' then 1 else 0 end ) enterprise 
	,sum(case  when modify_appli_type='OT' then 1 else 0 end ) institutions 
	,sum(case  when modify_appli_type='PE' then 1 else 0 end ) individual 
	,count(*) total_cnt 
	from d_patent_pub_info where patent_type in ('1','2','3') and yunnan_modify_appli_city_code is not null and yunnan_modify_appli_city_code !='' 
	group by yunnan_modify_appli_province,
	 yunnan_modify_appli_county ,yunnan_modify_appli_county_code,  
	yunnan_modify_appli_city , yunnan_modify_appli_city_code, pub_date,modify_appli_type,
	SUBSTRING(pub_date,1,4),SUBSTRING(pub_date,5,2) ,patent_type 
	</insert>
	

	<delete id="deleteForSyncHvDetail" parameterType="String"  >
	delete from d_height_value_patent_detail where year_batch=#{yearBatch}
	</delete>
	
	<insert id="insertForSyncHvDetail"  >
	insert into d_height_value_patent_detail(modify_appli_type,modify_appli_city_code,modify_appli_county_code,
	pub_id,data_type,pre_counts,high_value,appli_province,lic_counts,title,ipc_main,appli_city,ple_counts,appli,app_date,app_tran_counts,
	loc_str,modify_appli_city,curt_counts,national_eco_str,agency_name,modify_appli_province,appli_county,pub_number,appli_address,pat_tran_counts,app_number,modify_appli_county,
	patent_type,appli_type,status,
	hv_seis_press,hv_have_overseas_press,hv_keep10_press,hv_high_pledge_press,hv_technology_award_press,year_batch,month_batch,imp_batch 
	) 
	select modify_patentee_type,modify_city_code,modify_area_code,
	id,'act' data_type,pre_counts,high_value_pub,province_name,lic_counts,invention_name,ipc_main,city_name,
	ple_counts,patentee_name,app_date,app_tran_counts,
	loc_str,modify_city_name,curt_counts,national_eco_str,agency_name,modify_province_name,area_name,pub_number,appli_address,pat_tran_counts,app_number,modify_area_name,
	patent_type,patentee_type,status,hv_seis_pub,hv_have_overseas_pub,hv_keep10_pub,hv_high_pledge_pub,hv_technology_award_pub,year_batch,month_batch,imp_batch 
	from d_patent_effective_info where ((high_value_pub is not null and high_value_pub<![CDATA[<>]]>'') or hv_keep10_pub='1') and patent_type='发明' 
	and year_batch=#{yearBatch} and month_batch=#{monthBatch} 
	</insert>
	
	
	<delete id="deleteForSyncPubRank"  >
	delete from rzg_applicant_ranking_info
	</delete>
	
	<insert id="insertForSyncPubRank"  >
	insert into rzg_applicant_ranking_info(patentee_name,imp_batch,patents_total_number,applicant_type,
	invent,utility_model,appearance_design,city_code,city_name) 
	select patentee_name,pub_date,patents_total_number,
	(case  applicant_type when 'IME' then '企业' when 'OT' then '机关团体' when 'PE' then '个人' when 'SRI' then '科研机构' when 'UC' then '大专院校' else applicant_type end ) applicant_type,
	invent,utility_model,appearance_design,city_code,city_name from (
	select  appli patentee_name,pub_date,count(*) patents_total_number ,modify_appli_type applicant_type
	,sum(case  when patent_type='1' then 1 else 0 end ) invent  
	,sum(case  when patent_type='2' then 1 else 0 end ) utility_model 
	,sum(case  when patent_type='3' then 1 else 0 end ) appearance_design ,modify_appli_city_code city_code,modify_appli_city city_name
	from d_patent_pub_info where modify_appli_type in ('UC','SRI','IME','OT','PE') 
	group by appli ,pub_date,modify_appli_type ,modify_appli_city_code,modify_appli_city 
	) ff
	</insert>
	
	
	
	<delete id="deleteForSyncActRank"  >
	delete from rzl_applicant_ranking_info
	</delete>
	
	<insert id="insertForSyncActRank"  >
	insert into rzl_applicant_ranking_info(patentee_name,year,month,patents_total_number,applicant_type,
	invent,utility_model,appearance_design,city_code,city_name) 
	select  patentee_name,year_batch,month_batch,count(*) patents_total_number ,modify_patentee_type applicant_type
	,sum(case  when patent_type='发明' then 1 else 0 end ) invent  
	,sum(case  when patent_type='实用新型' then 1 else 0 end ) utility_model 
	,sum(case  when patent_type='外观设计' then 1 else 0 end ) appearance_design ,modify_city_code,modify_city_name 
	from d_patent_effective_info group by patentee_name,year_batch,month_batch ,modify_patentee_type ,modify_city_code,modify_city_name 
	</insert>
	
	
	<delete id="deleteForSyncAuthRank"  >
	delete from rzs_applicant_ranking_info
	</delete>
	
	<insert id="insertForSyncAuthRank"  >
	insert into rzs_applicant_ranking_info(patentee_name,imp_batch,patents_total_number,applicant_type,
	invent,utility_model,appearance_design,city_code,city_name) 
	select  patentee_name,imp_batch,count(*) patents_total_number ,modify_patentee_type applicant_type
	,sum(case  when patent_type='发明' then 1 else 0 end ) invent  
	,sum(case  when patent_type='实用新型' then 1 else 0 end ) utility_model 
	,sum(case  when patent_type='外观设计' then 1 else 0 end ) appearance_design ,modify_city_code,modify_city_name 
	from d_patent_auth_info group by patentee_name,imp_batch,modify_patentee_type ,modify_city_code,modify_city_name 
	</insert>
	
	<delete id="deleteForSyncAuthIpc"  >
	delete from rzs_ipc_statistics_info 
	</delete>
	<insert id="insertForSyncAuthIpc"  >
	insert into rzs_ipc_statistics_info( city_name,city_code,imp_batch,ipc_type,ipc_sub_type,number,patent_type,
	higher_school,research_institute,enterprise,institutions,individual,applicant_type,ipc_type_name,ipc_sub_type_name ) 
	select modify_city_name,modify_city_code,  imp_batch,ipc_type,ipc_sub_type,count(*) total_cnt ,patent_type
	,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 ,
	modify_patentee_type,ipc_type_name,ipc_sub_type_name
	from d_patent_auth_info group by  modify_city_name,modify_city_code,imp_batch ,
	ipc_type,ipc_sub_type,patent_type ,modify_patentee_type,ipc_type_name,ipc_sub_type_name
	</insert>
	

	<delete id="deleteForSyncPubIpc"  >
		delete from rzg_ipc_statistics_info 
	</delete>
	
	<insert id="insertForSyncPubIpc"  >
	insert into rzg_ipc_statistics_info( city_name,city_code,year,month,imp_batch,
	ipc_type,ipc_sub_type,ipc_type_name,ipc_sub_type_name,number,patent_type,
	higher_school,research_institute,enterprise,institutions,individual,applicant_type ) 
	select city_name,city_code,year_batch,month_batch,imp_batch,modify_ipc_type,modify_ipc_sub_type,modify_ipc_type_name,modify_ipc_sub_type_name,number,
	(case patent_type when '1' then '发明' when '2' then '实用新型' else '外观设计' end ) patent_type,
	higher_school,research_institute,enterprise,institutions,individual,
	(case  modify_appli_type when 'IME' then '企业' when 'OT' then '机关团体' when 'PE' then '个人' when 'SRI' then '科研机构' when 'UC' then '大专院校' else modify_appli_type end ) applicant_type
	from (
	select modify_appli_city city_name,modify_appli_city_code city_code,  substring(pub_date,1,4) year_batch,substring(pub_date,5,2) month_batch,substring(pub_date,1,6) imp_batch,
	modify_ipc_type,modify_ipc_sub_type,count(*) number ,patent_type
	,sum(case  when modify_appli_type = 'UC' then 1 else 0 end ) higher_school  
	,sum(case  when modify_appli_type='SRI' then 1 else 0 end ) research_institute 
	,sum(case  when modify_appli_type='IME' then 1 else 0 end ) enterprise 
	,sum(case  when modify_appli_type = 'OT'  then 1 else 0 end ) institutions 
	,sum(case  when modify_appli_type='PE' then 1 else 0 end ) individual ,modify_appli_type,modify_ipc_type_name,modify_ipc_sub_type_name
	from d_patent_pub_info where patent_type in ('1','2','3') and modify_appli_type in  ('UC','SRI','IME','OT','PE')
	group by  modify_appli_city,modify_appli_city_code,substring(pub_date,1,4),substring(pub_date,5,2) ,substring(pub_date,1,6) ,
	modify_ipc_type,modify_ipc_sub_type,patent_type ,modify_appli_type,modify_ipc_type_name,modify_ipc_sub_type_name
	) ff
	</insert>
	
	
	<delete id="deleteForSyncActIpc"  >
	delete from rzl_ipc_statistics_info 
	</delete>
	<insert id="insertForSyncActIpc"  >
	insert into rzl_ipc_statistics_info( city_name,city_code,year,month,ipc_type,ipc_sub_type,number,patent_type,
	higher_school,research_institute,enterprise,institutions,individual,
	applicant_type,ipc_type_name,ipc_sub_type_name ) 
	select modify_city_name,modify_city_code,  year_batch,month_batch,ipc_type,ipc_sub_type,count(*) total_cnt ,patent_type
	,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 ,
	modify_patentee_type,ipc_type_name,ipc_sub_type_name
	from d_patent_effective_info group by  modify_city_name,modify_city_code,
	year_batch,month_batch ,ipc_type,ipc_sub_type,patent_type ,modify_patentee_type,
	ipc_type_name,ipc_sub_type_name
	</insert>
	
	
	
	<delete id="deleteForSyncPubView"  >
		delete from rzg_view_statistics_info 
	</delete>
	<insert id="insertForSyncPubView"  >
	insert into rzg_view_statistics_info(province_name,city_name,city_code,area_name,area_code,year,month,total_cnt,patent_type,
	higher_school,research_institute,enterprise,institutions,individual) 
	select  yunnan_modify_appli_province province_name,yunnan_modify_appli_city city_name,yunnan_modify_appli_city_code city_code,
	yunnan_modify_appli_county area_name,yunnan_modify_appli_county_code area_code
	,SUBSTRING(pub_date,1,4) year_batch,SUBSTRING(pub_date,5,2) month_batch
	,count(*) total_cnt
	,(case  when patent_type='1' then '发明' when patent_type='2' then '实用新型' when patent_type='3' then '外观设计'  else '' end )  patent_type 
	,sum(case  when modify_appli_type='UC' then 1 else 0 end ) higher_school  
	,sum(case  when modify_appli_type='SRI' then 1 else 0 end ) research_institute 
	,sum(case  when modify_appli_type='IME' then 1 else 0 end ) enterprise 
	,sum(case  when modify_appli_type='OT' then 1 else 0 end ) institutions 
	,sum(case  when modify_appli_type='PE' then 1 else 0 end ) individual 
	from d_patent_pub_info where patent_type in ('1','2','3') 
	and modify_appli_type in ('UC','SRI','IME','OT','PE')
	group by yunnan_modify_appli_province,
	yunnan_modify_appli_city,yunnan_modify_appli_city_code,yunnan_modify_appli_county,yunnan_modify_appli_county_code,
	SUBSTRING(pub_date,1,4),SUBSTRING(pub_date,5,2) ,patent_type 
	</insert>
	
	
	<delete id="deleteForSyncAuthView"  >
		delete from rzs_view_statistics_info 
	</delete>
	<insert id="insertForSyncAuthView"  >
		insert into rzs_view_statistics_info(province_name,city_name,city_code,area_name,area_code,year,month,total_cnt,patent_type,
		higher_school,research_institute,enterprise,institutions,individual) 
		select modify_province_name,modify_city_name,modify_city_code,modify_area_name,modify_area_code,year_batch,month_batch,count(*) total_cnt ,patent_type
		,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 group by modify_province_name,modify_city_name,modify_city_code,modify_area_name,modify_area_code,
		year_batch,month_batch ,patent_type  
	</insert>
	
	<delete id="deleteForSyncActView"  >
		delete from rzl_view_statistics_info 
	</delete>
	<insert id="insertForSyncActView"  >
		insert into rzl_view_statistics_info(province_name,city_name,area_name,province_code,city_code,area_code,
		year,month,total_cnt,patent_type,
		higher_school,research_institute,enterprise,institutions,individual) 
		select  modify_province_name,modify_city_name,modify_area_name,
		modify_province_code,modify_city_code,modify_area_code
		,year_batch,month_batch,count(*) total_cnt ,patent_type
		,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 group by modify_province_name,modify_city_name,modify_area_name,
		modify_province_code,modify_city_code,modify_area_code,
		year_batch,month_batch ,patent_type 
	</insert>
	
    <resultMap type="DPatentDataCollationInfo" id="DPatentDataCollationInfoResult2">
        <id property="id" column="id"/>
        <result property="dataType" column="data_type"/>
        <result property="appNumber" column="app_number"/>
        <result property="appDate" column="app_date"/>
        <result property="pubDate" column="pub_date"/>
        <result property="appli" column="appli"/>
        <result property="patenteeName" column="patentee_name"/>
        <result property="appliTypeSrc" column="appli_type_src"/>
        <result property="appliType" column="appli_type"/>
        <result property="appliAddress" column="appli_address"/>
        <result property="modifyAppliAddress" column="modify_appli_address"/>
        <result property="appliProvince" column="appli_province"/>
        <result property="appliCity" column="appli_city"/>
        <result property="appliCounty" column="appli_county"/>
        <result property="modifyAppliProvince" column="modify_appli_province"/>
        <result property="modifyAppliCity" column="modify_appli_city"/>
        <result property="modifyAppliCounty" column="modify_appli_county"/>
        <result property="highValue" column="high_value"/>
        <result property="inboundDate" column="inbound_date"/>
        <result property="createMonth" column="create_month"/>
        <result property="addressAdjustmentTime" column="address_adjustment_time"/>
        <result property="applyAdjustmentTime" column="apply_adjustment_time"/>
        <result property="title" column="title"/>
        <result property="pubNumber" column="pub_number"/>
        <result property="patentType" column="patent_type"/>
        <result property="currPatentStatus" column="curr_patent_status"/>
        <result property="currPatentHolder" column="curr_patent_holder"/>
        <result property="ipcMain" column="ipc_main"/>
        <result property="locStr" column="loc_str"/>
        <result property="nationalEcoStr" column="national_eco_str"/>
        <result property="patTranCounts" column="pat_tran_counts"/>
        <result property="appTranCounts" column="app_tran_counts"/>
        <result property="licCounts" column="lic_counts"/>
        <result property="pleCounts" column="ple_counts"/>
        <result property="preCounts" column="pre_counts"/>
        <result property="curtCounts" column="curt_counts"/>
        <result property="agencyName" column="agency_name"/>
        <result property="agencyCode" column="agency_code"/>
        <result property="patenteePostcode" column="patentee_postcode"/>
        <result property="authInboundDate" column="auth_inbound_date"/>
        <result property="patenteeType" column="patentee_type"/>
        <result property="modifyCownerAddress" column="modify_cowner_address"/>
        <result property="createTime" column="create_time"/>
        
        <result property="cownerAddress" column="cowner_address"/>
        <result property="cownerProvince" column="cowner_province"/>
        <result property="cownerCity" column="cowner_city"/>
        <result property="cownerCounty" column="cowner_county"/>
        <result property="modifyCownerProvince" column="modify_cowner_province"/>
        <result property="modifyCownerCity" column="modify_cowner_city"/>
        <result property="modifyCownerCounty" column="modify_cowner_county"/>
        <result property="cownerProvinceCode" column="cowner_province_code"/>
        <result property="cownerCityCode" column="cowner_city_code"/>
        <result property="cownerCountyCode" column="cowner_county_code"/>
        <result property="modifyCownerProvinceCode" column="modify_cowner_province_code"/>
        <result property="modifyCownerCityCode" column="modify_cowner_city_code"/>
        <result property="modifyCownerCountyCode" column="modify_cowner_county_code"/>
        
    </resultMap>

<sql id = "whereForAdjPub">
	where 1=1 
      <if test="patentTypeId != null  and patentTypeId != ''">
      	<if test="patentTypeId == '1'.toString() "> and patent_type in ('1','4') </if>
       	<if test="patentTypeId != '1'.toString() "> and patent_type =#{patentTypeId} </if>
      </if>
              <if test="appNumber != null  and appNumber != '' and appNumber != 'null'">and app_number2 =#{appNumber}</if>
             <if test="authInboundDate != null  and authInboundDate != 'null'  "> and time_create >=CONCAT(#{authInboundDate},'00') and time_create <![CDATA[<=]]>CONCAT(#{authInboundDate},'31')  </if>
            <!-- 
            <if test="notThisArea != null  and notThisArea != 'null'  "> and not_this_area =#{notThisArea}  </if>
             -->
              <if test="notThisArea != null  and notThisArea == '1'.toString()  "> 
              and modify_appli_county_code is not null and SUBSTRING(modify_appli_county_code,1,4) != modify_appli_city_code  </if>
              
            <if test="appDateBegin != null  and appDateBegin != ''">and app_date>=#{appDateBegin}</if>
            <if test="appDateEnd != null  and appDateEnd != ''">and app_date<![CDATA[<=]]>#{appDateEnd}</if>
            <if test="pubDate != null  and pubDate != ''">and pub_date<![CDATA[=]]>#{pubDate}</if>
            <if test="addressAdjustmentTimeBegin != null  and addressAdjustmentTimeBegin != ''">and address_adjustment_time>=#{addressAdjustmentTimeBegin} </if>
            <if test="addressAdjustmentTimeEnd != null  and addressAdjustmentTimeEnd != ''">and address_adjustment_time <![CDATA[<=]]>#{addressAdjustmentTimeEnd} </if>
            <if test="applyAdjustmentTimeBegin != null  and applyAdjustmentTimeBegin != ''">and apply_adjustment_time>=#{applyAdjustmentTimeBegin} </if>
            <if test="applyAdjustmentTimeEnd != null  and applyAdjustmentTimeEnd != ''">and apply_adjustment_time <![CDATA[<=]]>#{applyAdjustmentTimeEnd} </if>
            <if test="appliTypeCode != null  and appliTypeCode != '' and appliTypeCode != 'null'">and appli_type =#{appliTypeCode} </if>
            <if test="appliTypeCode != null  and appliTypeCode != '' and appliTypeCode == 'null' ">and (appli_type is null or appli_type='') </if>
            
            <!-- 
            <if test="appliCity != null  and appliCity != '' and appliCity != 'null'">and appli_city =#{appliCity}</if>
            <if test="appliCity != null  and appliCity != '' and appliCity == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (appli_city is null or appli_city = '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty != 'null'  and appliCounty != 'notnull'"> and appli_county =#{appliCounty} </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false) ">and (appli_county is null or appli_county='') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'notnull' ">and appli_county is not null and appli_county !='' </if>
             -->
            <if test="appliCity != null  and appliCity != '' and appliCity != 'null'">and modify_appli_city =#{appliCity}</if>
            <if test="appliCity != null  and appliCity != '' and appliCity == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (modify_appli_city is null or modify_appli_city = '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty != 'null'  and appliCounty != 'notnull'"> and modify_appli_county =#{appliCounty} </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false) ">and (modify_appli_county is null or modify_appli_county='') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'notnull' ">and modify_appli_county is not null and modify_appli_county !='' </if>

            <!-- 
            <if test="appliAddress != null  and appliAddress != ''">and modify_cowner_address like concat('%', #{appliAddress},'%') </if>
             -->
             <if test="appliAddress != null  and appliAddress != ''">and modify_appli_address like concat('%', #{appliAddress},'%') </if>
            <if test="pubNumber != null  and pubNumber != ''">and pub_number =#{pubNumber}</if>
            <if test="highValue != null  and highValue != '' and highValue != '0'.toString()  and highValue != '-1'.toString()  ">
            	and high_value like concat('%',#{highValue},'%') 
            </if>
            <if test="highValue != null  and highValue != ''">
            	<if test="highValue == '0'.toString()  or highValue == '-1'.toString()">and (high_value is null or high_value='') </if>
           	</if>
            <if test="addressAdjustmentFlag != null  and addressAdjustmentFlag==2 "> and address_adjustment_time is not null  </if>
            <if test="addressAdjustmentFlag != null and  addressAdjustmentFlag==3 "> and address_adjustment_time is null </if>
            <if test="applyAdjustmentFlag != null  and applyAdjustmentFlag==2 "> and apply_adjustment_time is not null </if>
            <if test="applyAdjustmentFlag != null and applyAdjustmentFlag==3 "> and apply_adjustment_time is null </if>
            <!-- 
            <if test="cityAndAreaFlag != null and cityAndAreaFlag"> AND (appli_city is null or appli_county is null or appli_city='' or appli_county='')</if>
             <if test="cityAndAreaFlag != null and cityAndAreaFlag"> 
             AND (modify_cowner_county is null or modify_cowner_city is null or modify_cowner_county='' or modify_cowner_city='' or not_this_area='1')
             </if>
             -->
             <if test="cityAndAreaFlag != null and cityAndAreaFlag"> 
             AND (modify_appli_county is null or modify_appli_city is null or modify_appli_county='' or modify_appli_city='' 
					or (SUBSTRING(modify_appli_county_code,1,4) != modify_appli_city_code)
				)
             </if>
             
            <if test="timeValue != null and timeValue!='' "> and create_month=#{timeValue} </if>
            <if test="createTimeBegin != null  and createTimeBegin != ''"></if>
            <if test="createTimeEnd != null  and createTimeEnd != ''">
            </if>
            
             <if test= "@com.ruoyi.common.utils.SecurityUtils@isNeedFilterByCityCode()">
	                and modify_city_code = '${@com.ruoyi.common.utils.SecurityUtils@needFilterByCityCode()}' 
	            </if>
		</sql>

<sql id = "whereForAdjAct">
	where 1=1 
            <if test="appNumber != null  and appNumber != '' and appNumber != 'null'">and app_number =#{appNumber}</if>
            <if test="authInboundDate != null  and authInboundDate != 'null'  "> and auth_inbound_date >=CONCAT(#{authInboundDate},'00') and auth_inbound_date <![CDATA[<=]]>CONCAT(#{authInboundDate},'31')  </if>
             <if test="patentType != null  and patentType != ''">and patent_type =#{patentType}</if>
            <if test="appDateBegin != null  and appDateBegin != ''">and app_date>=#{appDateBegin}</if> 
            <if test="appDateEnd != null  and appDateEnd != ''">and app_date<![CDATA[<=]]>#{appDateEnd}</if>
			<if test="pubDate != null  and pubDate != ''">and pub_date_pub<![CDATA[=]]>#{pubDate}</if>
            <if test="addressAdjustmentTimeBegin != null  and addressAdjustmentTimeBegin != ''">and address_adjustment_time>=#{addressAdjustmentTimeBegin} </if>
            <if test="addressAdjustmentTimeEnd != null  and addressAdjustmentTimeEnd != ''">and address_adjustment_time <![CDATA[<=]]>#{addressAdjustmentTimeEnd} </if>
            <if test="applyAdjustmentTimeBegin != null  and applyAdjustmentTimeBegin != ''">and apply_adjustment_time>=#{applyAdjustmentTimeBegin} </if>
            <if test="applyAdjustmentTimeEnd != null  and applyAdjustmentTimeEnd != ''">and apply_adjustment_time <![CDATA[<=]]>#{applyAdjustmentTimeEnd} </if>
            
            <if test="appliType != null  and appliType != '' and appliType != 'null'">and patentee_type =#{appliType} </if>
            <if test="appliType != null  and appliType != '' and appliType == 'null' ">and (patentee_type is null or patentee_type='') </if>
            <!-- 
            <if test="appliCity != null  and appliCity != '' and appliCity != 'null'">and city_name =#{appliCity} </if>
            <if test="appliCity != null  and appliCity != '' and appliCity == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (city_name is null or city_name = '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty != 'null'  and appliCounty != 'notnull'"> and area_name =#{appliCounty} </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (area_name is null or area_name = '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'notnull' "> and not_this_area ='1'  </if>
             -->
             <if test="appliCity != null  and appliCity != '' and appliCity != 'null'">and modify_city_name =#{appliCity} </if>
            <if test="appliCity != null  and appliCity != '' and appliCity == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (modify_city_name is null or modify_city_name = '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty != 'null'  and appliCounty != 'notnull'"> and modify_area_name =#{appliCounty} </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (modify_area_name is null or modify_area_name = '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'notnull' "> and modify_area_name is not null and modify_area_name !=''  </if>
            
            <!-- 
            <if test="notThisArea != null  and notThisArea != 'null'  "> and not_this_area =#{notThisArea}  </if>
             -->
            <if test="notThisArea != null  and notThisArea == '1'.toString()"> and modify_area_code is not null and SUBSTRING(modify_area_code,1,4) != modify_city_code </if>
            
            
            <if test="appliAddress != null  and appliAddress != ''">and appli_address like concat('%', #{appliAddress}, '%') </if>
            <if test="pubNumber != null  and pubNumber != ''">and pub_number =#{pubNumber}</if>
            
            <if test="highValue != null  and highValue != '' and highValue != '0'.toString()  and highValue != '-1'.toString()  ">
            	and (high_value_pub like concat('%',#{highValue},'%')<if test="highValue == '3'.toString()" >or hv_keep10_pub='1'</if>)
            </if>
            <if test="highValue != null  and highValue != ''">
            	<if test="highValue == '0'.toString()  or highValue == '-1'.toString()">and (high_value_pub is null or high_value_pub='') </if>
           	</if>
            
            <if test="addressAdjustmentFlag != null  and addressAdjustmentFlag==2 "> and address_adjustment_time is not null  </if>
            <if test="addressAdjustmentFlag != null and addressAdjustmentFlag==3 "> and address_adjustment_time is null </if>
            <if test="applyAdjustmentFlag != null  and applyAdjustmentFlag==2 "> and apply_adjustment_time is not null </if>
            <if test="applyAdjustmentFlag != null and applyAdjustmentFlag==3 "> and apply_adjustment_time is null </if>
            <!-- 
            <if test="cityAndAreaFlag != null and cityAndAreaFlag"> AND (city_name is null or area_name is null or city_name='' or area_name='') </if>
             <if test="cityAndAreaFlag != null and cityAndAreaFlag"> 
             AND (modify_city_name is null or modify_city_name is null or modify_area_name='' or modify_area_name='' or not_this_area='1')
             </if>
             -->
             
             <if test="cityAndAreaFlag != null and cityAndAreaFlag"> 
             AND (modify_area_name is null or modify_city_name is null or modify_area_name='' or modify_city_name='' 
					or (SUBSTRING(modify_area_code,1,4) != modify_city_code)
				)
             </if>
             
            <if test="timeValue != null and timeValue!='' "> and create_month=#{timeValue} </if>
            <if test="createTimeBegin != null  and createTimeBegin != ''"></if>
            <if test="createTimeEnd != null  and createTimeEnd != ''">
            </if>
             <if test= "@com.ruoyi.common.utils.SecurityUtils@isNeedFilterByCityCode()">
	                and modify_city_code = '${@com.ruoyi.common.utils.SecurityUtils@needFilterByCityCode()}'  
	            </if>
		</sql>
		
		<sql id = "whereForAdjAuth">
		where 1=1 
            <if test="appNumber != null  and appNumber != '' and appNumber != 'null'">and apply_number =#{appNumber}</if>
            <if test="authInboundDate != null  and authInboundDate != 'null'  "> and auth_inbound_date >=CONCAT(#{authInboundDate},'00') and auth_inbound_date <![CDATA[<=]]>CONCAT(#{authInboundDate},'31')  </if>
            <if test="patentType != null  and patentType != ''">and patent_type =#{patentType}</if>
            <!-- 
            <if test="notThisArea != null  and notThisArea != 'null'  "> and not_this_area =#{notThisArea}  </if>
             -->
             <if test="notThisArea != null  and notThisArea == '1'.toString()  ">and modify_area_code is not null and SUBSTRING(modify_area_code,1,4) != modify_city_code  </if>
             
            <if test="appDateBegin != null  and appDateBegin != ''">and apply_date>=#{appDateBegin}</if>
			<if test="pubDate != null  and pubDate != ''">and pub_date_pub<![CDATA[=]]>#{pubDate}</if>
            <if test="appDateEnd != null  and appDateEnd != ''">and apply_date<![CDATA[<=]]>#{appDateEnd}</if>
            <if test="addressAdjustmentTimeBegin != null  and addressAdjustmentTimeBegin != ''">and address_adjustment_time>=#{addressAdjustmentTimeBegin} </if>
            <if test="addressAdjustmentTimeEnd != null  and addressAdjustmentTimeEnd != ''">and address_adjustment_time <![CDATA[<=]]>#{addressAdjustmentTimeEnd} </if>
            <if test="applyAdjustmentTimeBegin != null  and applyAdjustmentTimeBegin != ''">and apply_adjustment_time>=#{applyAdjustmentTimeBegin} </if>
            <if test="applyAdjustmentTimeEnd != null  and applyAdjustmentTimeEnd != ''">and apply_adjustment_time <![CDATA[<=]]>#{applyAdjustmentTimeEnd} </if>
            <if test="appliType != null  and appliType != '' and appliType != 'null'">and patentee_type =#{appliType} </if>
            <if test="appliType != null  and appliType != '' and appliType == 'null' ">and (patentee_type is null or patentee_type='') </if>
            <!-- 
            <if test="appliCity != null  and appliCity != '' and appliCity != 'null'"> and city_name =#{appliCity} </if>
            <if test="appliCity != null  and appliCity != '' and appliCity == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (city_name is null or city_name= '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty != 'null'  and appliCounty != 'notnull'"> and area_name =#{appliCounty} </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'null'  and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (area_name is null or area_name='') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'notnull' ">and area_name is not null and area_name !=''</if>
             -->
            
            <if test="appliCity != null  and appliCity != '' and appliCity != 'null'"> and modify_city_name =#{appliCity} </if>
            <if test="appliCity != null  and appliCity != '' and appliCity == 'null' and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (modify_city_name is null or modify_city_name= '') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty != 'null'  and appliCounty != 'notnull'"> and modify_area_name =#{appliCounty} </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'null'  and (cityAndAreaFlag==null or cityAndAreaFlag==false)">and (modify_area_name is null or modify_area_name='') </if>
            <if test="appliCounty != null  and appliCounty != '' and appliCounty == 'notnull' ">and modify_area_name is not null and modify_area_name !=''</if>
            
            <if test="appliAddress != null  and appliAddress != ''">and patentee_address like concat('%', #{appliAddress}, '%') </if>
            <if test="pubNumber != null  and pubNumber != ''">and pub_number =#{pubNumber}</if>
            
            <if test="highValue != null  and highValue != '' and highValue != '0'.toString()  and highValue != '-1'.toString()  ">and high_value_pub like concat('%',#{highValue},'%')</if>
            <if test="highValue != null  and highValue != ''">
            	<if test="highValue == '0'.toString()  or highValue == '-1'.toString()">and (high_value_pub is null or high_value_pub='') </if>
           	</if>
            <if test="addressAdjustmentFlag != null  and addressAdjustmentFlag==2 "> and address_adjustment_time is not null</if>
            <if test="addressAdjustmentFlag != null and addressAdjustmentFlag==3  "> and address_adjustment_time is null </if>
            <if test="applyAdjustmentFlag != null  and applyAdjustmentFlag==2 "> and apply_adjustment_time is not null  </if>
            <if test="applyAdjustmentFlag != null and applyAdjustmentFlag==3   "> and apply_adjustment_time is null </if>
            <!-- 
            <if test="cityAndAreaFlag != null and cityAndAreaFlag"> AND (city_name is null or area_name is null or city_name='' or area_name='') </if>
             <if test="cityAndAreaFlag != null and cityAndAreaFlag"> 
             AND (modify_city_name is null or modify_city_name is null or modify_area_name='' or modify_area_name='' or not_this_area='1')
             </if>
             -->
             <if test="cityAndAreaFlag != null and cityAndAreaFlag"> 
             AND (modify_city_name is null or modify_city_name is null or modify_area_name='' or modify_area_name='' 
					or (SUBSTRING(modify_area_code,1,4) != modify_city_code)
				)
             </if>
            <if test="timeValue != null and timeValue!='' "> and create_month=#{timeValue} </if>
            <if test="createTimeBegin != null  and createTimeBegin != ''"></if>
            <if test="createTimeEnd != null  and createTimeEnd != ''"></if>
            
             <if test= "@com.ruoyi.common.utils.SecurityUtils@isNeedFilterByCityCode()">
	                and modify_city_code = '${@com.ruoyi.common.utils.SecurityUtils@needFilterByCityCode()}'  
	            </if>
	            
		</sql>
		
		
    <select id="listForAdj_COUNT" resultType="Long" parameterType="DPatentDataCollationInfo">
        select count(*) from (
        <if test="queryPub != null  and queryPub == '1'.toString()">
            (SELECT id, 'pub' data_type FROM d_patent_pub_info <include refid="whereForAdjPub"/> )
            <if test="queryActive != null  and queryActive == '1'.toString()">union all</if>
            <if test="queryActive == null  or queryActive != '1'.toString()">
                <if test="queryAuth != null  and queryAuth == '1'.toString()">union all</if>
            </if>
        </if>
        <if test="queryActive != null  and queryActive == '1'.toString()">
            (SELECT id, 'act' data_type FROM d_patent_effective_info  <include refid="whereForAdjAct"/> )
            <if test="queryAuth != null  and queryAuth == '1'.toString()">union all</if>
        </if>
        <if test="queryAuth != null  and queryAuth == '1'.toString()">
           (SELECT id, 'auth' data_type FROM d_patent_auth_info  <include refid="whereForAdjAuth"/> )
        </if>
        ) ff
    </select>


    <select id="listForAdj" parameterType="DPatentDataCollationInfo" resultMap="DPatentDataCollationInfoResult2">
        select * from (
        <if test="queryPub != null  and queryPub == '1'.toString()">
            (SELECT
            id,
            'pub' data_type,
            app_number2 app_number,
            app_date,
            pub_date pub_date,
            appli,
            appli as patentee_name,
            appli_type as appli_type_src,
            appli_type as patentee_type,
            modify_appli_type as appli_type,
            appli_address as appli_address,<!-- 统计地址 -->
            appli_address as modify_appli_address,<!-- 申请人地址 -->
            modify_cowner_address  ,<!-- 当前申请人/专利权地址 -->
            cowner_address,
			cowner_province,cowner_province_code,cowner_city,cowner_city_code,cowner_county,cowner_county_code,
			modify_cowner_province,modify_cowner_province_code,modify_cowner_city,modify_cowner_city_code,modify_cowner_county,modify_cowner_county_code,
            appli_province_code,
            appli_province,
            appli_city_code,
            appli_city,
            appli_county_code,
            appli_county,
            modify_cowner_province_code as modify_appli_province_code,
            modify_cowner_province as modify_appli_province,
            modify_cowner_city_code as modify_appli_city_code,
            modify_cowner_city as modify_appli_city,
            modify_cowner_county_code as modify_appli_county_code,
            modify_appli_county as modify_appli_county,
            high_value,
            create_time AS inbound_date,
            time_create as auth_inbound_date,
            create_month as  create_month,
            address_adjustment_time,
            apply_adjustment_time,
            title,
            pub_number,
            patent_status AS curr_patent_status,
            patent_holder_pub AS curr_patent_holder,
            patent_type,
            ipc_main,
            loc_str,
            national_eco_str,
            pat_tran_counts,
            app_tran_counts,
            lic_counts,
            ple_counts,
            pre_counts,
            curt_counts,
            agency_name,
            '' as  agency_code,
            '' as patentee_postcode,
            del_flag,
            STATUS,create_time
            FROM
            d_patent_pub_info
            <include refid="whereForAdjPub"/> )
            <if test="queryActive != null  and queryActive == '1'.toString()">union all</if>
            <if test="queryActive == null  or queryActive != '1'.toString()">
                <if test="queryAuth != null  and queryAuth == '1'.toString()">union all</if>
            </if>
        </if>
        <if test="queryActive != null  and queryActive == '1'.toString()">
            (SELECT
            id,
            'act' data_type,
            app_number,
            app_date,
            pub_date_pub pub_date,
            patentee_name AS appli,
            patentee_name as patentee_name,
            patentee_type AS appli_type_src,
            patentee_type,
            modify_patentee_type AS appli_type,
            <!-- 
            appli_address_pub as appli_address,
            appli_address as modify_appli_address,
             -->
            appli_address_pub as modify_appli_address,<!-- 申请人地址，从公开数据中匹配到的申请人地址 -->
            appli_address as appli_address,<!-- 统计地址 -->
            modify_cowner_address  ,<!-- 当前申请人/专利权地址 -->
            cowner_address,
			cowner_province,cowner_province_code,cowner_city,cowner_city_code,cowner_county,cowner_county_code,
			modify_cowner_province,modify_cowner_province_code,modify_cowner_city,modify_cowner_city_code,modify_cowner_county,modify_cowner_county_code,
            province_code AS appli_province_code,
            province_name AS appli_province,
            city_code AS appli_city_code,
            city_name AS appli_city,
            area_code AS appli_county_code,
            area_name AS appli_county,
            modify_province_code AS modify_appli_province_code,
            modify_province_name AS modify_appli_province,
            modify_city_code AS modify_appli_city_code,
            modify_city_name AS modify_appli_city,
            modify_area_code AS modify_appli_county_code,
            modify_area_name AS modify_appli_county,
            high_value_pub AS high_value,
            create_time AS inbound_date,
            auth_inbound_date as auth_inbound_date,
            create_month ,
            address_adjustment_time,
            apply_adjustment_time,
            invention_name AS title,
            pub_number,
            patent_status AS curr_patent_status,
            patent_holder_pub AS curr_patent_holder,
            patent_type,
            ipc_main,
            loc_str,
            national_eco_str,
            pat_tran_counts,
            app_tran_counts,
            lic_counts,
            ple_counts,
            pre_counts,
            curt_counts,
            agency_name,
            agency_code,
            patentee_postcode,
            del_flag,
            STATUS,create_time
            FROM
            d_patent_effective_info
            <include refid="whereForAdjAct"/>  )
            <if test="queryAuth != null  and queryAuth == '1'.toString()">union all</if>
        </if>
        <if test="queryAuth != null  and queryAuth == '1'.toString()">
            (SELECT
            id,
            'auth' data_type,
            pub_date_pub pub_date,
            apply_number as app_number,
            apply_date as app_date,
            patentee_name AS appli,
            patentee_name as patentee_name,
            patentee_type AS appli_type_src,
            patentee_type  ,
            modify_patentee_type AS appli_type,
            <!-- 
            appli_address_pub AS appli_address,
            patentee_address AS modify_appli_address,
             -->
              patentee_address AS appli_address,<!-- 统计地址地址，excel 导入时表中的统计地址 --> 
            appli_address_pub AS modify_appli_address,<!-- 申请人地址，从公开数据中匹配到的申请人地址 -->
             modify_cowner_address  ,<!-- 当前申请人/专利权地址 -->
            cowner_address,
			cowner_province,cowner_province_code,cowner_city,cowner_city_code,cowner_county,cowner_county_code,
			modify_cowner_province,modify_cowner_province_code,modify_cowner_city,modify_cowner_city_code,modify_cowner_county,modify_cowner_county_code,
            province_code AS appli_province_code,
            province_name AS appli_province,
            city_code AS appli_city_code,
            city_name AS appli_city,
            area_code AS appli_county_code,
            area_name AS appli_county,
            modify_province_code AS modify_appli_province_code,
            modify_province_name AS modify_appli_province,
            modify_city_code AS modify_appli_city_code,
            modify_city_name AS modify_appli_city,
            modify_area_code AS modify_appli_county_code,
            modify_area_name AS modify_appli_county,
            high_value_pub AS high_value,
            create_time AS inbound_date,
            auth_inbound_date as auth_inbound_date,
            create_month,
            address_adjustment_time,
            apply_adjustment_time,
            invention_name AS title,
            pub_number,
            patent_status AS curr_patent_status,
            patent_holder_pub AS curr_patent_holder,
            patent_type,
            ipc_main,
            loc_str,
            national_eco_str,
            pat_tran_counts,
            app_tran_counts,
            lic_counts,
            ple_counts,
            pre_counts,
            curt_counts,
            agency_name,
            agency_code,
            patentee_postcode,
            del_flag,
            STATUS,create_time
            FROM
            d_patent_auth_info
            <include refid="whereForAdjAuth"/>   )
        </if>
        ) ff order by  app_date ,id desc
        <if test="exportNumBegin!=null and exportNumEnd!=null">
            limit #{exportNumBegin},#{exportNumEnd}  
        </if>
    </select>


</mapper>






