<?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.trade.mapper.CTrademarkMapper">


<delete id="clearData"    >
	truncate table c_trademark  
	</delete>
	
	
<!-- 
  <select id="listReportApply" resultType="map">
  	select 
  	<if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>
  	,apl_year ,count(*) total_cnt from c_trademark 
	where 1=1 
	<if test="cityCode != null  and cityCode != ''">
  		and modify_county is not null and modify_county !=''  
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		and modify_city is not null and modify_city !=''  
  	</if>
	and apl_year is not null and apl_year !='' and apl_date is not null and apl_date!='' 
	<if test="beginDate != null  and beginDate != ''">
		and apl_date <![CDATA[>=]]>#{beginDate}
	</if>
	<if test="endDate != null  and endDate != ''">
		and apl_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>,apl_year 
  </select>
   -->
   
   <select id="listReportApply" resultType="map">
  	select 
  	<if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city,modify_county_code modify_city_code
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city,modify_city_code
  	</if>
  	,apl_year ,sum(total_cnt) total_cnt from c_trademark_apl 
	where 1=1 
	<if test="beginDate != null  and beginDate != ''">
		and apl_date <![CDATA[>=]]>#{beginDate}
	</if>
	<if test="endDate != null  and endDate != ''">
		and apl_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county,modify_county_code
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city,modify_city_code
  	</if>,apl_year 
  </select>
  
  <!-- 
   <select id="listReportReg" resultType="map">
  	select 
  	<if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>
  	,reg_year ,count(*) total_cnt from c_trademark 
	where 1=1 
	<if test="cityCode != null  and cityCode != ''">
  		and modify_county is not null and modify_county !=''  
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		and modify_city is not null and modify_city !=''  
  	</if>
  	  and reg_year is not null and reg_year !='' and reg_date is not null and reg_date!='' 
	<if test="beginDate != null  and beginDate != ''">
		and reg_date <![CDATA[>=]]>#{beginDate}
	</if>
	<if test="endDate != null  and endDate != ''">
		and reg_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>,reg_year 
  </select>
   -->
   <select id="listReportReg" resultType="map">
  	select 
  	<if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city,modify_county_code modify_city_code
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city,modify_city_code
  	</if>
  	,reg_year ,sum(total_cnt) total_cnt from c_trademark_reg 
	where 1=1 
	<if test="beginDate != null  and beginDate != ''">
		and reg_date <![CDATA[>=]]>#{beginDate}
	</if>
	<if test="endDate != null  and endDate != ''">
		and reg_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county,modify_county_code 
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city,modify_city_code
  	</if>,reg_year 
  </select>
  
  <!-- 
  <select id="listReportAct" resultType="map">
   	select <if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>
  	,reg_year 
	,sum(case  when ( property_end_date>=#{endDate})  then 1 else 0 end ) total_cnt   
	from c_trademark 
	where property_end_date is not null and property_end_date!='' 
	<if test="cityCode != null  and cityCode != ''">
  		and modify_county is not null and modify_county !=''  
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		and modify_city is not null and modify_city !=''  
  	</if>
	and reg_year is not null and reg_year !=''  
	<if test="beginDate != null  and beginDate != ''">
		and reg_date <![CDATA[>=]]>#{beginDate}
	</if>
	<if test="endDate != null  and endDate != ''">
		and reg_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>,reg_year 
	
  </select>
   -->
   
   <!-- select sum(total_cnt) total_cnt ,modify_city,modify_city_code  from  c_trademark_act where property_end_date>=#{endDate}  group by modify_city,modify_city_code 
   select modify_city,modify_city_code ,sum(total_cnt) total_cnt from c_trademark_apl where 1=1 and apl_date <![CDATA[<=]]>#{endDate}  group by modify_city,modify_city_code
   select modify_city,modify_city_code ,sum(total_cnt) total_cnt from c_trademark_reg where 1=1 and reg_date <![CDATA[<=]]>#{endDate}  group by modify_city,modify_city_code 
    -->
<select id="listForLast" resultType="map">
	select   modify_city,modify_city_code  
  	,substring(#{endDate},1,4 ) reg_year  ,sum(total_cnt) total_cnt   from  c_trademark_act  where property_end_date>=#{endDate}  and reg_date  <![CDATA[<=]]> #{endDate}
	group by   modify_city,modify_city_code
</select>


<select id="listReportActSum" resultType="long">
SELECT
	ifnull(sum( total_cnt ),0) total_cnt 
FROM
	c_trademark_act 
WHERE
	property_end_date >=#{endTime} 
	AND reg_date <![CDATA[<=]]> #{endTime}
</select>

<select id="listReportAct" resultType="map">
 <foreach item="item" collection="endDateList" separator="union all" open="(" close=")" index="">
   	(select <if test="cityCode != null  and cityCode != ''"> modify_county modify_city,modify_county_code modify_city_code </if>
  	<if test="cityCode == null  or cityCode == ''"> modify_city,modify_city_code </if>
  	,substring(${item},1,4 ) reg_year  ,sum(total_cnt) total_cnt   from  c_trademark_act  where property_end_date>=#{item} 
	<if test="endDate != null  and endDate != ''">
		and reg_date <![CDATA[<=]]>#{item}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county,modify_county_code
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city,modify_city_code
  	</if>)
  </foreach>
</select>

<!-- 
  
   <select id="listReportAct" resultType="map">
   	select <if test="cityCode != null  and cityCode != ''"> modify_county modify_city </if>
  	<if test="cityCode == null  or cityCode == ''"> modify_city </if>
  	,reg_year  ,sum(total_cnt) total_cnt   from  c_trademark_act  where property_end_date>=#{endDate} 
	<if test="endDate != null  and endDate != ''">
		and reg_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>,reg_year 
  </select>
   -->
  <!-- 
  <select id="listReportAct2" resultType="map">
   	select <if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>
	,count(*) total_cnt   
	from c_trademark 
	where property_end_date>=#{endDate}  
	and property_end_date is not null and property_end_date!='' 
	<if test="cityCode != null  and cityCode != ''">
  		and modify_county is not null and modify_county !=''  
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		and modify_city is not null and modify_city !=''  
  	</if>
	and apl_year is not null and apl_year !=''  
	<if test="beginDate != null  and beginDate != ''">
		and apl_date <![CDATA[>=]]>#{beginDate}
	</if>
	<if test="endDate != null  and endDate != ''">
		and apl_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>
  </select>
   -->
    <select id="listReportAct2" resultType="map">
    select 
  	<if test="cityCode != null  and cityCode != ''">
  		modify_county modify_city
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if>
  	,sum(total_cnt) total_cnt from c_trademark_apl 
	where 1=1 
	<if test="beginDate != null  and beginDate != ''">
	<!-- 
		and apl_date <![CDATA[>=]]>#{beginDate}
		 -->
	</if>
	<if test="endDate != null  and endDate != ''">
		and apl_date <![CDATA[<=]]>#{endDate}
	</if>
	<if test="cityCode != null  and cityCode != ''">
  		and modify_city_code = #{cityCode}
  	</if>
	group by <if test="cityCode != null  and cityCode != ''">
  		modify_county
  	</if>
  	<if test="cityCode == null  or cityCode == ''">
  		modify_city
  	</if> 
  </select>
  <!-- 
  <select id="listReportNcGrowth" resultType="map">
		select nc 
		<if test="sumType == 'province'">,'云南省' modify_city </if>
		<if test="sumType == 'city'">,modify_city modify_city </if>
		<if test="sumType == 'area'">,modify_county modify_city </if>
		 ,count(*) total_cnt  from c_trademark 
		where 1=1  and modify_city is not null and modify_city !=''  
		<if test="sumType == 'city' and cityCode != '' and cityCode != 'null' and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="sumType == 'area' and cityCode != '' and cityCode != 'null'  and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="sumType == 'area'">and modify_county is not null and modify_county!=''</if>
		<if test="queryType == 'reg' ">
			and reg_date is not null and reg_date !=''   
		</if>
		
		<if test="queryType == 'apl' ">
			 and apl_date is not null and apl_date !=''    
		</if>
		<if test="queryType == 'act' ">
			and property_bgn_date is not null and property_bgn_date !=''   
			and property_end_date is not null and property_end_date !=''   
			and property_end_date>=#{endDate} 
		</if>
		
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''    and queryType == 'reg' ">
			and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''   and queryType == 'apl' ">
			and apl_date <![CDATA[>=]]>#{beginDate} and apl_date <![CDATA[<=]]>#{endDate}
		</if>
		
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''   and queryType == 'act' ">
			and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		
		group by <if test="sumType == 'city'">  modify_city ,</if>
			<if test="sumType == 'area'"> modify_county ,</if>nc 
	</select>
	 -->
  <select id="listReportNcGrowth" resultType="map">
		select nc  <if test="sumType == 'province'">,'云南省' modify_city </if> 
		<if test="sumType == 'city'">,modify_city modify_city </if> <if test="sumType == 'area'">,modify_county modify_city </if>
		 ,sum(total_cnt) total_cnt  from 
		 <if test="queryType == 'reg' ">c_trademark_reg_nc </if><if test="queryType == 'apl' ">c_trademark_apl_nc </if><if test="queryType == 'act' ">c_trademark_act_nc </if>
		where 1=1   
		<if test="sumType == 'city' and cityCode != '' and cityCode != null and cityCode != 'null' and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="sumType == 'area' and cityCode != '' and cityCode != null and cityCode != 'null'  and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="queryType == 'act' "> and property_end_date>=#{endDate}  </if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''    and queryType == 'reg' ">
			and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''   and queryType == 'apl' ">
			and apl_date <![CDATA[>=]]>#{beginDate} and apl_date <![CDATA[<=]]>#{endDate}
		</if>
		<if test="endDate != null  and endDate != ''   and queryType == 'act' ">
			and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		group by <if test="sumType == 'city'">  modify_city ,</if>
			<if test="sumType == 'area'"> modify_county ,</if>nc 
	</select>
  
  <!-- 
	<select id="listReportGrowth" resultType="map">
	  	select  modify_city 
		,sum(case when type='reg' then total_cnt else 0 end ) reg_total_cnt
		,sum(case when type='apl' then total_cnt else 0 end ) apl_total_cnt
		,sum(case when type='act' then total_cnt else 0 end ) act_total_cnt from (
		select 
		<if test="sumType == 'province'">'云南省' modify_city </if>
		<if test="sumType == 'city'">modify_city modify_city </if>
		<if test="sumType == 'area'">modify_county modify_city </if>
		 ,count(*) total_cnt,'reg' type from c_trademark  where 1=1 
	<if test="sumType == 'city' and cityCode != '' and cityCode != 'null' and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
	<if test="sumType == 'area' and cityCode != '' and cityCode != 'null'  and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		and modify_city is not null and modify_city !=''   
		and reg_date is not null and reg_date !=''   
		<if test="sumType == 'area'">and modify_county is not null and modify_county!=''</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
			</if>
			<if test="sumType == 'city'"> group by modify_city </if>
			<if test="sumType == 'area'">group by modify_county </if>
		union all 
		select  <if test="sumType == 'province'">'云南省' modify_city </if>
		<if test="sumType == 'city'">modify_city modify_city </if>
		<if test="sumType == 'area'">modify_county modify_city </if>
		  	,count(*) total_cnt,'apl' type from c_trademark 
		where 
		1=1 and modify_city is not null and modify_city !=''   
		<if test="sumType == 'area'">and modify_county is not null and modify_county!=''</if>
		<if test="sumType == 'city' and cityCode != '' and cityCode != 'null'">and modify_city_code=#{cityCode}</if>
	<if test="sumType == 'area' and cityCode != '' and cityCode != 'null' ">and modify_city_code=#{cityCode}</if>
		and apl_date is not null and apl_date !=''   
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and apl_date <![CDATA[>=]]>#{beginDate} and apl_date <![CDATA[<=]]>#{endDate}
			</if>
		<if test="sumType == 'city'"> group by modify_city </if>
		<if test="sumType == 'area'">group by modify_county </if>
		union all 
		select  <if test="sumType == 'province'">'云南省' modify_city </if>
		<if test="sumType == 'city'">modify_city modify_city </if>
		<if test="sumType == 'area'">modify_county modify_city </if>
		  	,count(*) total_cnt,'act' type from c_trademark 
		where 1=1 and modify_city is not null and modify_city !=''  
		<if test="sumType == 'area'">and modify_county is not null and modify_county!=''</if> 
		<if test="sumType == 'city' and cityCode != '' and cityCode != 'null'  and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="sumType == 'area' and cityCode != '' and cityCode != 'null' and cityCode != 'all' ">and modify_city_code=#{cityCode}</if>
		and property_bgn_date is not null and property_bgn_date !=''   
		and property_end_date is not null and property_end_date !=''   
		and property_end_date>=#{endDate}
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
			</if>
		<if test="sumType == 'city'"> group by modify_city </if>
			<if test="sumType == 'area'">group by modify_county </if>
		) ff group by modify_city
	</select>
   -->
   
   <select id="listReportGrowth" resultType="map">
	  	select  modify_city 
		,sum(case when type='reg' then total_cnt else 0 end ) reg_total_cnt
		,sum(case when type='apl' then total_cnt else 0 end ) apl_total_cnt
		,sum(case when type='act' then total_cnt else 0 end ) act_total_cnt from (
		select 
		<if test="sumType == 'province'">'云南省' modify_city </if>
		<if test="sumType == 'city'">modify_city modify_city </if>
		<if test="sumType == 'area'">modify_county modify_city </if>
		 ,sum(total_cnt) total_cnt,'reg' type from c_trademark_reg  where 1=1 
	<if test="sumType == 'city' and cityCode != '' and cityCode != 'null' and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
	<if test="sumType == 'area' and cityCode != '' and cityCode != 'null'  and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
			</if>
			<if test="sumType == 'city'"> group by modify_city </if>
			<if test="sumType == 'area'">group by modify_county </if>
		union all 
		select  <if test="sumType == 'province'">'云南省' modify_city </if>
		<if test="sumType == 'city'">modify_city modify_city </if>
		<if test="sumType == 'area'">modify_county modify_city </if>
		  	,sum(total_cnt) total_cnt,'apl' type from c_trademark_apl  where  1=1 
		<if test="sumType == 'city' and cityCode != '' and cityCode != 'null' and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="sumType == 'area' and cityCode != '' and cityCode != 'null' and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and apl_date <![CDATA[>=]]>#{beginDate} and apl_date <![CDATA[<=]]>#{endDate}
			</if>
		<if test="sumType == 'city'"> group by modify_city </if>
		<if test="sumType == 'area'">group by modify_county </if>
		union all 
		select  <if test="sumType == 'province'">'云南省' modify_city </if>
		<if test="sumType == 'city'">modify_city modify_city </if>
		<if test="sumType == 'area'">modify_county modify_city </if>
		  	,sum(total_cnt) total_cnt,'act' type from c_trademark_act 
		where 1=1 
		<if test="sumType == 'city' and cityCode != '' and cityCode != 'null'  and cityCode != 'all'">and modify_city_code=#{cityCode}</if>
		<if test="sumType == 'area' and cityCode != '' and cityCode != 'null' and cityCode != 'all' ">and modify_city_code=#{cityCode}</if>
		and property_end_date>=#{endDate}
		<if test="endDate != null  and endDate != ''">
				and reg_date <![CDATA[<=]]>#{endDate}
			</if>
		<if test="sumType == 'city'"> group by modify_city </if>
			<if test="sumType == 'area'">group by modify_county </if>
		) ff group by modify_city
	</select>
	
	
	
	<select id="listReportNc" resultType="map">
    	<if test="ncType != null  and ncType == 'reg'">
	    	select nc,sum(total_cnt) total_cnt from c_trademark_reg_nc  where 1=1
		  	<if test="cityCode != null  and cityCode != ''">
		  		and modify_city_code = #{cityCode}
		  	</if>
			<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
			</if>
			group by nc
    	</if>
    	<if test="ncType != null  and ncType == 'apl'">
   	 	select nc,sum(total_cnt) total_cnt from c_trademark_apl_nc  where 1=1 
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
			and apl_date <![CDATA[>=]]>#{beginDate} and apl_date <![CDATA[<=]]>#{endDate}
		</if>
		group by nc
    </if>
    
    <if test="ncType != null  and ncType == 'act'">
    	select nc,sum(total_cnt) total_cnt from c_trademark_act_nc  where 1=1 
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if>
		<if test="endDate != null  and endDate != ''">
			and property_end_date>=#{endDate}
		</if>
		<if test="endDate != null  and endDate != ''">
			 and reg_date <![CDATA[<=]]>#{endDate}
		  </if>
		group by nc
    </if>
	</select>
	
	 <!-- 
	 <select id="listReportNc" resultType="map">
    	<if test="ncType != null  and ncType == 'reg'">
	    	select nc,sum(total_cnt) total_cnt from c_trademark_reg_nc  where 1=1
		  	<if test="cityCode != null  and cityCode != ''">
		  		and modify_city_code = #{cityCode}
		  	</if>
			<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
				and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
			</if>
			group by nc
    	</if>
    	<if test="ncType != null  and ncType == 'apl'">
   	 	select nc,sum(total_cnt) total_cnt from c_trademark_apl_nc  where 1=1 
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
			and apl_date <![CDATA[>=]]>#{beginDate} and apl_date <![CDATA[<=]]>#{endDate}
		</if>
		group by nc
    </if>
    
    <if test="ncType != null  and ncType == 'act'">
    	select nc,sum(total_cnt) total_cnt from c_trademark_act_nc  where 1=1 
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if>
		<if test="endDate != null  and endDate != ''">
			and property_end_date>=#{endDate}
		</if>
		<if test="endDate != null  and endDate != ''">
			 and reg_date <![CDATA[<=]]>#{endDate}
		  </if>
		group by nc
    </if>
	</select>
	 -->
  
	<!-- 
	  <select id="listReportHouse" resultType="map">
	  	select <if test="cityCode != null  and cityCode != ''">
		  		modify_county modify_city
		  	</if>
		  	<if test="cityCode == null  or cityCode == ''">
		  		modify_city
		  	</if> 
		,sum(case  when (property_bgn_date<![CDATA[<=]]>#{currDate} and property_end_date>=#{currDate})  then 1 else 0 end ) total_cnt   
		from c_trademark 
		where 1=1 
		<if test="cityCode != null  and cityCode != ''">
	  		and modify_county is not null and modify_county !=''  
	  	</if>
	  	<if test="cityCode == null  or cityCode == ''">
	  		and modify_city is not null and modify_city !=''  
	  	</if>
	  	
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if>
		
		and reg_year is not null and reg_year !=''  
		<if test="queryDate != null  and queryDate != ''">
			and reg_date <![CDATA[<=]]>#{queryDate}
		</if>  
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
			and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		group by <if test="cityCode != null  and cityCode != ''">
		  		modify_county
		  	</if>
		  	<if test="cityCode == null  or cityCode == ''">
		  		modify_city
		  	</if> 
	  </select>
   
   
   <select id="listReportHouse" resultType="map">
	select <if test="cityCode != null  and cityCode != ''"> modify_county modify_city </if> <if test="cityCode == null  or cityCode == ''"> modify_city </if> 
		,sum(total_cnt) total_cnt  from c_trademark_act   where 1=1 
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if>
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
			and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		group by <if test="cityCode != null  and cityCode != ''"> modify_county </if> <if test="cityCode == null  or cityCode == ''"> modify_city </if> 
	  </select>-->
	  
	   <select id="listReportHouse" resultType="map">
	select <if test="cityCode != null  and cityCode != ''"> modify_county modify_city,modify_county_code modify_city_code </if> 
	<if test="cityCode == null  or cityCode == ''"> modify_city,modify_city_code </if> 
		,sum(total_cnt) total_cnt  from c_trademark_act   where 1=1 
	  	<if test="cityCode != null  and cityCode != ''">
	  		and modify_city_code = #{cityCode}
	  	</if> and property_end_date>=#{endDate}  and reg_date <![CDATA[<=]]>#{endDate}
	  	<!-- 
		<if test="beginDate != null  and beginDate != '' and endDate != null  and endDate != ''">
			and reg_date <![CDATA[>=]]>#{beginDate} and reg_date <![CDATA[<=]]>#{endDate}
		</if>
		 -->
		group by <if test="cityCode != null  and cityCode != ''"> modify_county,modify_county_code </if> 
		<if test="cityCode == null  or cityCode == ''"> modify_city,modify_city_code </if> 
	  </select>
	  
</mapper>



