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
4e69edea
Commit
4e69edea
authored
Aug 14, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
行为日志记录
parent
a89fb725
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
95 deletions
+134
-95
BehaviorTypeBiz.java
.../com/xxfc/platform/user/behavior/biz/BehaviorTypeBiz.java
+2
-11
CustomerBehaviorNotesBiz.java
.../platform/user/behavior/biz/CustomerBehaviorNotesBiz.java
+115
-81
ActivityBehaviorMapper.java
...platform/user/behavior/mapper/ActivityBehaviorMapper.java
+1
-1
ActivityBehaviorRelationMapper.java
.../user/behavior/mapper/ActivityBehaviorRelationMapper.java
+1
-1
BehaviorTypeMapper.java
...xfc/platform/user/behavior/mapper/BehaviorTypeMapper.java
+14
-0
CustomerBehaviorNotesMapper.xml
...src/main/resources/mapper/CustomerBehaviorNotesMapper.xml
+1
-1
No files found.
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/biz/BehaviorTypeBiz.java
View file @
4e69edea
...
...
@@ -4,10 +4,8 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import
com.xxfc.platform.user.behavior.dto.BehaviorTypeDTO
;
import
com.xxfc.platform.user.behavior.entity.BehaviorType
;
import
com.xxfc.platform.user.behavior.mapper.BehaviorTypeMapper
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -20,14 +18,7 @@ import java.util.List;
public
class
BehaviorTypeBiz
extends
BaseBiz
<
BehaviorTypeMapper
,
BehaviorType
>
{
public
List
<
BehaviorTypeDTO
>
findBehaviorTypesByIds
(
List
<
Integer
>
typeIds
){
List
<
BehaviorTypeDTO
>
behaviorTypeDTOS
=
new
ArrayList
<>();
List
<
BehaviorType
>
behaviorTypes
=
mapper
.
selectByIdList
(
typeIds
);
BehaviorTypeDTO
behaviorTypeDTO
;
for
(
BehaviorType
behaviorType
:
behaviorTypes
)
{
behaviorTypeDTO
=
new
BehaviorTypeDTO
();
BeanUtils
.
copyProperties
(
behaviorType
,
behaviorTypeDTO
);
behaviorTypeDTOS
.
add
(
behaviorTypeDTO
);
}
return
behaviorTypeDTOS
;
return
mapper
.
selectAllByIdList
(
typeIds
);
}
}
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/biz/CustomerBehaviorNotesBiz.java
View file @
4e69edea
...
...
@@ -84,6 +84,9 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
}
//根据活动id查询活动行为
List
<
ActivityBehaviorDTO
>
activityBehaviorDTOS
=
activityBehaviorBiz
.
findActivityBehaviorsByActivityId
(
activityId
);
if
(
CollectionUtils
.
isEmpty
(
activityBehaviorDTOS
)){
return
Collections
.
EMPTY_LIST
;
}
List
<
Integer
>
behaviorTypeIds
=
activityBehaviorDTOS
.
stream
().
map
(
ActivityBehaviorDTO:
:
getBehaviorTypeId
).
collect
(
Collectors
.
toList
());
//根据活动行为ids查询行为
List
<
BehaviorTypeDTO
>
behaviorTypeDTOS
=
behaviorTypeBiz
.
findBehaviorTypesByIds
(
behaviorTypeIds
);
...
...
@@ -97,89 +100,52 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
for
(
BehaviorEnum
behaviorEnum
:
behaviorEnums
)
{
behaviorNoteCollectVo
=
new
BehaviorNoteCollectVo
();
behaviorNoteCollectVo
.
setBehavior
(
codeAndName
.
get
(
behaviorEnum
.
getCode
()));
if
(
isEmpty
)
{
behaviorNoteCollectVos
.
add
(
behaviorNoteCollectVo
);
continue
;
}
else
{
long
default_p_total
,
default_p_avg
,
default_u_total
,
default_u_avg
;
long
default_p_total
,
default_p_avg
;
ActionAcount
actionAcount
;
switch
(
behaviorEnum
)
{
case
SUCCESS_INVIT:
actionAcount
=
new
ActionAcount
();
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
;
actionAcount
.
setDefault_p_total
(
default_p_total
);
actionAcount
.
setDefault_p_avg
(
default_p_avg
);
actionAcount
.
setDefault_u_total
(
default_p_total
);
actionAcount
.
setDefault_u_avg
(
default_p_avg
);
break
;
case
SUCCESS_MORE_10_INVIT:
actionAcount
=
new
ActionAcount
();
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
;
actionAcount
.
setDefault_p_total
(
default_p_total
);
actionAcount
.
setDefault_p_avg
(
default_p_avg
);
actionAcount
.
setDefault_u_total
(
default_p_total
);
actionAcount
.
setDefault_u_avg
(
default_p_avg
);
break
;
case
APP_VISIT_COUNT:
actionAcount
=
new
ActionAcount
();
default_p_total
=
mapper
.
selectAppVvisitsByType
(
BehaviorEnum
.
APP_VISIT_COUNT
.
getCode
());
default_p_avg
=
default_p_total
/
between_day
;
default_u_total
=
default_p_total
;
default_u_avg
=
default_p_avg
;
actionAcount
.
setDefault_p_total
(
default_p_total
);
actionAcount
.
setDefault_p_avg
(
default_p_avg
);
actionAcount
.
setDefault_u_total
(
default_p_total
);
actionAcount
.
setDefault_u_avg
(
default_p_avg
);
break
;
case
BANNER_CLICK:
List
<
CustomerBehaviorNotes
>
bannerClickData
=
behaviorTypeAndDataOfBizMap
.
get
(
BehaviorEnum
.
BANNER_CLICK
.
getCode
());
boolean
isEmptyofBannerClick
=
CollectionUtils
.
isEmpty
(
bannerClickData
);
default_p_total
=
isEmptyofBannerClick
?
0
:
bannerClickData
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
Set
<
CustomerBehaviorNotes
>
bannerClickDataSet
=
new
HashSet
<>(
isEmptyofBannerClick
?
Collections
.
EMPTY_SET
:
bannerClickData
);
default_u_total
=
bannerClickDataSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
break
;
case
WONDERFUL_ACTIVITY_CLICK:
List
<
CustomerBehaviorNotes
>
wonderfulActivityClickData
=
behaviorTypeAndDataOfBizMap
.
get
(
BehaviorEnum
.
WONDERFUL_ACTIVITY_CLICK
.
getCode
());
boolean
isEmptyofwonderful
=
CollectionUtils
.
isEmpty
(
wonderfulActivityClickData
);
default_p_total
=
isEmptyofwonderful
?
0
:
wonderfulActivityClickData
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
Set
<
CustomerBehaviorNotes
>
wonderfulActivityClickDataSet
=
new
HashSet
<>(
isEmptyofwonderful
?
Collections
.
EMPTY_SET
:
wonderfulActivityClickData
);
default_u_total
=
wonderfulActivityClickDataSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
break
;
case
DIALOG_WINDOW_TO:
List
<
CustomerBehaviorNotes
>
dialogWindowToData
=
behaviorTypeAndDataOfBizMap
.
get
(
BehaviorEnum
.
DIALOG_WINDOW_TO
);
boolean
isEmptyofdialogwindowto
=
CollectionUtils
.
isEmpty
(
dialogWindowToData
);
default_p_total
=
isEmptyofdialogwindowto
?
0
:
dialogWindowToData
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
Set
<
CustomerBehaviorNotes
>
dialogWindowtoSet
=
new
HashSet
<>(
isEmptyofdialogwindowto
?
Collections
.
EMPTY_SET
:
dialogWindowToData
);
default_u_total
=
dialogWindowtoSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
break
;
case
DIALOG_WINDOW:
List
<
CustomerBehaviorNotes
>
dialogWindowData
=
behaviorTypeAndDataOfBizMap
.
get
(
BehaviorEnum
.
DIALOG_WINDOW
);
boolean
isEmptyofdialogwindow
=
CollectionUtils
.
isEmpty
(
dialogWindowData
);
default_p_total
=
isEmptyofdialogwindow
?
0
:
dialogWindowData
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
Set
<
CustomerBehaviorNotes
>
dialogWindowSet
=
new
HashSet
<>(
isEmptyofdialogwindow
?
Collections
.
EMPTY_SET
:
dialogWindowData
);
default_u_total
=
dialogWindowSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
actionAcount
=
new
ActionAcount
(
between_day
,
behaviorTypeAndDataOfBizMap
).
invoke
(
behaviorEnum
);
break
;
default
:
//访问量
List
<
CustomerBehaviorNotes
>
customerBehaviors
=
behaviorAndDataMap
.
get
(
behaviorEnum
.
getCode
());
boolean
typeIsEmpty
=
CollectionUtils
.
isEmpty
(
customerBehaviors
);
default_p_total
=
typeIsEmpty
?
0
:
customerBehaviors
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
//用户访问量
Set
<
CustomerBehaviorNotes
>
customerBehaviorsSet
=
new
HashSet
<>(
typeIsEmpty
?
Collections
.
EMPTY_SET
:
customerBehaviors
);
default_u_total
=
customerBehaviorsSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
actionAcount
=
new
ActionAcount
(
between_day
,
behaviorAndDataMap
).
invoke
(
behaviorEnum
);
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
);
behaviorNoteCollectVo
.
setP_count
(
actionAcount
.
getDefault_p_total
()
);
behaviorNoteCollectVo
.
setP_avg_count
(
actionAcount
.
getDefault_p_avg
()
);
behaviorNoteCollectVo
.
setU_count
(
actionAcount
.
getDefault_u_total
()
);
behaviorNoteCollectVo
.
setU_avg_count
(
actionAcount
.
getDefault_u_avg
()
);
behaviorNoteCollectVos
.
add
(
behaviorNoteCollectVo
);
}
}
return
behaviorNoteCollectVos
;
}
...
...
@@ -201,4 +167,72 @@ public class CustomerBehaviorNotesBiz extends BaseBiz<CustomerBehaviorNotesMappe
return
ChronoUnit
.
DAYS
.
between
(
Instant
.
ofEpochMilli
(
startTime
.
get
()),
Instant
.
ofEpochMilli
(
endTime
.
get
()));
}
private
class
ActionAcount
{
private
long
between_day
;
private
Map
<
Integer
,
List
<
CustomerBehaviorNotes
>>
behaviorMap
;
private
long
default_p_total
;
private
long
default_p_avg
;
private
long
default_u_total
;
private
long
default_u_avg
;
public
ActionAcount
(
long
between_day
,
Map
<
Integer
,
List
<
CustomerBehaviorNotes
>>
behaviorMap
)
{
this
.
between_day
=
between_day
;
this
.
behaviorMap
=
behaviorMap
;
}
public
ActionAcount
()
{
}
public
ActionAcount
invoke
(
BehaviorEnum
behaviorEnum
)
{
List
<
CustomerBehaviorNotes
>
behaviorTypeData
=
behaviorMap
.
get
(
behaviorEnum
.
getCode
());
boolean
isEmpty
=
CollectionUtils
.
isEmpty
(
behaviorTypeData
);
default_p_total
=
isEmpty
?
0
:
behaviorTypeData
.
size
();
default_p_avg
=
default_p_total
/
between_day
;
Set
<
CustomerBehaviorNotes
>
behaviorTypeDataSet
=
new
HashSet
<>(
isEmpty
?
Collections
.
EMPTY_SET
:
behaviorTypeData
);
default_u_total
=
behaviorTypeDataSet
.
size
();
default_u_avg
=
default_u_total
/
between_day
;
return
this
;
}
public
long
getDefault_p_total
()
{
return
default_p_total
;
}
public
long
getDefault_p_avg
()
{
return
default_p_avg
;
}
public
long
getDefault_u_total
()
{
return
default_u_total
;
}
public
long
getDefault_u_avg
()
{
return
default_u_avg
;
}
public
void
setBetween_day
(
long
between_day
)
{
this
.
between_day
=
between_day
;
}
public
void
setBehaviorMap
(
Map
<
Integer
,
List
<
CustomerBehaviorNotes
>>
behaviorMap
)
{
this
.
behaviorMap
=
behaviorMap
;
}
public
void
setDefault_p_total
(
long
default_p_total
)
{
this
.
default_p_total
=
default_p_total
;
}
public
void
setDefault_p_avg
(
long
default_p_avg
)
{
this
.
default_p_avg
=
default_p_avg
;
}
public
void
setDefault_u_total
(
long
default_u_total
)
{
this
.
default_u_total
=
default_u_total
;
}
public
void
setDefault_u_avg
(
long
default_u_avg
)
{
this
.
default_u_avg
=
default_u_avg
;
}
}
}
\ No newline at end of file
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/mapper/ActivityBehaviorMapper.java
View file @
4e69edea
...
...
@@ -17,7 +17,7 @@ import java.util.List;
* @data 2019/8/13 14:10
*/
public
interface
ActivityBehaviorMapper
extends
Mapper
<
ActivityBehavior
>
{
@Select
(
"select `behavior_type_id` from `activity_behavior` where `activity_id`=#{activityId}"
)
@Select
(
"select `
activity_id`,`
behavior_type_id` from `activity_behavior` where `activity_id`=#{activityId}"
)
@Results
(
value
=
{
@Result
(
column
=
"activity_id"
,
property
=
"activityId"
),
@Result
(
column
=
"behavior_type_id"
,
property
=
"behaviorTypeId"
)
...
...
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/mapper/ActivityBehaviorRelationMapper.java
View file @
4e69edea
...
...
@@ -18,7 +18,7 @@ import java.util.List;
*/
public
interface
ActivityBehaviorRelationMapper
extends
Mapper
<
ActivityBehaviorRelation
>
{
@Select
(
"select
*
from `activity_behavior_relation` where `activity_id`=#{activityId}"
)
@Select
(
"select
`type`,`biz_id`,`activity_id`
from `activity_behavior_relation` where `activity_id`=#{activityId}"
)
@Results
(
value
=
{
@Result
(
property
=
"type"
,
column
=
"type"
),
@Result
(
property
=
"bizId"
,
column
=
"biz_id"
),
...
...
xx-user-behavior-collect/xx-user-behavior-server/src/main/java/com/xxfc/platform/user/behavior/mapper/BehaviorTypeMapper.java
View file @
4e69edea
package
com
.
xxfc
.
platform
.
user
.
behavior
.
mapper
;
import
com.xxfc.platform.user.behavior.dto.BehaviorTypeDTO
;
import
com.xxfc.platform.user.behavior.entity.BehaviorType
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Result
;
import
org.apache.ibatis.annotations.Results
;
import
org.apache.ibatis.annotations.Select
;
import
tk.mybatis.mapper.additional.idlist.IdListMapper
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
/**
* @author libin
* @version 1.0
...
...
@@ -11,4 +18,11 @@ import tk.mybatis.mapper.common.Mapper;
* @data 2019/8/13 14:13
*/
public
interface
BehaviorTypeMapper
extends
Mapper
<
BehaviorType
>,
IdListMapper
<
BehaviorType
,
Integer
>
{
@Select
(
"<script>select `name`,`code` from behavior_type where `id` in <foreach collection='typeIds' open='(' item='typeId' separator=',' close=')'> #{typeId}</foreach></script>"
)
@Results
(
value
=
{
@Result
(
column
=
"name"
,
property
=
"name"
),
@Result
(
column
=
"code"
,
property
=
"code"
)
})
List
<
BehaviorTypeDTO
>
selectAllByIdList
(
@Param
(
"typeIds"
)
List
<
Integer
>
typeIds
);
}
xx-user-behavior-collect/xx-user-behavior-server/src/main/resources/mapper/CustomerBehaviorNotesMapper.xml
View file @
4e69edea
...
...
@@ -45,6 +45,6 @@
<if
test=
"endTime != null and startTime == null"
>
and
<![CDATA[ `crt_time` <= #{endTime}]]>
</if>
and `type` in(0,1,2,3)
</select>
</mapper>
\ No newline at end of file
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