Commit f69ca760 by Water Wang

add dashboard practitioner statistics querey

parent a633d8f4
......@@ -120,6 +120,32 @@ public class AgmsDashboardServiceImpl implements AgmsDashboardService {
@Override
public StatisticsPractitionerResponseVO statisticsPractitioner(StatisticsPractitionerRequestVO requestVO) {
return null;
StatisticsPractitionerResponseVO responseVO = new StatisticsPractitionerResponseVO();
String type = requestVO.getType();
type = Strings.isNullOrEmpty(type) ? "b" : type;
List<StatisticsPractitionerInfo> statisticsPractitionerInfos = agmsDashboardDALService.statisticsPractitioner(type);
//获取实动率
getRealRate(statisticsPractitionerInfos);
responseVO.setStatisticsPractitionerInfos(statisticsPractitionerInfos);
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
return responseVO;
}
/**
* 获取实动率
* @param statisticsPractitionerInfos
*/
private void getRealRate(List<StatisticsPractitionerInfo> statisticsPractitionerInfos) {
if(statisticsPractitionerInfos != null && statisticsPractitionerInfos.size() > 0){
Integer realAmount,amount;
for(StatisticsPractitionerInfo item : statisticsPractitionerInfos){
realAmount = item.getRealAmount();
amount = item.getAmount();
if(amount > 0){
item.setRealRate(BigDecimal.valueOf((realAmount.doubleValue() / amount.doubleValue()) * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
}
}
}
......@@ -2,10 +2,20 @@ package com.yd.api.agms.vo.dashboard;
public class StatisticsPractitionerInfo {
private String typeName;
private Long typeId;
private Integer amount;
private Integer realAmount;
private Double realRate;
private Integer mdrt;
public Long getTypeId() {
return typeId;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public String getTypeName() {
return typeName;
}
......@@ -22,6 +32,14 @@ public class StatisticsPractitionerInfo {
this.amount = amount;
}
public Integer getRealAmount() {
return realAmount;
}
public void setRealAmount(Integer realAmount) {
this.realAmount = realAmount;
}
public Double getRealRate() {
return realRate;
}
......
package com.yd.dal.mapper.agms;
import com.yd.api.agms.vo.dashboard.StatisticsPractitionerInfo;
import com.yd.api.agms.vo.dashboard.StatisticsSalesInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsPEPInfo;
......@@ -14,4 +15,7 @@ public interface AgmsDashboardMapper {
List<StatisticsOpportunityInfo> statisticsOpportunity(@Param("type")String type,@Param("time") String time, @Param("dropOptionId") Long dropOptionId);
List<StatisticsSalesInfo> statisticsSales(@Param("type")String type, @Param("time")String time);
List<StatisticsPractitionerInfo> statisticsPractitioner(@Param("type")String type);
}
package com.yd.dal.service.agms;
import com.yd.api.agms.vo.dashboard.StatisticsPractitionerInfo;
import com.yd.api.agms.vo.dashboard.StatisticsSalesInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsPEPInfo;
......@@ -12,4 +13,6 @@ public interface AgmsDashboardDALService {
List<StatisticsOpportunityInfo> statisticsOpportunity(String type,String time, Long id);
List<StatisticsSalesInfo> statisticsSales(String type, String time);
List<StatisticsPractitionerInfo> statisticsPractitioner(String type);
}
package com.yd.dal.service.agms.impl;
import com.yd.api.agms.vo.dashboard.StatisticsPractitionerInfo;
import com.yd.api.agms.vo.dashboard.StatisticsSalesInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsPEPInfo;
......@@ -30,4 +31,9 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
public List<StatisticsSalesInfo> statisticsSales(String type, String time) {
return agmsDashboardMapper.statisticsSales(type,time);
}
@Override
public List<StatisticsPractitionerInfo> statisticsPractitioner(String type) {
return agmsDashboardMapper.statisticsPractitioner(type);
}
}
......@@ -143,4 +143,54 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc;
</select>
<select id="statisticsPractitioner" resultType="com.yd.api.agms.vo.dashboard.StatisticsPractitionerInfo">
<choose>
<when test="type.equalsIgnoreCase('B')">
select
ib.branch_name as typeName,
ib.id as typeId,
ifnull(count(p.id),0) as amount,
ifnull(a.real_count,0) as realAmount,
ifnull(b.mdrt_count,0) as mdrt
from ag_acl_practitioner p left join
(
select p.insurer_branch_id insurer_branch_id,count(distinct f.customer_id) as real_count
from ag_acl_customer_fortune f inner join ag_po_order o on f.order_id = o.id and o.status = 3 and f.grade_commission_rate != 5
inner join ag_acl_practitioner p on f.customer_id = p.customer_id
group by p.insurer_branch_id
)a on a.insurer_branch_id = p.insurer_branch_id
left join
(
select t.insurer_branch_id,count(t.id) as mdrt_count from ag_acl_practitioner t where t.cert_list is not null and t.cert_list like "%1%" group by t.insurer_branch_id
)b on b.insurer_branch_id = p.insurer_branch_id
left join ag_acl_insurer_branch ib on ib.id = p.insurer_branch_id
where p.is_active = 1
and p.insurer_branch_id is not null
group by p.insurer_branch_id order by amount desc ;
</when>
<otherwise>
select
s.id as typeId,
s.name as typeName,
ifnull(count(p.id),0) as amount,
ifnull(a.real_count,0) as realAmount,
ifnull(b.mdrt_count,0) as mdrt
from ag_acl_practitioner p left join
(
select p.subordinate_system_id subordinate_system_id,count(distinct f.customer_id) as real_count
from ag_acl_customer_fortune f inner join ag_po_order o on f.order_id = o.id and o.status = 3 and f.grade_commission_rate != 5
inner join ag_acl_practitioner p on f.customer_id = p.customer_id
group by p.subordinate_system_id
)a on a.subordinate_system_id = p.subordinate_system_id
left join
(
select t.subordinate_system_id,count(t.id) as mdrt_count from ag_acl_practitioner t where t.cert_list is not null and t.cert_list like "%1%" group by t.subordinate_system_id
)b on b.subordinate_system_id = p.subordinate_system_id
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id
where p.is_active = 1
and p.subordinate_system_id is not null
group by p.subordinate_system_id order by amount desc ;
</otherwise>
</choose>
</select>
</mapper>
\ No newline at end of file
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