Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
291a8ccf
Commit
291a8ccf
authored
Aug 13, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
行为日志记录
parent
4ecde1ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
40 deletions
+42
-40
CustomerBehaviorNotesBiz.java
.../platform/user/behavior/biz/CustomerBehaviorNotesBiz.java
+40
-38
CustomerBehaviorNotesController.java
...m/user/behavior/rest/CustomerBehaviorNotesController.java
+2
-2
No files found.
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/biz/CustomerBehaviorNotesBiz.java
View file @
291a8ccf
...
...
@@ -54,23 +54,10 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
behaviorAndDataMap
=
customerBehaviorNotes
.
stream
().
collect
(
Collectors
.
groupingBy
(
CustomerBehaviorNotes:
:
getType
,
Collectors
.
toList
()));
}
long
between_day
=
0
;
if
(
startTime
!=
null
&&
endTime
!=
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
startTime
),
Instant
.
ofEpochMilli
(
endTime
));
}
else
{
ActivityListDTO
activityListDTO
=
activityFeign
.
findActivityStartTimeAndEndTimeById
(
activityId
);
if
(
startTime
!=
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
startTime
),
Instant
.
now
());
}
if
(
endTime
!=
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
activityListDTO
.
getActivity_startTime
()),
Instant
.
ofEpochMilli
(
endTime
));
}
if
(
startTime
==
null
&&
endTime
==
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
activityListDTO
.
getActivity_startTime
()),
Instant
.
now
());
}
}
//获取时间间隔
long
between_day
=
getBetween_day
(
activityId
,
startTime
,
endTime
);
between_day
=
Math
.
abs
(
between_day
)==
0
?
1
:
Math
.
abs
(
between_day
);
between_day
=
Math
.
abs
(
between_day
)==
0
?
1
:
Math
.
abs
(
between_day
);
EnumSet
<
BehaviorEnum
>
behaviorEnums
=
EnumSet
.
allOf
(
BehaviorEnum
.
class
);
BehaviorNoteCollectVo
behaviorNoteCollectVo
;
for
(
BehaviorEnum
behaviorEnum
:
behaviorEnums
)
{
...
...
@@ -80,43 +67,58 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
behaviorNoteCollectVos
.
add
(
behaviorNoteCollectVo
);
continue
;
}
else
{
long
default_p_total
,
default_p_avg
,
default_u_total
,
default_u_avg
;
switch
(
behaviorEnum
)
{
case
SUCCESS_INVIT:
int
total
=
popularizeRelations
.
size
();
long
avg
=
(
total
/
between_day
);
behaviorNoteCollectVo
.
setP_count
(
total
);
behaviorNoteCollectVo
.
setP_avg_count
(
avg
);
behaviorNoteCollectVo
.
setU_count
(
total
);
behaviorNoteCollectVo
.
setU_avg_count
(
avg
);
default_p_total
=
popularizeRelations
.
size
();
default_p_avg
=
(
default_p_total
/
between_day
);
default_u_total
=
default_p_total
;
default_u_avg
=
default_p_avg
;
break
;
case
SUCCESS_MORE_10_INVIT:
long
default_totalMore10
=
popularizeRelations
.
stream
().
collect
(
Collectors
.
groupingBy
(
ActivityPopularizeRelationDTO:
:
getMajorUserId
,
Collectors
.
counting
())).
values
().
stream
().
filter
(
x
->
x
>=
10
).
count
();
long
default_avgMore10
=
default_totalMore10
/
between_day
;
behaviorNoteCollectVo
.
setP_count
(
default_totalMore10
);
behaviorNoteCollectVo
.
setP_avg_count
(
default_avgMore10
);
behaviorNoteCollectVo
.
setU_count
(
default_totalMore10
);
behaviorNoteCollectVo
.
setU_avg_count
(
default_avgMore10
);
default_p_total
=
popularizeRelations
.
stream
().
collect
(
Collectors
.
groupingBy
(
ActivityPopularizeRelationDTO:
:
getMajorUserId
,
Collectors
.
counting
())).
values
().
stream
().
filter
(
x
->
x
>=
10
).
count
();
default_p_avg
=
default_p_total
/
between_day
;
default_u_total
=
default_p_total
;
default_u_avg
=
default_p_avg
;
break
;
default
:
//访问量
List
<
CustomerBehaviorNotes
>
customerBehaviors
=
behaviorAndDataMap
==
null
?
Collections
.
EMPTY_LIST
:
behaviorAndDataMap
.
get
(
behaviorEnum
.
getCode
());
boolean
typeIsEmpty
=
CollectionUtils
.
isEmpty
(
customerBehaviors
);
long
default_p_total
=
typeIsEmpty
?
0
:
customerBehaviors
.
size
();
long
default_p_avg
=
default_p_total
/
between_day
;
behaviorNoteCollectVo
.
setP_count
(
default_p_total
);
behaviorNoteCollectVo
.
setP_avg_count
(
default_p_avg
);
default_p_total
=
typeIsEmpty
?
0
:
customerBehaviors
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
//用户访问量
Set
<
CustomerBehaviorNotes
>
customerBehaviorsSet
=
new
HashSet
<>(
typeIsEmpty
?
Collections
.
EMPTY_SET
:
customerBehaviorNotes
);
long
default_u_total
=
customerBehaviorsSet
.
size
();
long
default_u_avg
=
default_u_total
/
between_day
;
behaviorNoteCollectVo
.
setU_count
(
default_u_total
);
behaviorNoteCollectVo
.
setU_avg_count
(
default_u_avg
);
Set
<
CustomerBehaviorNotes
>
customerBehaviorsSet
=
new
HashSet
<>(
typeIsEmpty
?
Collections
.
EMPTY_SET
:
customerBehaviors
);
default_u_total
=
customerBehaviorsSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
break
;
}
behaviorNoteCollectVo
.
setP_count
(
default_p_total
);
behaviorNoteCollectVo
.
setP_avg_count
(
default_p_avg
);
behaviorNoteCollectVo
.
setU_count
(
default_u_total
);
behaviorNoteCollectVo
.
setU_avg_count
(
default_u_avg
);
behaviorNoteCollectVos
.
add
(
behaviorNoteCollectVo
);
}
}
return
behaviorNoteCollectVos
;
}
private
long
getBetween_day
(
Integer
activityId
,
Long
startTime
,
Long
endTime
)
{
long
between_day
=
0
;
if
(
startTime
!=
null
&&
endTime
!=
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
startTime
),
Instant
.
ofEpochMilli
(
endTime
));
}
else
{
ActivityListDTO
activityListDTO
=
activityFeign
.
findActivityStartTimeAndEndTimeById
(
activityId
);
if
(
startTime
!=
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
startTime
),
Instant
.
now
());
}
if
(
endTime
!=
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
activityListDTO
.
getActivity_startTime
()),
Instant
.
ofEpochMilli
(
endTime
));
}
if
(
startTime
==
null
&&
endTime
==
null
){
between_day
=
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
activityListDTO
.
getActivity_startTime
()),
Instant
.
now
());
}
}
return
between_day
;
}
}
\ No newline at end of file
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/rest/CustomerBehaviorNotesController.java
View file @
291a8ccf
...
...
@@ -21,13 +21,13 @@ import java.util.Objects;
* @data 2019/8/12 14:14
*/
@RestController
@RequestMapping
(
"customerBehaviorNotes"
)
@RequestMapping
(
"
/
customerBehaviorNotes"
)
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
CustomerBehaviorNotesController
{
private
final
CustomerBehaviorNotesBiz
customerBehaviorNotesBiz
;
@PostMapping
(
"app/unauth/save"
)
@PostMapping
(
"
/
app/unauth/save"
)
public
ObjectRestResponse
<
Void
>
saveCustomerBehavior
(
@RequestBody
CustomerBehaviorNoteDTO
customerBehaviorNoteDTO
,
AppUserDTO
appUserDTO
)
{
if
(
Objects
.
nonNull
(
appUserDTO
.
getUserid
()))
{
customerBehaviorNoteDTO
.
setCustomerId
(
String
.
valueOf
(
appUserDTO
.
getUserid
()));
...
...
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