Commit b6b589bb by jianan

Merge branch 'dev_20200908_PEP_Statistics' into dev

parents 054cfe2c 41032b4b
...@@ -72,8 +72,8 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService { ...@@ -72,8 +72,8 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
Long mdDropOptionId = schedule.getMdDropOptionId(); Long mdDropOptionId = schedule.getMdDropOptionId();
// 判断活动时间段是否冲突 // 判断活动时间段是否冲突
if (!CommonUtil.isNullOrBlank(taskTimeFrom) && !CommonUtil.isNullOrBlank(taskTimeEnd)) { if (!CommonUtil.isNullOrBlank(taskTimeFrom) && !CommonUtil.isNullOrBlank(taskTimeEnd)) {
int count = scheduleTrackMapper.checkTimePeriodConflict(trackTime, taskTimeFrom, taskTimeEnd, practitionerId); boolean isConflict = this.checkTimePeriodConflict(trackTime, taskTimeFrom, taskTimeEnd, practitionerId);
if (count > 0) { if (isConflict) {
resp.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830020"))); resp.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830020")));
return resp; return resp;
} }
...@@ -101,6 +101,8 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService { ...@@ -101,6 +101,8 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
this.insertOpportunityRecord(schedule); this.insertOpportunityRecord(schedule);
} }
if (2 == taskType && null != referPotentialId) { if (2 == taskType && null != referPotentialId) {
AclPractitionerPotential potential = aclPractitionerPotentialMapper.selectByPrimaryKey(referPotentialId);
schedule.setCustomerId(potential.getCustomerId());
this.insertPotentialAssignedTrack(schedule); this.insertPotentialAssignedTrack(schedule);
} }
resp.setCommonResult(new CommonResult(true, "任务添加成功")); resp.setCommonResult(new CommonResult(true, "任务添加成功"));
...@@ -111,6 +113,30 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService { ...@@ -111,6 +113,30 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
return resp; return resp;
} }
private boolean checkTimePeriodConflict(Date trackTime, String taskTimeFrom, String taskTimeEnd, Long practitionerId) {
List<ScheduleTrack> showList = new ArrayList<>();
List<ScheduleTrack> dataList = scheduleTrackMapper.queryScheduleTrackList(practitionerId);
// 获得当天展示的日程列表
for (ScheduleTrack schedule: dataList) {
if (this.checkFixedDay(CommonUtil.dateParseString(trackTime, "yyyy-MM-dd"), schedule)) {
showList.add(schedule);
}
}
// 检查时间段是否冲突
boolean isConflict = false;
String taskStartTime;
String taskEndTime;
for (ScheduleTrack schedule: showList) {
taskStartTime = schedule.getTaskTimeFrom();
taskEndTime = schedule.getTaskTimeEnd();
if (taskStartTime.compareTo(taskTimeEnd)<0 && taskEndTime.compareTo(taskTimeFrom)>0) {
isConflict = true;
break;
}
}
return isConflict;
}
private void insertOpportunityRecord(ScheduleTrack schedule) { private void insertOpportunityRecord(ScheduleTrack schedule) {
MktLeadsAssignedTrack track = new MktLeadsAssignedTrack(); MktLeadsAssignedTrack track = new MktLeadsAssignedTrack();
BeanUtils.copyProperties(schedule, track, "id"); BeanUtils.copyProperties(schedule, track, "id");
...@@ -201,12 +227,6 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService { ...@@ -201,12 +227,6 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
// 获取optionName // 获取optionName
optionName = taskTypeMap.get(schedule.getMdDropOptionId()).getDropOptionName(); optionName = taskTypeMap.get(schedule.getMdDropOptionId()).getDropOptionName();
scheduleTrackVO.setMdDropOptionName(optionName); scheduleTrackVO.setMdDropOptionName(optionName);
// 获取增员姓名和电话
if (schedule.getReferPotentialId() != null) {
AclPractitionerPotential potential = aclPractitionerPotentialMapper.selectByPrimaryKey(schedule.getReferPotentialId());
scheduleTrackVO.setName(potential.getName());
scheduleTrackVO.setMobileNo(potential.getMobileNo());
}
showList.add(scheduleTrackVO); showList.add(scheduleTrackVO);
} }
} }
......
...@@ -109,16 +109,16 @@ ...@@ -109,16 +109,16 @@
p.mobile_no, p.mobile_no,
p.customer_id, 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 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) sum(case when YEARWEEK(date_format(t.track_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1) then COALESCE(t.track_score,0) else 0 end) weekScore,
and to_days(t.track_time) &lt;= to_days(now()) sum(case when date_format(t.track_time,'%Y-%m')=date_format(now(),'%Y-%m') then COALESCE(t.track_score,0) else 0 end) monthScore
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 from ag_acl_practitioner p
left join (select practitioner_id, track_time, track_score 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) from ag_mkt_schedule_task_tracking
and date_format(track_time,'%Y-%m')=date_format(now(),'%Y-%m') where md_drop_option_id not in
(SELECT o.id FROM ag_md_drop_options o LEFT JOIN ag_md_drop_master m ON m.id = o.drop_master_id
WHERE m.scenario_code = 'pep_schedule_task_others')
and date_format(track_time,'%Y-%m')=date_format(now(),'%Y-%m')
and to_days(track_time) &lt;= to_days(now())
) t on p.id = t.practitioner_id ) t on p.id = t.practitioner_id
where 1=1 where 1=1
and p.is_active=1 and p.is_active=1
...@@ -189,7 +189,10 @@ ...@@ -189,7 +189,10 @@
FROM FROM
ag_mkt_schedule_task_tracking t ag_mkt_schedule_task_tracking t
WHERE 1=1 WHERE 1=1
AND md_drop_option_id in (223,224,225,226,227) AND md_drop_option_id in
(SELECT o.id FROM ag_md_drop_options o LEFT JOIN ag_md_drop_master m ON m.id = o.drop_master_id
WHERE m.scenario_code = 'pep_schedule_task_others'
)
AND practitioner_id in 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}
......
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