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 169f3492
authored
Sep 13, 2025
by
zhuht
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg]批次统计支持3种模式;
1 parent
aa1f4418
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
45 deletions
src/main/java/com/viontech/keliu/service/impl/PersonRecordServiceImpl.java
src/main/java/com/viontech/keliu/service/impl/PersonRecordServiceImpl.java
View file @
169f349
...
@@ -16,9 +16,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
...
@@ -16,9 +16,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
import
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
;
import
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
;
import
org.springframework.jdbc.core.namedparam.SqlParameterSource
;
import
org.springframework.jdbc.core.namedparam.SqlParameterSource
;
import
org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils
;
import
org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils
;
import
org.springframework.jdbc.core.simple.JdbcClient
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.client.RestClient
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.function.Function
;
...
@@ -74,23 +76,34 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -74,23 +76,34 @@ public class PersonRecordServiceImpl implements PersonRecordService {
@Autowired
@Autowired
private
JdbcTemplate
jdbcTemplate
;
private
JdbcTemplate
jdbcTemplate
;
@Autowired
@Autowired
private
JdbcClient
jdbcClient
;
@Autowired
private
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
private
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
@Override
@Override
public
void
handlePersonRecord
(
Long
mallId
,
Date
countDate
)
{
public
void
handlePersonRecord
(
Long
mallId
,
Date
countDate
)
{
//先删除数据
removeData
(
mallId
,
countDate
);
List
<
Person
>
personList
=
faceRecognitionDao
.
queryFaceRecognitionList
(
mallId
,
countDate
);
List
<
Person
>
personList
=
faceRecognitionDao
.
queryFaceRecognitionList
(
mallId
,
countDate
);
if
(
CollectionUtils
.
isEmpty
(
personList
))
{
if
(
CollectionUtils
.
isEmpty
(
personList
))
{
return
;
return
;
}
}
//有抓拍记录再删除数据
removeData
(
mallId
,
countDate
);
// 是否是自定义的汽车严格模式
boolean
strictMode
=
strictModeMallIds
!=
null
&&
strictModeMallIds
.
contains
(
mallId
);
boolean
strictMode
=
strictModeMallIds
!=
null
&&
strictModeMallIds
.
contains
(
mallId
);
L
ong
excludePersonTime
=
getExcludePersonTime
(
mallId
);
l
ong
excludePersonTime
=
getExcludePersonTime
(
mallId
);
Integer
filterAttention
=
getFilterAttention
(
mallId
);
int
filterAttention
=
getFilterAttention
(
mallId
);
Integer
effectVisitorsConfig
=
getEffectVisitors
(
mallId
);
Integer
effectVisitorsConfig
=
getEffectVisitors
(
mallId
);
Integer
personGroupMaxNum
=
getPersonGroupMaxNum
(
mallId
);
Integer
personGroupMaxNum
=
getPersonGroupMaxNum
(
mallId
);
int
batchStatisticsModel
=
getBatchStatisticsModel
(
mallId
);
if
(
batchStatisticsModel
==
1
)
{
// 标准模式,所有顾客都参与计算. 直接把有效顾客过滤条件配置改成0.这样统计批次时所有顾客都当有效顾客统计
effectVisitorsConfig
=
0
;
}
log
.
info
(
"门店:{} 批次统计,各参数,excludePersonTime: {}, filterAttention: {}, effectVisitorsConfig: {}, personGroupMaxNum: {}, batchStatisticsModel: {}"
,
mallId
,
excludePersonTime
,
filterAttention
,
effectVisitorsConfig
,
personGroupMaxNum
,
batchStatisticsModel
);
boolean
needFilter
=
filterAttention
==
1
;
boolean
needFilter
=
filterAttention
==
1
;
//出入口gateId
//出入口gateId
...
@@ -152,7 +165,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -152,7 +165,7 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
});
});
log
.
info
(
"personInOutDetailList.size:{}"
,
personInOutDetailList
.
size
());
if
(
CollectionUtils
.
isEmpty
(
personInOutDetailList
))
{
if
(
CollectionUtils
.
isEmpty
(
personInOutDetailList
))
{
return
;
return
;
}
}
...
@@ -199,51 +212,16 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -199,51 +212,16 @@ public class PersonRecordServiceImpl implements PersonRecordService {
//按personUnid分组
//按personUnid分组
//Map<String, List<DPersonRecord>> personRecordMap = recordList.stream().collect(Collectors.groupingBy(DPersonRecord::getPersonUnid));
//Map<String, List<DPersonRecord>> personRecordMap = recordList.stream().collect(Collectors.groupingBy(DPersonRecord::getPersonUnid));
List
<
DPersonRecord
>
personRecordList
=
new
ArrayList
<>();
List
<
DPersonRecord
>
personRecordList
=
new
ArrayList
<>();
log
.
info
(
"开始过滤并保存DPersonRecord. mallId:{}, countDate:{}"
,
mallId
,
DateUtil
.
formatDate
(
countDate
));
for
(
DPersonRecord
dPersonRecord
:
recordList
)
{
for
(
DPersonRecord
dPersonRecord
:
recordList
)
{
//没有匹配到出
// 根据统计模式,确定是否需要过滤掉人
if
(
dPersonRecord
.
getLeaveTime
()
==
null
)
{
if
(
batchStatisticsModel
==
3
)
{
//判断在店内的时间
if
(
needCarFilter
(
dPersonRecord
,
needFilter
,
excludePersonTime
,
strictMode
,
filterAttention
,
mallId
))
{
List
<
DPersonTrackDetail
>
personTrackDetailList
=
dPersonRecord
.
getPersonTrackDetailList
();
// 需要被汽车模式过滤,不保存,不加入后续统计
if
(
CollectionUtils
.
isEmpty
(
personTrackDetailList
))
{
continue
;
}
//计算区域的总停留时间,小于10分钟的排除掉
long
totalTime
=
personTrackDetailList
.
stream
().
mapToLong
(
DPersonTrackDetail:
:
getVisitDuration
).
sum
();
if
(
needFilter
&&
totalTime
<
excludePersonTime
*
60
*
1000
)
{
continue
;
continue
;
}
}
}
//排除掉短时间在店内的记录
if
(
needFilter
&&
dPersonRecord
.
getVisitDuration
()
<
excludePersonTime
*
60
*
1000
)
{
continue
;
}
}
if
(
strictMode
)
{
log
.
info
(
"门店:{}严格模式过滤"
,
mallId
);
// 严格模式,没接待,或没看车,就过滤
if
(
filterAttention
==
1
)
{
// if (dPersonRecord.getReceptionCount() == 0) {
// continue;
// }
List
<
DPersonTrackDetail
>
personTrackDetailList
=
dPersonRecord
.
getPersonTrackDetailList
();
if
(
CollectionUtils
.
isEmpty
(
personTrackDetailList
))
{
continue
;
}
List
<
DPersonTrackDetail
>
attentionList
=
personTrackDetailList
.
stream
().
filter
(
v
->
v
.
getVisitDuration
()
!=
null
&&
v
.
getVisitDuration
()
>
strictModeAttentionSecond
*
1000L
)
.
sorted
(
Comparator
.
comparing
(
DPersonTrackDetail:
:
getArriveTime
)).
toList
();
if
(
attentionList
.
isEmpty
())
{
continue
;
}
dPersonRecord
.
setAttentionCount
(
attentionList
.
size
());
dPersonRecord
.
setAttentionTime
(
attentionList
.
get
(
0
).
getArriveTime
());
}
}
else
{
//没有被接待,并且没有看车的排除掉
if
(
dPersonRecord
.
getReceptionCount
()
==
0
&&
filterAttention
==
1
&&
dPersonRecord
.
getAttentionCount
()
==
0
)
{
continue
;
}
}
personRecordList
.
add
(
dPersonRecord
);
personRecordList
.
add
(
dPersonRecord
);
dPersonRecordDao
.
createDPersonRecordBatch
(
Collections
.
singletonList
(
dPersonRecord
));
dPersonRecordDao
.
createDPersonRecordBatch
(
Collections
.
singletonList
(
dPersonRecord
));
if
(!
CollectionUtils
.
isEmpty
(
dPersonRecord
.
getPersonTrackDetailList
()))
{
if
(!
CollectionUtils
.
isEmpty
(
dPersonRecord
.
getPersonTrackDetailList
()))
{
...
@@ -265,6 +243,55 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -265,6 +243,55 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
private
boolean
needCarFilter
(
DPersonRecord
dPersonRecord
,
boolean
needFilter
,
long
excludePersonTime
,
boolean
strictMode
,
int
filterAttention
,
Long
mallId
)
{
//没有匹配到出
if
(
dPersonRecord
.
getLeaveTime
()
==
null
)
{
//判断在店内的时间
List
<
DPersonTrackDetail
>
personTrackDetailList
=
dPersonRecord
.
getPersonTrackDetailList
();
if
(
CollectionUtils
.
isEmpty
(
personTrackDetailList
))
{
return
true
;
}
//计算区域的总停留时间,小于10分钟的排除掉
long
totalTime
=
personTrackDetailList
.
stream
().
mapToLong
(
DPersonTrackDetail:
:
getVisitDuration
).
sum
();
if
(
needFilter
&&
totalTime
<
excludePersonTime
*
60
*
1000
)
{
return
true
;
}
}
//排除掉短时间在店内的记录
if
(
needFilter
&&
dPersonRecord
.
getVisitDuration
()
<
excludePersonTime
*
60
*
1000
)
{
return
true
;
}
if
(
strictMode
)
{
log
.
info
(
"门店:{}严格模式过滤"
,
mallId
);
// 严格模式,没接待,或没看车,就过滤
if
(
filterAttention
==
1
)
{
// if (dPersonRecord.getReceptionCount() == 0) {
// continue;
// }
// 没有店内分区的记录,过滤
List
<
DPersonTrackDetail
>
personTrackDetailList
=
dPersonRecord
.
getPersonTrackDetailList
();
if
(
CollectionUtils
.
isEmpty
(
personTrackDetailList
))
{
return
true
;
}
// 汽车专属门店定制严格模式,必须要在区域呆够指定时间才算关注
List
<
DPersonTrackDetail
>
attentionList
=
personTrackDetailList
.
stream
().
filter
(
v
->
v
.
getVisitDuration
()
!=
null
&&
v
.
getVisitDuration
()
>
strictModeAttentionSecond
*
1000L
)
.
sorted
(
Comparator
.
comparing
(
DPersonTrackDetail:
:
getArriveTime
)).
toList
();
if
(
attentionList
.
isEmpty
())
{
return
true
;
}
dPersonRecord
.
setAttentionCount
(
attentionList
.
size
());
dPersonRecord
.
setAttentionTime
(
attentionList
.
get
(
0
).
getArriveTime
());
}
}
else
{
// 普通汽车模式
//没有被接待,并且没有看车的排除掉
return
dPersonRecord
.
getReceptionCount
()
==
0
&&
filterAttention
==
1
&&
dPersonRecord
.
getAttentionCount
()
==
0
;
}
return
false
;
}
/**
/**
* 分组
* 分组
...
@@ -524,6 +551,19 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -524,6 +551,19 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
/**
/**
*
* @param mallId 门店
* @return 门店的批次统计计算模式。
* 1 标准模式:所有顾客都参与统计。
* 2 有效模式:仅有效顾客参与统计。
* 3 严格模式:延用汽车那一套。根据停留时长,接待,看车等条件过滤
*/
private
Integer
getBatchStatisticsModel
(
Long
mallId
)
{
String
batchStatisticsModel
=
configParamDao
.
getConfigParamByMallIdAndConfigKey
(
mallId
,
"batchStatisticsModel"
);
return
batchStatisticsModel
==
null
?
1
:
Integer
.
parseInt
(
batchStatisticsModel
);
}
/**
* @return 店内停留时间小于X秒的不算有效顾客人数
* @return 店内停留时间小于X秒的不算有效顾客人数
*/
*/
private
Integer
getEffectVisitors
(
Long
mallId
)
{
private
Integer
getEffectVisitors
(
Long
mallId
)
{
...
...
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