Commit d201f492 by yao.xiao

增加-团队长查询分数/预测销售额及保存目标区分团队,个人

parent 3e16d24c
...@@ -96,8 +96,8 @@ public class PractitionerController { ...@@ -96,8 +96,8 @@ public class PractitionerController {
/** /**
* 微信-上传多媒体文件 * 微信-上传多媒体文件
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/mediaGet") @RequestMapping("/mediaGet")
public Object mediaGet(@RequestBody MediaGetReqVO requestVO){ public Object mediaGet(@RequestBody MediaGetReqVO requestVO){
...@@ -110,8 +110,8 @@ public class PractitionerController { ...@@ -110,8 +110,8 @@ public class PractitionerController {
/*** /***
* 经纪人-经纪人查询自己的商机 * 经纪人-经纪人查询自己的商机
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/ownOpportunityQuery") @RequestMapping("/ownOpportunityQuery")
public Object ownOpportunityQuery(@RequestBody OwnOpportunityQueryRequestVO requestVO){ public Object ownOpportunityQuery(@RequestBody OwnOpportunityQueryRequestVO requestVO){
...@@ -137,8 +137,8 @@ public class PractitionerController { ...@@ -137,8 +137,8 @@ public class PractitionerController {
/*** /***
* 经纪人-经纪人查询自己的商机详情查询 * 经纪人-经纪人查询自己的商机详情查询
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/ownOpportunityDetailQuery") @RequestMapping("/ownOpportunityDetailQuery")
public Object ownOpportunityDetailQuery(@RequestBody OwnOpportunityDetailQueryRequestVO requestVO){ public Object ownOpportunityDetailQuery(@RequestBody OwnOpportunityDetailQueryRequestVO requestVO){
...@@ -192,8 +192,8 @@ public class PractitionerController { ...@@ -192,8 +192,8 @@ public class PractitionerController {
/** /**
* 经纪人-修改商机基本信息 * 经纪人-修改商机基本信息
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/ownOpportunityBasicInformationSave") @RequestMapping("/ownOpportunityBasicInformationSave")
public Object ownOpportunityBasicInformationSave(@RequestBody OwnOpportunityBasicInformationSaveRequestVO requestVO){ public Object ownOpportunityBasicInformationSave(@RequestBody OwnOpportunityBasicInformationSaveRequestVO requestVO){
...@@ -206,8 +206,8 @@ public class PractitionerController { ...@@ -206,8 +206,8 @@ public class PractitionerController {
/** /**
* 经纪人-保存商机跟进,修改商机基本信息 * 经纪人-保存商机跟进,修改商机基本信息
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/ownOpportunityRecordSave") @RequestMapping("/ownOpportunityRecordSave")
public Object ownOpportunityRecordSave(@RequestBody OwnOpportunityRecordSaveRequestVO requestVO){ public Object ownOpportunityRecordSave(@RequestBody OwnOpportunityRecordSaveRequestVO requestVO){
...@@ -220,8 +220,8 @@ public class PractitionerController { ...@@ -220,8 +220,8 @@ public class PractitionerController {
/** /**
* 经纪人-ydLife查询此经纪人总分数 按年月周日 分别统计 新增商机个数 达成率 * 经纪人-ydLife查询此经纪人总分数 按年月周日 分别统计 新增商机个数 达成率
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/opportunityStatistics") @RequestMapping("/opportunityStatistics")
public Object OpportunityStatistics(@RequestBody OpportunityStatisticsRequestVO requestVO){ public Object OpportunityStatistics(@RequestBody OpportunityStatisticsRequestVO requestVO){
...@@ -234,8 +234,8 @@ public class PractitionerController { ...@@ -234,8 +234,8 @@ public class PractitionerController {
/** /**
* 经纪人-保存销售目标 * 经纪人-保存销售目标
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/salesTargetSave") @RequestMapping("/salesTargetSave")
public Object salesTargetSave(@RequestBody SalesTargetSaveRequestVO requestVO){ public Object salesTargetSave(@RequestBody SalesTargetSaveRequestVO requestVO){
...@@ -248,8 +248,8 @@ public class PractitionerController { ...@@ -248,8 +248,8 @@ public class PractitionerController {
/** /**
* 经纪人-查询销售目标 * 经纪人-查询销售目标
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/salesTargetQuery") @RequestMapping("/salesTargetQuery")
public Object salesTargetQuery(@RequestBody SalesTargetQueryRequestVO requestVO){ public Object salesTargetQuery(@RequestBody SalesTargetQueryRequestVO requestVO){
...@@ -262,8 +262,8 @@ public class PractitionerController { ...@@ -262,8 +262,8 @@ public class PractitionerController {
/** /**
* 经纪人-保存月均目标 * 经纪人-保存月均目标
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/salesTargetMonthSave") @RequestMapping("/salesTargetMonthSave")
public Object salesTargetMonthSave(@RequestBody SalesTargetMonthSaveRequestVO requestVO){ public Object salesTargetMonthSave(@RequestBody SalesTargetMonthSaveRequestVO requestVO){
...@@ -276,8 +276,8 @@ public class PractitionerController { ...@@ -276,8 +276,8 @@ public class PractitionerController {
/** /**
* 团队长-查看组员得分均值 * 团队长-查看组员得分均值
* @param requestVO * @param requestVO 请求数据
* @return * @return 响应数据
*/ */
@RequestMapping("/teamActionsAverageQuery") @RequestMapping("/teamActionsAverageQuery")
public Object teamActionsAverageQuery(@RequestBody TeamActionsAverageQueryRequestVO requestVO){ public Object teamActionsAverageQuery(@RequestBody TeamActionsAverageQueryRequestVO requestVO){
......
...@@ -19,6 +19,7 @@ import com.yd.api.practitioner.vo.salestarget.*; ...@@ -19,6 +19,7 @@ import com.yd.api.practitioner.vo.salestarget.*;
import com.yd.api.practitioner.vo.setting.*; import com.yd.api.practitioner.vo.setting.*;
import com.yd.api.result.CommonResult; import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.*; import com.yd.dal.entity.customer.*;
import com.yd.dal.entity.insurer.AclInsurerBranchDept;
import com.yd.dal.entity.marketing.*; import com.yd.dal.entity.marketing.*;
import com.yd.dal.entity.meta.*; import com.yd.dal.entity.meta.*;
import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo; import com.yd.dal.entity.practitioner.opportunity.OwnOpportunityInfo;
...@@ -575,8 +576,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -575,8 +576,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
/** /**
* 商机客户基本信息 * 商机客户基本信息
* @param requestVO
* @return
*/ */
private OpportunityBasicInformationInfo getOpportunityBasicInformation(OwnOpportunityDetailQueryRequestVO requestVO) { private OpportunityBasicInformationInfo getOpportunityBasicInformation(OwnOpportunityDetailQueryRequestVO requestVO) {
OpportunityBasicInformationInfo info = new OpportunityBasicInformationInfo(); OpportunityBasicInformationInfo info = new OpportunityBasicInformationInfo();
...@@ -647,8 +646,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -647,8 +646,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
/** /**
* 客户标签查询 * 客户标签查询
* @param customerId
* @return
*/ */
private List<OpportunityCustomerTag> OpportunityCustomerTags(Long customerId) { private List<OpportunityCustomerTag> OpportunityCustomerTags(Long customerId) {
List<OpportunityCustomerTag> tags = new ArrayList<>(); List<OpportunityCustomerTag> tags = new ArrayList<>();
...@@ -675,8 +672,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -675,8 +672,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
/** /**
* 调查问卷答案,咨询服务 * 调查问卷答案,咨询服务
* @param requestVO
* @return
*/ */
private OpportunityConsultationInfo getOpportunityConsultation(OwnOpportunityDetailQueryRequestVO requestVO) { private OpportunityConsultationInfo getOpportunityConsultation(OwnOpportunityDetailQueryRequestVO requestVO) {
OpportunityConsultationInfo info = new OpportunityConsultationInfo(); OpportunityConsultationInfo info = new OpportunityConsultationInfo();
...@@ -699,8 +694,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -699,8 +694,6 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
/** /**
* 问卷答案 * 问卷答案
* @param requestVO
* @return
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private List<OpportunitySurveyAnswers> findSurveyAnswers(OwnOpportunityDetailQueryRequestVO requestVO) { private List<OpportunitySurveyAnswers> findSurveyAnswers(OwnOpportunityDetailQueryRequestVO requestVO) {
...@@ -1378,16 +1371,19 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1378,16 +1371,19 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//当前年份 //当前年份
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
Integer goalsType = requestVO.getGoalsType();
//初始化之前数据 全部修改为不启用 //初始化之前数据 全部修改为不启用
initializationAction(practitionerId,year); initializationAction(practitionerId,year,goalsType);
//查询经纪人所在团队
AclPractitionerSubordinateSystem subordinate = aclPractitionerSubordinateSystemDALService.findByPractitionerId(practitionerId);
//保存年目标 //保存年目标
Date date = new Date(); Date date = new Date();
saveYearGoal(requestVO,practitionerId,date,year); saveYearGoal(requestVO,practitionerId,date,year,goalsType,subordinate);
//保存月目标 //保存月目标
List<SalesTargetMonth> salesTargetMonths = requestVO.getSalesTargetMonths(); List<SalesTargetMonth> salesTargetMonths = requestVO.getSalesTargetMonths();
for(SalesTargetMonth info: salesTargetMonths){ for(SalesTargetMonth info: salesTargetMonths){
saveMonthGoal(info,practitionerId,date,year); saveMonthGoal(info,practitionerId,date,year,goalsType,subordinate);
} }
//保存经纪人商机活动量均分 //保存经纪人商机活动量均分
...@@ -1421,11 +1417,13 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1421,11 +1417,13 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//当前年份 //当前年份
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
Integer goalsType = requestVO.getGoalsType();
//通过is_active = 1 经纪人id 和 目标所属年度 去查询ag_mkt_leads_goals/ag_mkt_leads_goals_actions //通过is_active = 1 经纪人id 和 目标所属年度 去查询ag_mkt_leads_goals/ag_mkt_leads_goals_actions
MktLeadsGoals mktLeadsGoals = new MktLeadsGoals(); MktLeadsGoals mktLeadsGoals = new MktLeadsGoals();
mktLeadsGoals.setIsActive(1); mktLeadsGoals.setIsActive(1);
mktLeadsGoals.setPractitionerId(practitionerId); mktLeadsGoals.setPractitionerId(practitionerId);
mktLeadsGoals.setCurrentYear(year); mktLeadsGoals.setCurrentYear(year);
mktLeadsGoals.setGoalsType(goalsType);
List<MktLeadsGoals> mktLeadsGoalsList = mktLeadsGoalsDALService.findByMktLeadsGoals(mktLeadsGoals); List<MktLeadsGoals> mktLeadsGoalsList = mktLeadsGoalsDALService.findByMktLeadsGoals(mktLeadsGoals);
List<SalesTargetMonth> salesTargetMonthList = new ArrayList<>(); List<SalesTargetMonth> salesTargetMonthList = new ArrayList<>();
for (MktLeadsGoals info :mktLeadsGoalsList){ for (MktLeadsGoals info :mktLeadsGoalsList){
...@@ -1476,13 +1474,15 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1476,13 +1474,15 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
//当前年份 //当前年份
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
mktLeadsGoalsActionsDALService.updateIsActiveIsNull(practitionerId,year); Integer goalsType = requestVO.getGoalsType();
mktLeadsGoalsActionsDALService.updateIsActiveIsNull(practitionerId,year,goalsType);
List<SalesTargetActions> salesTargetActionsList = requestVO.getSalesTargetActionsList(); List<SalesTargetActions> salesTargetActionsList = requestVO.getSalesTargetActionsList();
Date date = new Date(); Date date = new Date();
MktLeadsGoalsActions mktLeadsGoalsActions; MktLeadsGoalsActions mktLeadsGoalsActions;
for (SalesTargetActions info : salesTargetActionsList){ for (SalesTargetActions info : salesTargetActionsList){
mktLeadsGoalsActions = new MktLeadsGoalsActions(); mktLeadsGoalsActions = new MktLeadsGoalsActions();
mktLeadsGoalsActions.setPractitionerId(practitionerId); mktLeadsGoalsActions.setPractitionerId(practitionerId);
mktLeadsGoalsActions.setGoalsType(goalsType);
mktLeadsGoalsActions.setCurrentYear(year); mktLeadsGoalsActions.setCurrentYear(year);
mktLeadsGoalsActions.setStatisticTimeUnit(3); mktLeadsGoalsActions.setStatisticTimeUnit(3);
mktLeadsGoalsActions.setLeadsActionId(info.getLeadsActionId()); mktLeadsGoalsActions.setLeadsActionId(info.getLeadsActionId());
...@@ -1504,32 +1504,90 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1504,32 +1504,90 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
public TeamActionsAverageQueryResponseVO teamScoreAverageQuery(TeamActionsAverageQueryRequestVO requestVO) { public TeamActionsAverageQueryResponseVO teamScoreAverageQuery(TeamActionsAverageQueryRequestVO requestVO) {
TeamActionsAverageQueryResponseVO responseVO = new TeamActionsAverageQueryResponseVO(); TeamActionsAverageQueryResponseVO responseVO = new TeamActionsAverageQueryResponseVO();
Long practitionerId = requestVO.getPractitionerId(); Long practitionerId = requestVO.getPractitionerId();
List<MdDropOptions> mdDropOptionsList = mdDropOptionsDALService.findByDropMasterCode("bizchance_promotion_action"); //该团队长下团队所有经纪人信息
ConcurrentMap<Long,Integer> optionScoreMap = new ConcurrentHashMap<>();
for (MdDropOptions info : mdDropOptionsList){
optionScoreMap.put(info.getId(),info.getDropOptionScore());
}
List<AclPractitioner> aclPractitioners = aclPractitionerDALService.findForSubordinateIdByPractitionerId(practitionerId); List<AclPractitioner> aclPractitioners = aclPractitionerDALService.findForSubordinateIdByPractitionerId(practitionerId);
//经纪人个数 //团队经纪人个数
int practitionerNum = aclPractitioners.size(); BigDecimal practitionerNum = BigDecimal.valueOf(aclPractitioners.size());
List<Long> practitionerIds = new ArrayList<>(); List<Long> practitionerIds = new ArrayList<>();
for (AclPractitioner info : aclPractitioners){ for (AclPractitioner info : aclPractitioners){
practitionerIds.add(info.getId()); practitionerIds.add(info.getId());
} }
System.out.println(practitionerIds.toString());
//查询此团队经纪人所有得跟进状态 //查询此团队经纪人所有得跟进状态
List<Integer> totalStatistics = mktLeadsAssignedTrackDALService.totalStatisticsForTeam(practitionerIds); List<MdDropOptions> mdDropOptions = mdDropOptionsDALService.findByDropMasterCode("bizchance_promotion_action");
Integer totalDay = totalStatistics.get(0); ConcurrentMap<String,Long> optionCodeToId = new ConcurrentHashMap<>();
Integer totalWeek = totalStatistics.get(1); for (MdDropOptions info : mdDropOptions){
Integer totalMonth = totalStatistics.get(2); optionCodeToId.put(info.getDropOptionCode(),info.getId());
}
//查询其团队天,周,月总分
HashMap<String,BigDecimal> totalStatistics = mktLeadsAssignedTrackDALService.totalStatisticsForTeam(practitionerIds);
//总分除以人数得到均分
Double scoreDayAverage = getScoreAverage(totalStatistics.get("scoreToday"),practitionerNum);
Double scoreWeekAverage= getScoreAverage(totalStatistics.get("scoreWeek"),practitionerNum);
Double scoreMonthAverage= getScoreAverage(totalStatistics.get("scoreMonth"),practitionerNum);
//计算此团队一周增加的商机数 ag_mkt_leads_assigneds
Integer opportunitiesNum = mktLeadsAssignedsDALService.countPractitionerIdsAndThisWeek(practitionerIds);
//计算年/季/月 首年保费(premium)/佣金(commission)/件数(pieces) 均取至指派表ag_mkt_leads_assigneds
//拿到商机跟踪,失败id
Long refusedId = optionCodeToId.get("refused");
HashMap<String,BigDecimal> performanceForecast = mktLeadsAssignedsDALService.performanceForecastForTeam(practitionerIds,refusedId);
//月平均保费
Double premiumMonthAverage = getScoreAverage(performanceForecast.get("totalFYCMonth"),practitionerNum);
//月平均佣金
Double commissionMonthAverage = getScoreAverage(performanceForecast.get("totalFYPMonth"),practitionerNum);
//月平均件数
Double piecesMonthAverage = getScoreAverage(performanceForecast.get("totalPiecesMonth"),practitionerNum);
// 季度平均保费
Double premiumQuarterAverage = getScoreAverage(performanceForecast.get("totalFYCQuarter"),practitionerNum);
// 季度平均佣金
Double commissionQuarterAverage = getScoreAverage(performanceForecast.get("totalFYPQuarter"),practitionerNum);
//季度平均件数
Double piecesQuarterAverage = getScoreAverage(performanceForecast.get("totalPiecesQuarter"),practitionerNum);
//年平均保费
Double premiumYearAverage = getScoreAverage(performanceForecast.get("totalFYCYear"),practitionerNum);
//年平均佣金
Double commissionYearAverage = getScoreAverage(performanceForecast.get("totalFYPYear"),practitionerNum);
//年平均件数
Double piecesYearAverage = getScoreAverage(performanceForecast.get("totalPiecesYear"),practitionerNum);
responseVO.setScoreDayAverage(scoreDayAverage);
responseVO.setScoreWeekAverage(scoreWeekAverage);
responseVO.setScoreMonthAverage(scoreMonthAverage);
responseVO.setOpportunitiesNum(opportunitiesNum);
responseVO.setPremiumMonthAverage(premiumMonthAverage);
responseVO.setCommissionMonthAverage(commissionMonthAverage);
responseVO.setPiecesMonthAverage(piecesMonthAverage);
responseVO.setPremiumQuarterAverage(premiumQuarterAverage);
responseVO.setCommissionQuarterAverage(commissionQuarterAverage);
responseVO.setPiecesQuarterAverage(piecesQuarterAverage);
responseVO.setPremiumYearAverage(premiumYearAverage);
responseVO.setCommissionYearAverage(commissionYearAverage);
responseVO.setPiecesYearAverage(piecesYearAverage);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000"))); responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
return responseVO; return responseVO;
} }
private void initializationAction(Long practitionerId, int year) { /**
* 通过总分计算平均分 保留两位小数
* @param total 总分
* @param practitionerNum 人数
* @return 均分
*/
private Double getScoreAverage(BigDecimal total, BigDecimal practitionerNum) {
Double scoreAverage = 0D;
if (!CommonUtil.isNullOrZero(total)){
scoreAverage = total
.divide(practitionerNum,2,BigDecimal.ROUND_HALF_UP)
.doubleValue();
}
return scoreAverage;
}
private void initializationAction(Long practitionerId, int year,Integer goalsType) {
//通过经纪人id 和 目标所属年度 去查询ag_mkt_leads_goals/ag_mkt_leads_goals_actions 并将is_active = 0 //通过经纪人id 和 目标所属年度 去查询ag_mkt_leads_goals/ag_mkt_leads_goals_actions 并将is_active = 0
mktLeadsGoalsDALService.updateIsActiveIsNull(practitionerId,year); mktLeadsGoalsDALService.updateIsActiveIsNull(practitionerId,year,goalsType);
mktLeadsGoalsActionsDALService.updateIsActiveIsNull(practitionerId,year); mktLeadsGoalsActionsDALService.updateIsActiveIsNull(practitionerId,year,goalsType);
} }
private SalesTargetActions saveLeadsGoalsActions(MdGoalsCalculateExpression info, ScriptEngine jScriptEngine, int year, int piecesMonth, Long practitionerId , Date date) { private SalesTargetActions saveLeadsGoalsActions(MdGoalsCalculateExpression info, ScriptEngine jScriptEngine, int year, int piecesMonth, Long practitionerId , Date date) {
...@@ -1570,16 +1628,19 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1570,16 +1628,19 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
/** /**
* 保存月度商机目标 * 保存月度商机目标
* @param info * @param info 入参
* @param practitionerId 经纪人id * @param practitionerId 经纪人id
* @param date 版本号 * @param date 版本号
* @param year 当前年份 * @param year 当前年份
*/ */
private void saveMonthGoal(SalesTargetMonth info, Long practitionerId, Date date,int year) { private void saveMonthGoal(SalesTargetMonth info, Long practitionerId, Date date,int year,Integer goalsType,AclPractitionerSubordinateSystem subordinate) {
MktLeadsGoals mktLeadsGoals = new MktLeadsGoals(); MktLeadsGoals mktLeadsGoals = new MktLeadsGoals();
mktLeadsGoals.setPractitionerId(practitionerId); mktLeadsGoals.setPractitionerId(practitionerId);
mktLeadsGoals.setPremium(info.getPremium()); mktLeadsGoals.setPremium(info.getPremium());
mktLeadsGoals.setCommission(info.getCommission()); mktLeadsGoals.setCommission(info.getCommission());
mktLeadsGoals.setGoalsType(goalsType);
mktLeadsGoals.setSubordinateSystemId(subordinate.getId());
mktLeadsGoals.setSubordinateSystemName(subordinate.getName());
mktLeadsGoals.setPieces(info.getPieces()); mktLeadsGoals.setPieces(info.getPieces());
mktLeadsGoals.setPieceAveragePremium(info.getPieceAveragePremium()); mktLeadsGoals.setPieceAveragePremium(info.getPieceAveragePremium());
mktLeadsGoals.setCurrentYear(year); mktLeadsGoals.setCurrentYear(year);
...@@ -1596,18 +1657,21 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -1596,18 +1657,21 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
/** /**
* 保存商机年目标 * 保存商机年目标
* @param requestVO * @param requestVO 入参
* @param practitionerId 经纪人id * @param practitionerId 经纪人id
* @param date 版本号 * @param date 版本号
* @param year 当前年份 * @param year 当前年份
*/ */
private void saveYearGoal(SalesTargetSaveRequestVO requestVO,Long practitionerId,Date date,int year) { private void saveYearGoal(SalesTargetSaveRequestVO requestVO,Long practitionerId,Date date,int year,Integer goalsType,AclPractitionerSubordinateSystem subordinate) {
Integer premium = requestVO.getPremium(); Integer premium = requestVO.getPremium();
Integer commission = requestVO.getCommission(); Integer commission = requestVO.getCommission();
Integer pieces = requestVO.getPieces(); Integer pieces = requestVO.getPieces();
Integer pieceAveragePremium = requestVO.getPieceAveragePremium(); Integer pieceAveragePremium = requestVO.getPieceAveragePremium();
MktLeadsGoals mktLeadsGoals = new MktLeadsGoals(); MktLeadsGoals mktLeadsGoals = new MktLeadsGoals();
mktLeadsGoals.setPractitionerId(practitionerId); mktLeadsGoals.setPractitionerId(practitionerId);
mktLeadsGoals.setGoalsType(goalsType);
mktLeadsGoals.setSubordinateSystemId(subordinate.getId());
mktLeadsGoals.setSubordinateSystemName(subordinate.getName());
mktLeadsGoals.setPremium(premium); mktLeadsGoals.setPremium(premium);
mktLeadsGoals.setCommission(commission); mktLeadsGoals.setCommission(commission);
mktLeadsGoals.setPieces(pieces); mktLeadsGoals.setPieces(pieces);
......
...@@ -7,5 +7,9 @@ import java.util.List; ...@@ -7,5 +7,9 @@ import java.util.List;
@Data @Data
public class SalesTargetMonthSaveRequestVO { public class SalesTargetMonthSaveRequestVO {
private Long practitionerId; private Long practitionerId;
/**
* 目标类型:1:经纪人指标,2:团队指标
*/
private Integer goalsType;
private List<SalesTargetActions> salesTargetActionsList; private List<SalesTargetActions> salesTargetActionsList;
} }
...@@ -5,4 +5,5 @@ import lombok.Data; ...@@ -5,4 +5,5 @@ import lombok.Data;
@Data @Data
public class SalesTargetQueryRequestVO { public class SalesTargetQueryRequestVO {
private Long practitionerId; private Long practitionerId;
private Integer goalsType;
} }
...@@ -22,5 +22,9 @@ public class SalesTargetSaveRequestVO { ...@@ -22,5 +22,9 @@ public class SalesTargetSaveRequestVO {
* 均价 * 均价
*/ */
private Integer pieceAveragePremium; private Integer pieceAveragePremium;
/**
* 目标类型:1:经纪人指标,2:团队指标
*/
private Integer goalsType;
private List<SalesTargetMonth> salesTargetMonths; private List<SalesTargetMonth> salesTargetMonths;
} }
...@@ -6,8 +6,57 @@ import lombok.Data; ...@@ -6,8 +6,57 @@ import lombok.Data;
@Data @Data
public class TeamActionsAverageQueryResponseVO { public class TeamActionsAverageQueryResponseVO {
/**
* 天均分
*/
private Double scoreDayAverage; private Double scoreDayAverage;
/**
* 天均分
*/
private Double scoreWeekAverage; private Double scoreWeekAverage;
/**
* 月均分
*/
private Double scoreMonthAverage; private Double scoreMonthAverage;
/**
* 本周新增商机
*/
private Integer opportunitiesNum;
/**
* 月平均保费
*/
private Double premiumMonthAverage;
/**
* 月平均佣金
*/
private Double commissionMonthAverage;
/**
* 月平均件数
*/
private Double piecesMonthAverage;
/**
* 季度平均保费
*/
private Double premiumQuarterAverage;
/**
* 季度平均佣金
*/
private Double commissionQuarterAverage;
/**
* 季度平均件数
*/
private Double piecesQuarterAverage;
/**
* 年平均保费
*/
private Double premiumYearAverage;
/**
* 年平均佣金
*/
private Double commissionYearAverage;
/**
* 年平均件数
*/
private Double piecesYearAverage;
private CommonResult commonResult; private CommonResult commonResult;
} }
...@@ -4,7 +4,7 @@ import java.util.Date; ...@@ -4,7 +4,7 @@ import java.util.Date;
import lombok.Data; import lombok.Data;
/** /**
* 经纪人商机目标设定 * 经纪人(或团队长)商机目标设定
*/ */
@Data @Data
public class MktLeadsGoals { public class MktLeadsGoals {
...@@ -14,11 +14,26 @@ public class MktLeadsGoals { ...@@ -14,11 +14,26 @@ public class MktLeadsGoals {
private Long id; private Long id;
/** /**
* FK ag_acl_practitioner.id 经纪人 * 目标类型:1:经纪人指标,2:团队指标
*/
private Integer goalsType;
/**
* FK ag_acl_practitioner.id 经纪人(或团队长)
*/ */
private Long practitionerId; private Long practitionerId;
/** /**
* FK ag_acl_practitioner_subordinate_system.id 团队ID
*/
private Long subordinateSystemId;
/**
* FK ag_acl_practitioner_subordinate_system.name 团队Name
*/
private String subordinateSystemName;
/**
* 目标所属年度 * 目标所属年度
*/ */
private Integer currentYear; private Integer currentYear;
......
...@@ -4,7 +4,7 @@ import java.util.Date; ...@@ -4,7 +4,7 @@ import java.util.Date;
import lombok.Data; import lombok.Data;
/** /**
* 经纪人商机活动量分摊细化设置 * 经纪人(或团队长)商机活动量分摊细化设置
*/ */
@Data @Data
public class MktLeadsGoalsActions { public class MktLeadsGoalsActions {
...@@ -14,7 +14,12 @@ public class MktLeadsGoalsActions { ...@@ -14,7 +14,12 @@ public class MktLeadsGoalsActions {
private Long id; private Long id;
/** /**
* FK ag_acl_practitioner.id 经纪人 * 目标类型:1:经纪人指标,2:团队指标
*/
private Integer goalsType;
/**
* FK ag_acl_practitioner.id 经纪人(或团队长)
*/ */
private Long practitionerId; private Long practitionerId;
......
...@@ -17,4 +17,6 @@ public interface AclPractitionerSubordinateSystemMapper { ...@@ -17,4 +17,6 @@ public interface AclPractitionerSubordinateSystemMapper {
int updateByPrimaryKey(AclPractitionerSubordinateSystem record); int updateByPrimaryKey(AclPractitionerSubordinateSystem record);
PractitionerSubordinateInfo findSubordinateInfo(Long subordinateId); PractitionerSubordinateInfo findSubordinateInfo(Long subordinateId);
AclPractitionerSubordinateSystem findByPractitionerId(Long practitionerId);
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package com.yd.dal.mapper.marketing; ...@@ -3,6 +3,8 @@ package com.yd.dal.mapper.marketing;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.yd.dal.entity.marketing.MktLeadsAssignedTrack; import com.yd.dal.entity.marketing.MktLeadsAssignedTrack;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface MktLeadsAssignedTrackMapper { public interface MktLeadsAssignedTrackMapper {
...@@ -22,5 +24,5 @@ public interface MktLeadsAssignedTrackMapper { ...@@ -22,5 +24,5 @@ public interface MktLeadsAssignedTrackMapper {
List<MktLeadsAssignedTrack> findByTrackTimeForNew(MktLeadsAssignedTrack mktLeadsAssignedTrack); List<MktLeadsAssignedTrack> findByTrackTimeForNew(MktLeadsAssignedTrack mktLeadsAssignedTrack);
List<Integer> totalStatisticsForTeam(List<Long> practitionerIds); HashMap<String, BigDecimal> totalStatisticsForTeam(List<Long> practitionerIds);
} }
\ No newline at end of file
package com.yd.dal.mapper.marketing; package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsAssigneds;import java.util.List; import com.yd.dal.entity.marketing.MktLeadsAssigneds;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
public interface MktLeadsAssignedsMapper { public interface MktLeadsAssignedsMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
...@@ -18,4 +23,8 @@ public interface MktLeadsAssignedsMapper { ...@@ -18,4 +23,8 @@ public interface MktLeadsAssignedsMapper {
List<MktLeadsAssigneds> findByMktLeadsAssigneds(MktLeadsAssigneds mktLeadsAssigneds); List<MktLeadsAssigneds> findByMktLeadsAssigneds(MktLeadsAssigneds mktLeadsAssigneds);
List<MktLeadsAssigneds> findByPractitionerIdAndThisWeek(Long practitionerId); List<MktLeadsAssigneds> findByPractitionerIdAndThisWeek(Long practitionerId);
Integer countPractitionerIdsAndThisWeek(List<Long> practitionerIds);
HashMap<String, BigDecimal> performanceForecastForTeam(@Param("practitionerIds") List<Long> practitionerIds,@Param("refusedId") Long refusedId);
} }
\ No newline at end of file
package com.yd.dal.mapper.marketing; package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsGoalsActions; import com.yd.dal.entity.marketing.MktLeadsGoalsActions;import org.apache.ibatis.annotations.Param;import java.util.List;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MktLeadsGoalsActionsMapper { public interface MktLeadsGoalsActionsMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
...@@ -18,7 +15,7 @@ public interface MktLeadsGoalsActionsMapper { ...@@ -18,7 +15,7 @@ public interface MktLeadsGoalsActionsMapper {
int updateByPrimaryKey(MktLeadsGoalsActions record); int updateByPrimaryKey(MktLeadsGoalsActions record);
void updateIsActiveIsNull(@Param("practitionerId") Long practitionerId,@Param("year") Integer year); void updateIsActiveIsNull(@Param("practitionerId") Long practitionerId, @Param("year") Integer year, @Param("goalsType") Integer goalsType);
List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions); List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions);
} }
\ No newline at end of file
package com.yd.dal.mapper.marketing; package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.marketing.MktLeadsGoals;import org.apache.ibatis.annotations.Param; import com.yd.dal.entity.marketing.MktLeadsGoals;import org.apache.ibatis.annotations.Param;import java.util.List;
import java.util.List;
public interface MktLeadsGoalsMapper { public interface MktLeadsGoalsMapper {
int deleteByPrimaryKey(Long id); int deleteByPrimaryKey(Long id);
...@@ -17,7 +15,7 @@ public interface MktLeadsGoalsMapper { ...@@ -17,7 +15,7 @@ public interface MktLeadsGoalsMapper {
int updateByPrimaryKey(MktLeadsGoals record); int updateByPrimaryKey(MktLeadsGoals record);
void updateIsActiveIsNull(@Param("practitionerId") Long practitionerId, @Param("year") Integer year); void updateIsActiveIsNull(@Param("practitionerId") Long practitionerId, @Param("year") Integer year, @Param("goalsType") Integer goalsType);
List<MktLeadsGoals> selectByMktLeadsGoals(MktLeadsGoals mktLeadsGoals); List<MktLeadsGoals> selectByMktLeadsGoals(MktLeadsGoals mktLeadsGoals);
} }
\ No newline at end of file
package com.yd.dal.service.customer; package com.yd.dal.service.customer;
import com.yd.dal.entity.customer.AclPractitionerSubordinateSystem;
import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo; import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service("aclPractitionerSubordinateSystemDALService") @Service("aclPractitionerSubordinateSystemDALService")
public interface AclPractitionerSubordinateSystemDALService { public interface AclPractitionerSubordinateSystemDALService {
PractitionerSubordinateInfo findSubordinateInfo(Long subordinateId); PractitionerSubordinateInfo findSubordinateInfo(Long subordinateId);
AclPractitionerSubordinateSystem findByPractitionerId(Long practitionerId);
} }
package com.yd.dal.service.customer.impl; package com.yd.dal.service.customer.impl;
import com.yd.dal.entity.customer.AclPractitionerSubordinateSystem;
import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo; import com.yd.dal.entity.customer.practitioner.PractitionerSubordinateInfo;
import com.yd.dal.mapper.customer.AclPractitionerSubordinateSystemMapper; import com.yd.dal.mapper.customer.AclPractitionerSubordinateSystemMapper;
import com.yd.dal.service.customer.AclPractitionerSubordinateSystemDALService; import com.yd.dal.service.customer.AclPractitionerSubordinateSystemDALService;
...@@ -24,4 +25,9 @@ public class AclPractitionerSubordinateSystemDALServiceImpl implements AclPracti ...@@ -24,4 +25,9 @@ public class AclPractitionerSubordinateSystemDALServiceImpl implements AclPracti
} }
return subordinateInfo; return subordinateInfo;
} }
@Override
public AclPractitionerSubordinateSystem findByPractitionerId(Long practitionerId) {
return aclPractitionerSubordinateSystemMapper.findByPractitionerId(practitionerId);
}
} }
...@@ -8,6 +8,8 @@ import com.yd.dal.service.marketing.MktLeadsAssignedTrackDALService; ...@@ -8,6 +8,8 @@ import com.yd.dal.service.marketing.MktLeadsAssignedTrackDALService;
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.HashMap;
import java.util.List; import java.util.List;
@Service("mktLeadsAssignedTrackDALService") @Service("mktLeadsAssignedTrackDALService")
...@@ -39,7 +41,7 @@ public class MktLeadsAssignedTrackDALServiceImpl implements MktLeadsAssignedTrac ...@@ -39,7 +41,7 @@ public class MktLeadsAssignedTrackDALServiceImpl implements MktLeadsAssignedTrac
} }
@Override @Override
public List<Integer> totalStatisticsForTeam(List<Long> practitionerIds) { public HashMap<String, BigDecimal> totalStatisticsForTeam(List<Long> practitionerIds) {
return mktLeadsAssignedTrackMapper.totalStatisticsForTeam(practitionerIds); return mktLeadsAssignedTrackMapper.totalStatisticsForTeam(practitionerIds);
} }
} }
...@@ -6,6 +6,8 @@ import com.yd.dal.service.marketing.MktLeadsAssignedsDALService; ...@@ -6,6 +6,8 @@ import com.yd.dal.service.marketing.MktLeadsAssignedsDALService;
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.HashMap;
import java.util.List; import java.util.List;
@Service("mktLeadsAssignedsDALService") @Service("mktLeadsAssignedsDALService")
...@@ -37,4 +39,14 @@ public class MktLeadsAssignedsDALServiceImpl implements MktLeadsAssignedsDALServ ...@@ -37,4 +39,14 @@ public class MktLeadsAssignedsDALServiceImpl implements MktLeadsAssignedsDALServ
public List<MktLeadsAssigneds> findByPractitionerIdAndThisWeek(Long practitionerId) { public List<MktLeadsAssigneds> findByPractitionerIdAndThisWeek(Long practitionerId) {
return mktLeadsAssignedsMapper.findByPractitionerIdAndThisWeek(practitionerId); return mktLeadsAssignedsMapper.findByPractitionerIdAndThisWeek(practitionerId);
} }
@Override
public Integer countPractitionerIdsAndThisWeek(List<Long> practitionerIds) {
return mktLeadsAssignedsMapper.countPractitionerIdsAndThisWeek(practitionerIds);
}
@Override
public HashMap<String, BigDecimal> performanceForecastForTeam(List<Long> practitionerIds,Long refusedId) {
return mktLeadsAssignedsMapper.performanceForecastForTeam(practitionerIds,refusedId);
}
} }
...@@ -20,8 +20,8 @@ public class MktLeadsGoalsActionsDALServiceImpl implements MktLeadsGoalsActionsD ...@@ -20,8 +20,8 @@ public class MktLeadsGoalsActionsDALServiceImpl implements MktLeadsGoalsActionsD
} }
@Override @Override
public void updateIsActiveIsNull(Long practitionerId, int year) { public void updateIsActiveIsNull(Long practitionerId, int year,Integer goalsType) {
mktLeadsGoalsActionsMapper.updateIsActiveIsNull(practitionerId, year); mktLeadsGoalsActionsMapper.updateIsActiveIsNull(practitionerId, year,goalsType);
} }
@Override @Override
......
...@@ -6,6 +6,8 @@ import com.yd.dal.service.marketing.MktLeadsGoalsDALService; ...@@ -6,6 +6,8 @@ import com.yd.dal.service.marketing.MktLeadsGoalsDALService;
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.HashMap;
import java.util.List; import java.util.List;
@Service("mktLeadsGoalsDALService") @Service("mktLeadsGoalsDALService")
...@@ -20,12 +22,13 @@ public class MktLeadsGoalsDALServiceImpl implements MktLeadsGoalsDALService { ...@@ -20,12 +22,13 @@ public class MktLeadsGoalsDALServiceImpl implements MktLeadsGoalsDALService {
} }
@Override @Override
public void updateIsActiveIsNull(Long practitionerId, Integer year) { public void updateIsActiveIsNull(Long practitionerId, Integer year,Integer goalsType) {
mktLeadsGoalsMapper.updateIsActiveIsNull(practitionerId, year) ; mktLeadsGoalsMapper.updateIsActiveIsNull(practitionerId, year,goalsType) ;
} }
@Override @Override
public List<MktLeadsGoals> findByMktLeadsGoals(MktLeadsGoals mktLeadsGoals) { public List<MktLeadsGoals> findByMktLeadsGoals(MktLeadsGoals mktLeadsGoals) {
return mktLeadsGoalsMapper.selectByMktLeadsGoals(mktLeadsGoals); return mktLeadsGoalsMapper.selectByMktLeadsGoals(mktLeadsGoals);
} }
} }
...@@ -2,6 +2,8 @@ package com.yd.dal.service.marketing; ...@@ -2,6 +2,8 @@ package com.yd.dal.service.marketing;
import com.yd.dal.entity.marketing.MktLeadsAssignedTrack; import com.yd.dal.entity.marketing.MktLeadsAssignedTrack;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface MktLeadsAssignedTrackDALService { public interface MktLeadsAssignedTrackDALService {
...@@ -13,5 +15,10 @@ public interface MktLeadsAssignedTrackDALService { ...@@ -13,5 +15,10 @@ public interface MktLeadsAssignedTrackDALService {
List<MktLeadsAssignedTrack> findByTrackTimeForNew(MktLeadsAssignedTrack mktLeadsAssignedTrack); List<MktLeadsAssignedTrack> findByTrackTimeForNew(MktLeadsAssignedTrack mktLeadsAssignedTrack);
List<Integer> totalStatisticsForTeam(List<Long> practitionerIds); /**
* 计算经纪人得分统计
* @param practitionerIds 经纪人id的list
* @return 返回他们的分数统计 1.天得分 2.周得分 3.月得分
*/
HashMap<String, BigDecimal> totalStatisticsForTeam(List<Long> practitionerIds);
} }
...@@ -2,6 +2,8 @@ package com.yd.dal.service.marketing; ...@@ -2,6 +2,8 @@ package com.yd.dal.service.marketing;
import com.yd.dal.entity.marketing.MktLeadsAssigneds; import com.yd.dal.entity.marketing.MktLeadsAssigneds;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface MktLeadsAssignedsDALService { public interface MktLeadsAssignedsDALService {
...@@ -14,4 +16,15 @@ public interface MktLeadsAssignedsDALService { ...@@ -14,4 +16,15 @@ public interface MktLeadsAssignedsDALService {
void save(MktLeadsAssigneds assigneds); void save(MktLeadsAssigneds assigneds);
List<MktLeadsAssigneds> findByPractitionerIdAndThisWeek(Long practitionerId); List<MktLeadsAssigneds> findByPractitionerIdAndThisWeek(Long practitionerId);
/**
* 统计这些经纪人id本周一共新增多少商机
*/
Integer countPractitionerIdsAndThisWeek(List<Long> practitionerIds);
/**
* 计算年/季/月 首年保费(premium)/佣金(commission)/件数(pieces) 均取至指派表ag_mkt_leads_assigneds
* ag_mkt_leads_assigned_track跟进记录不可有"拒绝" md_drop_option_id = 102 (传入)
*/
HashMap<String, BigDecimal> performanceForecastForTeam(List<Long> practitionerIds,Long refusedId);
} }
...@@ -7,7 +7,7 @@ import java.util.List; ...@@ -7,7 +7,7 @@ import java.util.List;
public interface MktLeadsGoalsActionsDALService { public interface MktLeadsGoalsActionsDALService {
void save(MktLeadsGoalsActions mktLeadsGoalsActions); void save(MktLeadsGoalsActions mktLeadsGoalsActions);
void updateIsActiveIsNull(Long practitionerId, int year); void updateIsActiveIsNull(Long practitionerId, int year,Integer goalsType);
List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions); List<MktLeadsGoalsActions> findByMktLeadsGoalsActions(MktLeadsGoalsActions mktLeadsGoalsActions);
} }
...@@ -2,12 +2,15 @@ package com.yd.dal.service.marketing; ...@@ -2,12 +2,15 @@ package com.yd.dal.service.marketing;
import com.yd.dal.entity.marketing.MktLeadsGoals; import com.yd.dal.entity.marketing.MktLeadsGoals;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface MktLeadsGoalsDALService { public interface MktLeadsGoalsDALService {
void saveMktLeadsGoals(MktLeadsGoals mktLeadsGoals); void saveMktLeadsGoals(MktLeadsGoals mktLeadsGoals);
void updateIsActiveIsNull(Long practitionerId, Integer year); void updateIsActiveIsNull(Long practitionerId, Integer year,Integer goalsType);
List<MktLeadsGoals> findByMktLeadsGoals(MktLeadsGoals mktLeadsGoals); List<MktLeadsGoals> findByMktLeadsGoals(MktLeadsGoals mktLeadsGoals);
} }
...@@ -242,4 +242,10 @@ ...@@ -242,4 +242,10 @@
and s.id = #{subordinateId} and s.id = #{subordinateId}
</select> </select>
<select id="findByPractitionerId" resultMap="BaseResultMap">
select s.*
from ag_acl_practitioner_subordinate_system s
left join ag_acl_practitioner p on p.subordinate_system_id = s.id
where p.id = #{practitionerId,jdbcType=BIGINT}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -323,30 +323,13 @@ ...@@ -323,30 +323,13 @@
</if> </if>
</where> </where>
</select> </select>
<select id="totalStatisticsForTeam" resultType="integer"> <select id="totalStatisticsForTeam" resultType="hashmap">
SELECT sum(track_score) as scoreToday select sum(case when to_days(track_time) = to_days(now()) then track_score end) scoreToday,
FROM ag_mkt_leads_assigned_track sum(case when YEARWEEK(date_format(track_time,'%Y-%m-%d')) = YEARWEEK(now()) then track_score end) scoreWeek,
where is_active = 1 sum(case when date_format(track_time,'%Y-%m')=date_format(now(),'%Y-%m') then track_score end) scoreMonth
and to_days(track_time) = to_days(now()) from ag_mkt_leads_assigned_track
and practitioner_id in where is_active = 1
<foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=","> and practitioner_id in
#{practitionerId,jdbcType=BIGINT}
</foreach>
UNION all
SELECT sum(track_score) as scoreWeek
FROM ag_mkt_leads_assigned_track
where is_active = 1
and YEARWEEK(date_format(track_time,'%Y-%m-%d')) = YEARWEEK(now())
and practitioner_id in
<foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT}
</foreach>
UNION all
SELECT sum(track_score) as scoreMonth
FROM ag_mkt_leads_assigned_track
where is_active = 1
and date_format(track_time,'%Y-%m')=date_format(now(),'%Y-%m')
and practitioner_id in
<foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=","> <foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT} #{practitionerId,jdbcType=BIGINT}
</foreach> </foreach>
......
...@@ -243,4 +243,40 @@ ...@@ -243,4 +243,40 @@
assigned_practitioner_id = #{practitionerId,jdbcType=BIGINT} assigned_practitioner_id = #{practitionerId,jdbcType=BIGINT}
and YEARWEEK(date_format(created_at,'%Y-%m-%d')) = YEARWEEK(now()) and YEARWEEK(date_format(created_at,'%Y-%m-%d')) = YEARWEEK(now())
</select> </select>
<select id="countPractitionerIdsAndThisWeek" resultType="integer">
select
count(*)
from ag_mkt_leads_assigneds
where
assigned_practitioner_id in
<foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT}
</foreach>
and YEARWEEK(date_format(created_at,'%Y-%m-%d')) = YEARWEEK(now())
</select>
<select id="performanceForecastForTeam" resultType="hashmap">
select sum(case when date_format(time_to_close,'%Y-%m')=date_format(now(),'%Y-%m') then FYC end) totalFYCMonth,
sum(case when date_format(time_to_close,'%Y-%m')=date_format(now(),'%Y-%m') then FYP end) totalFYPMonth,
sum(case when date_format(time_to_close,'%Y-%m')=date_format(now(),'%Y-%m') then pieces end) totalPiecesMonth,
sum(case when QUARTER(time_to_close)=QUARTER(now()) then FYC end) totalFYCQuarter,
sum(case when QUARTER(time_to_close)=QUARTER(now()) then FYP end) totalFYPQuarter,
sum(case when QUARTER(time_to_close)=QUARTER(now()) then pieces end) totalPiecesQuarter,
sum(case when YEAR(time_to_close)=YEAR(NOW()) then FYC end) totalFYCYear,
sum(case when YEAR(time_to_close)=YEAR(NOW()) then FYP end) totalFYPYear,
sum(case when YEAR(time_to_close)=YEAR(NOW()) then pieces end) totalPiecesYear
from ag_mkt_leads_assigneds a
where a.is_active=1
and a.assigned_practitioner_id in
<foreach collection="practitionerIds" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT}
</foreach>
and not EXISTS (select t.leads_assigned_id
from ag_mkt_leads_assigned_track t
where t.md_drop_option_id = #{refusedId,jdbcType=BIGINT}
and t.practitioner_id in
<foreach collection="practitionerIds" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT}
</foreach>
and a.id = t.leads_assigned_id)
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<!--@mbg.generated--> <!--@mbg.generated-->
<!--@Table ag_mkt_leads_goals_actions--> <!--@Table ag_mkt_leads_goals_actions-->
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="goals_type" jdbcType="INTEGER" property="goalsType" />
<result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" /> <result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" />
<result column="current_year" jdbcType="INTEGER" property="currentYear" /> <result column="current_year" jdbcType="INTEGER" property="currentYear" />
<result column="statistic_time_unit" jdbcType="INTEGER" property="statisticTimeUnit" /> <result column="statistic_time_unit" jdbcType="INTEGER" property="statisticTimeUnit" />
...@@ -20,9 +21,9 @@ ...@@ -20,9 +21,9 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, practitioner_id, current_year, statistic_time_unit, leads_action_id, leads_action_name, id, goals_type, practitioner_id, current_year, statistic_time_unit, leads_action_id,
action_standards, current_version, is_active, created_at, created_by, updated_at, leads_action_name, action_standards, current_version, is_active, created_at, created_by,
updated_by updated_at, updated_by
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated--> <!--@mbg.generated-->
...@@ -38,21 +39,24 @@ ...@@ -38,21 +39,24 @@
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsGoalsActions" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsGoalsActions" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into ag_mkt_leads_goals_actions (practitioner_id, current_year, statistic_time_unit, insert into ag_mkt_leads_goals_actions (goals_type, practitioner_id, current_year,
leads_action_id, leads_action_name, action_standards, statistic_time_unit, leads_action_id, leads_action_name,
current_version, is_active, created_at, action_standards, current_version, is_active,
created_by, updated_at, updated_by created_at, created_by, updated_at,
) updated_by)
values (#{practitionerId,jdbcType=BIGINT}, #{currentYear,jdbcType=INTEGER}, #{statisticTimeUnit,jdbcType=INTEGER}, values (#{goalsType,jdbcType=INTEGER}, #{practitionerId,jdbcType=BIGINT}, #{currentYear,jdbcType=INTEGER},
#{leadsActionId,jdbcType=BIGINT}, #{leadsActionName,jdbcType=VARCHAR}, #{actionStandards,jdbcType=INTEGER}, #{statisticTimeUnit,jdbcType=INTEGER}, #{leadsActionId,jdbcType=BIGINT}, #{leadsActionName,jdbcType=VARCHAR},
#{currentVersion,jdbcType=TIMESTAMP}, #{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{actionStandards,jdbcType=INTEGER}, #{currentVersion,jdbcType=TIMESTAMP}, #{isActive,jdbcType=INTEGER},
#{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=BIGINT} #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{updatedAt,jdbcType=TIMESTAMP},
) #{updatedBy,jdbcType=BIGINT})
</insert> </insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsGoalsActions" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsGoalsActions" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into ag_mkt_leads_goals_actions insert into ag_mkt_leads_goals_actions
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="goalsType != null">
goals_type,
</if>
<if test="practitionerId != null"> <if test="practitionerId != null">
practitioner_id, practitioner_id,
</if> </if>
...@@ -91,6 +95,9 @@ ...@@ -91,6 +95,9 @@
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="goalsType != null">
#{goalsType,jdbcType=INTEGER},
</if>
<if test="practitionerId != null"> <if test="practitionerId != null">
#{practitionerId,jdbcType=BIGINT}, #{practitionerId,jdbcType=BIGINT},
</if> </if>
...@@ -133,6 +140,9 @@ ...@@ -133,6 +140,9 @@
<!--@mbg.generated--> <!--@mbg.generated-->
update ag_mkt_leads_goals_actions update ag_mkt_leads_goals_actions
<set> <set>
<if test="goalsType != null">
goals_type = #{goalsType,jdbcType=INTEGER},
</if>
<if test="practitionerId != null"> <if test="practitionerId != null">
practitioner_id = #{practitionerId,jdbcType=BIGINT}, practitioner_id = #{practitionerId,jdbcType=BIGINT},
</if> </if>
...@@ -175,7 +185,8 @@ ...@@ -175,7 +185,8 @@
<update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.marketing.MktLeadsGoalsActions"> <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.marketing.MktLeadsGoalsActions">
<!--@mbg.generated--> <!--@mbg.generated-->
update ag_mkt_leads_goals_actions update ag_mkt_leads_goals_actions
set practitioner_id = #{practitionerId,jdbcType=BIGINT}, set goals_type = #{goalsType,jdbcType=INTEGER},
practitioner_id = #{practitionerId,jdbcType=BIGINT},
current_year = #{currentYear,jdbcType=INTEGER}, current_year = #{currentYear,jdbcType=INTEGER},
statistic_time_unit = #{statisticTimeUnit,jdbcType=INTEGER}, statistic_time_unit = #{statisticTimeUnit,jdbcType=INTEGER},
leads_action_id = #{leadsActionId,jdbcType=BIGINT}, leads_action_id = #{leadsActionId,jdbcType=BIGINT},
...@@ -196,6 +207,7 @@ ...@@ -196,6 +207,7 @@
where where
practitioner_id = #{practitionerId,jdbcType=BIGINT} practitioner_id = #{practitionerId,jdbcType=BIGINT}
and current_year = #{year,jdbcType=INTEGER} and current_year = #{year,jdbcType=INTEGER}
and goals_type = #{goalsType,jdbcType=INTEGER}
and is_active =1; and is_active =1;
</update> </update>
<select id="findByMktLeadsGoalsActions" resultMap="BaseResultMap"> <select id="findByMktLeadsGoalsActions" resultMap="BaseResultMap">
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
<!--@mbg.generated--> <!--@mbg.generated-->
<!--@Table ag_mkt_leads_goals--> <!--@Table ag_mkt_leads_goals-->
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="goals_type" jdbcType="INTEGER" property="goalsType" />
<result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" /> <result column="practitioner_id" jdbcType="BIGINT" property="practitionerId" />
<result column="subordinate_system_id" jdbcType="BIGINT" property="subordinateSystemId" />
<result column="subordinate_system_name" jdbcType="VARCHAR" property="subordinateSystemName" />
<result column="current_year" jdbcType="INTEGER" property="currentYear" /> <result column="current_year" jdbcType="INTEGER" property="currentYear" />
<result column="statistic_time_unit" jdbcType="INTEGER" property="statisticTimeUnit" /> <result column="statistic_time_unit" jdbcType="INTEGER" property="statisticTimeUnit" />
<result column="seq_time" jdbcType="INTEGER" property="seqTime" /> <result column="seq_time" jdbcType="INTEGER" property="seqTime" />
...@@ -22,9 +25,9 @@ ...@@ -22,9 +25,9 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, practitioner_id, current_year, statistic_time_unit, seq_time, premium, commission, id, goals_type, practitioner_id, subordinate_system_id, subordinate_system_name,
pieces, piece_average_premium, current_version, is_active, created_at, created_by, current_year, statistic_time_unit, seq_time, premium, commission, pieces, piece_average_premium,
updated_at, updated_by current_version, is_active, created_at, created_by, updated_at, updated_by
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated--> <!--@mbg.generated-->
...@@ -40,12 +43,14 @@ ...@@ -40,12 +43,14 @@
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsGoals" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.marketing.MktLeadsGoals" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
insert into ag_mkt_leads_goals (practitioner_id, current_year, statistic_time_unit, insert into ag_mkt_leads_goals (goals_type, practitioner_id, subordinate_system_id,
subordinate_system_name, current_year, statistic_time_unit,
seq_time, premium, commission, seq_time, premium, commission,
pieces, piece_average_premium, current_version, pieces, piece_average_premium, current_version,
is_active, created_at, created_by, is_active, created_at, created_by,
updated_at, updated_by) updated_at, updated_by)
values (#{practitionerId,jdbcType=BIGINT}, #{currentYear,jdbcType=INTEGER}, #{statisticTimeUnit,jdbcType=INTEGER}, values (#{goalsType,jdbcType=INTEGER}, #{practitionerId,jdbcType=BIGINT}, #{subordinateSystemId,jdbcType=BIGINT},
#{subordinateSystemName,jdbcType=VARCHAR}, #{currentYear,jdbcType=INTEGER}, #{statisticTimeUnit,jdbcType=INTEGER},
#{seqTime,jdbcType=INTEGER}, #{premium,jdbcType=INTEGER}, #{commission,jdbcType=INTEGER}, #{seqTime,jdbcType=INTEGER}, #{premium,jdbcType=INTEGER}, #{commission,jdbcType=INTEGER},
#{pieces,jdbcType=INTEGER}, #{pieceAveragePremium,jdbcType=INTEGER}, #{currentVersion,jdbcType=TIMESTAMP}, #{pieces,jdbcType=INTEGER}, #{pieceAveragePremium,jdbcType=INTEGER}, #{currentVersion,jdbcType=TIMESTAMP},
#{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT}, #{isActive,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=BIGINT},
...@@ -55,9 +60,18 @@ ...@@ -55,9 +60,18 @@
<!--@mbg.generated--> <!--@mbg.generated-->
insert into ag_mkt_leads_goals insert into ag_mkt_leads_goals
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="goalsType != null">
goals_type,
</if>
<if test="practitionerId != null"> <if test="practitionerId != null">
practitioner_id, practitioner_id,
</if> </if>
<if test="subordinateSystemId != null">
subordinate_system_id,
</if>
<if test="subordinateSystemName != null">
subordinate_system_name,
</if>
<if test="currentYear != null"> <if test="currentYear != null">
current_year, current_year,
</if> </if>
...@@ -99,9 +113,18 @@ ...@@ -99,9 +113,18 @@
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="goalsType != null">
#{goalsType,jdbcType=INTEGER},
</if>
<if test="practitionerId != null"> <if test="practitionerId != null">
#{practitionerId,jdbcType=BIGINT}, #{practitionerId,jdbcType=BIGINT},
</if> </if>
<if test="subordinateSystemId != null">
#{subordinateSystemId,jdbcType=BIGINT},
</if>
<if test="subordinateSystemName != null">
#{subordinateSystemName,jdbcType=VARCHAR},
</if>
<if test="currentYear != null"> <if test="currentYear != null">
#{currentYear,jdbcType=INTEGER}, #{currentYear,jdbcType=INTEGER},
</if> </if>
...@@ -147,9 +170,18 @@ ...@@ -147,9 +170,18 @@
<!--@mbg.generated--> <!--@mbg.generated-->
update ag_mkt_leads_goals update ag_mkt_leads_goals
<set> <set>
<if test="goalsType != null">
goals_type = #{goalsType,jdbcType=INTEGER},
</if>
<if test="practitionerId != null"> <if test="practitionerId != null">
practitioner_id = #{practitionerId,jdbcType=BIGINT}, practitioner_id = #{practitionerId,jdbcType=BIGINT},
</if> </if>
<if test="subordinateSystemId != null">
subordinate_system_id = #{subordinateSystemId,jdbcType=BIGINT},
</if>
<if test="subordinateSystemName != null">
subordinate_system_name = #{subordinateSystemName,jdbcType=VARCHAR},
</if>
<if test="currentYear != null"> <if test="currentYear != null">
current_year = #{currentYear,jdbcType=INTEGER}, current_year = #{currentYear,jdbcType=INTEGER},
</if> </if>
...@@ -195,7 +227,10 @@ ...@@ -195,7 +227,10 @@
<update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.marketing.MktLeadsGoals"> <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.marketing.MktLeadsGoals">
<!--@mbg.generated--> <!--@mbg.generated-->
update ag_mkt_leads_goals update ag_mkt_leads_goals
set practitioner_id = #{practitionerId,jdbcType=BIGINT}, set goals_type = #{goalsType,jdbcType=INTEGER},
practitioner_id = #{practitionerId,jdbcType=BIGINT},
subordinate_system_id = #{subordinateSystemId,jdbcType=BIGINT},
subordinate_system_name = #{subordinateSystemName,jdbcType=VARCHAR},
current_year = #{currentYear,jdbcType=INTEGER}, current_year = #{currentYear,jdbcType=INTEGER},
statistic_time_unit = #{statisticTimeUnit,jdbcType=INTEGER}, statistic_time_unit = #{statisticTimeUnit,jdbcType=INTEGER},
seq_time = #{seqTime,jdbcType=INTEGER}, seq_time = #{seqTime,jdbcType=INTEGER},
...@@ -216,6 +251,7 @@ ...@@ -216,6 +251,7 @@
SET is_active = 0 SET is_active = 0
WHERE practitioner_id = #{practitionerId,jdbcType=BIGINT} WHERE practitioner_id = #{practitionerId,jdbcType=BIGINT}
AND current_year = #{year,jdbcType=INTEGER} AND current_year = #{year,jdbcType=INTEGER}
and goals_type = #{goalsType,jdbcType=INTEGER}
AND is_active = 1; AND is_active = 1;
</update> </update>
<select id="selectByMktLeadsGoals" resultMap="BaseResultMap"> <select id="selectByMktLeadsGoals" resultMap="BaseResultMap">
......
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