Commit 337034b7 by Simon Cheng

Merge remote-tracking branch 'origin/dev_20200908_PEP_Statistics' into dev

parents 3db5a4f0 32045435
......@@ -2,6 +2,7 @@ package com.yd.api.practitioner;
import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.service.PractitionerService;
import com.yd.api.practitioner.service.ScheduleTrackService;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginResponseVO;
import com.yd.api.practitioner.vo.media.MediaGetReqVO;
......@@ -21,6 +22,7 @@ import com.yd.api.practitioner.vo.rank.PractitionerRankRequestVO;
import com.yd.api.practitioner.vo.rank.PractitionerRankResponseVO;
import com.yd.api.practitioner.vo.recruit.*;
import com.yd.api.practitioner.vo.salestarget.*;
import com.yd.api.practitioner.vo.sechedule.*;
import com.yd.api.practitioner.vo.setting.*;
import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryRequestVO;
import com.yd.api.practitioner.vo.subordinate.SubordinateSystemMemberQueryResponseVO;
......@@ -29,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
@RestController
@RequestMapping("/practitioner")
......@@ -38,7 +41,8 @@ public class PractitionerController {
private PractitionerService practitionerService;
@Autowired
private PractitionerBasicInfoService practitionerBasicInfoService;
@Autowired
private ScheduleTrackService scheduleTrackService;
/**
* 经纪人登录
* @param requestVO 请求数据
......@@ -501,4 +505,75 @@ public class PractitionerController {
result.setData(responseVO);
return result;
}
/**
* 新建日程
* @param requestVO
* @return
*/
@RequestMapping("/addScheduleTrack")
public Object addScheduleTrack(@RequestBody AddScheduleTrackRequestVO requestVO){
JsonResult result = new JsonResult();
AddScheduleTrackResponseVO responseVO = scheduleTrackService.insert(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* 根据经纪人id查询日程列表
* @param requestVO
* @return
*/
@RequestMapping("/queryScheduleTrackList")
public Object queryScheduleTrackList(@RequestBody QueryScheduleTrackListRequestVO requestVO){
JsonResult result = new JsonResult();
QueryScheduleTrackListResponseVO responseVO = scheduleTrackService.queryScheduleTrackList(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* 根据id删除日程记录
* @param requestVO
* @return
*/
@RequestMapping("/deleteScheduleTrackById")
public Object deleteScheduleTrackById(@RequestBody DeleteScheduleTrackByIdRequestVO requestVO){
JsonResult result = new JsonResult();
DeleteScheduleByIdResponseVO responseVO = scheduleTrackService.deleteScheduleTrackById(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* 查询战队PEP得分
* @param requestVO
* @return
*/
@RequestMapping("/queryPEPScore")
public Object queryPEPScore(@RequestBody QueryPEPScoreRequestVO requestVO){
JsonResult result = new JsonResult();
QueryPEPScoreResponseVO responseVO = scheduleTrackService.queryPEPScore(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* 查询个人PEP得分详情
* @param requestVO
* @return
*/
@RequestMapping("/queryPEPScoreDetail")
public Object queryPEPScoreDetail(@RequestBody QueryPEPScoreDetailRequestVO requestVO){
JsonResult result = new JsonResult();
QueryPEPScoreDetailResponseVO responseVO = scheduleTrackService.queryPEPScoreDetail(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
}
package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.sechedule.*;
import org.springframework.stereotype.Service;
@Service("scheduleTrackService")
public interface ScheduleTrackService {
AddScheduleTrackResponseVO insert(AddScheduleTrackRequestVO requestVO);
QueryScheduleTrackListResponseVO queryScheduleTrackList(QueryScheduleTrackListRequestVO requestVO);
QueryPEPScoreResponseVO queryPEPScore(QueryPEPScoreRequestVO requestVO);
QueryPEPScoreDetailResponseVO queryPEPScoreDetail(QueryPEPScoreDetailRequestVO requestVO);
DeleteScheduleByIdResponseVO deleteScheduleTrackById(DeleteScheduleTrackByIdRequestVO requestVO);
}
package com.yd.api.practitioner.service.impl;
import com.yd.api.practitioner.service.ScheduleTrackService;
import com.yd.api.practitioner.vo.sechedule.*;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.AclPractitionerPotentialAssignedTrack;
import com.yd.dal.entity.marketing.MktLeadsAssignedTrack;
import com.yd.dal.entity.meta.MdDropOptions;
import com.yd.dal.entity.practitioner.*;
import com.yd.dal.mapper.marketing.ScheduleTrackMapper;
import com.yd.dal.service.agms.AgmsDashboardDALService;
import com.yd.dal.service.customer.AclPractitionerPotentialAssignedTrackDALService;
import com.yd.dal.service.marketing.MktLeadsAssignedTrackDALService;
import com.yd.dal.service.meta.MdDropOptionsDALService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Service
public class ScheduleTrackServiceImpl implements ScheduleTrackService {
@Autowired
private ScheduleTrackMapper scheduleTrackMapper;
@Autowired
private AclPractitionerPotentialAssignedTrackDALService aclPractitionerPotentialAssignedTrackDALService;
@Autowired
private MdDropOptionsDALService mdDropOptionsDALService;
@Autowired
private MktLeadsAssignedTrackDALService mktLeadsAssignedTrackDALService;
@Autowired
private AgmsDashboardDALService agmsDashboardDALService;
@Override
public AddScheduleTrackResponseVO insert(AddScheduleTrackRequestVO requestVO) {
// 响应实体
AddScheduleTrackResponseVO resp = new AddScheduleTrackResponseVO();
// 数据库实体
ScheduleTrack schedule = new ScheduleTrack();
BeanUtils.copyProperties(requestVO, schedule);
try {
// id不为空即修改-先删除旧的
Long id = requestVO.getId();
Integer taskType = requestVO.getTaskType();
if (!CommonUtil.isNullOrZero(id)) {
// 根据id删除日程表记录
scheduleTrackMapper.deleteScheduleTrackById(id);
if (Integer.valueOf(1).equals(taskType)) {
// 根据id删除商机表记录
mktLeadsAssignedTrackDALService.deleteScheduleTrackById(id);
}
if (Integer.valueOf(2).equals(taskType)) {
// 根据id删除增员记录
aclPractitionerPotentialAssignedTrackDALService.deleteScheduleTrackById(id);
}
// id置空
schedule.setId(null);
}
String taskTimeFrom = schedule.getTaskTimeFrom();
String taskTimeEnd = schedule.getTaskTimeEnd();
Date trackTime = schedule.getTrackTime();
Long practitionerId = schedule.getPractitionerId();
Long mdDropOptionId = schedule.getMdDropOptionId();
// 判断活动时间段是否冲突
if (!CommonUtil.isNullOrBlank(taskTimeFrom) && !CommonUtil.isNullOrBlank(taskTimeEnd)) {
int count = scheduleTrackMapper.checkTimePeriodConflict(trackTime, taskTimeFrom, taskTimeEnd, practitionerId);
if (count > 0) {
resp.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830020")));
return resp;
}
} else {
resp.setCommonResult(new CommonResult(false, "taskTimeFrom,taskTimeEnd不能为空"));
return resp;
}
Map<Long, MdDropOptions> taskTypeMap = this.getScheduleTaskTypeMap();
Integer trackScore = taskTypeMap.get(mdDropOptionId).getDropOptionScore();
schedule.setTrackScore(trackScore);
schedule.setCreatedBy(practitionerId);
schedule.setUpdatedBy(practitionerId);
schedule.setUpdatorType(2);
schedule.setCreatorType(2);
Date curTime = new Date();
schedule.setUpdatedAt(new Date());
schedule.setCreatedAt(curTime);
scheduleTrackMapper.insert(schedule);
// 营销日程同步插入到商机活动跟踪表,增员日程同步插入到增援活动跟踪表
Long referLeadsId = schedule.getReferLeadsId();
Long referPotentialId = schedule.getReferPotentialId();
if (1 == taskType && null != referLeadsId) {
this.insertOpportunityRecord(schedule);
}
if (2 == taskType && null != referPotentialId) {
this.insertPotentialAssignedTrack(schedule);
}
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
private void insertOpportunityRecord(ScheduleTrack schedule) {
MktLeadsAssignedTrack track = new MktLeadsAssignedTrack();
BeanUtils.copyProperties(schedule, track, "id");
track.setLeadsAssignedId(schedule.getReferLeadsId());
track.setSalesNotice(schedule.getNotice());
track.setScheduleTaskTrackingId(schedule.getId());
List<MktLeadsAssignedTrack> trackList = mktLeadsAssignedTrackDALService.findByTrackTimeForNew(track);
if (trackList.isEmpty()){
//保存
mktLeadsAssignedTrackDALService.saveTrack(track);
} else {
//更新
mktLeadsAssignedTrackDALService.updateTrack(track);
}
}
private void insertPotentialAssignedTrack(ScheduleTrack schedule) {
Long practitionerId = schedule.getPractitionerId();
Long potentialId = schedule.getReferPotentialId();
Long trackStatusId = schedule.getMdDropOptionId();
String notice = schedule.getNotice();
Date trackTimeDate = schedule.getTrackTime();
AclPractitionerPotentialAssignedTrack assignedTrack = new AclPractitionerPotentialAssignedTrack();
List<AclPractitionerPotentialAssignedTrack> assignedTrackIsLastedList = aclPractitionerPotentialAssignedTrackDALService.findByPotentialIdAndIsLasted(potentialId,1);
//1、更新最新的状态
if(assignedTrackIsLastedList != null && !assignedTrackIsLastedList.isEmpty()){
List<AclPractitionerPotentialAssignedTrack> assignedTrackUpdateList = new ArrayList<>();
for(AclPractitionerPotentialAssignedTrack item : assignedTrackIsLastedList){
item.setIsLasted(0);
item.setUpdatedBy(practitionerId);
item.setUpdaterType(2);
item.setUpdatedAt(new Date());
assignedTrackUpdateList.add(item);
}
aclPractitionerPotentialAssignedTrackDALService.updateAll(assignedTrackUpdateList);
}
//2、查询团队长对该增员所有增员状态
List<AclPractitionerPotentialAssignedTrack> assignedTrackList = aclPractitionerPotentialAssignedTrackDALService.findByPractitionerIdAndPotentialIdAndTrackStatusId(practitionerId,potentialId,trackStatusId,trackTimeDate);
if (assignedTrackList == null || assignedTrackList.isEmpty()) {//3、如果没有,获取增员状态对应的分值,
MdDropOptions options = mdDropOptionsDALService.findById(trackStatusId);
assignedTrack.setTrackScore(options.getDropOptionScore());
assignedTrack.setPractitionerAssignedId(practitionerId);
assignedTrack.setPractitionerPotentialId(potentialId);
assignedTrack.setTrackStatusId(trackStatusId);
assignedTrack.setNotice(notice);
assignedTrack.setTrackTime(trackTimeDate);
assignedTrack.setIsActive(1);
assignedTrack.setIsLasted(1);
assignedTrack.setCreatorType(2);
assignedTrack.setCreatedBy(practitionerId);
assignedTrack.setCreatedAt(new Date());
aclPractitionerPotentialAssignedTrackDALService.save(assignedTrack);
} else {
assignedTrack = assignedTrackList.get(0);
assignedTrack.setNotice(notice);
assignedTrack.setIsLasted(1);
assignedTrack.setUpdatedAt(new Date());
assignedTrack.setUpdatedBy(practitionerId);
assignedTrack.setUpdaterType(2);
aclPractitionerPotentialAssignedTrackDALService.update(assignedTrack);
}
}
@Override
public QueryScheduleTrackListResponseVO queryScheduleTrackList(QueryScheduleTrackListRequestVO requestVO) {
QueryScheduleTrackListResponseVO resp = new QueryScheduleTrackListResponseVO();
Long practitionerId = requestVO.getPractitionerId();
String trackDate = requestVO.getTrackTime();
if (StringUtils.isEmpty(trackDate) || null == practitionerId) {
resp.setCommonResult(new CommonResult(true, "经纪人id和查询时间不能为空"));
return resp;
}
List<ScheduleTrackVO> showList = new ArrayList<>();
try {
List<ScheduleTrack> dataList = scheduleTrackMapper.queryScheduleTrackList(practitionerId);
Map<Long, MdDropOptions> taskTypeMap = this.getScheduleTaskTypeMap();
String optionName = null;
for (ScheduleTrack schedule: dataList) {
if (this.checkFixedDay(trackDate, schedule)) {
ScheduleTrackVO scheduleTrackVO = new ScheduleTrackVO();
BeanUtils.copyProperties(schedule, scheduleTrackVO);
optionName = taskTypeMap.get(schedule.getMdDropOptionId()).getDropOptionName();
scheduleTrackVO.setMdDropOptionName(optionName);
showList.add(scheduleTrackVO);
}
}
resp.setDataList(showList);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
private Map<Long, MdDropOptions> getScheduleTaskTypeMap() {
Map<Long, MdDropOptions> saleOptMap = mdDropOptionsDALService.queryIdObjMapByByDropMasterCode("bizchance_promotion_action");
Map<Long, MdDropOptions> recruitOptMap = mdDropOptionsDALService.queryIdObjMapByByDropMasterCode("team_building_track");
Map<Long, MdDropOptions> otherOptMap = mdDropOptionsDALService.queryIdObjMapByByDropMasterCode("pep_schedule_task_others");
Map<Long, MdDropOptions> taskTypeMap = new HashMap<>();
taskTypeMap.putAll(saleOptMap);
taskTypeMap.putAll(recruitOptMap);
taskTypeMap.putAll(otherOptMap);
return taskTypeMap;
}
private boolean checkFixedDay(String trackDate, ScheduleTrack track) {
Date date = CommonUtil.stringParseDate(trackDate, "yyyy-MM-dd");
String week = CommonUtil.getWeekOfDate(date);
String trackTime = CommonUtil.dateParseString(track.getTrackTime(), "yyyy-MM-dd");
Integer flag = 0;
switch (week) {
case "1":
flag = track.getTaskRoutineAtweek1();
break;
case "2":
flag = track.getTaskRoutineAtweek2();
break;
case "3":
flag = track.getTaskRoutineAtweek3();
break;
case "4":
flag = track.getTaskRoutineAtweek4();
break;
case "5":
flag = track.getTaskRoutineAtweek5();
break;
case "6":
flag = track.getTaskRoutineAtweek6();
break;
case "0":
flag = track.getTaskRoutineAtweek7();
break;
default:
break;
}
return trackTime.equals(trackDate) || Integer.valueOf(1).equals(flag);
}
@Override
public QueryPEPScoreResponseVO queryPEPScore(QueryPEPScoreRequestVO requestVO) {
QueryPEPScoreResponseVO resp = new QueryPEPScoreResponseVO();
Long practitionerId = requestVO.getPractitionerId();
try {
// 获取本月第一天
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, 0);
// 获取到本月起始日
int actualMinimum = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), actualMinimum, 00, 00, 00);
// 获取本月起始日的年月日时分秒格式
Date monthOne = cal.getTime();
// 获取本月当前日的年月日时分秒格式
Date today = new Date();
// 获取本周第一天(周一为始)
Calendar cal2 = Calendar.getInstance();
cal2.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal2.set(Calendar.HOUR_OF_DAY, 0);
cal2.set(Calendar.MINUTE, 0);
cal2.set(Calendar.SECOND, 0);
Date weekOne = cal2.getTime();
List<Long> practitionerIdList = scheduleTrackMapper.queryTeamAllPractitionerId(practitionerId);
if (CollectionUtils.isEmpty(practitionerIdList)) {
// 集合为空,说明该经纪人不是团队长
practitionerIdList.add(practitionerId);
}
// 根据团队长经纪人id查询团队每个成员本日,本周,本月得分以及---线上本月FYC
List<PersonalPEPScore> saleAndRecuit = scheduleTrackMapper.querySaleRecuitScoreFYC(practitionerIdList);
// 获取mobileNoList
List<String> mobileNoList = new ArrayList<>();
saleAndRecuit.forEach(i->mobileNoList.add(i.getMobileNo()));
List<PersonalOffLineFYC> personalOffLineFYCList = agmsDashboardDALService.offLineFYC(mobileNoList);
// 计算总FYC
this.computeTotalFYC(saleAndRecuit, personalOffLineFYCList);
// 其他活动有长期固定,通过计算时间段内展示次数,算得总分
// 先获得每个人所有的其他活动
List<PersonalSchedule> personalScheduleList = scheduleTrackMapper.queryPersonalScheduleList(practitionerIdList);
// 根据活动算本日,本周,本月的分数
this.computeOtherScore(personalScheduleList, today, weekOne, monthOne);
// 最后合并营销增员和其他活动的分数
this.mergeScore(personalScheduleList, saleAndRecuit);
// 计算团队平均分
Map<String, Object> average = this.computeTeamAverageScore(saleAndRecuit, practitionerIdList.size());
resp.setPersonalList(saleAndRecuit);
resp.setAverage(average);
for (PersonalPEPScore s: saleAndRecuit) {
if (s.getPractitionerId().equals(practitionerId)) {
resp.setPerson(s);
}
}
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
private void computeTotalFYC(List<PersonalPEPScore> saleAndRecuit, List<PersonalOffLineFYC> personalOffLineFYCList) {
for (PersonalPEPScore online: saleAndRecuit ) {
for (PersonalOffLineFYC offline: personalOffLineFYCList) {
if (online.getMobileNo().equals(offline.getMobileNo())) {
BigDecimal totalFYC = online.getFYC().add(offline.getFYC());
online.setFYC(totalFYC);
break;
}
}
}
}
@Override
public QueryPEPScoreDetailResponseVO queryPEPScoreDetail(QueryPEPScoreDetailRequestVO requestVO) {
QueryPEPScoreDetailResponseVO resp = new QueryPEPScoreDetailResponseVO();
Long practitionerId = requestVO.getPractitionerId();
String time = requestVO.getTime();
Calendar cal = Calendar.getInstance();
// 根据time获取查询起始日期,默认当天
Date startDate = new Date();
// 根据time获取查询结束日期,默认当天
Date endDate = new Date();
if ("w".equalsIgnoreCase(time)) {
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
startDate = cal.getTime();
}
if ("m".equalsIgnoreCase(time)) {
cal.add(Calendar.MONTH, 0);
// 获取到本月起始日
int actualMinimum = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), actualMinimum, 00, 00, 00);
startDate = cal.getTime();
}
try {
// 根据经纪人id查询个人所有日程
List<ScheduleTrack> scheduleList = scheduleTrackMapper.queryPersonalScheduleListByTime(practitionerId, time);
// 计算增员日程和销售日程的得分
List<Integer> saleOption = Arrays.asList(95,96,97,98,99,101,228);
List<Integer> RecruitOption = Arrays.asList(107,108,109,110,111,112);
Long recruitScore = 0L;
Long saleScore = 0L;
Long coachScore = 0L;
Long trainScore = 0L;
Long meetingScore = 0L;
for (ScheduleTrack schedule : scheduleList) {
if (saleOption.contains(schedule.getMdDropOptionId().intValue())) {
saleScore += schedule.getTrackScore();
continue;
}
if (RecruitOption.contains(schedule.getMdDropOptionId().intValue())) {
recruitScore += schedule.getTrackScore();
continue;
}
if (223 == schedule.getMdDropOptionId()) {
coachScore += this.calculateScheduleDisplayCount(schedule, startDate, endDate) * schedule.getTrackScore();
continue;
}
if (224 == schedule.getMdDropOptionId()) {
trainScore += this.calculateScheduleDisplayCount(schedule, startDate, endDate) * schedule.getTrackScore();
continue;
}
if (226 == schedule.getMdDropOptionId()) {
meetingScore += this.calculateScheduleDisplayCount(schedule, startDate, endDate) * schedule.getTrackScore();
continue;
}
}
PEPScoreDetail PEPScoreDetail = new PEPScoreDetail();
PEPScoreDetail.setRecruitScore(recruitScore);
PEPScoreDetail.setSaleScore(saleScore);
PEPScoreDetail.setCoachScore(coachScore);
PEPScoreDetail.setTrainScore(trainScore);
PEPScoreDetail.setMeetingScore(meetingScore);
// 根据practitionerId查询经纪人姓名
String name = scheduleTrackMapper.queryNameByPractitionerId(practitionerId);
PEPScoreDetail.setName(name);
resp.setDetail(PEPScoreDetail);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
@Override
public DeleteScheduleByIdResponseVO deleteScheduleTrackById(DeleteScheduleTrackByIdRequestVO requestVO) {
DeleteScheduleByIdResponseVO resp = new DeleteScheduleByIdResponseVO();
Long scheduleTrackId = requestVO.getScheduleTrackId();
Integer taskType = requestVO.getTaskType();
try {
// 根据id删除日程表记录
scheduleTrackMapper.deleteScheduleTrackById(scheduleTrackId);
if (Integer.valueOf(1).equals(taskType)) {
// 根据id删除商机表记录
mktLeadsAssignedTrackDALService.deleteScheduleTrackById(scheduleTrackId);
}
if (Integer.valueOf(2).equals(taskType)) {
// 根据id删除增员记录
aclPractitionerPotentialAssignedTrackDALService.deleteScheduleTrackById(scheduleTrackId);
}
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
private Map<String, Object> computeTeamAverageScore(List<PersonalPEPScore> saleAndRecuit, int teamSize) {
PersonalPEPScore personalScore = null;
Long dayScore = 0L;
Long weekScore = 0L;
Long monthScore = 0L;
BigDecimal FYC = new BigDecimal(0);
for (int i = 0; i < saleAndRecuit.size(); i++) {
personalScore = saleAndRecuit.get(i);
dayScore += personalScore.getDayScore();
weekScore += personalScore.getWeekScore();
monthScore += personalScore.getMonthScore();
FYC = FYC.add(personalScore.getFYC());
}
Double dayAverage = 0D;
Double weekAverage = 0D;
Double monthAverage = 0D;
// 平均分效
Double rate = 0D;
if (!CommonUtil.isNullOrZero(teamSize)){
dayAverage = BigDecimal.valueOf(dayScore)
.divide(BigDecimal.valueOf(teamSize),2, BigDecimal.ROUND_HALF_UP)
.doubleValue();
weekAverage = BigDecimal.valueOf(weekScore)
.divide(BigDecimal.valueOf(teamSize),2, BigDecimal.ROUND_HALF_UP)
.doubleValue();
monthAverage = BigDecimal.valueOf(monthScore)
.divide(BigDecimal.valueOf(teamSize),2, BigDecimal.ROUND_HALF_UP)
.doubleValue();
}
if (!CommonUtil.isNullOrZero(monthScore)){
rate = FYC.divide(BigDecimal.valueOf(monthScore), 2, BigDecimal.ROUND_HALF_UP)
.doubleValue();
}
Map<String, Object> average = new HashMap<>();
average.put("dayScore", dayAverage);
average.put("weekScore", weekAverage);
average.put("monthScore", monthAverage);
average.put("rate", rate);
return average;
}
private void mergeScore(List<PersonalSchedule> personalScheduleList, List<PersonalPEPScore> saleAndRecuit) {
for (PersonalPEPScore socre : saleAndRecuit) {
for (PersonalSchedule schedule : personalScheduleList) {
Long curPractitionerId = schedule.getPractitionerId();
if (curPractitionerId.equals(socre.getPractitionerId())) {
Map<String, Long> otherMap = schedule.getOther();
Long dayScore = socre.getDayScore() + otherMap.get("dayScore");
Long weekScore = socre.getWeekScore() + otherMap.get("weekScore");
Long monthScore = socre.getMonthScore() + otherMap.get("monthScore");
socre.setDayScore(dayScore);
socre.setWeekScore(weekScore);
socre.setMonthScore(monthScore);
}
}
Double rate = 0D;
if (!CommonUtil.isNullOrZero(socre.getMonthScore())){
// 单人分效
rate = socre.getFYC().divide(BigDecimal.valueOf(socre.getMonthScore()), 2, BigDecimal.ROUND_HALF_UP)
.doubleValue();
}
socre.setRate(rate);
}
}
private void computeOtherScore(List<PersonalSchedule> personalScheduleList, Date today, Date weekOne, Date monthOne) {
for (PersonalSchedule perSchedule:personalScheduleList) {
List<ScheduleTrack> scheduleList = perSchedule.getScheduleList();
Integer trackScore = null;
long dayOther = 0L;
long weekOther = 0L;
long monthOther = 0L;
// 计算所有其他活动的本日,本周,本月得分
for (ScheduleTrack s:scheduleList) {
trackScore = s.getTrackScore();
dayOther += this.calculateScheduleDisplayCount(s, today, today) * trackScore;
weekOther += this.calculateScheduleDisplayCount(s, weekOne, today) * trackScore;
monthOther += this.calculateScheduleDisplayCount(s, monthOne, today) * trackScore;
}
Map<String, Long> map = new HashMap<>();
map.put("dayScore", dayOther);
map.put("weekScore", weekOther);
map.put("monthScore", monthOther);
perSchedule.setOther(map);
}
}
private long calculateScheduleDisplayCount(ScheduleTrack s, Date firstDay, Date lastDay) {
Date trackTime = s.getTrackTime();
String trackTimeStr = CommonUtil.dateParseString(trackTime,"yyyy-MM-dd");
String firstDayStr = CommonUtil.dateParseString(firstDay,"yyyy-MM-dd");
String lastDayStr = CommonUtil.dateParseString(lastDay,"yyyy-MM-dd");
if (trackTimeStr.compareTo(firstDayStr) > 0) {
firstDay = trackTime;
}
long count = 0L;
if (Integer.valueOf(1).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 1);
}
if (Integer.valueOf(2).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 2);
}
if (Integer.valueOf(3).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 3);
}
if (Integer.valueOf(4).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 4);
}
if (Integer.valueOf(5).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 5);
}
if (Integer.valueOf(6).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 6);
}
if (Integer.valueOf(7).equals(s.getTaskRoutineAtweek1())) {
count += CommonUtil.weekDayCount(firstDay, lastDay, 7);
}
// 判断trackTime是否在时间范围内
if (trackTimeStr.compareTo(firstDayStr)>=0 && trackTimeStr.compareTo(lastDayStr)<=0) {
String week = CommonUtil.getWeekOfDate(trackTime);
Integer flag = 0;
switch (week) {
case "1":
flag = s.getTaskRoutineAtweek1();
break;
case "2":
flag = s.getTaskRoutineAtweek2();
break;
case "3":
flag = s.getTaskRoutineAtweek3();
break;
case "4":
flag = s.getTaskRoutineAtweek4();
break;
case "5":
flag = s.getTaskRoutineAtweek5();
break;
case "6":
flag = s.getTaskRoutineAtweek6();
break;
case "0":
flag = s.getTaskRoutineAtweek7();
break;
default:
break;
}
// trackTime星期与长期固定星期不重复
if (!Integer.valueOf(1).equals(flag)) {
count += 1;
}
}
return count;
}
}
package com.yd.api.practitioner.vo.sechedule;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class AddScheduleTrackRequestVO {
private Long id;
private Long practitionerId;
private String notice;
private Integer taskType;
private Long referLeadsId;
private Long referPotentialId;
private Integer taskImportantTag;
private Integer isActive;
private String taskTimeFrom;
private String taskTimeEnd;
private Integer taskRoutineAtweek7;
private Integer taskRoutineAtweek6;
private Integer taskRoutineAtweek5;
private Integer taskRoutineAtweek4;
private Integer taskRoutineAtweek3;
private Integer taskRoutineAtweek2;
private Integer taskRoutineAtweek1;
private Long customerId;
private Long mdDropOptionId;
private String mdDropOptionName;
private Integer trackScore;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date trackTime;
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import lombok.Data;
@Data
public class AddScheduleTrackResponseVO {
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import lombok.Data;
@Data
public class DeleteScheduleByIdResponseVO {
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
import lombok.Data;
@Data
public class DeleteScheduleTrackByIdRequestVO {
private Long scheduleTrackId;
private Integer taskType;
}
package com.yd.api.practitioner.vo.sechedule;
import lombok.Data;
@Data
public class QueryPEPScoreDetailRequestVO {
private Long practitionerId;
private String time;
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.practitioner.PEPScoreDetail;
import lombok.Data;
@Data
public class QueryPEPScoreDetailResponseVO {
private PEPScoreDetail detail;
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
public class QueryPEPScoreRequestVO {
private Long practitionerId;
public Long getPractitionerId() {
return practitionerId;
}
public void setPractitionerId(Long practitionerId) {
this.practitionerId = practitionerId;
}
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.practitioner.PersonalPEPScore;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class QueryPEPScoreResponseVO {
private Map<String, Object> average;
private PersonalPEPScore person;
private List<PersonalPEPScore> personalList;
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
import lombok.Data;
@Data
public class QueryScheduleTrackListRequestVO {
private Long practitionerId;
private String trackTime;
}
package com.yd.api.practitioner.vo.sechedule;
import com.yd.api.result.CommonResult;
import lombok.Data;
import java.util.List;
@Data
public class QueryScheduleTrackListResponseVO {
private List<ScheduleTrackVO> dataList;
private CommonResult commonResult;
}
package com.yd.api.practitioner.vo.sechedule;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class ScheduleTrackVO {
private Long id;
private Long practitionerId;
private String notice;
private Integer taskType;
private Long referLeadsId;
private Long referPotentialId;
private Integer taskImportantTag;
private Integer isActive;
private String taskTimeFrom;
private String taskTimeEnd;
private Integer taskRoutineAtweek7;
private Integer taskRoutineAtweek6;
private Integer taskRoutineAtweek5;
private Integer taskRoutineAtweek4;
private Integer taskRoutineAtweek3;
private Integer taskRoutineAtweek2;
private Integer taskRoutineAtweek1;
private Long customerId;
private Long mdDropOptionId;
private String mdDropOptionName;
private Integer trackScore;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date trackTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createdAt;
private Long createdBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updatedAt;
private Long updatedBy;
private Integer creatorType;
private Integer updatorType;
}
......@@ -70,5 +70,10 @@ public class AclPractitionerPotentialAssignedTrack implements Serializable {
private Date trackTime;
/**
* 关联ag_mkt_schedule_task_tracking.id 日程表
*/
private Long scheduleTaskTrackingId;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -92,5 +92,10 @@ public class MktLeadsAssignedTrack implements Serializable {
private Date trackTime;
/**
* 关联ag_mkt_schedule_task_tracking.id 日程表
*/
private Long scheduleTaskTrackingId;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.yd.dal.entity.practitioner;
import lombok.Data;
@Data
public class PEPScoreDetail {
private String name;
private Long recruitScore;
private Long saleScore;
private Long coachScore;
private Long trainScore;
private Long meetingScore;
}
package com.yd.dal.entity.practitioner;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PersonalOffLineFYC {
private String mobileNo;
private BigDecimal FYC;
}
package com.yd.dal.entity.practitioner;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PersonalPEPScore {
private Long practitionerId;
private String name;
private String mobileNo;
private Long dayScore;
private Long weekScore;
private Long monthScore;
private BigDecimal FYC;
private Double rate;
}
package com.yd.dal.entity.practitioner;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class PersonalSchedule {
private Long practitionerId;
private List<ScheduleTrack> scheduleList;
private Map<String, Long> other;
}
package com.yd.dal.entity.practitioner;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class ScheduleTrack {
private Long id;
private Long practitionerId;
private String notice;
private Integer taskType;
private Long referLeadsId;
private Long referPotentialId;
private Integer taskImportantTag;
private Integer isActive;
private String taskTimeFrom;
private String taskTimeEnd;
private Integer taskRoutineAtweek7;
private Integer taskRoutineAtweek6;
private Integer taskRoutineAtweek5;
private Integer taskRoutineAtweek4;
private Integer taskRoutineAtweek3;
private Integer taskRoutineAtweek2;
private Integer taskRoutineAtweek1;
private Long customerId;
private Long mdDropOptionId;
private String mdDropOptionName;
private Integer trackScore;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date trackTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createdAt;
private Long createdBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updatedAt;
private Long updatedBy;
private Integer creatorType;
private Integer updatorType;
}
......@@ -4,6 +4,7 @@ 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;
import com.yd.dal.entity.practitioner.PersonalOffLineFYC;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -22,4 +23,6 @@ public interface AgmsDashboardMapper {
List<StatisticsPractitionerInfo> statisticsPractitioner(@Param("type")String type);
List<StatisticsSalesInfo> statisticsSalesEG(@Param("type")String type, @Param("time")String time);
List<PersonalOffLineFYC> personalOffLineFYC(List<String> mobileNoList);
}
......@@ -30,4 +30,6 @@ public interface AclPractitionerPotentialAssignedTrackMapper {
List<AclPractitionerPotentialAssignedTrack> findByPractitionerIdAndPotentialId(@Param("practitionerId")Long practitionerId, @Param("potentialId")Long potentialId);
List<AclPractitionerPotentialAssignedTrack> findScoreByPractitionerIdAndDate(@Param("practitionerId")Long practitionerId, @Param("time")String time);
void deleteScheduleTrackById(Long scheduleTrackId);
}
\ No newline at end of file
......@@ -31,4 +31,6 @@ public interface MktLeadsAssignedTrackMapper {
MktLeadsAssignedTrack findByListNotesForCustomerId(Long customerId);
List<SalesScoreDetail> getSalesScoreDetailByPractitionerId(@Param("practitionerId") Long practitionerId,@Param("time") String time);
void deleteScheduleTrackById(Long scheduleTrackId);
}
\ No newline at end of file
package com.yd.dal.mapper.marketing;
import com.yd.dal.entity.practitioner.PersonalPEPScore;
import com.yd.dal.entity.practitioner.PersonalSchedule;
import com.yd.dal.entity.practitioner.ScheduleTrack;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
public interface ScheduleTrackMapper {
void insert(ScheduleTrack schedule);
List<ScheduleTrack> queryScheduleTrackList(@Param("practitionerId")Long practitionerId);
int checkTimePeriodConflict(@Param("trackTime")Date trackTime, @Param("taskTimeFrom")String taskTimeFrom,
@Param("taskTimeEnd")String taskTimeEnd, @Param("practitionerId")Long practitionerId);
List<PersonalPEPScore> querySaleRecuitScoreFYC(@Param("list")List<Long> practitionerIdList);
List<Long> queryTeamAllPractitionerId(@Param("practitionerId")Long practitionerId);
List<PersonalSchedule> queryPersonalScheduleList(List<Long> practitionerIdList);
List<ScheduleTrack> queryPersonalScheduleListByTime(@Param("practitionerId")Long practitionerId, @Param("time")String time);
void deleteScheduleTrackById(@Param("scheduleTrackId")Long scheduleTrackId);
String queryNameByPractitionerId(Long practitionerId);
}
......@@ -4,6 +4,7 @@ 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;
import com.yd.dal.entity.practitioner.PersonalOffLineFYC;
import java.util.List;
......@@ -17,4 +18,6 @@ public interface AgmsDashboardDALService {
List<StatisticsPractitionerInfo> statisticsPractitioner(String type);
List<StatisticsSalesInfo> statisticsSalesEG(String type, String time);
List<PersonalOffLineFYC> offLineFYC(List<String> mobileNoList);
}
......@@ -4,6 +4,7 @@ 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;
import com.yd.dal.entity.practitioner.PersonalOffLineFYC;
import com.yd.dal.mapper.agms.AgmsDashboardMapper;
import com.yd.dal.service.agms.AgmsDashboardDALService;
import com.yd.util.intercept.annotation.TargetDataSource;
......@@ -138,4 +139,11 @@ public class AgmsDashboardDALServiceImpl implements AgmsDashboardDALService {
getUnitPremium(statisticsSalesInfos);
return statisticsSalesInfos;
}
@Override
@TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
public List<PersonalOffLineFYC> offLineFYC(List<String> mobileNoList) {
List<PersonalOffLineFYC> personalOffLineFYCList = agmsDashboardMapper.personalOffLineFYC(mobileNoList);
return personalOffLineFYCList;
}
}
......@@ -24,4 +24,6 @@ public interface AclPractitionerPotentialAssignedTrackDALService {
List<AclPractitionerPotentialAssignedTrack> findScoreByPractitionerIdAndDate(Long practitionerId, String time);
void update(AclPractitionerPotentialAssignedTrack assignedTrack);
void deleteScheduleTrackById(Long scheduleTrackId);
}
......@@ -55,4 +55,9 @@ public class AclPractitionerPotentialAssignedTrackDALServiceImpl implements AclP
public void update(AclPractitionerPotentialAssignedTrack assignedTrack) {
aclPractitionerPotentialAssignedTrackMapper.updateByPrimaryKeySelective(assignedTrack);
}
@Override
public void deleteScheduleTrackById(Long scheduleTrackId) {
aclPractitionerPotentialAssignedTrackMapper.deleteScheduleTrackById(scheduleTrackId);
}
}
......@@ -55,4 +55,9 @@ public class MktLeadsAssignedTrackDALServiceImpl implements MktLeadsAssignedTrac
public List<SalesScoreDetail> getSalesScoreDetailByPractitionerId(Long practitionerId, String time) {
return mktLeadsAssignedTrackMapper.getSalesScoreDetailByPractitionerId(practitionerId, time);
}
@Override
public void deleteScheduleTrackById(Long scheduleTrackId) {
mktLeadsAssignedTrackMapper.deleteScheduleTrackById(scheduleTrackId);
}
}
......@@ -32,4 +32,6 @@ public interface MktLeadsAssignedTrackDALService {
* @return 跟进状态详情
*/
List<SalesScoreDetail> getSalesScoreDetailByPractitionerId(Long practitionerId, String time);
void deleteScheduleTrackById(Long scheduleTrackId);
}
......@@ -6,6 +6,8 @@ import com.yd.dal.entity.meta.MdDropOptions;
import com.yd.dal.entity.meta.OptionsEGolden;
import java.util.List;
import java.util.Map;
public interface MdDropOptionsDALService {
List<MdDropOptions> findByDropMasterId(long dropMasterId);
......@@ -40,4 +42,6 @@ public interface MdDropOptionsDALService {
List<InsurerBranchInfo> findInsurerBranchInfoEG();
List<MdDropOptions> findByDropMasterCodes(List<String> asList);
Map<Long, MdDropOptions> queryIdObjMapByByDropMasterCode(String masterCode);
}
......@@ -11,7 +11,9 @@ import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("mdDropOptionsDALService")
public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService {
......@@ -111,4 +113,12 @@ public class MdDropOptionsDALServiceImpl implements MdDropOptionsDALService {
public List<MdDropOptions> findByDropMasterCodes(List<String> masterCodeList) {
return mdDropOptionsMapper.findByDropMasterCodes(masterCodeList);
}
@Override
public Map<Long, MdDropOptions> queryIdObjMapByByDropMasterCode(String masterCode) {
Map<Long,MdDropOptions> optMap = new HashMap<>();
List<MdDropOptions> dropOptionsList = this.findByDropMasterCode(masterCode);
dropOptionsList.forEach(i->optMap.put(i.getId(), i));
return optMap;
}
}
......@@ -16,6 +16,7 @@ import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.*;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -1451,4 +1452,55 @@ public class CommonUtil {
}
return false;
}
/**
* 根据日期获得星期
* @param date
* @return
*/
public static String getWeekOfDate(Date date) {
String[] weekDaysName = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
String[] weekDaysCode = { "0", "1", "2", "3", "4", "5", "6" };
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int intWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
return weekDaysCode[intWeek];
}
/**
* 给定时间段和星期几,计算该时间段内共有多少个给定的星期几
* @param start 开始时间
* @param end 结束时间
* @param a 星期几,从星期一到星期天,分别用数字1-7表示
* @return 星期几统计数
*/
public static long weekDayCount(Date start, Date end, int a){
long sumDay = 0;//计数
try{
Calendar startDate = Calendar.getInstance(); //开始时间
startDate.setTime(start);
Calendar endDate = Calendar.getInstance();//结束时间
endDate.setTime(end);
int SW = startDate.get(Calendar.DAY_OF_WEEK)-1;//开始日期是星期几
int EW = endDate.get(Calendar.DAY_OF_WEEK)-1;//结束日期是星期几
long diff = endDate.getTimeInMillis()-startDate.getTimeInMillis();
long days = diff / (1000 * 60 * 60 * 24);//给定时间段内一共有多少天
long w = Math.round(Math.ceil(((days+SW+(7-EW))/7.0)));//给定时间内,共有多少个星期
sumDay = w;//总的星期几统计数
if (a<SW) {
//给定的星期几小于起始日期的星期几,需要减少一天
sumDay--;
}
if (a>EW) {
//给定的星期几大于结束日期的星期几,需要减少一天
sumDay--;
}
}catch(Exception se){
se.printStackTrace();
}
return sumDay;
}
}
......@@ -9,6 +9,7 @@
######################用户提示信息########################
800000=执行成功!
800001=执行失败!
##系统提示信息
810001=token无效或者错误!
820001=未查询到相应结果。
......@@ -22,6 +23,7 @@
830007=上传头像失败,请重新上传!
830008=上传生活照失败,请重新上传!
830009=上传微信二维码失败,请重新上传!
830020=活动时间段冲突
830010=该用户已经注册为银盾经纪人
830011=该增员已存在!
830012=请填写跟进时间!
......
......@@ -281,4 +281,20 @@ where ps.practitioner_type_id = 28
</choose>
order by sum(policy.INS001_FYCTOTAL) desc
</select>
<select id="personalOffLineFYC" resultType="com.yd.dal.entity.practitioner.PersonalOffLineFYC">
SELECT DISTINCT
sales.SAL_MST_MOBILE mobileNo,
ifnull(sum(policy.INS001_FYCTOTAL),0) FYC
FROM sal001 sales LEFT JOIN ins003 p_sales on sales.SAL_MST_ID = p_sales.FK_SAL_MST_ID
LEFT JOIN ins001 policy on policy.INS_MST_ID = p_sales.FK_INS_MST_ID
WHERE policy.INS_MST_REPEAL != 1
AND DATE_FORMAT(policy.INS_MST_ACCEPT_DATE, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
AND sales.SAL_MST_MOBILE in
<foreach collection="list" item="mobileNo" index="index" open="(" close=")" separator=",">
#{mobileNo,jdbcType=VARCHAR}
</foreach>
group by sales.SAL_MST_MOBILE
</select>
</mapper>
\ No newline at end of file
......@@ -115,6 +115,9 @@
<if test="trackTime != null">
track_time,
</if>
<if test="scheduleTaskTrackingId != null">
schedule_task_tracking_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="practitionerPotentialId != null">
......@@ -159,6 +162,9 @@
<if test="trackTime != null">
#{trackTime,jdbcType=TIMESTAMP},
</if>
<if test="scheduleTaskTrackingId != null">
#{scheduleTaskTrackingId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<insert id="insertList" parameterType="java.util.List" useGeneratedKeys="true" >
......@@ -325,4 +331,9 @@
</choose>
</select>
<delete id="deleteScheduleTrackById" parameterType="java.lang.Long">
delete from ag_acl_practitioner_potential_assigned_track
where schedule_task_tracking_id = #{scheduleTrackId,jdbcType=BIGINT}
</delete>
</mapper>
\ No newline at end of file
......@@ -101,6 +101,9 @@
<if test="trackTime != null">
track_time,
</if>
<if test="scheduleTaskTrackingId != null">
schedule_task_tracking_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">
......@@ -151,6 +154,9 @@
<if test="trackTime != null">
#{trackTime,jdbcType=TIMESTAMP},
</if>
<if test="scheduleTaskTrackingId != null">
#{scheduleTaskTrackingId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.marketing.MktLeadsAssignedTrack">
......@@ -372,4 +378,9 @@
group by t.md_drop_option_id,o.drop_option_order
ORDER BY o.drop_option_order
</select>
<delete id="deleteScheduleTrackById" parameterType="java.lang.Long">
delete from ag_mkt_leads_assigned_track
where schedule_task_tracking_id = #{scheduleTrackId,jdbcType=BIGINT}
</delete>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yd.dal.mapper.marketing.ScheduleTrackMapper">
<resultMap id="ScheduleTrackResultMap" type="com.yd.dal.entity.practitioner.ScheduleTrack">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="notice" jdbcType="VARCHAR" property="notice"/>
<result column="task_type" jdbcType="INTEGER" property="taskType"/>
<result column="refer_leads_id" jdbcType="BIGINT" property="referLeadsId"/>
<result column="refer_potential_id" jdbcType="BIGINT" property="referPotentialId"/>
<result column="task_important_tag" jdbcType="INTEGER" property="taskImportantTag"/>
<result column="task_routine_at_week7" jdbcType="INTEGER" property="taskRoutineAtweek7"/>
<result column="task_routine_at_week6" jdbcType="INTEGER" property="taskRoutineAtweek6"/>
<result column="task_routine_at_week5" jdbcType="INTEGER" property="taskRoutineAtweek5"/>
<result column="task_routine_at_week4" jdbcType="INTEGER" property="taskRoutineAtweek4"/>
<result column="task_routine_at_week3" jdbcType="INTEGER" property="taskRoutineAtweek3"/>
<result column="task_routine_at_week2" jdbcType="INTEGER" property="taskRoutineAtweek2"/>
<result column="task_routine_at_week1" jdbcType="INTEGER" property="taskRoutineAtweek1"/>
<result column="task_time_from" jdbcType="VARCHAR" property="taskTimeFrom"/>
<result column="task_time_end" jdbcType="VARCHAR" property="taskTimeEnd"/>
<result column="is_active" jdbcType="INTEGER" property="isActive"/>
<result column="practitioner_id" jdbcType="BIGINT" property="practitionerId"/>
<result column="customer_id" jdbcType="BIGINT" property="customerId"/>
<result column="md_drop_option_id" jdbcType="BIGINT" property="mdDropOptionId"/>
<result column="track_score" jdbcType="INTEGER" property="trackScore"/>
<result column="track_time" jdbcType="TIMESTAMP" property="trackTime"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="created_by" jdbcType="BIGINT" property="createdBy"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
<result column="updated_by" jdbcType="BIGINT" property="updatedBy"/>
<result column="updator_type" jdbcType="INTEGER" property="updatorType"/>
<result column="creator_type" jdbcType="INTEGER" property="creatorType"/>
</resultMap>
<select id="queryScheduleTrackList" resultMap="ScheduleTrackResultMap">
SELECT id, notice, task_type, refer_leads_id, refer_potential_id,
task_important_tag, task_routine_at_week7,task_routine_at_week6, task_routine_at_week5,
task_routine_at_week4, task_routine_at_week3, task_routine_at_week2, task_routine_at_week1,
DATE_FORMAT(task_time_from,'%H:%i') task_time_from, DATE_FORMAT(task_time_end,'%H:%i') task_time_end,
is_active, practitioner_id, customer_id, md_drop_option_id, track_score, track_time,
created_at, created_by, updated_at, updated_by, updator_type, creator_type
FROM
ag_mkt_schedule_task_tracking t
WHERE practitioner_id = #{practitionerId,jdbcType=BIGINT}
ORDER BY task_time_from
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.practitioner.ScheduleTrack" useGeneratedKeys="true">
insert into ag_mkt_schedule_task_tracking
(notice, task_type, refer_leads_id, refer_potential_id,
task_important_tag, task_routine_at_week7,task_routine_at_week6, task_routine_at_week5,
task_routine_at_week4, task_routine_at_week3, task_routine_at_week2, task_routine_at_week1,
task_time_from, task_time_end, is_active, practitioner_id, customer_id, md_drop_option_id, track_score, track_time,
created_at, created_by, updated_at, updated_by, updator_type,creator_type )
values (#{notice,jdbcType=VARCHAR},
#{taskType,jdbcType=INTEGER},
#{referLeadsId,jdbcType=BIGINT},
#{referPotentialId,jdbcType=BIGINT},
#{taskImportantTag,jdbcType=INTEGER},
#{taskRoutineAtweek7,jdbcType=INTEGER},
#{taskRoutineAtweek6,jdbcType=INTEGER},
#{taskRoutineAtweek5,jdbcType=INTEGER},
#{taskRoutineAtweek4,jdbcType=INTEGER},
#{taskRoutineAtweek3,jdbcType=INTEGER},
#{taskRoutineAtweek2,jdbcType=INTEGER},
#{taskRoutineAtweek1,jdbcType=INTEGER},
#{taskTimeFrom,jdbcType=VARCHAR},
#{taskTimeEnd,jdbcType=VARCHAR},
#{isActive,jdbcType=INTEGER},
#{practitionerId,jdbcType=BIGINT},
#{customerId,jdbcType=BIGINT},
#{mdDropOptionId,jdbcType=BIGINT},
#{trackScore,jdbcType=INTEGER},
#{trackTime,jdbcType=TIMESTAMP},
#{createdAt,jdbcType=TIMESTAMP},
#{createdBy,jdbcType=BIGINT},
#{updatedAt,jdbcType=TIMESTAMP},
#{updatedBy,jdbcType=BIGINT},
#{updatorType,jdbcType=INTEGER},
#{creatorType,jdbcType=INTEGER}
)
</insert>
<select id="checkTimePeriodConflict" resultType="int">
SELECT count(1)
FROM ag_mkt_schedule_task_tracking
WHERE 1=1
AND to_days(track_time) = to_days(#{taskTimeEnd,jdbcType=TIMESTAMP})
AND practitioner_id = #{practitionerId,jdbcType=BIGINT}
AND (task_time_from &lt; STR_TO_DATE(#{taskTimeEnd,jdbcType=VARCHAR}, '%H:%i:%s')
AND task_time_end &gt; STR_TO_DATE(#{taskTimeFrom,jdbcType=VARCHAR}, '%H:%i:%s')
)
</select>
<resultMap id="PersonalPEPScore" type="com.yd.dal.entity.practitioner.PersonalPEPScore">
<result column="practitionerId" jdbcType="BIGINT" property="practitionerId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="mobile_no" jdbcType="VARCHAR" property="mobileNo" typeHandler="com.yd.util.deshandler.DESTypeHandler"/>
<result column="dayScore" jdbcType="BIGINT" property="dayScore"/>
<result column="weekScore" jdbcType="BIGINT" property="weekScore"/>
<result column="monthScore" jdbcType="BIGINT" property="monthScore"/>
<result column="FYC" jdbcType="DECIMAL" property="FYC"/>
</resultMap>
<select id="querySaleRecuitScoreFYC" resultMap="PersonalPEPScore">
SELECT practitionerId, name, dayScore, weekScore, monthScore, COALESCE(fyc,0) FYC, mobile_no
FROM
(select p.id practitionerId,
p.name,
p.mobile_no,
p.customer_id,
sum(case when to_days(t.track_time) = to_days(now()) then COALESCE(t.track_score,0) else 0 end) dayScore,
sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
and to_days(t.track_time) &lt;= to_days(now())
then COALESCE(t.track_score,0) else 0 end) weekScore,
sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m')
and to_days(t.track_time) &lt;= to_days(now())
then COALESCE(t.track_score,0) else 0 end) monthScore
from ag_acl_practitioner p
left join (select practitioner_id, track_time, track_score
from ag_mkt_schedule_task_tracking where md_drop_option_id not in (223,224,225,226,227)
and date_format(track_time,'%Y-%m')=date_format(now(),'%Y-%m')
) t on p.id = t.practitioner_id
where 1=1
and p.is_active=1
and p.id in
<foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT}
</foreach>
group by p.id
) s
LEFT JOIN
(select t.customer_id, sum(t.fyc_amount) fyc
from ag_acl_customer_fortune t left join ag_po_order o on t.order_id = o.id
where o.`status` =3
and o.payment_status =3
and o.fyc_amount>0
and t.drop_option_code ='S01'
and DATE_FORMAT(o.created_at, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' )
group by t.customer_id
) fyc
ON s.customer_id = fyc.customer_id
ORDER BY dayScore desc, weekScore desc, monthScore desc
</select>
<select id="queryTeamAllPractitionerId" resultType="Long">
SELECT id from ag_acl_practitioner
where subordinate_system_id =
(select subordinate_system_id from ag_acl_practitioner where id = #{practitionerId,jdbcType=BIGINT})
</select>
<resultMap id="PersonalSchedule" type="com.yd.dal.entity.practitioner.PersonalSchedule">
<result column="practitioner_id" jdbcType="BIGINT" property="practitionerId"/>
<collection property="scheduleList" ofType="com.yd.dal.entity.practitioner.ScheduleTrack">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="notice" jdbcType="VARCHAR" property="notice"/>
<result column="task_type" jdbcType="INTEGER" property="taskType"/>
<result column="refer_leads_id" jdbcType="BIGINT" property="referLeadsId"/>
<result column="refer_potential_id" jdbcType="BIGINT" property="referPotentialId"/>
<result column="task_important_tag" jdbcType="INTEGER" property="taskImportantTag"/>
<result column="task_routine_at_week7" jdbcType="INTEGER" property="taskRoutineAtweek7"/>
<result column="task_routine_at_week6" jdbcType="INTEGER" property="taskRoutineAtweek6"/>
<result column="task_routine_at_week5" jdbcType="INTEGER" property="taskRoutineAtweek5"/>
<result column="task_routine_at_week4" jdbcType="INTEGER" property="taskRoutineAtweek4"/>
<result column="task_routine_at_week3" jdbcType="INTEGER" property="taskRoutineAtweek3"/>
<result column="task_routine_at_week2" jdbcType="INTEGER" property="taskRoutineAtweek2"/>
<result column="task_routine_at_week1" jdbcType="INTEGER" property="taskRoutineAtweek1"/>
<result column="task_time_from" jdbcType="VARCHAR" property="taskTimeFrom"/>
<result column="task_time_end" jdbcType="VARCHAR" property="taskTimeEnd"/>
<result column="is_active" jdbcType="INTEGER" property="isActive"/>
<result column="practitioner_id" jdbcType="BIGINT" property="practitionerId"/>
<result column="customer_id" jdbcType="BIGINT" property="customerId"/>
<result column="md_drop_option_id" jdbcType="BIGINT" property="mdDropOptionId"/>
<result column="track_score" jdbcType="INTEGER" property="trackScore"/>
<result column="track_time" jdbcType="TIMESTAMP" property="trackTime"/>
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt"/>
<result column="created_by" jdbcType="BIGINT" property="createdBy"/>
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt"/>
<result column="updated_by" jdbcType="BIGINT" property="updatedBy"/>
<result column="updator_type" jdbcType="INTEGER" property="updatorType"/>
<result column="creator_type" jdbcType="INTEGER" property="creatorType"/>
</collection>
</resultMap>
<select id="queryPersonalScheduleList" resultMap="PersonalSchedule">
SELECT id, notice, task_type, refer_leads_id, refer_potential_id,
task_important_tag, task_routine_at_week7,task_routine_at_week6, task_routine_at_week5,
task_routine_at_week4, task_routine_at_week3, task_routine_at_week2, task_routine_at_week1,
task_time_from, task_time_end, is_active, practitioner_id, customer_id, md_drop_option_id, track_score, track_time,
created_at, created_by, updated_at, updated_by, updator_type, creator_type
FROM
ag_mkt_schedule_task_tracking t
WHERE 1=1
AND md_drop_option_id in (223,224,225,226,227)
AND practitioner_id in
<foreach collection="list" item="practitionerId" index="index" open="(" close=")" separator=",">
#{practitionerId,jdbcType=BIGINT}
</foreach>
</select>
<select id="queryPersonalScheduleListByTime" resultMap="ScheduleTrackResultMap">
select id, notice, task_type, refer_leads_id, refer_potential_id,
task_important_tag, task_routine_at_week7,task_routine_at_week6, task_routine_at_week5,
task_routine_at_week4, task_routine_at_week3, task_routine_at_week2, task_routine_at_week1,
task_time_from, task_time_end, is_active, practitioner_id, customer_id, md_drop_option_id, track_score, track_time,
created_at, created_by, updated_at, updated_by, updator_type, creator_type
from ag_mkt_schedule_task_tracking t
where t.practitioner_id = #{practitionerId,jdbcType=BIGINT}
and to_days(t.track_time) &lt;= to_days(now())
<if test="time != null">
<choose>
<when test="time == 'd'.toString() || time == 'D'.toString()">
and to_days(t.track_time) = to_days(now())
</when>
<when test="time == 'w'.toString() || time == 'W'.toString()">
and YEARWEEK(date_format(t.track_time, '%Y-%m-%d')) = YEARWEEK(now())
</when>
<when test="time == 'm'.toString() || time == 'M'.toString()">
and date_format(t.track_time, '%Y-%m') = date_format(now(), '%Y-%m')
</when>
</choose>
</if>
</select>
<delete id="deleteScheduleTrackById">
delete from ag_mkt_schedule_task_tracking where id=#{scheduleTrackId,jdbcType=BIGINT}
</delete>
<select id="queryNameByPractitionerId" resultType="String">
SELECT p.name from ag_acl_practitioner p
where p.id = #{practitionerId,jdbcType=BIGINT}
</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