Commit 0de6b3be by jianan

1.团队经纪人报聘,过滤“执业证”无效

2.团队PEP得分没有取到数据
3.寿险经纪人商机预测缺少上海营业部
parent 639a3160
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
if(p.insurer_branch_id is null,0,p.insurer_branch_id) branchId, if(p.insurer_branch_id is null,0,p.insurer_branch_id) branchId,
if(s.name is null ,'暂无团队',s.name) subordinateName, if(s.name is null ,'暂无团队',s.name) subordinateName,
if(p.subordinate_system_id is null ,0,p.subordinate_system_id) subordinateId, if(p.subordinate_system_id is null ,0,p.subordinate_system_id) subordinateId,
sum(case when to_days(t.track_time)=to_days(now()) then t.track_score else 0 end) scoreDay, ifnull(sum(case when to_days(t.track_time)=to_days(now()) then t.track_score else 0 end), 0) scoreDay,
sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d')) = YEARWEEK(now()) then t.track_score else 0 end) scoreWeek, ifnull(sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d')) = YEARWEEK(now()) then t.track_score else 0 end), 0) scoreWeek,
sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then t.track_score else 0 end) scoreMonth, ifnull(sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then t.track_score else 0 end), 0) scoreMonth,
sum(case when QUARTER(t.track_time)=QUARTER(now()) then t.track_score else 0 end) scoreQuarter, ifnull(sum(case when QUARTER(t.track_time)=QUARTER(now()) and YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end), 0) scoreQuarter,
sum(case when YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end) scoreYear, ifnull(sum(case when YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end), 0) scoreYear,
sum(case when t.track_score is not null then t.track_score else 0 end) scoreTotal ifnull(sum(case when t.track_score is not null then t.track_score else 0 end), 0) scoreTotal
from ag_acl_practitioner p from ag_acl_practitioner p
left join ag_mkt_leads_assigneds a on p.id = a.assigned_practitioner_id and a.is_active = 1 left join ag_mkt_leads_assigneds a on p.id = a.assigned_practitioner_id and a.is_active = 1
left join ag_mkt_leads_assigned_track t on t.leads_assigned_id = a.id left join ag_mkt_leads_assigned_track t on t.leads_assigned_id = a.id
...@@ -45,12 +45,12 @@ ...@@ -45,12 +45,12 @@
if(p.insurer_branch_id is null,0,p.insurer_branch_id) branchId, if(p.insurer_branch_id is null,0,p.insurer_branch_id) branchId,
(select name from ag_acl_practitioner_subordinate_system where id=#{item.id}) as subordinateName, (select name from ag_acl_practitioner_subordinate_system where id=#{item.id}) as subordinateName,
#{item.id} as subordinateId, #{item.id} as subordinateId,
sum(case when to_days(t.track_time)=to_days(now()) then t.track_score else 0 end) scoreDay, ifnull(sum(case when to_days(t.track_time)=to_days(now()) then t.track_score else 0 end), 0) scoreDay,
sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d')) = YEARWEEK(now()) then t.track_score else 0 end) scoreWeek, ifnull(sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d')) = YEARWEEK(now()) then t.track_score else 0 end), 0) scoreWeek,
sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then t.track_score else 0 end) scoreMonth, ifnull(sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then t.track_score else 0 end), 0) scoreMonth,
sum(case when QUARTER(t.track_time)=QUARTER(now()) then t.track_score else 0 end) scoreQuarter, ifnull(sum(case when QUARTER(t.track_time)=QUARTER(now()) and YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end), 0) scoreQuarter,
sum(case when YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end) scoreYear, ifnull(sum(case when YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end), 0) scoreYear,
sum(case when t.track_score is not null then t.track_score else 0 end) scoreTotal ifnull(sum(case when t.track_score is not null then t.track_score else 0 end), 0) scoreTotal
from ag_acl_practitioner p from ag_acl_practitioner p
left join ag_mkt_leads_assigneds a on p.id = a.assigned_practitioner_id and a.is_active = 1 left join ag_mkt_leads_assigneds a on p.id = a.assigned_practitioner_id and a.is_active = 1
left join ag_mkt_leads_assigned_track t on t.leads_assigned_id = a.id left join ag_mkt_leads_assigned_track t on t.leads_assigned_id = a.id
...@@ -128,9 +128,64 @@ ...@@ -128,9 +128,64 @@
group by p.subordinate_system_id group by p.subordinate_system_id
</when> </when>
</choose> </choose>
<!-- 上海营业部 -->
union all
<include refid="shangHaiDept" />
order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc
</select> </select>
<sql id="shangHaiDept">
select '上海营业部' as branchName,
'' as subordinateName,
<choose>
<when test="time.equalsIgnoreCase('D')">
ifnull(sum(case when to_days(a.created_at)=to_days(now()) then 1 else 0 end), 0) opportunityNum,
ifnull(sum(case when to_days(a.time_to_close)=to_days(now()) then a.FYP else 0 end), 0) predictFYP,
ifnull(sum(case when to_days(a.time_to_close)=to_days(now()) then a.FYC else 0 end), 0) predictFYC,
ifnull(sum(case when to_days(a.time_to_close)=to_days(now()) then a.pieces else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('W')">
ifnull(sum(case when YEARWEEK(date_format(a.created_at, '%Y-%m-%d'))=YEARWEEK(now()) then 1 else 0 end), 0) opportunityNum,
ifnull(sum(case when YEARWEEK(date_format(a.time_to_close, '%Y-%m-%d')) = YEARWEEK(now()) then a.FYP else 0 end), 0) predictFYP,
ifnull(sum(case when YEARWEEK(date_format(a.time_to_close, '%Y-%m-%d')) = YEARWEEK(now()) then a.FYC else 0 end), 0) predictFYC,
ifnull(sum(case when YEARWEEK(date_format(a.time_to_close, '%Y-%m-%d')) = YEARWEEK(now()) then a.pieces else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('M')">
ifnull(sum(case when date_format(a.created_at, '%Y-%m') = date_format(now(), '%Y-%m') then 1 else 0 end), 0) opportunityNum,
ifnull(sum(case when date_format(a.time_to_close, '%Y-%m') = date_format(now(), '%Y-%m') then a.FYP else 0 end), 0) predictFYP,
ifnull(sum(case when date_format(a.time_to_close, '%Y-%m') = date_format(now(), '%Y-%m') then a.FYC else 0 end), 0) predictFYC,
ifnull(sum(case when date_format(a.time_to_close, '%Y-%m') = date_format(now(), '%Y-%m') then a.pieces else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('Q')">
ifnull(sum(case when QUARTER(a.created_at)=QUARTER(now()) then 1 else 0 end), 0) opportunityNum,
ifnull(sum(case when QUARTER(a.time_to_close) = QUARTER(now()) then a.FYP else 0 end), 0) predictFYP,
ifnull(sum(case when QUARTER(a.time_to_close) = QUARTER(now()) then a.FYC else 0 end), 0) predictFYC,
ifnull(sum(case when QUARTER(a.time_to_close) = QUARTER(now()) then a.pieces else 0 end), 0) pieces
</when>
<when test="time.equalsIgnoreCase('Y')">
ifnull(sum(case when YEAR(a.created_at)=YEAR(now()) then 1 else 0 end), 0) opportunityNum,
ifnull(sum(case when YEAR(a.time_to_close) = YEAR(now()) then a.FYP else 0 end), 0) predictFYP,
ifnull(sum(case when YEAR(a.time_to_close) = YEAR(now()) then a.FYC else 0 end), 0) predictFYC,
ifnull(sum(case when YEAR(a.time_to_close) = YEAR(now()) then a.pieces else 0 end), 0) pieces
</when>
</choose>
from ag_acl_practitioner p
left join ag_mkt_leads_assigneds a on p.id = a.assigned_practitioner_id and a.is_active = 1
left join ag_acl_insurer_branch b on b.id = p.insurer_branch_id
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id
left join ag_acl_practitioner_setting ps on ps.practitioner_id = p.id
where
ps.practitioner_type_id = 28
and p.is_active = 1
and p.dept_id = (SELECT id from ag_acl_insurer_branch_dept where insurer_id=888 and name='上海营业部')
and not EXISTS(
select tt.leads_assigned_id
from ag_mkt_leads_assigned_track tt
where tt.md_drop_option_id = #{dropOptionId,jdbcType=BIGINT}
and a.id = tt.leads_assigned_id
)
</sql>
<select id="statisticsOpportunityTeam" resultType="com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo"> <select id="statisticsOpportunityTeam" resultType="com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo">
<foreach collection="list" item="item" index="index" separator=" union all " > <foreach collection="list" item="item" index="index" separator=" union all " >
<if test="item.teamMember != null"> <if test="item.teamMember != null">
...@@ -354,7 +409,6 @@ ...@@ -354,7 +409,6 @@
ib.id AS typeId, ib.id AS typeId,
ifnull( count( p.id ), 0 ) AS amount, ifnull( count( p.id ), 0 ) AS amount,
ifnull( a.real_count, 0 ) AS realAmount, ifnull( a.real_count, 0 ) AS realAmount,
<include refid="statisticsPractitionerHiring"/> AS hiringAmount,
sum(case when p.cert_list LIKE "%1%" then 1 else 0 end) AS mdrt sum(case when p.cert_list LIKE "%1%" then 1 else 0 end) AS mdrt
FROM FROM
ag_acl_practitioner p ag_acl_practitioner p
...@@ -379,26 +433,19 @@ ...@@ -379,26 +433,19 @@
</select> </select>
<select id="statisticsPractitionerTeam" resultType="com.yd.api.agms.vo.dashboard.StatisticsPractitionerInfo"> <select id="statisticsPractitionerTeam" resultType="com.yd.api.agms.vo.dashboard.StatisticsPractitionerInfo">
<foreach collection="list" item="item" index="index" separator=" union all " > SELECT
<if test="item.teamMember != null"> p.subordinate_system_id as typeId,
SELECT (select name from ag_acl_practitioner_subordinate_system where id=p.subordinate_system_id) as typeName,
#{item.id} as typeId, ifnull(count( p.id ), 0 ) AS amount,
(select name from ag_acl_practitioner_subordinate_system where id=#{item.id}) as typeName,
ifnull( count( p.id ), 0 ) AS amount,
<include refid="realAmount"/> AS realAmount,
<include refid="statisticsPractitionerHiring"/> AS hiringAmount,
sum(case when p.cert_list LIKE "%1%" then 1 else 0 end) AS mdrt
FROM
ag_acl_practitioner p
left join ag_acl_practitioner_hiring_approve_records hr on hr.hiring_basic_info_id=p.hiring_basic_info_id
and hr.approve_step_id=5 and hr.approving_status=1
WHERE 1=1
and p.id in <foreach collection="item.teamMember" item="p_id" open="(" separator="," close=")">#{p_id,jdbcType=BIGINT}</foreach>
and p.is_active = 1
</if>
</foreach>
<include refid="realAmount"/> AS realAmount,
sum(case when p.cert_list LIKE "%1%" then 1 else 0 end) AS mdrt
FROM ag_acl_practitioner p
WHERE 1=1
and p.is_active = 1
and p.subordinate_system_id is not null
GROUP BY p.subordinate_system_id
ORDER BY amount DESC
</select> </select>
<sql id="realAmount"> <sql id="realAmount">
...@@ -407,10 +454,10 @@ ...@@ -407,10 +454,10 @@
FROM FROM
ag_acl_customer_fortune f ag_acl_customer_fortune f
left JOIN ag_po_order o ON f.order_id = o.id and o.STATUS = 3 AND o.payment_status = 3 left JOIN ag_po_order o ON f.order_id = o.id and o.STATUS = 3 AND o.payment_status = 3
left JOIN ag_acl_practitioner p ON p.id = f.sale_practitioner_id left JOIN ag_acl_practitioner p2 ON p2.id = f.sale_practitioner_id
WHERE 1=1 WHERE 1=1
and p.id in <foreach collection="item.teamMember" item="p_id" open="(" separator="," close=")">#{p_id,jdbcType=BIGINT}</foreach> and p2.subordinate_system_id = p.subordinate_system_id
and p.is_active = 1 and p2.is_active = 1
<choose> <choose>
<when test="time.equalsIgnoreCase('D')"> <when test="time.equalsIgnoreCase('D')">
and TO_DAYS(o.underwriting_date) = TO_DAYS(now()) and TO_DAYS(o.underwriting_date) = TO_DAYS(now())
...@@ -431,29 +478,6 @@ ...@@ -431,29 +478,6 @@
) )
</sql> </sql>
<sql id="statisticsPractitionerHiring">
sum(case
when
<choose>
<when test="time.equalsIgnoreCase('D')">
TO_DAYS(hr.created_at) = TO_DAYS(now())
</when>
<when test="time.equalsIgnoreCase('W')">
YEARWEEK(DATE_FORMAT(hr.created_at,'%Y-%m-%d')) = YEARWEEK(NOW())
</when>
<when test="time.equalsIgnoreCase('M')">
DATE_FORMAT(hr.created_at, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time.equalsIgnoreCase('Q')">
QUARTER(hr.created_at) = QUARTER(NOW()) AND year(hr.created_at)=year(now())
</when>
<otherwise>
YEAR(hr.created_at) = YEAR(now())
</otherwise>
</choose>
then 1 else 0 end)
</sql>
<select id="statisticsSalesEG" resultType="com.yd.api.agms.vo.dashboard.StatisticsSalesInfo"> <select id="statisticsSalesEG" resultType="com.yd.api.agms.vo.dashboard.StatisticsSalesInfo">
select select
<choose> <choose>
......
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