Commit b6d35e88 by Water Wang

optimize

parent 67186862
...@@ -2300,28 +2300,93 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2300,28 +2300,93 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
Long subordinateSystemId = subordinateSystem.getId(); Long subordinateSystemId = subordinateSystem.getId();
Integer time = requestVO.getTime(); Integer time = requestVO.getTime();
time = (time == null) ? 1 : time; time = (time == null) ? 1 : time;
List<SubordinateSystemMemberInfo> memberInfoList = new ArrayList<>(); String mobileNo = aclPractitionerDALService.findMobileNoByPractitionerId(practitionerId);
SubordinateSystemStatisticInfo statisticInfo = new SubordinateSystemStatisticInfo();
//2、查询该团队长所在体系的所有成员
List<AclPractitioner> practitionerList = aclPractitionerDALService.findBySubordinateSystemId(subordinateSystemId);
double fypSum = 0D,fycSum = 0D; double fypSum = 0D,fycSum = 0D;
int countSum = 0; int countSum = 0;
SubordinateSystemStatisticInfo statisticInfo = new SubordinateSystemStatisticInfo();
Map<String,SubordinateSystemMemberInfo> memberInfoMap = new HashMap<>();
//银盾保险在线
getMemberInfoForOnLine(memberInfoMap,subordinateSystemId,time);
//eGolden
getMemberInfoForEGolden(memberInfoMap,mobileNo,time);
//查询出来的结果按照fyp进行排序
List<SubordinateSystemMemberInfo> memberInfoList = (List<SubordinateSystemMemberInfo>)memberInfoMap.values();
memberInfoList.sort(Comparator.comparingDouble(SubordinateSystemMemberInfo::getFyp));
Collections.reverse(memberInfoList);
statisticInfo.setCount(countSum);
statisticInfo.setFyc(CommonUtil.doubleFormat(fycSum,2));
statisticInfo.setFyp(CommonUtil.doubleFormat(fypSum,2));
statisticInfo.setCompletionRate(getCompletionRate(subordinateSystemId,fycSum,time));
responseVO.setId(subordinateSystemId);
responseVO.setSubordinateSystemName(subordinateSystem.getName());
responseVO.setContactName(subordinateSystem.getContactName());
responseVO.setContactNo(subordinateSystem.getContactNo());
responseVO.setRemark(subordinateSystem.getRemark());
responseVO.setStatisticInfo(statisticInfo);
responseVO.setMemberInfoList(memberInfoList);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
}else{
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830054")));
}
}else{
String[] params = {"practitionerId"};
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("610001", params)));
}
return responseVO;
}
/**
* EGolden体系中的成员信息
* @param memberInfoMap 成员类型
* @param mobileNo 团队长手机号码
* @param time 时间
*/
private void getMemberInfoForEGolden(Map<String, SubordinateSystemMemberInfo> memberInfoMap, String mobileNo, Integer time) {
if(!Strings.isNullOrEmpty(mobileNo)){
}
}
/**
* 银盾在线查询体系中的成员信息
* @param memberInfoMap 成员类型
* @param subordinateSystemId 体系id
* @param time 时间
*/
private void getMemberInfoForOnLine(Map<String,SubordinateSystemMemberInfo> memberInfoMap, Long subordinateSystemId,Integer time) {
//1、查询该团队长所在体系的所有成员
List<AclPractitioner> practitionerList = aclPractitionerDALService.findBySubordinateSystemId(subordinateSystemId);
if(!practitionerList.isEmpty() && practitionerList.get(0) != null){ if(!practitionerList.isEmpty() && practitionerList.get(0) != null){
Map<Long,Long> customerMap = new HashMap<>();
Map<Long,String> practitionerIdMobileNoMap = new HashMap<>();
List<Long> practitionerIds = new ArrayList<>(); List<Long> practitionerIds = new ArrayList<>();
practitionerList.forEach(i->practitionerIds.add(i.getId())); List<Long> customerIds = new ArrayList<>();
//3、查询该体系下经纪人的财富订单统计 for(AclPractitioner item : practitionerList){
practitionerIds.add(item.getId());
customerIds.add(item.getCustomerId());
customerMap.put(item.getCustomerId(),item.getId());
}
//2、查询该体系下经纪人的财富订单统计
List<AclCustomerFortuneStatistics> customerFortuneStatistics = aclCustomerFortuneDALService.findBySubordinateSystemStatistics(subordinateSystemId,time); List<AclCustomerFortuneStatistics> customerFortuneStatistics = aclCustomerFortuneDALService.findBySubordinateSystemStatistics(subordinateSystemId,time);
Map<Long,AclCustomerFortuneStatistics> customerFortuneStatisticsMap = new HashMap<>(); Map<Long,AclCustomerFortuneStatistics> customerFortuneStatisticsMap = new HashMap<>();
customerFortuneStatistics.forEach(i->customerFortuneStatisticsMap.put(i.getPractitionerId(),i)); customerFortuneStatistics.forEach(i->customerFortuneStatisticsMap.put(i.getPractitionerId(),i));
//获取所有成员的级别 //3、获取所有成员的级别
List<AclPractitionerSetting> practitionerSettings = aclpractitionersettingDALService.findByPractitionerIdList(practitionerIds); List<AclPractitionerSetting> practitionerSettings = aclpractitionersettingDALService.findByPractitionerIdList(practitionerIds);
Map<Long,Long> practitionerSettingMap = new HashMap<>(); Map<Long,Long> practitionerSettingMap = new HashMap<>();
practitionerSettings.forEach(i->practitionerSettingMap.put(i.getPractitionerId(),i.getPractitionerLevel())); practitionerSettings.forEach(i->practitionerSettingMap.put(i.getPractitionerId(),i.getPractitionerLevel()));
//获取所有经纪人登记的基础信息 //4、获取所有经纪人登记的基础信息
List<MdDropOptions> practitionerLevelInfo = mdDropOptionsDALService.findByDropMasterCode("practitioner_level");//5L List<MdDropOptions> practitionerLevelInfo = mdDropOptionsDALService.findByDropMasterCode("practitioner_level");//5L
Map<Long,String> levelInfoNameMap= new HashMap<>() ,levelInfoCodeMap = new HashMap<>(); Map<Long,String> levelInfoNameMap= new HashMap<>() ,levelInfoCodeMap = new HashMap<>();
practitionerLevelInfo.forEach(i->levelInfoNameMap.put(i.getId(),i.getDropOptionName())); practitionerLevelInfo.forEach(i->levelInfoNameMap.put(i.getId(),i.getDropOptionName()));
practitionerLevelInfo.forEach(i->levelInfoCodeMap.put(i.getId(),i.getDropOptionCode())); practitionerLevelInfo.forEach(i->levelInfoCodeMap.put(i.getId(),i.getDropOptionCode()));
//5、查询所以经纪人手机号码
List<AclCustomer> customerList = aclCustomerDALService.findByIds(customerIds);
customerList.forEach(i->practitionerIdMobileNoMap.put(customerMap.get(i.getId()),i.getMobileNo()));
// for(AclCustomer item : customerList){
// practitionerIdMobileNoMap.put(customerMap.get(item.getId()),item.getMobileNo());
// }
SubordinateSystemMemberInfo memberInfo; SubordinateSystemMemberInfo memberInfo;
Long practitionerIdForMember,practitionerLevelId; Long practitionerIdForMember,practitionerLevelId;
AclCustomerFortuneStatistics customerFortuneStatisticsItem; AclCustomerFortuneStatistics customerFortuneStatisticsItem;
...@@ -2340,40 +2405,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -2340,40 +2405,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
fyc = customerFortuneStatisticsItem.getFyc(); fyc = customerFortuneStatisticsItem.getFyc();
fyp = customerFortuneStatisticsItem.getFyp(); fyp = customerFortuneStatisticsItem.getFyp();
count = customerFortuneStatisticsItem.getCount(); count = customerFortuneStatisticsItem.getCount();
fycSum = fycSum + fyc;
fypSum = fypSum + fyp;
countSum = countSum + count;
} }
memberInfo.setFyc(CommonUtil.doubleFormat(fyc,2)); memberInfo.setFyc(CommonUtil.doubleFormat(fyc,2));
memberInfo.setFyp(CommonUtil.doubleFormat(fyp,2)); memberInfo.setFyp(CommonUtil.doubleFormat(fyp,2));
memberInfo.setCount(count); memberInfo.setCount(count);
memberInfoList.add(memberInfo); memberInfoMap.put(practitionerIdMobileNoMap.get(practitionerIdForMember),memberInfo);
} // memberInfoList.add(memberInfo);
}
//查询出来的结果按照fyp进行排序
memberInfoList.sort(Comparator.comparingDouble(SubordinateSystemMemberInfo::getFyp));
Collections.reverse(memberInfoList);
statisticInfo.setCount(countSum);
statisticInfo.setFyc(CommonUtil.doubleFormat(fycSum,2));
statisticInfo.setFyp(CommonUtil.doubleFormat(fypSum,2));
statisticInfo.setCompletionRate(getCompletionRate(subordinateSystemId,fycSum,time));
responseVO.setId(subordinateSystemId);
responseVO.setSubordinateSystemName(subordinateSystem.getName());
responseVO.setContactName(subordinateSystem.getContactName());
responseVO.setContactNo(subordinateSystem.getContactNo());
responseVO.setRemark(subordinateSystem.getRemark());
responseVO.setStatisticInfo(statisticInfo);
responseVO.setMemberInfoList(memberInfoList);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
}else{
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830054")));
} }
}else{
String[] params = {"practitionerId"};
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("610001", params)));
} }
return responseVO;
} }
/** /**
......
package com.yd.dal.mapper.customer; package com.yd.dal.mapper.customer;
import com.yd.dal.entity.customer.AclCustomer;import java.util.List; import com.yd.dal.entity.customer.AclCustomer;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface AclCustomerMapper { public interface AclCustomerMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
...@@ -18,4 +21,6 @@ public interface AclCustomerMapper { ...@@ -18,4 +21,6 @@ public interface AclCustomerMapper {
List<AclCustomer> findByLogin(String mobileNo); List<AclCustomer> findByLogin(String mobileNo);
AclCustomer findByMobileNo(String mobileNo); AclCustomer findByMobileNo(String mobileNo);
List<AclCustomer> findByIds(@Param("customerIds") List<Long> customerIds);
} }
\ No newline at end of file
...@@ -46,4 +46,6 @@ public interface AclPractitionerMapper { ...@@ -46,4 +46,6 @@ public interface AclPractitionerMapper {
List<PlayerSalesActivityInfo> playerSalesActivityQuery(@Param("practitionerId") Long practitionerId,@Param("optionsId") Long optionsId); List<PlayerSalesActivityInfo> playerSalesActivityQuery(@Param("practitionerId") Long practitionerId,@Param("optionsId") Long optionsId);
List<AclPractitioner> findBySubordinateSystemId(@Param("subordinateSystemId")Long subordinateSystemId); List<AclPractitioner> findBySubordinateSystemId(@Param("subordinateSystemId")Long subordinateSystemId);
String findMobileNoByPractitionerId(@Param("practitionerId")Long practitionerId);
} }
\ No newline at end of file
...@@ -32,5 +32,7 @@ public interface AclCustomerDALService { ...@@ -32,5 +32,7 @@ public interface AclCustomerDALService {
AclCustomer findByCustomerId(Long customerId); AclCustomer findByCustomerId(Long customerId);
AclCustomer findByMobileNo(String mobileNo); AclCustomer findByMobileNo(String mobileNo);
List<AclCustomer> findByIds(List<Long> customerIds);
} }
...@@ -102,4 +102,11 @@ public interface AclPractitionerDALService { ...@@ -102,4 +102,11 @@ public interface AclPractitionerDALService {
* @return * @return
*/ */
List<AclPractitioner> findBySubordinateSystemId(Long subordinateSystemId); List<AclPractitioner> findBySubordinateSystemId(Long subordinateSystemId);
/**
* 更具经纪人id查询该经纪人手机号码
* @param practitionerId 经纪人id
* @return 查询结果
*/
String findMobileNoByPractitionerId(Long practitionerId);
} }
...@@ -47,4 +47,9 @@ public class AclCustomerDALServiceImpl implements AclCustomerDALService { ...@@ -47,4 +47,9 @@ public class AclCustomerDALServiceImpl implements AclCustomerDALService {
return aclCustomerMapper.findByMobileNo(mobileNo); return aclCustomerMapper.findByMobileNo(mobileNo);
} }
@Override
public List<AclCustomer> findByIds(List<Long> customerIds) {
return aclCustomerMapper.findByIds(customerIds);
}
} }
...@@ -9,6 +9,7 @@ import com.yd.dal.entity.customer.practitioner.PractitionerInfo; ...@@ -9,6 +9,7 @@ import com.yd.dal.entity.customer.practitioner.PractitionerInfo;
import com.yd.dal.entity.customer.practitioner.PractitionerRankInfo; import com.yd.dal.entity.customer.practitioner.PractitionerRankInfo;
import com.yd.dal.mapper.customer.AclPractitionerMapper; import com.yd.dal.mapper.customer.AclPractitionerMapper;
import com.yd.dal.service.customer.AclPractitionerDALService; import com.yd.dal.service.customer.AclPractitionerDALService;
import com.yd.util.deshandler.DESTypeHandler;
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.log4j.Logger; import org.apache.log4j.Logger;
...@@ -102,4 +103,14 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService ...@@ -102,4 +103,14 @@ public class AclPractitionerDALServiceImpl implements AclPractitionerDALService
public List<AclPractitioner> findBySubordinateSystemId(Long subordinateSystemId) { public List<AclPractitioner> findBySubordinateSystemId(Long subordinateSystemId) {
return aclPractitionerMapper.findBySubordinateSystemId(subordinateSystemId); return aclPractitionerMapper.findBySubordinateSystemId(subordinateSystemId);
} }
@Override
public String findMobileNoByPractitionerId(Long practitionerId) {
String mobileNo = aclPractitionerMapper.findMobileNoByPractitionerId(practitionerId);
if(!Strings.isNullOrEmpty(mobileNo)){
DESTypeHandler jpaCryptoConverter = new DESTypeHandler();
mobileNo = jpaCryptoConverter.decode(mobileNo);
}
return mobileNo;
}
} }
...@@ -307,9 +307,9 @@ ...@@ -307,9 +307,9 @@
p.id practitionerId , p.id practitionerId ,
p.`name` name , p.`name` name ,
p.subordinate_system_id subordinateSystemId , p.subordinate_system_id subordinateSystemId ,
COUNT(f.id) count , ifnull(COUNT(f.id),0) count ,
SUM(f.order_price) FYP , ifnull(SUM(f.order_price),0) FYP ,
SUM(f.referral_amount) FYC , ifnull(SUM(f.fyc_amount),0) FYC ,
s.practitioner_level practitionerLevelId s.practitioner_level practitionerLevelId
FROM FROM
((ag_acl_practitioner_setting s LEFT JOIN ag_acl_practitioner p ON s.practitioner_id = p.id) ((ag_acl_practitioner_setting s LEFT JOIN ag_acl_practitioner p ON s.practitioner_id = p.id)
......
...@@ -771,4 +771,13 @@ ...@@ -771,4 +771,13 @@
from ag_acl_customer from ag_acl_customer
where mobile_no = #{mobileNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler} where mobile_no = #{mobileNo,jdbcType=VARCHAR,typeHandler=com.yd.util.deshandler.DESTypeHandler}
</select> </select>
<select id="findByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_acl_customer
where id in
<foreach collection="customerIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -547,14 +547,14 @@ ...@@ -547,14 +547,14 @@
md.DRP_TITLE_LEVEL as titleCode,-- 职称code md.DRP_TITLE_LEVEL as titleCode,-- 职称code
md.DRP_TITLE_NAME as titleName,-- 职称名称 md.DRP_TITLE_NAME as titleName,-- 职称名称
spc.SPC_DIV_NAME as spcDivName,-- 体系id spc.SPC_DIV_NAME as spcDivName,-- 体系id
count(m.MON025_002) as count,-- 保单id ifnull(count(m.MON025_002),0) as count,-- 保单id
sum(m.MON025_401) as fyp,-- 保费 ifnull(sum(m.MON025_401),0) as fyp,-- 保费
sum(m.MON025_405) as fyc -- 应发佣金 ifnull(sum(policy.INS001_FYCTOTAL),0) as fyc -- 应发佣金
FROM MON025 m INNER JOIN sal001 p on m.MON025_007 = p.SAL_MST_ID -- 业务员id FROM MON025 m INNER JOIN sal001 p on m.MON025_007 = p.SAL_MST_ID -- 业务员id
left join DRP003 md on p.FK_DRP_TITLE_CODE = md.DRP_TITLE_CODE left join DRP003 md on p.FK_DRP_TITLE_CODE = md.DRP_TITLE_CODE
inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID -- 保单id inner JOIN ins001 policy on m.MON025_002 = policy.INS_MST_ID -- 保单id
inner join spc004 spc on m.MON025_006 = spc.SPC_DIV_ID -- 体系 inner join spc004 spc on m.MON025_006 = spc.SPC_DIV_ID -- 体系
WHERE m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 WHERE m.MON025_109 IN (1,2,3) AND m.MON025_303 = 1 AND m.mon025_108 = 'S01'
<choose> <choose>
<when test="time == 1"> <when test="time == 1">
and DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' ) and DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
...@@ -575,9 +575,9 @@ ...@@ -575,9 +575,9 @@
p.id as practitionerIdForOnLine , p.id as practitionerIdForOnLine ,
p.name as name ,-- 姓名 p.name as name ,-- 姓名
ss.name as spcDivName,-- 体系id ss.name as spcDivName,-- 体系id
count(f.id) as count,-- 保单id ifnull(count(f.id),0) as count,-- 保单id
sum(f.order_price) as fyp,-- 保费 ifnull(sum(f.order_price),0) as fyp,-- 保费
sum(f.referral_amount) as fyc -- 应发佣金 ifnull(sum(f.fyc_amount),0) as fyc -- 应发佣金
FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id
inner JOIN ag_acl_practitioner p ON f.customer_id = p.customer_id inner JOIN ag_acl_practitioner p ON f.customer_id = p.customer_id
left join ag_acl_practitioner_setting s on p.id = s.practitioner_id left join ag_acl_practitioner_setting s on p.id = s.practitioner_id
...@@ -607,9 +607,9 @@ ...@@ -607,9 +607,9 @@
p.id as practitionerIdForOnLine , p.id as practitionerIdForOnLine ,
p.name as name ,-- 姓名 p.name as name ,-- 姓名
ss.name as spcDivName,-- 体系id ss.name as spcDivName,-- 体系id
count(f.id) as count,-- 保单id ifnull(count(f.id),0) as count,-- 保单id
sum(f.order_price) as fyp,-- 保费 ifnull(sum(f.order_price),0) as fyp,-- 保费
sum(f.referral_amount) as fyc -- 应发佣金 ifnull(sum(f.fyc_amount),0) as fyc -- 应发佣金
FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id FROM ag_acl_customer_fortune f INNER JOIN ag_po_order o ON f.order_id = o.id
inner JOIN ag_acl_practitioner p ON f.customer_id = p.customer_id inner JOIN ag_acl_practitioner p ON f.customer_id = p.customer_id
left join ag_acl_customer c on p.customer_id = c.id left join ag_acl_customer c on p.customer_id = c.id
...@@ -765,4 +765,9 @@ ...@@ -765,4 +765,9 @@
from ag_acl_practitioner from ag_acl_practitioner
where subordinate_system_id = #{subordinateSystemId,jdbcType=BIGINT} and is_active = 1 where subordinate_system_id = #{subordinateSystemId,jdbcType=BIGINT} and is_active = 1
</select> </select>
<select id="findMobileNoByPractitionerId" resultType="java.lang.String">
select c.mobile_no
from ag_acl_practitioner p left join ag_acl_customer c on p.customer_id = c.id and c.is_active = 1
where p.id = #{practitionerId,jdbcType=BIGINT} limit 1;
</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