Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huluobin
gogirl-miniapp-backend
Commits
bdcdbf6d
Commit
bdcdbf6d
authored
May 20, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3a519075
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
64 deletions
+81
-64
Schedule.java
...ain/java/com/gogirl/infrastructure/schedule/Schedule.java
+81
-64
No files found.
src/main/java/com/gogirl/infrastructure/schedule/Schedule.java
View file @
bdcdbf6d
...
...
@@ -25,6 +25,7 @@ import com.gogirl.domain.user.customer.Customer;
import
com.gogirl.domain.user.customer.CustomerBalanceRecord
;
import
com.gogirl.domain.xcx.WeekConfig
;
import
com.gogirl.infrastructure.common.util.DateUtils
;
import
com.gogirl.infrastructure.common.util.JsonUtilByJackson
;
import
com.gogirl.infrastructure.common.util.ListUtil
;
import
com.gogirl.infrastructure.config.property.GogirlProperties
;
import
com.gogirl.infrastructure.mapper.market.coupon.CouponCustomerRelevanceMapper
;
...
...
@@ -46,14 +47,28 @@ import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMappe
import
com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper
;
import
com.gogirl.infrastructure.service.push.PushMsgService
;
import
com.gogirl.infrastructure.service.push.TechnicianPushService
;
import
com.gogirl.shared.admin.AdminPage
;
import
com.gogirl.shared.admin.AdminResult
;
import
com.gogirl.shared.admin.AdminTechnicianScore
;
import
com.gogirl.shared.admin.GetTechnicianPageRequest
;
import
com.google.common.collect.Lists
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.ParameterizedTypeReference
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -106,6 +121,8 @@ public class Schedule {
private
final
TimesCardCustomerRelevanceMapper
timesCardCustomerRelevanceMapper
;
private
final
RestTemplate
restTemplate
;
/**
* 每天3点判断优惠券是否过期。
*/
...
...
@@ -366,7 +383,7 @@ public class Schedule {
/**
* 每天0点定时同步美甲师成长历程
*/
@Scheduled
(
cron
=
"0 0
0
* * *"
)
@Scheduled
(
cron
=
"0 0
/1 *
* * *"
)
public
void
syncTechnicianCareer
()
{
log
.
info
(
"定时同步美甲师成长历程** 任务开始"
);
...
...
@@ -376,50 +393,50 @@ public class Schedule {
storeTechnicianList
.
forEach
(
storeTechnician
->
{
//
ParameterizedTypeReference<AdminResult<AdminPage<AdminTechnicianScore>>> responseBodyType = new ParameterizedTypeReference<AdminResult<AdminPage<AdminTechnicianScore>>>() {
//
};
//
GetTechnicianPageRequest allRequest = GetTechnicianPageRequest.builder()
//
.page(1)
//
.rows(30)
//
.sidx("grade")
//
.sord("asc")
//
//在职
//
.status(1)
//
.technician_id(storeTechnician.getId())
//
.build();
//
HttpHeaders headers = new HttpHeaders();
//
headers.setContentType(MediaType.APPLICATION_JSON);
//
HttpEntity<GetTechnicianPageRequest> allHttpEntity = new HttpEntity<>(allRequest, headers);
//
AdminTechnicianScore allAdminResult = restTemplate.exchange(gogirlProperties.getAdminBackendUrl(), HttpMethod.POST, allHttpEntity, responseBodyType)
//
.getBody()
//
.getData()
//
.getItems()
//
.stream()
//
.findAny()
//
.orElse(new AdminTechnicianScore());
//
GetTechnicianPageRequest monthRequest = GetTechnicianPageRequest.builder()
//
.page(1)
//
.rows(30)
//
.sidx("grade")
//
.sord("asc")
//
//在职
//
.status(1)
//
.date_utc(Lists.newArrayList(LocalDateTime.of(LocalDate.of(2020, 4, 1), LocalTime.of(0, 0)).toString(), LocalDateTime.now().toString()))
//
.technician_id(storeTechnician.getId())
//
.build();
//
//
HttpEntity<GetTechnicianPageRequest> monthHttpEntity = new HttpEntity<>(monthRequest, headers);
//
log.debug(JsonUtilByJackson.writeValueAsString(monthRequest));
//
AdminTechnicianScore monthAdminResult = restTemplate.exchange(gogirlProperties.getAdminBackendUrl(), HttpMethod.POST, monthHttpEntity, responseBodyType)
//
.getBody()
//
.getData()
//
.getItems()
//
.stream()
//
.findAny()
//
.orElse(new AdminTechnicianScore());
ParameterizedTypeReference
<
AdminResult
<
AdminPage
<
AdminTechnicianScore
>>>
responseBodyType
=
new
ParameterizedTypeReference
<
AdminResult
<
AdminPage
<
AdminTechnicianScore
>>>()
{
};
GetTechnicianPageRequest
allRequest
=
GetTechnicianPageRequest
.
builder
()
.
page
(
1
)
.
rows
(
30
)
.
sidx
(
"grade"
)
.
sord
(
"asc"
)
//在职
.
status
(
1
)
.
technician_id
(
storeTechnician
.
getId
())
.
build
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
HttpEntity
<
GetTechnicianPageRequest
>
allHttpEntity
=
new
HttpEntity
<>(
allRequest
,
headers
);
AdminTechnicianScore
allAdminResult
=
restTemplate
.
exchange
(
gogirlProperties
.
getAdminBackendUrl
(),
HttpMethod
.
POST
,
allHttpEntity
,
responseBodyType
)
.
getBody
()
.
getData
()
.
getItems
()
.
stream
()
.
findAny
()
.
orElse
(
new
AdminTechnicianScore
());
GetTechnicianPageRequest
monthRequest
=
GetTechnicianPageRequest
.
builder
()
.
page
(
1
)
.
rows
(
30
)
.
sidx
(
"grade"
)
.
sord
(
"asc"
)
//在职
.
status
(
1
)
.
date_utc
(
Lists
.
newArrayList
(
LocalDateTime
.
of
(
LocalDate
.
of
(
2020
,
4
,
1
),
LocalTime
.
of
(
0
,
0
)).
toString
(),
LocalDateTime
.
now
().
toString
()))
.
technician_id
(
storeTechnician
.
getId
())
.
build
();
HttpEntity
<
GetTechnicianPageRequest
>
monthHttpEntity
=
new
HttpEntity
<>(
monthRequest
,
headers
);
log
.
debug
(
JsonUtilByJackson
.
writeValueAsString
(
monthRequest
));
AdminTechnicianScore
monthAdminResult
=
restTemplate
.
exchange
(
gogirlProperties
.
getAdminBackendUrl
(),
HttpMethod
.
POST
,
monthHttpEntity
,
responseBodyType
)
.
getBody
()
.
getData
()
.
getItems
()
.
stream
()
.
findAny
()
.
orElse
(
new
AdminTechnicianScore
());
Career
career
=
careerMapper
.
selectOne
(
new
LambdaQueryWrapper
<
Career
>().
eq
(
Career:
:
getTechnicianId
,
storeTechnician
.
getId
()));
...
...
@@ -443,66 +460,66 @@ public class Schedule {
/*当月*/
//当月开卡数量
//
career.setMonthBalanceCardNum(monthAdminResult.getCard_count());
career
.
setMonthBalanceCardNum
(
monthAdminResult
.
getCard_count
());
//当月考勤准时
career
.
setMonthAttendancePercent
(
null
);
//当月信息录入完整度
//
career.setMonthInfoPercent(monthAdminResult.getAvg_data_integrity());
career
.
setMonthInfoPercent
(
monthAdminResult
.
getAvg_data_integrity
());
//当月订单总数
Integer
monthOrderNum
=
careerMapper
.
queryMonthOrderNum
(
storeTechnician
.
getId
(),
month
);
career
.
setMonthOrderNum
(
monthOrderNum
);
//当月客户好评率
//
career.setMonthPraisePercent(monthAdminResult.getPraise_proportion());
career
.
setMonthPraisePercent
(
monthAdminResult
.
getPraise_proportion
());
//当月复购率
//
career.setMonthRepurchasePercent(monthAdminResult.getRepeat_purchase_client_roportion());
career
.
setMonthRepurchasePercent
(
monthAdminResult
.
getRepeat_purchase_client_roportion
());
//当月服务客户数
//
career.setMonthServeCustomerNum(monthAdminResult.getTotal_client_count());
career
.
setMonthServeCustomerNum
(
monthAdminResult
.
getTotal_client_count
());
//当月服务次数
//
career.setMonthServeNum(monthAdminResult.getTotal_service_count());
career
.
setMonthServeNum
(
monthAdminResult
.
getTotal_service_count
());
//当月信息录入完整度
//
BigDecimal montInfoPercent = monthAdminResult.getAvg_data_integrity();
//
if (montInfoPercent != null) {
//
career.setMonthInfoPercent(montInfoPercent.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
//
}
BigDecimal
montInfoPercent
=
monthAdminResult
.
getAvg_data_integrity
();
if
(
montInfoPercent
!=
null
)
{
career
.
setMonthInfoPercent
(
montInfoPercent
.
divide
(
new
BigDecimal
(
100
),
2
,
BigDecimal
.
ROUND_HALF_UP
));
}
/*总计*/
//总考勤准时率
career
.
setTotalAttendancePercent
(
null
);
//总开卡数
//
career.setTotalBalanceCardNum(allAdminResult.getCard_count());
career
.
setTotalBalanceCardNum
(
allAdminResult
.
getCard_count
());
//总信息录入完整度
//
BigDecimal totalInfoPercent = allAdminResult.getAvg_data_integrity();
//
if (totalInfoPercent != null) {
//
career.setTotalInfoPercent(totalInfoPercent.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP));
//
}
BigDecimal
totalInfoPercent
=
allAdminResult
.
getAvg_data_integrity
();
if
(
totalInfoPercent
!=
null
)
{
career
.
setTotalInfoPercent
(
totalInfoPercent
.
divide
(
new
BigDecimal
(
100
),
2
,
BigDecimal
.
ROUND_HALF_UP
));
}
//总订单数
Integer
totalOrderNum
=
careerMapper
.
queryTotalOrderNum
(
storeTechnician
.
getId
(),
month
);
career
.
setTotalOrderNum
(
totalOrderNum
);
//总好评率
//
career.setTotalPraisePercent(allAdminResult.getPraise_proportion());
career
.
setTotalPraisePercent
(
allAdminResult
.
getPraise_proportion
());
//总考勤准时比率
career
.
setTotalAttendancePercent
(
null
);
//总复购率
//
career.setTotalRepurchasePercent(allAdminResult.getRepeat_purchase_client_roportion());
career
.
setTotalRepurchasePercent
(
allAdminResult
.
getRepeat_purchase_client_roportion
());
//服务客户总数
//
career.setTotalServeCustomerNum(allAdminResult.getTotal_client_count());
career
.
setTotalServeCustomerNum
(
allAdminResult
.
getTotal_client_count
());
//服务总次数
//
career.setTotalServeNum(allAdminResult.getTotal_service_count());
career
.
setTotalServeNum
(
allAdminResult
.
getTotal_service_count
());
/*美甲师信息*/
//美甲师名字
...
...
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