Commit 7402a45b by yao.xiao

增加-AGMS中Dashboard商机预测列表

parent 90cc4e19
......@@ -5,6 +5,8 @@ import lombok.Data;
@Data
public class StatisticsOpportunityInfo {
private String branchName;
private String subordinateName;
private Long opportunityNum;
private Double predictFYC;
private Double predictFYP;
private Long pieces;
......
......@@ -33,29 +33,35 @@
</select>
<select id="statisticsOpportunity" resultType="com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo">
select b.branch_name branchName,
select if(b.branch_name is null,'暂无公司',b.branch_name) branchName,
if(s.name is null ,'暂无团队',s.name) subordinateName,
<choose>
<when test="time.equalsIgnoreCase('D')">
count(case when to_days(a.created_at)=to_days(now()) then a.id else 0 end) opportunityNum,
sum(case when to_days(a.time_to_close)=to_days(now()) then a.FYP else 0 end) predictFYP,
sum(case when to_days(a.time_to_close)=to_days(now()) then a.FYC else 0 end) predictFYC,
sum(case when to_days(a.time_to_close)=to_days(now()) then a.pieces else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('W')">
count(case when YEARWEEK(date_format(a.created_at, '%Y-%m-%d'))=YEARWEEK(now()) then a.id else 0 end) opportunityNum,
sum(case when YEARWEEK(date_format(a.time_to_close, '%Y-%m-%d')) = YEARWEEK(now()) then a.FYP else 0 end) predictFYP,
sum(case when YEARWEEK(date_format(a.time_to_close, '%Y-%m-%d')) = YEARWEEK(now()) then a.FYC else 0 end) predictFYC,
sum(case when YEARWEEK(date_format(a.time_to_close, '%Y-%m-%d')) = YEARWEEK(now()) then a.pieces else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('M')">
count(case when date_format(a.created_at, '%Y-%m') = date_format(now(), '%Y-%m') then a.id else 0 end) opportunityNum,
sum(case when date_format(a.time_to_close, '%Y-%m') = date_format(now(), '%Y-%m') then a.FYP else 0 end) predictFYP,
sum(case when date_format(a.time_to_close, '%Y-%m') = date_format(now(), '%Y-%m') then a.FYC else 0 end) predictFYC,
sum(case when date_format(a.time_to_close, '%Y-%m') = date_format(now(), '%Y-%m') then a.pieces else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('Q')">
count(case when QUARTER(a.created_at)=QUARTER(now()) then a.id else 0 end) opportunityNum,
sum(case when QUARTER(a.time_to_close) = QUARTER(now()) then a.FYP else 0 end) predictFYP,
sum(case when QUARTER(a.time_to_close) = QUARTER(now()) then a.FYC else 0 end) predictFYC,
sum(case when QUARTER(a.time_to_close) = QUARTER(now()) then a.pieces else 0 end) pieces
</when>
<when test="time.equalsIgnoreCase('Y')">
count(case when YEAR(a.created_at)=YEAR(now()) then a.id else 0 end) opportunityNum,
sum(case when YEAR(a.time_to_close) = YEAR(now()) then a.FYP else 0 end) predictFYP,
sum(case when YEAR(a.time_to_close) = YEAR(now()) then a.FYC else 0 end) predictFYC,
sum(case when YEAR(a.time_to_close) = YEAR(now()) then a.pieces else 0 end) pieces
......@@ -64,6 +70,7 @@ select b.branch_name branchName,
from ag_acl_practitioner p
left join ag_mkt_leads_assigneds a on p.id = a.assigned_practitioner_id
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
where not EXISTS(
select tt.leads_assigned_id
from ag_mkt_leads_assigned_track tt
......
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