Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-backend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AutogeneralShanghai
yd-backend
Commits
57192da0
Commit
57192da0
authored
Sep 16, 2020
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PEP得分查询bug修复及优化
parent
0f652e37
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
81 deletions
+143
-81
yd-api/src/main/java/com/yd/api/practitioner/service/impl/ScheduleTrackServiceImpl.java
+104
-60
yd-api/src/main/java/com/yd/api/practitioner/vo/sechedule/QueryPEPScoreResponseVO.java
+3
-2
yd-api/src/main/java/com/yd/dal/entity/practitioner/PersonalPEPScore.java
+15
-0
yd-api/src/main/java/com/yd/dal/mapper/marketing/ScheduleTrackMapper.java
+3
-2
yd-api/src/main/resources/mapper/marketing/ScheduleTrackMapper.xml
+18
-17
No files found.
yd-api/src/main/java/com/yd/api/practitioner/service/impl/ScheduleTrackServiceImpl.java
View file @
57192da0
...
@@ -6,6 +6,7 @@ import com.yd.api.result.CommonResult;
...
@@ -6,6 +6,7 @@ import com.yd.api.result.CommonResult;
import
com.yd.dal.entity.customer.AclPractitionerPotentialAssignedTrack
;
import
com.yd.dal.entity.customer.AclPractitionerPotentialAssignedTrack
;
import
com.yd.dal.entity.marketing.MktLeadsAssignedTrack
;
import
com.yd.dal.entity.marketing.MktLeadsAssignedTrack
;
import
com.yd.dal.entity.meta.MdDropOptions
;
import
com.yd.dal.entity.meta.MdDropOptions
;
import
com.yd.dal.entity.practitioner.PersonalPEPScore
;
import
com.yd.dal.entity.practitioner.PersonalSchedule
;
import
com.yd.dal.entity.practitioner.PersonalSchedule
;
import
com.yd.dal.entity.practitioner.ScheduleTrack
;
import
com.yd.dal.entity.practitioner.ScheduleTrack
;
import
com.yd.dal.mapper.marketing.ScheduleTrackMapper
;
import
com.yd.dal.mapper.marketing.ScheduleTrackMapper
;
...
@@ -215,81 +216,124 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
...
@@ -215,81 +216,124 @@ public class ScheduleTrackServiceImpl implements ScheduleTrackService {
default
:
default
:
break
;
break
;
}
}
if
(
trackTime
.
equals
(
trackDate
)
||
Integer
.
valueOf
(
1
).
equals
(
flag
))
{
return
trackTime
.
equals
(
trackDate
)
||
Integer
.
valueOf
(
1
).
equals
(
flag
);
return
true
;
}
else
{
return
false
;
}
}
}
@Override
@Override
public
QueryPEPScoreResponseVO
queryPEPScore
(
Long
practitionerId
)
{
public
QueryPEPScoreResponseVO
queryPEPScore
(
Long
practitionerId
)
{
QueryPEPScoreResponseVO
resp
=
new
QueryPEPScoreResponseVO
();
QueryPEPScoreResponseVO
resp
=
new
QueryPEPScoreResponseVO
();
// 获取本月第一天
try
{
Calendar
cal
=
Calendar
.
getInstance
();
// 获取本月第一天
cal
.
add
(
Calendar
.
MONTH
,
0
);
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
);
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
monthOne
=
cal
.
getTime
();
// 获取本月当前日的年月日时分秒格式
Date
today
=
new
Date
();
// 获取本月当前日的年月日时分秒格式
// 获取本周第一天(周一为始)
Date
today
=
new
Date
();
cal
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
// 获取本周第一天(周一为始)
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
cal
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
cal
.
set
(
Calendar
.
SECOND
,
0
);
cal
.
set
(
Calendar
.
MINUTE
,
0
);
Date
weekOne
=
cal
.
getTime
();
cal
.
set
(
Calendar
.
SECOND
,
0
);
Date
weekOne
=
cal
.
getTime
();
// 根据团队长经纪人id查询团队每个成员本日,本周,本月得分以及本月FYC
List
<
Map
<
String
,
Object
>>
saleAndRecuit
=
scheduleTrackMapper
.
querySaleRecuitScoreFYC
(
practitionerId
,
monthOne
,
today
);
// 根据团队长经纪人id查询团队每个成员本日,本周,本月得分以及本月FYC
List
<
PersonalPEPScore
>
saleAndRecuit
=
scheduleTrackMapper
.
querySaleRecuitScoreFYC
(
practitionerId
,
monthOne
,
today
);
// 其他活动有长期固定,通过计算时间段内展示次数,算得总分
// 先获得每个人所有的其他活动
// 其他活动有长期固定,通过计算时间段内展示次数,算得总分
List
<
Long
>
practitionerIdList
=
scheduleTrackMapper
.
queryTeamAllPractitionerId
(
practitionerId
);
// 先获得每个人所有的其他活动
List
<
PersonalSchedule
>
personalScheduleList
=
scheduleTrackMapper
.
queryPersonalScheduleList
(
practitionerIdList
);
List
<
Long
>
practitionerIdList
=
scheduleTrackMapper
.
queryTeamAllPractitionerId
(
practitionerId
);
List
<
PersonalSchedule
>
personalScheduleList
=
scheduleTrackMapper
.
queryPersonalScheduleList
(
practitionerIdList
);
// 根据活动算本日,本周,本月的分数
this
.
computeOtherScore
(
personalScheduleList
,
today
,
weekOne
,
monthOne
);
// 根据活动算本日,本周,本月的分数
// 最后合并营销增员和其他活动的分数
this
.
computeOtherScore
(
personalScheduleList
,
today
,
weekOne
,
monthOne
);
this
.
mergeScore
(
personalScheduleList
,
saleAndRecuit
);
// 最后合并营销增员和其他活动的分数
this
.
mergeScore
(
personalScheduleList
,
saleAndRecuit
);
resp
.
setPersonalList
(
saleAndRecuit
);
// 计算团队平均分
Map
<
String
,
Object
>
average
=
this
.
computeTeamAverageScore
(
saleAndRecuit
,
practitionerIdList
.
size
());
System
.
out
.
println
(
"看看结果集"
);
System
.
out
.
println
(
saleAndRecuit
);
resp
.
setPersonalList
(
saleAndRecuit
);
resp
.
setAverage
(
average
);
resp
.
setCommonResult
(
new
CommonResult
(
true
,
ZHBErrorConfig
.
getErrorInfo
(
"800000"
)));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
resp
.
setCommonResult
(
new
CommonResult
(
false
,
ZHBErrorConfig
.
getErrorInfo
(
"800001"
)));
}
return
resp
;
return
resp
;
}
}
private
void
mergeScore
(
List
<
PersonalSchedule
>
personalScheduleList
,
List
<
Map
<
String
,
Object
>>
saleAndRecuit
)
{
private
Map
<
String
,
Object
>
computeTeamAverageScore
(
List
<
PersonalPEPScore
>
saleAndRecuit
,
int
teamSize
)
{
DecimalFormat
df
=
new
DecimalFormat
(
"#.##%"
);
PersonalPEPScore
personalScore
=
null
;
for
(
Map
<
String
,
Object
>
scoreMap:
saleAndRecuit
)
{
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
=
0
D
;
Double
weekAverage
=
0
D
;
Double
monthAverage
=
0
D
;
// 平均分效
Double
rate
=
0
D
;
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
);
for
(
PersonalSchedule
perSchedule:
personalScheduleList
)
{
return
average
;
Long
curPractitionerId
=
perSchedule
.
getPractitionerId
();
}
if
(
curPractitionerId
.
equals
(
scoreMap
.
get
(
"practitionerId"
)))
{
Map
<
String
,
Long
>
otherMap
=
perSchedule
.
getOther
();
Long
dayScore
=
Long
.
parseLong
(
scoreMap
.
get
(
"dayScore"
).
toString
())
+
otherMap
.
get
(
"dayScore"
);
private
void
mergeScore
(
List
<
PersonalSchedule
>
personalScheduleList
,
List
<
PersonalPEPScore
>
saleAndRecuit
)
{
Long
weekScore
=
Long
.
parseLong
(
scoreMap
.
get
(
"weekScore"
).
toString
())
+
otherMap
.
get
(
"weekScore"
);
for
(
PersonalPEPScore
socre
:
saleAndRecuit
)
{
Long
monthScore
=
Long
.
parseLong
(
scoreMap
.
get
(
"monthScore"
).
toString
())
+
otherMap
.
get
(
"monthScore"
);
for
(
PersonalSchedule
schedule
:
personalScheduleList
)
{
Long
curPractitionerId
=
schedule
.
getPractitionerId
();
if
(
curPractitionerId
.
equals
(
socre
.
getPractitionerId
()))
{
Map
<
String
,
Long
>
otherMap
=
schedule
.
getOther
();
scoreMap
.
put
(
"dayScore"
,
dayScore
);
Long
dayScore
=
socre
.
getDayScore
()
+
otherMap
.
get
(
"dayScore"
);
scoreMap
.
put
(
"weekScore"
,
weekScore
);
Long
weekScore
=
socre
.
getWeekScore
()
+
otherMap
.
get
(
"weekScore"
);
scoreMap
.
put
(
"monthScore"
,
monthScore
);
Long
monthScore
=
socre
.
getMonthScore
()
+
otherMap
.
get
(
"monthScore"
);
socre
.
setDayScore
(
dayScore
);
socre
.
setWeekScore
(
weekScore
);
socre
.
setMonthScore
(
monthScore
);
}
}
}
}
// 单人分效 scoreMap.get("monthScore").toString()
Double
rate
=
0
D
;
Double
rate
=
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
scoreMap
.
get
(
"FYC"
).
toString
()))
if
(!
CommonUtil
.
isNullOrZero
(
socre
.
getMonthScore
())){
.
divide
(
BigDecimal
.
valueOf
(
Long
.
parseLong
(
scoreMap
.
get
(
"monthScore"
).
toString
())
),
2
,
BigDecimal
.
ROUND_HALF_UP
)
// 单人分效
.
doubleValue
();
rate
=
socre
.
getFYC
().
divide
(
BigDecimal
.
valueOf
(
socre
.
getMonthScore
()),
2
,
BigDecimal
.
ROUND_HALF_UP
)
scoreMap
.
put
(
"rate"
,
df
.
format
(
rate
));
.
doubleValue
();
}
socre
.
setRate
(
rate
);
}
}
}
}
private
void
computeOtherScore
(
List
<
PersonalSchedule
>
personalScheduleList
,
Date
today
,
Date
weekOne
,
Date
monthOne
)
{
private
void
computeOtherScore
(
List
<
PersonalSchedule
>
personalScheduleList
,
Date
today
,
Date
weekOne
,
Date
monthOne
)
{
...
...
yd-api/src/main/java/com/yd/api/practitioner/vo/sechedule/QueryPEPScoreResponseVO.java
View file @
57192da0
package
com
.
yd
.
api
.
practitioner
.
vo
.
sechedule
;
package
com
.
yd
.
api
.
practitioner
.
vo
.
sechedule
;
import
com.yd.api.result.CommonResult
;
import
com.yd.api.result.CommonResult
;
import
com.yd.dal.entity.practitioner.PersonalPEPScore
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.List
;
...
@@ -8,7 +9,7 @@ import java.util.Map;
...
@@ -8,7 +9,7 @@ import java.util.Map;
@Data
@Data
public
class
QueryPEPScoreResponseVO
{
public
class
QueryPEPScoreResponseVO
{
private
Map
<
String
,
String
>
average
;
private
Map
<
String
,
Object
>
average
;
private
List
<
Map
<
String
,
Object
>
>
personalList
;
private
List
<
PersonalPEPScore
>
personalList
;
private
CommonResult
commonResult
;
private
CommonResult
commonResult
;
}
}
yd-api/src/main/java/com/yd/dal/entity/practitioner/PersonalPEPScore.java
0 → 100644
View file @
57192da0
package
com
.
yd
.
dal
.
entity
.
practitioner
;
import
lombok.Data
;
import
java.math.BigDecimal
;
@Data
public
class
PersonalPEPScore
{
private
Long
practitionerId
;
private
String
name
;
private
Long
dayScore
;
private
Long
weekScore
;
private
Long
monthScore
;
private
BigDecimal
FYC
;
private
Double
rate
;
}
yd-api/src/main/java/com/yd/dal/mapper/marketing/ScheduleTrackMapper.java
View file @
57192da0
package
com
.
yd
.
dal
.
mapper
.
marketing
;
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.PersonalSchedule
;
import
com.yd.dal.entity.practitioner.ScheduleTrack
;
import
com.yd.dal.entity.practitioner.ScheduleTrack
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -17,8 +18,8 @@ public interface ScheduleTrackMapper {
...
@@ -17,8 +18,8 @@ public interface ScheduleTrackMapper {
int
checkTimePeriodConflict
(
@Param
(
"taskTimeFrom"
)
String
taskTimeFrom
,
@Param
(
"taskTimeEnd"
)
String
taskTimeEnd
,
int
checkTimePeriodConflict
(
@Param
(
"taskTimeFrom"
)
String
taskTimeFrom
,
@Param
(
"taskTimeEnd"
)
String
taskTimeEnd
,
@Param
(
"practitionerId"
)
Long
practitionerId
);
@Param
(
"practitionerId"
)
Long
practitionerId
);
List
<
Map
<
String
,
Object
>
>
querySaleRecuitScoreFYC
(
@Param
(
"practitionerId"
)
Long
practitionerId
,
@Param
(
"firstDay"
)
Date
firstDay
,
List
<
PersonalPEPScore
>
querySaleRecuitScoreFYC
(
@Param
(
"practitionerId"
)
Long
practitionerId
,
@Param
(
"firstDay"
)
Date
firstDay
,
@Param
(
"lastDay"
)
Date
lastDay
);
@Param
(
"lastDay"
)
Date
lastDay
);
List
<
Map
<
String
,
Object
>>
queryOtherScore
(
@Param
(
"practitionerId"
)
Long
practitionerId
);
List
<
Map
<
String
,
Object
>>
queryOtherScore
(
@Param
(
"practitionerId"
)
Long
practitionerId
);
...
...
yd-api/src/main/resources/mapper/marketing/ScheduleTrackMapper.xml
View file @
57192da0
...
@@ -87,23 +87,23 @@
...
@@ -87,23 +87,23 @@
</select>
</select>
<select
id=
"querySaleRecuitScoreFYC"
resultType=
"
hashmap
"
>
<select
id=
"querySaleRecuitScoreFYC"
resultType=
"
com.yd.dal.entity.practitioner.PersonalPEPScore
"
>
SELECT practitioner
_id
, dayScore, weekScore, monthScore, COALESCE(fyc,0) FYC
SELECT practitioner
Id, name
, dayScore, weekScore, monthScore, COALESCE(fyc,0) FYC
FROM
FROM
(select p
ractitioner_i
d,
(select p
.id practitionerI
d,
sum(case when to_days(created_at) = to_days(now()) then COALESCE(track_score,0) else 0 end) dayScor
e,
p.nam
e,
sum(case when
YEARWEEK(date_format(created_at,'%Y-%m-%d'),1) = YEARWEEK(now(),1) then COALESCE(track_score,0) else 0 end) week
Score,
sum(case when
to_days(t.created_at) = to_days(now()) then COALESCE(t.track_score,0) else 0 end) day
Score,
sum(case when
date_format(created_at,'%Y-%m')=date_format(now(),'%Y-%m') then COALESCE(track_score,0) else 0 end) monthScore
sum(case when
YEARWEEK(date_format(t.created_at,'%Y-%m-%d'),1) = YEARWEEK(now(),1) then COALESCE(t.track_score,0) else 0 end) weekScore,
from ag_mkt_schedule_task_tracking
sum(case when date_format(t.created_at,'%Y-%m')=date_format(now(),'%Y-%m') then COALESCE(t.track_score,0) else 0 end) monthScore
where is_active = 1
from ag_acl_practitioner p
and practitioner_id in (SELECT id from ag_acl_practitioner
left join (select practitioner_id, created_at, track_score
where subordinate_system_id =
from ag_mkt_schedule_task_tracking where md_drop_option_id not in (223,224,225,226,227)
(select subordinate_system_id from ag_acl_practitioner where id = #{practitionerId,jdbcType=BIGINT})
) t on p.id = t.practitioner_id
)
left join ag_acl_practitioner_subordinate_system s on s.id = p.subordinate_system_id
and md_drop_option_id not in (223,224,225,226,227)
where s.owner_practitioner_id = #{practitionerId,jdbcType=BIGINT}
and
created_at between #{firstDay,jdbcType=TIMESTAMP}
and
s.is_active=1
and #{lastDay,jdbcType=TIMESTAMP}
and p.is_active=1
group by p
ractitioner_
id
group by p
.
id
) s
) s
LEFT JOIN
LEFT JOIN
(select t.customer_id, sum(t.fyc_amount) fyc
(select t.customer_id, sum(t.fyc_amount) fyc
...
@@ -116,7 +116,8 @@
...
@@ -116,7 +116,8 @@
and #{lastDay,jdbcType=TIMESTAMP}
and #{lastDay,jdbcType=TIMESTAMP}
group by t.customer_id
group by t.customer_id
) fyc
) fyc
ON s.practitioner_id = fyc.customer_id
ON s.practitionerId = fyc.customer_id
ORDER BY dayScore desc, weekScore desc, monthScore desc
</select>
</select>
<select
id=
"queryTeamAllPractitionerId"
resultType=
"Long"
>
<select
id=
"queryTeamAllPractitionerId"
resultType=
"Long"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment