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 aa1cc9e5
authored
Sep 18, 2024
by
朱海
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[add]小时级顾客人数修改
1 parent
cabfe10c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
0 deletions
src/main/java/com/viontech/keliu/entity/DMallHourFaceRecognitionSta.java
src/main/java/com/viontech/keliu/service/impl/PersonRecordServiceImpl.java
src/main/java/com/viontech/keliu/entity/DMallHourFaceRecognitionSta.java
0 → 100644
View file @
aa1cc9e
package
com
.
viontech
.
keliu
.
entity
;
import
lombok.Data
;
import
java.util.Date
;
/**
* Created with IntelliJ IDEA.
*
* @author: zhuhai
* Date: 2024-08-13
* Time: 18:12
*/
@Data
public
class
DMallHourFaceRecognitionSta
{
private
Long
mallId
;
private
Long
personCount
;
private
Long
customCount
;
private
Long
maleCount
;
private
Long
femaleCount
;
private
String
maleStage
;
private
String
femaleStage
;
private
Date
counttime
;
private
int
[]
maleStageArr
;
private
int
[]
femaleStageArr
;
private
Date
countdate
;
private
Long
groupNum
;
private
Long
singleGroupNum
;
private
Long
doubleGroupNum
;
private
Long
multipleGroupNum
;
private
Long
familyGroupNum
;
/**
* 情侣组
*/
private
Long
loverGroupNum
;
/**
* 伙伴组
*/
private
Long
partnerGroupNum
;
private
Long
staffCount
;
}
\ No newline at end of file
\ No newline at end of file
src/main/java/com/viontech/keliu/service/impl/PersonRecordServiceImpl.java
View file @
aa1cc9e
...
@@ -12,6 +12,7 @@ import com.viontech.keliu.dao.DPersonTrackDetailDao;
...
@@ -12,6 +12,7 @@ import com.viontech.keliu.dao.DPersonTrackDetailDao;
import
com.viontech.keliu.dao.FaceRecognitionDao
;
import
com.viontech.keliu.dao.FaceRecognitionDao
;
import
com.viontech.keliu.entity.CustomerGroupResult
;
import
com.viontech.keliu.entity.CustomerGroupResult
;
import
com.viontech.keliu.entity.DMallDayFaceRecognitionSta
;
import
com.viontech.keliu.entity.DMallDayFaceRecognitionSta
;
import
com.viontech.keliu.entity.DMallHourFaceRecognitionSta
;
import
com.viontech.keliu.entity.DPersonBatch
;
import
com.viontech.keliu.entity.DPersonBatch
;
import
com.viontech.keliu.entity.DPersonReception
;
import
com.viontech.keliu.entity.DPersonReception
;
import
com.viontech.keliu.entity.DPersonRecord
;
import
com.viontech.keliu.entity.DPersonRecord
;
...
@@ -25,6 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -25,6 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.jdbc.core.BeanPropertyRowMapper
;
import
org.springframework.jdbc.core.BeanPropertyRowMapper
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
;
import
org.springframework.jdbc.core.namedparam.SqlParameterSource
;
import
org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -34,9 +38,11 @@ import java.util.Arrays;
...
@@ -34,9 +38,11 @@ import java.util.Arrays;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -78,6 +84,8 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -78,6 +84,8 @@ public class PersonRecordServiceImpl implements PersonRecordService {
private
List
<
Long
>
personBatchMallIds
;
private
List
<
Long
>
personBatchMallIds
;
@Autowired
@Autowired
private
JdbcTemplate
jdbcTemplate
;
private
JdbcTemplate
jdbcTemplate
;
@Autowired
private
NamedParameterJdbcTemplate
namedParameterJdbcTemplate
;
@Override
@Override
...
@@ -214,6 +222,8 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -214,6 +222,8 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
//修改统计数据
//修改统计数据
updateFaceRecognitionSta
(
mallId
,
countDate
,
personRecordList
);
updateFaceRecognitionSta
(
mallId
,
countDate
,
personRecordList
);
//修改统计数据小时
updateFaceRecognitionStaHour
(
mallId
,
countDate
,
personRecordList
);
...
@@ -546,6 +556,93 @@ public class PersonRecordServiceImpl implements PersonRecordService {
...
@@ -546,6 +556,93 @@ public class PersonRecordServiceImpl implements PersonRecordService {
}
}
private
void
updateFaceRecognitionStaHour
(
Long
mallId
,
Date
countDate
,
List
<
DPersonRecord
>
personRecords
)
{
Map
<
String
,
List
<
DPersonRecord
>>
personUnidMap
=
personRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
DPersonRecord:
:
getPersonUnid
));
List
<
DPersonRecord
>
personList
=
new
ArrayList
<>();
personUnidMap
.
forEach
((
k
,
v
)
->
{
DPersonRecord
dPersonRecord
=
v
.
stream
().
sorted
(
Comparator
.
comparing
(
DPersonRecord:
:
getArriveTime
)).
findFirst
().
get
();
personList
.
add
(
dPersonRecord
);
});
Map
<
String
,
List
<
DPersonRecord
>>
hourMap
=
personList
.
stream
().
collect
(
Collectors
.
groupingBy
(
d
->
DateUtil
.
format
(
d
.
getArriveTime
(),
"yyyy-MM-dd HH:00:00"
)));
String
sql
=
"select mall_id,countdate,counttime,person_count,staff_count from d_mall_hour_face_recognition_sta where mall_id = ? and countdate = ?;"
;
List
<
DMallHourFaceRecognitionSta
>
list
=
jdbcTemplate
.
query
(
sql
,
new
BeanPropertyRowMapper
<>(
DMallHourFaceRecognitionSta
.
class
),
mallId
,
countDate
);
Map
<
String
,
DMallHourFaceRecognitionSta
>
hourStaMap
=
list
.
stream
().
collect
(
Collectors
.
toMap
(
d
->
DateUtil
.
format
(
d
.
getCounttime
(),
"yyyy-MM-dd HH:00:00"
),
Function
.
identity
(),
(
v1
,
v2
)
->
v1
));
List
<
DMallHourFaceRecognitionSta
>
updateList
=
new
ArrayList
<>();
hourStaMap
.
forEach
((
k
,
v
)
->
{
List
<
DPersonRecord
>
dPersonRecords
=
hourMap
.
get
(
k
);
long
customerCount
=
0L
;
long
maleCount
=
0L
;
long
femaleCount
=
0L
;
//男性年龄
Map
<
Integer
,
Long
>
maleStageMap
=
new
HashMap
<>();
//女性年龄
Map
<
Integer
,
Long
>
femaleStageMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
dPersonRecords
))
{
//顾客总人数
customerCount
=
dPersonRecords
.
stream
().
count
();
//男性顾客人数
List
<
DPersonRecord
>
malePersonList
=
dPersonRecords
.
stream
().
filter
(
personRecord
->
personRecord
.
getGender
()
==
1
).
collect
(
Collectors
.
toList
());
maleCount
=
malePersonList
.
size
();
//女性顾客人数
List
<
DPersonRecord
>
femalePersonList
=
dPersonRecords
.
stream
().
filter
(
personRecord
->
personRecord
.
getGender
()
==
0
).
collect
(
Collectors
.
toList
());
femaleCount
=
femalePersonList
.
size
();
//男性年龄
maleStageMap
=
malePersonList
.
stream
().
collect
(
Collectors
.
groupingBy
(
DPersonRecord:
:
getAge
,
Collectors
.
counting
()));
//女性年龄
femaleStageMap
=
femalePersonList
.
stream
().
collect
(
Collectors
.
groupingBy
(
DPersonRecord:
:
getAge
,
Collectors
.
counting
()));
}
long
newPersonCount
=
v
.
getStaffCount
()
+
customerCount
;
DMallHourFaceRecognitionSta
updateSta
=
new
DMallHourFaceRecognitionSta
();
updateSta
.
setCountdate
(
countDate
);
updateSta
.
setPersonCount
(
newPersonCount
);
updateSta
.
setCustomCount
(
customerCount
);
updateSta
.
setMaleCount
(
maleCount
);
updateSta
.
setFemaleCount
(
femaleCount
);
updateSta
.
setCounttime
(
DateUtil
.
parse
(
k
,
"yyyy-MM-dd HH:00:00"
));
Long
[]
maleStages
=
new
Long
[
100
];
maleStageMap
.
forEach
((
k1
,
v1
)
->
{
maleStages
[
k1
]
=
v1
;
});
Long
[]
femaleStages
=
new
Long
[
100
];
femaleStageMap
.
forEach
((
k1
,
v1
)
->
{
femaleStages
[
k1
]
=
v1
;
});
String
maleStageStr
=
arraysToString
(
maleStages
);
String
femaleStageStr
=
arraysToString
(
femaleStages
);
updateSta
.
setMaleStage
(
maleStageStr
);
updateSta
.
setFemaleStage
(
femaleStageStr
);
CustomerGroupResult
customerGroupResult
=
new
CustomerGroupResult
();
Map
<
String
,
List
<
DPersonRecord
>>
groupMap
=
personRecords
.
stream
().
collect
(
Collectors
.
groupingBy
(
DPersonRecord:
:
getGroupUnid
));
groupMap
.
forEach
((
k1
,
v1
)
->
{
calGroup
(
1
,
customerGroupResult
,
v1
);
});
updateSta
.
setGroupNum
(
customerGroupResult
.
getGroupNum
());
updateSta
.
setSingleGroupNum
(
customerGroupResult
.
getSingleGroup
());
updateSta
.
setDoubleGroupNum
(
customerGroupResult
.
getDoubleGroup
());
updateSta
.
setMultipleGroupNum
(
customerGroupResult
.
getMultipleGroup
());
updateSta
.
setFamilyGroupNum
(
customerGroupResult
.
getDoubleFamilyGroup
()
+
customerGroupResult
.
getMultipleFamilyGroup
());
updateSta
.
setLoverGroupNum
(
customerGroupResult
.
getDoubleLoverGroup
());
updateSta
.
setPartnerGroupNum
(
customerGroupResult
.
getDoublePartnerGroup
()
+
customerGroupResult
.
getMultiplePartnerGroup
());
updateList
.
add
(
updateSta
);
});
if
(
CollectionUtils
.
isNotEmpty
(
updateList
))
{
String
updateSql
=
"update d_mall_hour_face_recognition_sta set person_count = :personCount,custom_count = :customCount,male_count = :maleCount,female_count = :femaleCount,male_stage = :maleStage, female_stage = :femaleStage, group_num = :groupNum, single_group_num = :singleGroupNum, double_group_num = :doubleGroupNum, multiple_group_num = :multipleGroupNum, family_group_num = :familyGroupNum, lover_group_num = :loverGroupNum, partner_group_num = :partnerGroupNum where mall_id = :mallId and countdate = :countDate and counttime = :counttime;"
;
SqlParameterSource
[]
updateSources
=
SqlParameterSourceUtils
.
createBatch
(
updateList
.
toArray
());
namedParameterJdbcTemplate
.
batchUpdate
(
updateSql
,
updateSources
);
}
}
public
String
arraysToString
(
Long
[]
arrays
)
{
public
String
arraysToString
(
Long
[]
arrays
)
{
return
Arrays
.
toString
(
arrays
).
substring
(
1
,
Arrays
.
toString
(
arrays
).
length
()
-
1
);
return
Arrays
.
toString
(
arrays
).
substring
(
1
,
Arrays
.
toString
(
arrays
).
length
()
-
1
);
}
}
...
...
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