top sql

<!-- *********************************jglist1 全部********************************************* -->
	
	<select id="searchSystemApplyListByOrg" parameterType="com.tanovo.model.SystemApply" resultMap="mapSystemApply">
		select a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
		from dj_system_apply a, dj_system_level l ,zk_test_org o 
		where a.sid=l.system_sid and a.org_sid=o.sid and a.`status`="通过"
		<if test="orgName != null and orgName != '' ">and o.name LIKE "%${orgName}%"</if>
		order by create_date
	</select>
	<select id="searchCountSystemApplyListByOrg" parameterType="com.tanovo.model.SystemApply" resultType="java.lang.Integer">
		select count(*)  
		from dj_system_apply a, dj_system_level l ,zk_test_org o 
		where a.sid=l.system_sid and a.org_sid=o.sid and a.`status`="通过"
		<if test="orgName != null and orgName != '' ">and o.name LIKE "%${orgName}%"</if> 
	</select>
	
	<!-- ********************************* jglist1 正常备案********************************************* -->
	
	<select id="searchSystemApplyListInDate" parameterType="com.tanovo.model.SystemApply" resultMap="mapSystemApply">
		
		SELECT w.* from 
			(select  ss.sid ,MAX(pp.report_date)  as report_date from  zk_system ss LEFT JOIN zk_project pp ON ss.sid=pp.system_sid  GROUP BY ss.sid) u   ,
 			(select s.sid as ssid, p.sag_level,p.report_date,a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
			from dj_system_apply a, dj_system_level l ,zk_test_org o ,zk_system s LEFT JOIN zk_project p ON s.sid=p.system_sid
			where a.sid=l.system_sid and a.org_sid=o.sid and a.record_no=s.record_no) w 
		WHERE u.sid=w.ssid AND u.report_date=w.report_date AND
			((w.sag_level="d02" AND YEAR(u.report_date)=YEAR(NOW()))OR 
			(w.sag_level="d03" AND u.report_date between date_sub(now(),interval 2 year) and now())) 
			<if test="orgName != null and orgName != '' ">AND w.orgName LIKE "%${orgName}%"</if>
			and w.`status`="通过"
		order by w.create_date DESC
	</select>
	<select id="searchCountSystemApplyListInDate" parameterType="com.tanovo.model.SystemApply" resultType="java.lang.Integer">
		SELECT count(*) from 
			(select  ss.sid ,MAX(pp.report_date)  as report_date from  zk_system ss LEFT JOIN zk_project pp ON ss.sid=pp.system_sid  GROUP BY ss.sid) u   ,
 			(select s.sid as ssid, p.sag_level,p.report_date,a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
			from dj_system_apply a, dj_system_level l ,zk_test_org o ,zk_system s LEFT JOIN zk_project p ON s.sid=p.system_sid
			where a.sid=l.system_sid and a.org_sid=o.sid and a.record_no=s.record_no) w 
		WHERE u.sid=w.ssid AND u.report_date=w.report_date AND
			((w.sag_level="d02" AND YEAR(u.report_date)=YEAR(NOW()))OR 
			(w.sag_level="d03" AND u.report_date between date_sub(now(),interval 2 year) and now())) 
			<if test="orgName != null and orgName != '' ">AND w.orgName LIKE "%${orgName}%"</if>
			and w.`status`="通过"
	</select>
	
	<!-- *********************************jglist1 备案已过期********************************************* -->
	
	<select id="searchSystemApplyListOverDate" parameterType="com.tanovo.model.SystemApply" resultMap="mapSystemApply">
		
		SELECT w.* from 
			(select  ss.sid ,MAX(pp.report_date)  as report_date from  zk_system ss LEFT JOIN zk_project pp ON ss.sid=pp.system_sid  GROUP BY ss.sid) u   ,
 			(select s.sid as ssid, p.sag_level,p.report_date,a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
			from dj_system_apply a, dj_system_level l ,zk_test_org o ,zk_system s LEFT JOIN zk_project p ON s.sid=p.system_sid
			where a.sid=l.system_sid and a.org_sid=o.sid and a.record_no=s.record_no) w 
		WHERE u.sid=w.ssid AND u.report_date=w.report_date AND
			((w.sag_level="d02" AND DATE_SUB(CURDATE(), INTERVAL 1 year) > date(u.report_date))OR 
			(w.sag_level="d03" AND DATE_SUB(CURDATE(), INTERVAL 2 year) > date(u.report_date)) ) 
			<if test="orgName != null and orgName != '' ">AND w.orgName LIKE "%${orgName}%"</if>
			and w.`status`="通过"
		order by w.create_date DESC
	</select>
	<select id="searchCountSystemApplyListOverDate" parameterType="com.tanovo.model.SystemApply" resultType="java.lang.Integer">
		SELECT count(*) from 
			(select  ss.sid ,MAX(pp.report_date)  as report_date from  zk_system ss LEFT JOIN zk_project pp ON ss.sid=pp.system_sid  GROUP BY ss.sid) u   ,
 			(select s.sid as ssid, p.sag_level,p.report_date,a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
			from dj_system_apply a, dj_system_level l ,zk_test_org o ,zk_system s LEFT JOIN zk_project p ON s.sid=p.system_sid
			where a.sid=l.system_sid and a.org_sid=o.sid and a.record_no=s.record_no) w 
		WHERE u.sid=w.ssid AND u.report_date=w.report_date AND
			((w.sag_level="d02" AND DATE_SUB(CURDATE(), INTERVAL 1 year) > date(u.report_date))OR 
			(w.sag_level="d03" AND DATE_SUB(CURDATE(), INTERVAL 2 year) > date(u.report_date)) ) 
			<if test="orgName != null and orgName != '' ">AND w.orgName LIKE "%${orgName}%"</if>
			and w.`status`="通过"
	</select>
	<!-- *********************************jglist1 已定级未备案********************************************* -->
	<select id="searchSystemApplyListNoRecord" parameterType="com.tanovo.model.SystemApply" resultMap="mapSystemApply">
		
		select a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
		from dj_system_apply a, dj_system_level l ,zk_test_org o 
		where a.sid=l.system_sid and a.org_sid=o.sid and( a.record_no='' or a.record_no is NULL or 0=(select count(*) from zk_system s where  a.record_no=s.record_no))
			<if test="orgName != null and orgName != '' ">AND o.name LIKE "%${orgName}%"</if>
			and a.`status`="通过"
		order by a.create_date DESC
	</select>
	<select id="searchCountSystemApplyListNoRecord" parameterType="com.tanovo.model.SystemApply" resultType="java.lang.Integer">
		SELECT count(*) from dj_system_apply a, dj_system_level l ,zk_test_org o 
		where a.sid=l.system_sid and a.org_sid=o.sid and( a.record_no='' or a.record_no is NULL or 0=(select count(*) from zk_system s where  a.record_no=s.record_no))
		and a.`status`="通过"
			<if test="orgName != null and orgName != '' ">AND o.name LIKE "%${orgName}%"</if>
	</select>
	<!-- *********************************jglist2 取每月申请数********************************************* -->
	<resultMap type="com.tanovo.model.SystemCount" id="mapSystemCount">
		<result property="year" column="year" />
		<result property="month" column="month" />
		<result property="num" column="num" />
		<result property="dateKey" column="date_key" />
	</resultMap>
	<select id="searchCountSystemEveryMonth" resultMap="mapSystemCount">
		select DATE_FORMAT(create_date,'%Y-%m') AS date_key,count(*) as num from dj_system_apply where `status`="通过" 
		GROUP BY DATE_FORMAT(create_date,'%Y-%m') ORDER BY  DATE_FORMAT(create_date,'%Y-%m') DESC  LIMIT 6
	</select>
	<!-- *********************************jglist2 取每年申请数********************************************* -->
	<select id="searchCountSystemEveryYear"  resultMap="mapSystemCount">
		select year(create_date) year,count(*) as num from dj_system_apply where `status`="通过"  GROUP BY year(create_date) ORDER BY year(create_date) desc 
	</select>
	<!-- ********************************* jglist2 正常备案********************************************* -->
	
	<select id="searchCountSystemInDateByCity" parameterType="java.lang.String"  resultType="java.lang.Integer">
		SELECT count(*) from 
			(select  ss.sid ,MAX(pp.report_date)  as report_date from  zk_system ss LEFT JOIN zk_project pp ON ss.sid=pp.system_sid  GROUP BY ss.sid) u   ,
 			(select s.sid as ssid, p.sag_level,p.report_date,a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
			from dj_system_apply a, dj_system_level l ,zk_test_org o ,zk_system s LEFT JOIN zk_project p ON s.sid=p.system_sid
			where a.sid=l.system_sid and a.org_sid=o.sid and a.record_no=s.record_no and o.city =#{city}) w 
		WHERE u.sid=w.ssid AND u.report_date=w.report_date AND
			((w.sag_level="d02" AND YEAR(u.report_date)=YEAR(NOW()))OR 
			(w.sag_level="d03" AND u.report_date between date_sub(now(),interval 2 year) and now())) 
			and w.`status`="通过"
	</select>
	
	<!-- *********************************jglist1 备案已过期********************************************* -->
	
	<select id="searchCountSystemOverDateByCity" parameterType="java.lang.String" resultType="java.lang.Integer">
		SELECT count(*) from 
			(select  ss.sid ,MAX(pp.report_date)  as report_date from  zk_system ss LEFT JOIN zk_project pp ON ss.sid=pp.system_sid  GROUP BY ss.sid) u   ,
 			(select s.sid as ssid, p.sag_level,p.report_date,a.sid,o.name as orgName,a.name, IFNULL(a.`status`,"") as status ,l.g as level ,o.linkman,o.phone,a.create_date,a.record_no  
			from dj_system_apply a, dj_system_level l ,zk_test_org o ,zk_system s LEFT JOIN zk_project p ON s.sid=p.system_sid
			where a.sid=l.system_sid and a.org_sid=o.sid and a.record_no=s.record_no and o.city =#{city}) w 
		WHERE u.sid=w.ssid AND u.report_date=w.report_date AND
			((w.sag_level="d02" AND DATE_SUB(CURDATE(), INTERVAL 1 year) > date(u.report_date))OR 
			(w.sag_level="d03" AND DATE_SUB(CURDATE(), INTERVAL 2 year) > date(u.report_date)) ) 
			and w.`status`="通过"
	</select>
	<!-- *********************************jglist1 已定级未备案********************************************* -->
	<select id="searchCountSystemNoRecordByCity" parameterType="java.lang.String" resultType="java.lang.Integer">
		SELECT count(*) from dj_system_apply a, dj_system_level l ,zk_test_org o 
		where a.sid=l.system_sid and a.org_sid=o.sid and( a.record_no='' or a.record_no is NULL or 0=(select count(*) from zk_system s where  a.record_no=s.record_no))
		and a.`status`="通过" and o.city =#{city}
	</select>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值