Commit 8c2c2eaa authored by huagnxiner's avatar huagnxiner

回访报表修改线上的sql

parent 24de9101
...@@ -3,18 +3,6 @@ ...@@ -3,18 +3,6 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.house365.ws.dao.mapper.StatisticReportMapper"> <mapper namespace="com.house365.ws.dao.mapper.StatisticReportMapper">
<!-- <select id="getStatisticSummary" resultType="java.util.HashMap">-->
<!-- <![CDATA[-->
<!-- SELECT (-->
<!-- SELECT FORMAT(count(distinct id),0) from customer as c where STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and (manager_id in ($managerId$))) as waitCount,-->
<!-- (SELECT FORMAT(count(distinct id),0) from customer as c where STATUS in(11,0,99) and (manager_id in ($managerId$))) as allCount,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0 and l.source = 1 and l.call_record_id is not null) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as callToday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=1 and l.source = 1 and l.call_record_id is not null) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as callYesterday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0 ) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as allCallToday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=1 ) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as allCallYesterday-->
<!-- ]]>-->
<!-- </select>-->
<select id="getStatisticSummary" resultType="java.util.HashMap"> <select id="getStatisticSummary" resultType="java.util.HashMap">
<![CDATA[ <![CDATA[
SELECT( SELECT(
......
...@@ -3,37 +3,25 @@ ...@@ -3,37 +3,25 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.house365.ws.dao.mapper.StatisticReportMapper"> <mapper namespace="com.house365.ws.dao.mapper.StatisticReportMapper">
<!-- <select id="getStatisticSummary" resultType="java.util.HashMap">-->
<!-- <![CDATA[-->
<!-- SELECT (-->
<!-- SELECT FORMAT(count(distinct id),0) from customer as c where STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and (manager_id in ($managerId$))) as waitCount,-->
<!-- (SELECT FORMAT(count(distinct id),0) from customer as c where STATUS in(11,0,99) and (manager_id in ($managerId$))) as allCount,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0 and l.source = 1 and l.call_record_id is not null) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as callToday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=1 and l.source = 1 and l.call_record_id is not null) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as callYesterday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0 ) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as allCallToday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=1 ) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as allCallYesterday-->
<!-- ]]>-->
<!-- </select>-->
<select id="getStatisticSummary" resultType="java.util.HashMap"> <select id="getStatisticSummary" resultType="java.util.HashMap">
<![CDATA[ <![CDATA[
SELECT( SELECT(
SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 AND c.STATUS in(11,0,99) and manager_id = #{managerId} SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 AND c.STATUS in(11,0,99) and manager_id = #{managerId}
and c.create_time>=#{startTime} and c.create_time<=#{endTime} and (c.isWaitCall=0 OR c.isWaitCall IS NULL)) as allCount, and c.bind_time>=#{startTime} and c.bind_time<=#{endTime} and (c.isWaitCall=0 OR c.isWaitCall IS NULL)) as allCount,
(SELECT FORMAT(count(id),0) from customer as c where c.STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and manager_id = #{managerId} (SELECT FORMAT(count(id),0) from customer as c where c.STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and manager_id = #{managerId}
and c.create_time>=#{startTime} and c.create_time<=#{endTime}) as waitCount, and c.bind_time>=#{startTime} and c.bind_time<=#{endTime}) as waitCount,
(SELECT FORMAT(count(id),0) FROM customer_merge c inner join (select customer_id,count((substr(ccl.manager_name,1,5)!='CRM用户' and ccl.manager_id!=0) or null) as count (SELECT FORMAT(count(id),0) FROM customer_merge c inner join (select customer_id,count((substr(ccl.manager_name,1,5)!='CRM用户' and ccl.manager_id!=0) or null) as count
from customer_callback_log ccl group by customer_id having count>0) n on c.id=n.customer_id where 1=1 from customer_callback_log ccl group by customer_id having count>0) n on c.id=n.customer_id where 1=1
and manager_id = #{managerId} and c.create_time>=#{startTime} and c.create_time<=#{endTime} and manager_id = #{managerId} and c.bind_time>=#{startTime} and c.bind_time<=#{endTime}
AND c.last_call_time is not null AND c.is_delete = 0 AND c.STATUS IN ( 11, 0, 99) AND c.last_call_time is not null AND c.is_delete = 0 AND c.STATUS IN ( 11, 0, 99)
AND ( c.isWaitCall = 0 OR c.isWaitCall IS NULL)) as callCount, AND ( c.isWaitCall = 0 OR c.isWaitCall IS NULL)) as callCount,
(SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 and manager_id = #{managerId} (SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 and manager_id = #{managerId}
and c.create_time>=#{startTime} and c.create_time<=#{endTime} and (c.isWaitCall = 0 OR c.isWaitCall IS NULL) and c.bind_time>=#{startTime} and c.bind_time<=#{endTime} and (c.isWaitCall = 0 OR c.isWaitCall IS NULL)
AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudSent, AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudSent,
(select FORMAT(count(id),0) FROM customer_merge c inner join (select m.customer_id from customer_callback_log m inner join (select FORMAT(count(id),0) FROM customer_merge c inner join (select m.customer_id from customer_callback_log m inner join
(select customer_id,count(*) as count from customer_callback_log group by customer_id) n (select customer_id,count(*) as count from customer_callback_log group by customer_id) n
on n.count=1 and m.customer_id=n.customer_id and m.manager_id=0) c2 on c.id=c2.customer_id on n.count=1 and m.customer_id=n.customer_id and m.manager_id=0) c2 on c.id=c2.customer_id
where 1=1 AND c.is_delete = 0 and manager_id = #{managerId} and c.create_time>=#{startTime} and c.create_time<=#{endTime} where 1=1 AND c.is_delete = 0 and manager_id = #{managerId} and c.bind_time>=#{startTime} and c.bind_time<=#{endTime}
AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudWait AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudWait
]]> ]]>
</select> </select>
......
...@@ -3,37 +3,25 @@ ...@@ -3,37 +3,25 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.house365.ws.dao.mapper.StatisticReportMapper"> <mapper namespace="com.house365.ws.dao.mapper.StatisticReportMapper">
<!-- <select id="getStatisticSummary" resultType="java.util.HashMap">-->
<!-- <![CDATA[-->
<!-- SELECT (-->
<!-- SELECT FORMAT(count(distinct id),0) from customer as c where STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and (manager_id in ($managerId$))) as waitCount,-->
<!-- (SELECT FORMAT(count(distinct id),0) from customer as c where STATUS in(11,0,99) and (manager_id in ($managerId$))) as allCount,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0 and l.source = 1 and l.call_record_id is not null) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as callToday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=1 and l.source = 1 and l.call_record_id is not null) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as callYesterday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0 ) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as allCallToday,-->
<!-- (select FORMAT(count(distinct id),0) from customer as c join ( SELECT l.customer_id FROM customer_callback_log l where TIMESTAMPDIFF(DAY,date_format(create_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=1 ) d on c.id=d.customer_id and c.is_delete = 0 and (c.manager_id in ($managerId$))) as allCallYesterday-->
<!-- ]]>-->
<!-- </select>-->
<select id="getStatisticSummary" resultType="java.util.HashMap"> <select id="getStatisticSummary" resultType="java.util.HashMap">
<![CDATA[ <![CDATA[
SELECT( SELECT(
SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 AND c.STATUS in(11,0,99) and manager_id = #{managerId} SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 AND c.STATUS in(11,0,99) and manager_id = #{managerId}
and c.create_time>=#{startTime} and c.create_time<=#{endTime} and (c.isWaitCall=0 OR c.isWaitCall IS NULL)) as allCount, and c.bind_time>=#{startTime} and c.bind_time<=#{endTime} and (c.isWaitCall=0 OR c.isWaitCall IS NULL)) as allCount,
(SELECT FORMAT(count(id),0) from customer as c where c.STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and manager_id = #{managerId} (SELECT FORMAT(count(id),0) from customer as c where c.STATUS in(11,0,99) and isWaitCall = 1 and c.is_delete = 0 and manager_id = #{managerId}
and c.create_time>=#{startTime} and c.create_time<=#{endTime}) as waitCount, and c.bind_time>=#{startTime} and c.bind_time<=#{endTime}) as waitCount,
(SELECT FORMAT(count(id),0) FROM customer_merge c inner join (select customer_id,count((substr(ccl.manager_name,1,5)!='CRM用户' and ccl.manager_id!=0) or null) as count (SELECT FORMAT(count(id),0) FROM customer_merge c inner join (select customer_id,count((substr(ccl.manager_name,1,5)!='CRM用户' and ccl.manager_id!=0) or null) as count
from customer_callback_log ccl group by customer_id having count>0) n on c.id=n.customer_id where 1=1 from customer_callback_log ccl group by customer_id having count>0) n on c.id=n.customer_id where 1=1
and manager_id = #{managerId} and c.create_time>=#{startTime} and c.create_time<=#{endTime} and manager_id = #{managerId} and c.bind_time>=#{startTime} and c.bind_time<=#{endTime}
AND c.last_call_time is not null AND c.is_delete = 0 AND c.STATUS IN ( 11, 0, 99) AND c.last_call_time is not null AND c.is_delete = 0 AND c.STATUS IN ( 11, 0, 99)
AND ( c.isWaitCall = 0 OR c.isWaitCall IS NULL)) as callCount, AND ( c.isWaitCall = 0 OR c.isWaitCall IS NULL)) as callCount,
(SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 and manager_id = #{managerId} (SELECT FORMAT(count(id),0) from customer_merge as c where c.is_delete = 0 and manager_id = #{managerId}
and c.create_time>=#{startTime} and c.create_time<=#{endTime} and (c.isWaitCall = 0 OR c.isWaitCall IS NULL) and c.bind_time>=#{startTime} and c.bind_time<=#{endTime} and (c.isWaitCall = 0 OR c.isWaitCall IS NULL)
AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudSent, AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudSent,
(select FORMAT(count(id),0) FROM customer_merge c inner join (select m.customer_id from customer_callback_log m inner join (select FORMAT(count(id),0) FROM customer_merge c inner join (select m.customer_id from customer_callback_log m inner join
(select customer_id,count(*) as count from customer_callback_log group by customer_id) n (select customer_id,count(*) as count from customer_callback_log group by customer_id) n
on n.count=1 and m.customer_id=n.customer_id and m.manager_id=0) c2 on c.id=c2.customer_id on n.count=1 and m.customer_id=n.customer_id and m.manager_id=0) c2 on c.id=c2.customer_id
where 1=1 AND c.is_delete = 0 and manager_id = #{managerId} and c.create_time>=#{startTime} and c.create_time<=#{endTime} where 1=1 AND c.is_delete = 0 and manager_id = #{managerId} and c.bind_time>=#{startTime} and c.bind_time<=#{endTime}
AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudWait AND c.STATUS IN ( 11, 0, 99 ) and c.customer_source_type=7) as cloudWait
]]> ]]>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment