Commit 10b70a35 by Water Wang

add life sales statistics

parent f69ca760
...@@ -97,21 +97,10 @@ public class AgmsDashboardServiceImpl implements AgmsDashboardService { ...@@ -97,21 +97,10 @@ public class AgmsDashboardServiceImpl implements AgmsDashboardService {
time = Strings.isNullOrEmpty(time) ? "m" : time; time = Strings.isNullOrEmpty(time) ? "m" : time;
type = Strings.isNullOrEmpty(type) ? "b" : type; type = Strings.isNullOrEmpty(type) ? "b" : type;
List<StatisticsSalesInfo> statisticsSalesInfos; List<StatisticsSalesInfo> statisticsSalesInfos;
if("life".equals(category)){ if("life".equals(category)){//寿险
statisticsSalesInfos = agmsDashboardDALService.statisticsSales(type,time); statisticsSalesInfos = agmsDashboardDALService.statisticsSalesEG(type,time);
}else{ }else{//产险
statisticsSalesInfos = agmsDashboardDALService.statisticsSales(type,time); statisticsSalesInfos = agmsDashboardDALService.statisticsSalesYD(type,time);
}
if(statisticsSalesInfos != null && statisticsSalesInfos.size() > 0){
Double fyp;
Integer pieces;
for(StatisticsSalesInfo item : statisticsSalesInfos){
fyp = item.getFyp();
pieces = item.getPieces();
if(pieces != null && pieces != 0){
item.setUnitPremium(BigDecimal.valueOf(fyp / pieces).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
} }
responseVO.setStatisticsSalesInfos(statisticsSalesInfos); responseVO.setStatisticsSalesInfos(statisticsSalesInfos);
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
...@@ -124,28 +113,10 @@ public class AgmsDashboardServiceImpl implements AgmsDashboardService { ...@@ -124,28 +113,10 @@ public class AgmsDashboardServiceImpl implements AgmsDashboardService {
String type = requestVO.getType(); String type = requestVO.getType();
type = Strings.isNullOrEmpty(type) ? "b" : type; type = Strings.isNullOrEmpty(type) ? "b" : type;
List<StatisticsPractitionerInfo> statisticsPractitionerInfos = agmsDashboardDALService.statisticsPractitioner(type); List<StatisticsPractitionerInfo> statisticsPractitionerInfos = agmsDashboardDALService.statisticsPractitioner(type);
//获取实动率
getRealRate(statisticsPractitionerInfos);
responseVO.setStatisticsPractitionerInfos(statisticsPractitionerInfos); responseVO.setStatisticsPractitionerInfos(statisticsPractitionerInfos);
responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true,ZHBErrorConfig.getErrorInfo("800000")));
return responseVO; 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,11 +2,11 @@ package com.yd.api.agms.vo.dashboard; ...@@ -2,11 +2,11 @@ package com.yd.api.agms.vo.dashboard;
public class StatisticsSalesInfo { public class StatisticsSalesInfo {
private String typeName; private String typeName;
private Double fyp; private String fyp;
private Double fyc; private String fyc;
private Double api; private Double api;
private Integer pieces; private Integer pieces;
private Double unitPremium; private String unitPremium;
public String getTypeName() { public String getTypeName() {
return typeName; return typeName;
...@@ -16,19 +16,19 @@ public class StatisticsSalesInfo { ...@@ -16,19 +16,19 @@ public class StatisticsSalesInfo {
this.typeName = typeName; this.typeName = typeName;
} }
public Double getFyp() { public String getFyp() {
return fyp; return fyp;
} }
public void setFyp(Double fyp) { public void setFyp(String fyp) {
this.fyp = fyp; this.fyp = fyp;
} }
public Double getFyc() { public String getFyc() {
return fyc; return fyc;
} }
public void setFyc(Double fyc) { public void setFyc(String fyc) {
this.fyc = fyc; this.fyc = fyc;
} }
...@@ -48,11 +48,11 @@ public class StatisticsSalesInfo { ...@@ -48,11 +48,11 @@ public class StatisticsSalesInfo {
this.pieces = pieces; this.pieces = pieces;
} }
public Double getUnitPremium() { public String getUnitPremium() {
return unitPremium; return unitPremium;
} }
public void setUnitPremium(Double unitPremium) { public void setUnitPremium(String unitPremium) {
this.unitPremium = unitPremium; this.unitPremium = unitPremium;
} }
} }
...@@ -14,8 +14,9 @@ public interface AgmsDashboardMapper { ...@@ -14,8 +14,9 @@ public interface AgmsDashboardMapper {
List<StatisticsOpportunityInfo> statisticsOpportunity(@Param("type")String type,@Param("time") String time, @Param("dropOptionId") Long dropOptionId); 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<StatisticsSalesInfo> statisticsSalesYD(@Param("type")String type, @Param("time")String time);
List<StatisticsPractitionerInfo> statisticsPractitioner(@Param("type")String type); List<StatisticsPractitionerInfo> statisticsPractitioner(@Param("type")String type);
List<StatisticsSalesInfo> statisticsSalesEG(@Param("type")String type, @Param("time")String time);
} }
...@@ -12,7 +12,9 @@ public interface AgmsDashboardDALService { ...@@ -12,7 +12,9 @@ public interface AgmsDashboardDALService {
List<StatisticsOpportunityInfo> statisticsOpportunity(String type,String time, Long id); List<StatisticsOpportunityInfo> statisticsOpportunity(String type,String time, Long id);
List<StatisticsSalesInfo> statisticsSales(String type, String time); List<StatisticsSalesInfo> statisticsSalesYD(String type, String time);
List<StatisticsPractitionerInfo> statisticsPractitioner(String type); List<StatisticsPractitionerInfo> statisticsPractitioner(String type);
List<StatisticsSalesInfo> statisticsSalesEG(String type, String time);
} }
...@@ -6,9 +6,12 @@ import com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo; ...@@ -6,9 +6,12 @@ import com.yd.dal.entity.agms.dashboard.StatisticsOpportunityInfo;
import com.yd.dal.entity.agms.dashboard.StatisticsPEPInfo; import com.yd.dal.entity.agms.dashboard.StatisticsPEPInfo;
import com.yd.dal.mapper.agms.AgmsDashboardMapper; import com.yd.dal.mapper.agms.AgmsDashboardMapper;
import com.yd.dal.service.agms.AgmsDashboardDALService; import com.yd.dal.service.agms.AgmsDashboardDALService;
import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Service("agmsDashboardDALService") @Service("agmsDashboardDALService")
...@@ -28,12 +31,52 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService { ...@@ -28,12 +31,52 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
} }
@Override @Override
public List<StatisticsSalesInfo> statisticsSales(String type, String time) { public List<StatisticsSalesInfo> statisticsSalesYD(String type, String time) {
return agmsDashboardMapper.statisticsSales(type,time); List<StatisticsSalesInfo> statisticsSalesInfos = agmsDashboardMapper.statisticsSalesYD(type,time);
getUnitPremium(statisticsSalesInfos);
return statisticsSalesInfos;
}
/**
* 获取均件保费
* @param statisticsSalesInfos
*/
private void getUnitPremium(List<StatisticsSalesInfo> statisticsSalesInfos) {
if(statisticsSalesInfos != null && statisticsSalesInfos.size() > 0){
String fyp;
Integer pieces;
for(StatisticsSalesInfo item : statisticsSalesInfos){
fyp = item.getFyp();
pieces = item.getPieces();
if(pieces != null && pieces != 0){
item.setUnitPremium(BigDecimal.valueOf(Double.parseDouble(fyp) / pieces).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
}
}
}
} }
@Override @Override
public List<StatisticsPractitionerInfo> statisticsPractitioner(String type) { public List<StatisticsPractitionerInfo> statisticsPractitioner(String type) {
return agmsDashboardMapper.statisticsPractitioner(type); List<StatisticsPractitionerInfo> statisticsPractitionerInfos = agmsDashboardMapper.statisticsPractitioner(type);
//计算实动率
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());
}
}
}
return statisticsPractitionerInfos;
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public List<StatisticsSalesInfo> statisticsSalesEG(String type, String time) {
List<StatisticsSalesInfo> statisticsSalesInfos = agmsDashboardMapper.statisticsSalesEG(type,time);
getUnitPremium(statisticsSalesInfos);
return statisticsSalesInfos;
} }
} }
...@@ -88,7 +88,7 @@ where not EXISTS( ...@@ -88,7 +88,7 @@ where not EXISTS(
</choose> </choose>
order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc; order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc;
</select> </select>
<select id="statisticsSales" resultType="com.yd.api.agms.vo.dashboard.StatisticsSalesInfo"> <select id="statisticsSalesYD" resultType="com.yd.api.agms.vo.dashboard.StatisticsSalesInfo">
select select
<choose> <choose>
<when test="type.equalsIgnoreCase('B')"> <when test="type.equalsIgnoreCase('B')">
...@@ -98,11 +98,11 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc; ...@@ -98,11 +98,11 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc;
s.name as typeName, s.name as typeName,
</otherwise> </otherwise>
</choose> </choose>
ifnull(sum(cf.order_price),0) as fyp, concat(ifnull(sum(cf.order_price),0),'') as fyp,
ifnull(sum(cf.fyc_amount),0) as fyc, concat(ifnull(sum(cf.fyc_amount),0),'') as fyc,
ifnull(count(cf.order_id),0) as pieces ifnull(count(cf.order_id),0) as pieces
from ag_acl_practitioner p left join ag_acl_customer_fortune cf on p.customer_id = cf.customer_id and cf.grade_commission_rate != 5 from ag_acl_practitioner p inner join ag_acl_customer_fortune cf on p.customer_id = cf.customer_id and cf.grade_commission_rate != 5
left join ag_po_order o on cf.order_id = o.id and o.status = 3 inner join ag_po_order o on cf.order_id = o.id and o.status = 3
left join ag_acl_insurer_branch b on b.id = p.insurer_branch_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_subordinate_system s on s.id = p.subordinate_system_id
where where
...@@ -139,7 +139,7 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc; ...@@ -139,7 +139,7 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc;
group by p.subordinate_system_id group by p.subordinate_system_id
</otherwise> </otherwise>
</choose> </choose>
order by fyc desc order by sum(cf.fyc_amount) desc
</select> </select>
...@@ -193,4 +193,53 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc; ...@@ -193,4 +193,53 @@ order by predictFYC desc ,predictFYP desc ,pieces desc ,opportunityNum desc;
</otherwise> </otherwise>
</choose> </choose>
</select> </select>
<select id="statisticsSalesEG" resultType="com.yd.api.agms.vo.dashboard.StatisticsSalesInfo">
select
<choose>
<when test="type.equalsIgnoreCase('B')">
spc1.SPC_AREA_NAME as typeName,
</when>
<otherwise>
spc4.SPC_DIV_NAME as typeName,
</otherwise>
</choose>
ifnull(count(distinct policy.INS_MST_ID),0) as pieces,
concat(ifnull(sum(policy.INS_MST_TOTAL_PREIUM),0),'') as fyp,
concat(ifnull(sum(policy.INS001_FYCTOTAL),0),'') as fyc
FROM
ins001 policy INNER JOIN mon025 m on policy.INS_MST_ID = m.MON025_002 and m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
INNER JOIN (
SELECT mon025_002,MAX(MON025_405) as MON025_405 FROM mon025 group by mon025_002 ORDER BY mon025_002
) b on m.mon025_002 = b.mon025_002 AND m.MON025_405 = b.MON025_405
inner join spc004 spc4 on m.MON025_006 = spc4.SPC_DIV_ID -- 体系
inner join spc002 spc2 on spc4.FK_BUS_ID = spc2.SPC_BUS_ID -- 营业部
inner join spc001 spc1 on spc2.FK_AREA_ID = spc1.SPC_AREA_ID -- 分公司
where
<choose>
<when test="time.equalsIgnoreCase('D')">
TO_DAYS(policy.INS_MST_ACCEPT_DATE) = TO_DAYS(now())
</when>
<when test="time.equalsIgnoreCase('W')">
YEARWEEK(DATE_FORMAT(policy.INS_MST_ACCEPT_DATE,'%Y-%m-%d')) = YEARWEEK(NOW())
</when>
<when test="time.equalsIgnoreCase('M')">
DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
</when>
<when test="time.equalsIgnoreCase('Q')">
QUARTER(policy.INS_MST_ACCEPT_DATE) = QUARTER(NOW()) AND year(policy.INS_MST_ACCEPT_DATE)=year(now())
</when>
<otherwise>
YEAR(policy.INS_MST_ACCEPT_DATE) = YEAR(now())
</otherwise>
</choose>
<choose>
<when test="type.equalsIgnoreCase('B')">
group by spc1.SPC_AREA_ID
</when>
<otherwise>
group by m.MON025_006
</otherwise>
</choose>
order by sum(policy.INS001_FYCTOTAL) desc
</select>
</mapper> </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