Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
朱海
/
VVAS-PicGroup
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 377cf53b
authored
Oct 22, 2025
by
zhuht
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg]批次统计兼容新有效顾客配置;
1 parent
169f3492
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
13 deletions
pom.xml
src/main/java/com/viontech/keliu/service/impl/PersonRecordServiceImpl.java
src/main/java/com/viontech/keliu/vo/EffectVisitorsConfig.java
pom.xml
View file @
377cf53
...
...
@@ -14,6 +14,10 @@
<version>
1.0-SNAPSHOT
</version>
<name>
VVAS-PicGroup
</name>
<properties>
<java.version>
21
</java.version>
</properties>
<dependencies>
<!--<dependency>
<groupId>com.viontech.keliu</groupId>
...
...
src/main/java/com/viontech/keliu/service/impl/PersonRecordServiceImpl.java
View file @
377cf53
...
...
@@ -3,10 +3,12 @@ package com.viontech.keliu.service.impl;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.viontech.keliu.dao.*
;
import
com.viontech.keliu.entity.*
;
import
com.viontech.keliu.service.PersonRecordService
;
import
com.viontech.keliu.vo.EffectVisitorsConfig
;
import
jakarta.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -20,7 +22,6 @@ import org.springframework.jdbc.core.simple.JdbcClient;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.client.RestClient
;
import
java.util.*
;
import
java.util.function.Function
;
...
...
@@ -95,12 +96,14 @@ public class PersonRecordServiceImpl implements PersonRecordService {
long
excludePersonTime
=
getExcludePersonTime
(
mallId
);
int
filterAttention
=
getFilterAttention
(
mallId
);
Integer
effectVisitorsConfig
=
getEffectVisitors
(
mallId
);
EffectVisitorsConfig
effectVisitorsConfig
=
getEffectVisitors
(
mallId
);
Integer
personGroupMaxNum
=
getPersonGroupMaxNum
(
mallId
);
int
batchStatisticsModel
=
getBatchStatisticsModel
(
mallId
);
if
(
batchStatisticsModel
==
1
)
{
// 标准模式,所有顾客都参与计算. 直接把有效顾客过滤条件配置改成0.这样统计批次时所有顾客都当有效顾客统计
effectVisitorsConfig
=
0
;
// 标准模式,所有顾客都参与计算.
effectVisitorsConfig
.
setUseTime
(
false
);
effectVisitorsConfig
.
setUseGender
(
false
);
effectVisitorsConfig
.
setUseAge
(
false
);
}
log
.
info
(
"门店:{} 批次统计,各参数,excludePersonTime: {}, filterAttention: {}, effectVisitorsConfig: {}, personGroupMaxNum: {}, batchStatisticsModel: {}"
,
mallId
,
excludePersonTime
,
filterAttention
,
effectVisitorsConfig
,
personGroupMaxNum
,
batchStatisticsModel
);
...
...
@@ -566,9 +569,19 @@ public class PersonRecordServiceImpl implements PersonRecordService {
/**
* @return 店内停留时间小于X秒的不算有效顾客人数
*/
private
Integer
getEffectVisitors
(
Long
mallId
)
{
private
EffectVisitorsConfig
getEffectVisitors
(
Long
mallId
)
{
EffectVisitorsConfig
config
;
String
effectVisitorsConfig
=
configParamDao
.
getConfigParamByMallIdAndConfigKey
(
mallId
,
"effectVisitorsConfig"
);
return
effectVisitorsConfig
==
null
?
0
:
Integer
.
parseInt
(
effectVisitorsConfig
);
if
(
JSONUtil
.
isTypeJSON
(
effectVisitorsConfig
))
{
config
=
JSONUtil
.
toBean
(
effectVisitorsConfig
,
EffectVisitorsConfig
.
class
);
}
else
{
config
=
new
EffectVisitorsConfig
();
config
.
setSeconds
(
effectVisitorsConfig
==
null
?
0
:
Integer
.
parseInt
(
effectVisitorsConfig
));
config
.
setUseTime
(
config
.
getSeconds
()
>
0
);
config
.
setUseGender
(
false
);
config
.
setUseAge
(
false
);
}
return
config
;
}
/**
...
...
@@ -582,7 +595,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
private
void
updateFaceRecognitionSta
(
Long
mallId
,
Date
countDate
,
List
<
DPersonRecord
>
personRecords
,
boolean
needFilter
,
Integer
effectVisitorsConfig
,
Integer
personGroupMaxNum
)
{
private
void
updateFaceRecognitionSta
(
Long
mallId
,
Date
countDate
,
List
<
DPersonRecord
>
personRecords
,
boolean
needFilter
,
EffectVisitorsConfig
effectVisitorsConfig
,
Integer
personGroupMaxNum
)
{
Map
<
String
,
DPersonRecord
>
personRecordMap
=
personRecords
.
stream
().
collect
(
Collectors
.
toMap
(
DPersonRecord:
:
getPersonUnid
,
dPersonRecord
->
dPersonRecord
,
(
k1
,
k2
)
->
k1
));
//顾客总人数
long
customerCount
=
personRecordMap
.
keySet
().
size
();
...
...
@@ -675,24 +688,58 @@ public class PersonRecordServiceImpl implements PersonRecordService {
* @param effectVisitorsConfig 有效顾客停留时长配置
* @return 停留时长小于配置值的用户unid
*/
private
Set
<
String
>
nonEffectVisitorsUnids
(
List
<
DPersonRecord
>
recordList
,
Integer
effectVisitorsConfig
)
{
if
(
effectVisitorsConfig
==
null
||
effectVisitorsConfig
==
0
||
CollectionUtils
.
isEmpty
(
recordList
))
{
private
Set
<
String
>
nonEffectVisitorsUnids
(
List
<
DPersonRecord
>
recordList
,
EffectVisitorsConfig
effectVisitorsConfig
)
{
if
(
effectVisitorsConfig
==
null
||
(!
effectVisitorsConfig
.
isUseTime
()
&&
!
effectVisitorsConfig
.
isUseAge
()
&&
!
effectVisitorsConfig
.
isUseGender
()
))
{
return
Collections
.
emptySet
();
}
Set
<
String
>
nonEffectVisitorUnid
=
new
HashSet
<>();
recordList
.
stream
().
collect
(
Collectors
.
groupingBy
(
DPersonRecord:
:
getPersonUnid
))
.
values
().
forEach
(
personList
->
{
long
staySecondSum
=
personList
.
stream
().
filter
(
p
->
p
.
getArriveTime
()
!=
null
&&
p
.
getLeaveTime
()
!=
null
)
.
mapToLong
(
p
->
DateUtil
.
between
(
p
.
getArriveTime
(),
p
.
getLeaveTime
(),
DateUnit
.
SECOND
)).
sum
();
if
(
staySecondSum
>
0
&&
staySecondSum
<
effectVisitorsConfig
)
{
if
(
isNonEffectVisitor
(
personList
,
effectVisitorsConfig
))
{
nonEffectVisitorUnid
.
add
(
personList
.
get
(
0
).
getPersonUnid
());
}
});
return
nonEffectVisitorUnid
;
}
private
void
updateFaceRecognitionStaHour
(
Long
mallId
,
Date
countDate
,
List
<
DPersonRecord
>
personRecords
,
boolean
needFilter
,
Integer
effectVisitorsConfig
,
Integer
personGroupMaxNum
)
{
/**
* @param personList 顾客记录
* @param config 过滤有效顾客的配置项
* @return 是否是无效顾客
*/
private
boolean
isNonEffectVisitor
(
List
<
DPersonRecord
>
personList
,
EffectVisitorsConfig
config
)
{
if
(
config
.
isUseTime
())
{
long
staySecondSum
=
personList
.
stream
().
filter
(
p
->
p
.
getArriveTime
()
!=
null
&&
p
.
getLeaveTime
()
!=
null
)
.
mapToLong
(
p
->
DateUtil
.
between
(
p
.
getArriveTime
(),
p
.
getLeaveTime
(),
DateUnit
.
SECOND
)).
sum
();
// 停留时长小于
if
(
staySecondSum
>
0
&&
staySecondSum
<
Optional
.
ofNullable
(
config
.
getSeconds
()).
orElse
(
0
))
{
return
true
;
}
}
// 过滤性别
if
(
config
.
isUseGender
())
{
if
(
"male"
.
equalsIgnoreCase
(
config
.
getExcludeGender
())
&&
personList
.
getFirst
().
getGender
()
==
1
)
{
return
true
;
}
if
(
"female"
.
equalsIgnoreCase
(
config
.
getExcludeGender
())
&&
personList
.
getFirst
().
getGender
()
==
0
)
{
return
true
;
}
}
// 过滤年龄
if
(
config
.
isUseAge
())
{
if
(
"child"
.
equalsIgnoreCase
(
config
.
getExcludeAge
())
&&
personList
.
getFirst
().
getAge
()
<
18
)
{
return
true
;
}
if
(
"adult"
.
equalsIgnoreCase
(
config
.
getExcludeAge
())
&&
personList
.
getFirst
().
getAge
()
>=
18
)
{
return
true
;
}
}
return
false
;
}
private
void
updateFaceRecognitionStaHour
(
Long
mallId
,
Date
countDate
,
List
<
DPersonRecord
>
personRecords
,
boolean
needFilter
,
EffectVisitorsConfig
effectVisitorsConfig
,
Integer
personGroupMaxNum
)
{
Set
<
String
>
nonEffectVisitorsUnids
=
nonEffectVisitorsUnids
(
personRecords
,
effectVisitorsConfig
);
...
...
src/main/java/com/viontech/keliu/vo/EffectVisitorsConfig.java
0 → 100644
View file @
377cf53
package
com
.
viontech
.
keliu
.
vo
;
import
lombok.Data
;
/**
* 有效顾客的定义。由于要用排除法统计有效顾客,所以定义的条件都是需要排除的
*/
@Data
public
class
EffectVisitorsConfig
{
/**
* 是否使用停留时长过滤
*/
private
boolean
useTime
;
/**
* 停留时长阈值。小于n秒的顾客算无效顾客
*/
private
Integer
seconds
;
/**
* 是否使用年龄过滤
*/
private
boolean
useAge
;
/**
* 需要排除的年龄段。adult/child (成人/儿童)
*/
private
String
excludeAge
;
/**
* 是否使用性别排除
*/
private
boolean
useGender
;
/**
* 需要排除的性别。 male/female
*/
private
String
excludeGender
;
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment