Commit 60b4483b by jianan

dashboard-13

parent 16393a09
...@@ -26,10 +26,16 @@ public interface AgmsDashboardMapper { ...@@ -26,10 +26,16 @@ public interface AgmsDashboardMapper {
List<PersonalOffLineFYC> personalOffLineFYC(List<String> mobileNoList); List<PersonalOffLineFYC> personalOffLineFYC(List<String> mobileNoList);
List<Map<String, String>> queryTeamAllMap(); List<Map<String, Object>> queryTeamAllMap();
List<StatisticsSalesInfo> statisticsSalesTeam(@Param("category")String category, List<StatisticsSalesInfo> statisticsSalesTeam(@Param("category")String category,
@Param("time")String time, @Param("list")List<Map<String, String>> teamMapList); @Param("time")String time, @Param("list")List<Map<String, Object>> teamMapList);
List<StatisticsPractitionerInfo> statisticsPractitionerTeam(@Param("time")String time, @Param("list")List<Map<String, String>> teamMapList); List<StatisticsPractitionerInfo> statisticsPractitionerTeam(@Param("time")String time, @Param("list")List<Map<String, Object>> teamMapList);
List<StatisticsPEPInfo> statisticsPEPTeam(@Param("type")String type, @Param("dropOptionId")Long dropOptionId,
@Param("list")List<Map<String, Object>> teamMapList);
List<StatisticsOpportunityInfo> statisticsOpportunityTeam(@Param("type")String type, @Param("time")String time,
@Param("dropOptionId")Long dropOptionId, @Param("list")List<Map<String, Object>> teamMapList);
} }
...@@ -34,5 +34,5 @@ public interface AgmsDashboardDALService { ...@@ -34,5 +34,5 @@ public interface AgmsDashboardDALService {
*/ */
List<Achieve> queryN22FYC(Integer time, Integer isPersonal, String loginName); List<Achieve> queryN22FYC(Integer time, Integer isPersonal, String loginName);
List<Map<String, String>> queryTeamAllMap(); List<Map<String, Object>> queryTeamAllMap();
} }
...@@ -14,11 +14,13 @@ import com.yd.rmi.n22.salary.service.N22SalaryService; ...@@ -14,11 +14,13 @@ import com.yd.rmi.n22.salary.service.N22SalaryService;
import com.yd.util.CommonUtil; import com.yd.util.CommonUtil;
import com.yd.util.intercept.annotation.TargetDataSource; import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey; import com.yd.util.intercept.commons.DataSourceKey;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -33,15 +35,34 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -33,15 +35,34 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
private AgmsDashboardMapper agmsDashboardMapper; private AgmsDashboardMapper agmsDashboardMapper;
@Autowired @Autowired
private N22SalaryService n22SalaryService; private N22SalaryService n22SalaryService;
@Autowired
private AgmsDashboardDALService agmsDashboardDALService;
@Override @Override
public List<StatisticsPEPInfo> statisticsPEP(String type,Long dropOptionId) { public List<StatisticsPEPInfo> statisticsPEP(String type,Long dropOptionId) {
//查询总分数
List<StatisticsPEPInfo> statisticsPEPInfos = agmsDashboardMapper.statisticsPEP(type, dropOptionId);
//查询寿险经纪人人数统计,按type分类 //查询寿险经纪人人数统计,按type分类
List<Map<String,Long>> practitionerNums = agmsDashboardMapper.getPractitionerNums(type); List<Map<String,Long>> practitionerNums = agmsDashboardMapper.getPractitionerNums(type);
ConcurrentMap<Long,Long> practitionerNumMap = new ConcurrentHashMap<>(); ConcurrentMap<Long,Long> practitionerNumMap = new ConcurrentHashMap<>();
practitionerNums.forEach(u->practitionerNumMap.put(u.get("id"),u.get("practitionerNum"))); practitionerNums.forEach(u->practitionerNumMap.put(u.get("id"),u.get("practitionerNum")));
//查询总分数
List<StatisticsPEPInfo> statisticsPEPInfos = new ArrayList<>();
if ("b".equalsIgnoreCase(type)) {
statisticsPEPInfos = agmsDashboardMapper.statisticsPEP(type, dropOptionId);
} else {
// 新体系
List<Map<String, Object>> teamMapList = agmsDashboardDALService.queryTeamAllMap();
statisticsPEPInfos = agmsDashboardMapper.statisticsPEPTeam(type, dropOptionId, teamMapList);
for (Map<String, Object> teamMap :teamMapList) {
String teamMember = (String) teamMap.get("teamMember");
if (StringUtils.isNotBlank(teamMember)) {
String[] strings = teamMember.split(",");
practitionerNumMap.put((Long) teamMap.get("id"), (long) strings.length);
}
}
}
for (StatisticsPEPInfo statisticsPEPInfo:statisticsPEPInfos) { for (StatisticsPEPInfo statisticsPEPInfo:statisticsPEPInfos) {
Long practitionerNum = 0L; Long practitionerNum = 0L;
if (type.equalsIgnoreCase("B")){ if (type.equalsIgnoreCase("B")){
...@@ -54,6 +75,9 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -54,6 +75,9 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
practitionerNum = practitionerNumMap.get(0L); practitionerNum = practitionerNumMap.get(0L);
statisticsPEPInfo.setPractitionerNum(practitionerNum); statisticsPEPInfo.setPractitionerNum(practitionerNum);
} }
if ("暂无公司".equals(statisticsPEPInfo.getBranchName())) {
continue;
}
Double scoreDay = BigDecimal.valueOf(statisticsPEPInfo.getScoreDay()) Double scoreDay = BigDecimal.valueOf(statisticsPEPInfo.getScoreDay())
.divide(BigDecimal.valueOf(practitionerNum),2,BigDecimal.ROUND_HALF_UP) .divide(BigDecimal.valueOf(practitionerNum),2,BigDecimal.ROUND_HALF_UP)
.doubleValue(); .doubleValue();
...@@ -84,10 +108,10 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -84,10 +108,10 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
.doubleValue(); .doubleValue();
statisticsPEPInfo.setScoreTotal(scoreTotal); statisticsPEPInfo.setScoreTotal(scoreTotal);
} }
Comparator<StatisticsPEPInfo> byDay = Comparator.comparing(StatisticsPEPInfo::getScoreDay).reversed(); Comparator<StatisticsPEPInfo> byDay = Comparator.comparing(StatisticsPEPInfo::getScoreDay, Comparator.nullsLast(Double::compareTo)).reversed();
Comparator<StatisticsPEPInfo> byWeek = Comparator.comparing(StatisticsPEPInfo::getScoreWeek).reversed(); Comparator<StatisticsPEPInfo> byWeek = Comparator.comparing(StatisticsPEPInfo::getScoreWeek, Comparator.nullsLast(Double::compareTo)).reversed();
Comparator<StatisticsPEPInfo> byMonth = Comparator.comparing(StatisticsPEPInfo::getScoreMonth).reversed(); Comparator<StatisticsPEPInfo> byMonth = Comparator.comparing(StatisticsPEPInfo::getScoreMonth, Comparator.nullsLast(Double::compareTo)).reversed();
Comparator<StatisticsPEPInfo> byQuarter = Comparator.comparing(StatisticsPEPInfo::getScoreQuarter).reversed(); Comparator<StatisticsPEPInfo> byQuarter = Comparator.comparing(StatisticsPEPInfo::getScoreQuarter, Comparator.nullsLast(Double::compareTo)).reversed();
Comparator<StatisticsPEPInfo> statisticsPEPInfoComparator = byDay.thenComparing(byWeek).thenComparing(byMonth).thenComparing(byQuarter); Comparator<StatisticsPEPInfo> statisticsPEPInfoComparator = byDay.thenComparing(byWeek).thenComparing(byMonth).thenComparing(byQuarter);
statisticsPEPInfos = statisticsPEPInfos.stream().sorted(statisticsPEPInfoComparator).collect(Collectors.toList()); statisticsPEPInfos = statisticsPEPInfos.stream().sorted(statisticsPEPInfoComparator).collect(Collectors.toList());
return statisticsPEPInfos; return statisticsPEPInfos;
...@@ -95,7 +119,13 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -95,7 +119,13 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
@Override @Override
public List<StatisticsOpportunityInfo> statisticsOpportunity(String type,String time, Long dropOptionId) { public List<StatisticsOpportunityInfo> statisticsOpportunity(String type,String time, Long dropOptionId) {
return agmsDashboardMapper.statisticsOpportunity(type , time, dropOptionId); if ("b".equalsIgnoreCase(type)) {
return agmsDashboardMapper.statisticsOpportunity(type, time, dropOptionId);
} else {
// 新体系
List<Map<String, Object>> teamMapList = agmsDashboardDALService.queryTeamAllMap();
return agmsDashboardMapper.statisticsOpportunityTeam(type, time, dropOptionId, teamMapList);
}
} }
@Override @Override
...@@ -104,8 +134,8 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -104,8 +134,8 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
if ("b".equalsIgnoreCase(type)) { if ("b".equalsIgnoreCase(type)) {
statisticsSalesInfos = agmsDashboardMapper.statisticsSalesYD(category, type,time); statisticsSalesInfos = agmsDashboardMapper.statisticsSalesYD(category, type,time);
} else { } else {
List<Map<String, String>> teamMapList = this.queryTeamAllMap(); List<Map<String, Object>> teamMapList = this.queryTeamAllMap();
System.out.println(teamMapList);
statisticsSalesInfos = agmsDashboardMapper.statisticsSalesTeam(category, time, teamMapList); statisticsSalesInfos = agmsDashboardMapper.statisticsSalesTeam(category, time, teamMapList);
} }
getUnitPremium(statisticsSalesInfos); getUnitPremium(statisticsSalesInfos);
...@@ -166,7 +196,7 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -166,7 +196,7 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
} }
@Override @Override
public List<Map<String, String>> queryTeamAllMap() { public List<Map<String, Object>> queryTeamAllMap() {
return agmsDashboardMapper.queryTeamAllMap(); return agmsDashboardMapper.queryTeamAllMap();
} }
...@@ -176,7 +206,7 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -176,7 +206,7 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
if ("b".equalsIgnoreCase(type)) { if ("b".equalsIgnoreCase(type)) {
statisticsPractitionerInfos = agmsDashboardMapper.statisticsPractitioner(type, time); statisticsPractitionerInfos = agmsDashboardMapper.statisticsPractitioner(type, time);
} else { } else {
List<Map<String, String>> teamMapList = this.queryTeamAllMap(); List<Map<String, Object>> teamMapList = this.queryTeamAllMap();
statisticsPractitionerInfos = agmsDashboardMapper.statisticsPractitionerTeam(time, teamMapList); statisticsPractitionerInfos = agmsDashboardMapper.statisticsPractitionerTeam(time, teamMapList);
} }
//计算实动率 //计算实动率
......
...@@ -35,7 +35,40 @@ ...@@ -35,7 +35,40 @@
group by p.subordinate_system_id group by p.subordinate_system_id
</when> </when>
</choose> </choose>
order by scoreDay desc ,scoreWeek desc ,scoreMonth desc; order by scoreDay desc ,scoreWeek desc ,scoreMonth desc
</select>
<select id="statisticsPEPTeam" resultType="com.yd.dal.entity.agms.dashboard.StatisticsPEPInfo">
<foreach collection="list" item="item" index="index" separator=" union all " >
<if test="item.teamMember != null">
select if(b.branch_name is null,'暂无公司',b.branch_name) branchName,
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,
#{item.id} as subordinateId,
sum(case when to_days(t.track_time)=to_days(now()) then t.track_score else 0 end) scoreDay,
sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d')) = YEARWEEK(now()) then t.track_score else 0 end) scoreWeek,
sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then t.track_score else 0 end) scoreMonth,
sum(case when QUARTER(t.track_time)=QUARTER(now()) then t.track_score else 0 end) scoreQuarter,
sum(case when YEAR(t.track_time)=YEAR(now()) then t.track_score else 0 end) scoreYear,
sum(case when t.track_score is not null then t.track_score else 0 end) scoreTotal
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_assigned_track t on t.leads_assigned_id = a.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
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 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)
and p.id in (#{item.teamMember})
</if>
</foreach>
order by scoreDay desc ,scoreWeek desc ,scoreMonth desc
</select> </select>
<select id="statisticsOpportunity" resultType="com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo"> <select id="statisticsOpportunity" resultType="com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo">
...@@ -96,7 +129,64 @@ ...@@ -96,7 +129,64 @@
group by p.subordinate_system_id group by p.subordinate_system_id
</when> </when>
</choose> </choose>
order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc; order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc
</select>
<select id="statisticsOpportunityTeam" resultType="com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo">
<foreach collection="list" item="item" index="index" separator=" union all " >
<if test="item.teamMember != null">
select if(b.branch_name is null,'暂无公司',b.branch_name) branchName,
(select name from ag_acl_practitioner_subordinate_system where id=#{item.id}) as subordinateName,
<choose>
<when test="time.equalsIgnoreCase('D')">
sum(case when to_days(a.created_at)=to_days(now()) then 1 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')">
sum(case when YEARWEEK(date_format(a.created_at, '%Y-%m-%d'))=YEARWEEK(now()) then 1 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')">
sum(case when date_format(a.created_at, '%Y-%m') = date_format(now(), '%Y-%m') then 1 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')">
sum(case when QUARTER(a.created_at)=QUARTER(now()) then 1 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')">
sum(case when YEAR(a.created_at)=YEAR(now()) then 1 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
</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 and b.is_active = 1
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id and s.is_active = 1
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 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)
and p.id in (#{item.teamMember})
</if>
</foreach>
order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc
</select> </select>
<select id="getPractitionerNums" resultType="java.util.Map"> <select id="getPractitionerNums" resultType="java.util.Map">
......
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