|
@@ -2,9 +2,36 @@
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.qmth.sop.business.mapper.CrmAnalyseMapper">
|
|
<mapper namespace="com.qmth.sop.business.mapper.CrmAnalyseMapper">
|
|
<select id="region" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
|
|
<select id="region" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
|
|
|
|
+ <!-- SELECT-->
|
|
|
|
+ <!-- r.id,-->
|
|
|
|
+ <!-- r.region_name,-->
|
|
|
|
+ <!-- count( c.id ) count-->
|
|
|
|
+ <!-- FROM-->
|
|
|
|
+ <!-- t_b_crm c-->
|
|
|
|
+ <!-- LEFT JOIN sys_custom cu ON cu.id = c.custom_id-->
|
|
|
|
+ <!-- LEFT JOIN t_b_service s ON c.service_id = s.id-->
|
|
|
|
+ <!-- left join t_b_service_region r on r.service_id=s.id-->
|
|
|
|
+ <!-- <where>-->
|
|
|
|
+ <!-- and s.`status`='PUBLISH' and c.service_id is not null and r.id is not null-->
|
|
|
|
+ <!-- <if test="type != null and type != ''">-->
|
|
|
|
+ <!-- and cu.type = #{type}-->
|
|
|
|
+ <!-- </if>-->
|
|
|
|
+ <!--<!– <if test="year != null and year != ''">–>-->
|
|
|
|
+ <!--<!– and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}–>-->
|
|
|
|
+ <!--<!– </if>–>-->
|
|
|
|
+ <!-- <if test="startTime != null">-->
|
|
|
|
+ <!-- AND s.start_time >= #{startTime}-->
|
|
|
|
+ <!-- </if>-->
|
|
|
|
+ <!-- <if test="endTime != null">-->
|
|
|
|
+ <!-- AND #{endTime} >= s.start_time-->
|
|
|
|
+ <!-- </if>-->
|
|
|
|
+ <!-- </where>-->
|
|
|
|
+ <!-- GROUP BY-->
|
|
|
|
+ <!-- r.id,-->
|
|
|
|
+ <!-- r.region_name-->
|
|
|
|
+ <!-- order by count( c.id )-->
|
|
SELECT
|
|
SELECT
|
|
- r.id,
|
|
|
|
- r.region_name,
|
|
|
|
|
|
+ cu.province name,
|
|
count( c.id ) count
|
|
count( c.id ) count
|
|
FROM
|
|
FROM
|
|
t_b_crm c
|
|
t_b_crm c
|
|
@@ -16,9 +43,9 @@
|
|
<if test="type != null and type != ''">
|
|
<if test="type != null and type != ''">
|
|
and cu.type = #{type}
|
|
and cu.type = #{type}
|
|
</if>
|
|
</if>
|
|
-<!-- <if test="year != null and year != ''">-->
|
|
|
|
-<!-- and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}-->
|
|
|
|
-<!-- </if>-->
|
|
|
|
|
|
+ <!-- <if test="year != null and year != ''">-->
|
|
|
|
+ <!-- and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}-->
|
|
|
|
+ <!-- </if>-->
|
|
<if test="startTime != null">
|
|
<if test="startTime != null">
|
|
AND s.start_time >= #{startTime}
|
|
AND s.start_time >= #{startTime}
|
|
</if>
|
|
</if>
|
|
@@ -27,15 +54,14 @@
|
|
</if>
|
|
</if>
|
|
</where>
|
|
</where>
|
|
GROUP BY
|
|
GROUP BY
|
|
- r.id,
|
|
|
|
- r.region_name
|
|
|
|
|
|
+ cu.province
|
|
order by count( c.id )
|
|
order by count( c.id )
|
|
</select>
|
|
</select>
|
|
<select id="project" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
|
|
<select id="project" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
|
|
SELECT
|
|
SELECT
|
|
s.id,
|
|
s.id,
|
|
s.`name`,
|
|
s.`name`,
|
|
- sum(case when c.`status`='FINISH' then 1 else 0 end)/count( c.id ) count
|
|
|
|
|
|
+ sum(case when c.`status`='FINISH' then 1 else 0 end)/count( c.id ) count
|
|
FROM
|
|
FROM
|
|
t_b_crm c
|
|
t_b_crm c
|
|
LEFT JOIN sys_custom cu ON cu.id = c.custom_id
|
|
LEFT JOIN sys_custom cu ON cu.id = c.custom_id
|
|
@@ -136,8 +162,8 @@
|
|
t_b_crm c
|
|
t_b_crm c
|
|
LEFT JOIN t_b_service s ON c.service_id = s.id
|
|
LEFT JOIN t_b_service s ON c.service_id = s.id
|
|
LEFT join sys_custom cu on cu.id=c.custom_id
|
|
LEFT join sys_custom cu on cu.id=c.custom_id
|
|
-<!-- WHERE-->
|
|
|
|
-<!-- YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}-->
|
|
|
|
|
|
+ <!-- WHERE-->
|
|
|
|
+ <!-- YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}-->
|
|
<where>
|
|
<where>
|
|
<!-- <if test="year != null and year != ''">-->
|
|
<!-- <if test="year != null and year != ''">-->
|
|
<!-- and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}-->
|
|
<!-- and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))= #{year}-->
|
|
@@ -203,10 +229,10 @@
|
|
AND #{endTime} >= tbs.start_time
|
|
AND #{endTime} >= tbs.start_time
|
|
</if>
|
|
</if>
|
|
<if test="crmYear != null and crmYear != ''">
|
|
<if test="crmYear != null and crmYear != ''">
|
|
- and YEAR ( FROM_UNIXTIME( a.begin_time / 1000 ))= #{crmYear}
|
|
|
|
|
|
+ and YEAR ( FROM_UNIXTIME( a.begin_time / 1000 ))= #{crmYear}
|
|
</if>
|
|
</if>
|
|
<if test="month != null and month != ''">
|
|
<if test="month != null and month != ''">
|
|
- and MONTH ( FROM_UNIXTIME( a.begin_time / 1000 ))= #{month}
|
|
|
|
|
|
+ and MONTH ( FROM_UNIXTIME( a.begin_time / 1000 ))= #{month}
|
|
</if>
|
|
</if>
|
|
</where>
|
|
</where>
|
|
|
|
|