Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
vion-label
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 6588593b
authored
Jan 30, 2024
by
姚冰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加sendDataFromFile接口及相关实体
1 parent
f2de590c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
193 additions
and
9 deletions
label-tool-keliu/pom.xml
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/config/VionConfig.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/config/WebConfig.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/controller/KeliuController.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/model/BodyRecognition.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/model/ImageInfo.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/model/ROI.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/service/FileService.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/service/LocalFileServiceImpl.java
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/service/OnlineFileServiceImpl.java
label-tool-keliu/src/main/resources/application-option.properties
label-tool-keliu/pom.xml
View file @
6588593
...
...
@@ -44,7 +44,7 @@
<dependency>
<groupId>
com.viontech.keliu
</groupId>
<artifactId>
AlgApiClient
</artifactId>
<version>
6.
0.6
</version>
<version>
6.
1.0-SNAPSHOT
</version>
<exclusions>
<exclusion>
<artifactId>
tomcat-websocket
</artifactId>
...
...
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/config/VionConfig.java
View file @
6588593
...
...
@@ -26,6 +26,7 @@ public class VionConfig {
private
String
targetUrl
;
private
String
keliuImageUrl
;
private
String
keliuImagePath
;
private
String
featureUrl
;
private
static
final
ThreadPoolExecutor
POOL_EXECUTOR
=
new
ThreadPoolExecutor
(
20
,
20
,
1
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>(
10000
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
}
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/config/WebConfig.java
View file @
6588593
...
...
@@ -4,10 +4,12 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
;
import
com.viontech.keliu.websocket.AlgApiClient
;
import
com.viontech.label.core.base.DateConverter
;
import
com.viontech.label.tool.keliu.service.FileService
;
import
com.viontech.label.tool.keliu.service.LocalFileServiceImpl
;
import
com.viontech.label.tool.keliu.service.OnlineFileServiceImpl
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -31,6 +33,9 @@ import java.util.Date;
*/
@Configuration
public
class
WebConfig
implements
WebMvcConfigurer
{
@Value
(
"${vion.feature-url:}"
)
private
String
faceFeatureUrl
;
@Bean
@Primary
public
ObjectMapper
jacksonObjectMapper
(
Jackson2ObjectMapperBuilder
builder
)
{
...
...
@@ -54,17 +59,23 @@ public class WebConfig implements WebMvcConfigurer {
@Bean
(
"fileService"
)
@ConditionalOnProperty
(
"vion.keliu-image-path"
)
@ConditionalOnProperty
(
value
=
"vion.keliu-image-path"
)
public
FileService
localFileService
()
{
return
new
LocalFileServiceImpl
();
}
@Bean
(
"fileService"
)
@ConditionalOnProperty
(
"vion.keliu-image-url"
)
@ConditionalOnProperty
(
value
=
"vion.keliu-image-url"
)
public
FileService
onlineFileService
()
{
return
new
OnlineFileServiceImpl
();
}
@Bean
(
"algApiClientFeature"
)
@ConditionalOnProperty
(
value
=
"vion.feature-url"
)
public
AlgApiClient
algApiClientFeatureConfig
()
{
return
new
AlgApiClient
(
faceFeatureUrl
);
}
@Configuration
public
static
class
CorsConfig
{
@Bean
...
...
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/controller/KeliuController.java
View file @
6588593
...
...
@@ -3,9 +3,11 @@ package com.viontech.label.tool.keliu.controller;
import
com.viontech.keliu.util.DateUtil
;
import
com.viontech.keliu.util.JsonMessageUtil
;
import
com.viontech.label.tool.keliu.config.VionConfig
;
import
com.viontech.label.tool.keliu.model.BodyRecognition
;
import
com.viontech.label.tool.keliu.model.FaceRecognition
;
import
com.viontech.label.tool.keliu.repository.KeliuRepository
;
import
com.viontech.label.tool.keliu.service.FileService
;
import
com.viontech.label.tool.keliu.service.LocalFileServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.core.io.ByteArrayResource
;
import
org.springframework.http.*
;
...
...
@@ -18,6 +20,10 @@ import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
...
...
@@ -59,7 +65,7 @@ public class KeliuController {
public
Object
sendData
(
@RequestParam
Date
date
,
@RequestParam
Long
mallId
,
@RequestParam
Long
packId
,
@RequestParam
(
required
=
false
)
Long
taskId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"-1,0,1"
)
String
direction
,
@RequestParam
(
required
=
false
,
defaultValue
=
"0,1"
)
String
personType
,
@RequestParam
(
required
=
false
,
value
=
"deviceSerialNum"
)
String
deviceSerialNum
,
@RequestParam
(
required
=
false
,
value
=
"deviceSerialNum"
)
String
deviceSerialNum
,
@RequestParam
(
required
=
false
,
value
=
"channelSerialNum"
)
String
channelSerialNum
,
@RequestParam
(
required
=
false
,
value
=
"startTime"
)
Date
startTime
,
@RequestParam
(
required
=
false
,
value
=
"endTime"
)
Date
endTime
...
...
@@ -72,7 +78,7 @@ public class KeliuController {
ThreadPoolExecutor
threadPoolExecutor
=
new
ThreadPoolExecutor
(
20
,
20
,
1
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>(
10000
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
try
{
AtomicLong
count
=
new
AtomicLong
();
List
<
FaceRecognition
>
faceRecognitions
=
keliuRepository
.
getFaceRecognitionsByDateAndMallId
(
date
,
mallId
,
direction
,
deviceSerialNum
,
personType
,
channelSerialNum
,
startTime
,
endTime
);
List
<
FaceRecognition
>
faceRecognitions
=
keliuRepository
.
getFaceRecognitionsByDateAndMallId
(
date
,
mallId
,
direction
,
deviceSerialNum
,
personType
,
channelSerialNum
,
startTime
,
endTime
);
log
.
info
(
"上传数据量:"
+
faceRecognitions
.
size
());
for
(
FaceRecognition
faceRecognition
:
faceRecognitions
)
{
Future
<
JsonMessageUtil
.
JsonMessage
>
submit
=
threadPoolExecutor
.
submit
(()
->
{
...
...
@@ -149,4 +155,104 @@ public class KeliuController {
map
.
add
(
"gateId"
,
faceRecognition
.
getGateId
());
return
new
HttpEntity
<>(
map
,
headers
);
}
private
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
getBodyRequestEntity
(
BodyRecognition
bodyRecognition
,
byte
[]
bodyPic
,
byte
[]
bodyFeature
,
Long
packId
,
Long
taskId
,
Date
date
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
MULTIPART_FORM_DATA
);
ByteArrayResource
picResource
=
new
ByteArrayResource
(
bodyPic
)
{
@Override
public
String
getFilename
()
{
return
bodyRecognition
.
getBodyPic
();
}
};
ByteArrayResource
featureResource
=
new
ByteArrayResource
(
bodyFeature
)
{
@Override
public
String
getFilename
()
{
return
bodyRecognition
.
getBodyPic
()
+
".feature"
;
}
};
LinkedMultiValueMap
<
String
,
Object
>
map
=
new
LinkedMultiValueMap
<>();
map
.
add
(
"pic"
,
picResource
);
map
.
add
(
"feature"
,
featureResource
);
map
.
add
(
"unid"
,
bodyRecognition
.
getUnid
());
map
.
add
(
"personUnid"
,
bodyRecognition
.
getPersonUnid
());
map
.
add
(
"packId"
,
packId
);
map
.
add
(
"taskId"
,
taskId
);
map
.
add
(
"countTime"
,
DateUtil
.
format
(
"yyyy-MM-dd HH:mm:ss"
,
date
));
map
.
add
(
"direction"
,
bodyRecognition
.
getDirection
());
map
.
add
(
"gateId"
,
bodyRecognition
.
getGateId
());
return
new
HttpEntity
<>(
map
,
headers
);
}
@GetMapping
(
"/sendDataFromFile"
)
public
Object
sendDataFromFile
(
@RequestParam
Date
date
,
@RequestParam
String
pkgName
,
@RequestParam
Long
packId
,
@RequestParam
(
required
=
false
)
Long
taskId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"-1,0,1"
)
String
direction
,
@RequestParam
(
required
=
false
,
defaultValue
=
"0,1"
)
String
personType
,
@RequestParam
(
required
=
false
,
value
=
"deviceSerialNum"
)
String
deviceSerialNum
)
{
List
<
Future
<
JsonMessageUtil
.
JsonMessage
>>
responses
=
new
LinkedList
<>();
if
(
SEND_DATA
)
{
return
JsonMessageUtil
.
getErrorJsonMsg
(
"有数据传输任务正在进行"
);
}
else
{
SEND_DATA
=
true
;
ThreadPoolExecutor
threadPoolExecutor
=
new
ThreadPoolExecutor
(
20
,
20
,
1
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>(
10000
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
try
{
AtomicLong
count
=
new
AtomicLong
();
// List<FaceRecognition> faceRecognitions = keliuRepository.getFaceRecognitionsByDateAndMallId(date, mallId, direction, deviceSerialNum,personType, channelSerialNum, startTime, endTime);
List
<
BodyRecognition
>
bodyRecognitions
=
fileService
.
getFaceRecognition
(
pkgName
,
direction
);
if
(
bodyRecognitions
==
null
)
{
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success:0;failed:0"
);
}
log
.
info
(
"上传数据量:"
+
bodyRecognitions
.
size
());
for
(
BodyRecognition
bodyRecognition
:
bodyRecognitions
)
{
Future
<
JsonMessageUtil
.
JsonMessage
>
submit
=
threadPoolExecutor
.
submit
(()
->
{
try
{
byte
[]
bodyPic
=
bodyRecognition
.
getBodyPicture
();
byte
[]
bodyFeature
=
bodyRecognition
.
getBodyFeature
();
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
getBodyRequestEntity
(
bodyRecognition
,
bodyPic
,
bodyFeature
,
packId
,
taskId
,
date
);
ResponseEntity
<
JsonMessageUtil
.
JsonMessage
>
exchange
=
restTemplate
.
exchange
(
vionConfig
.
getTargetUrl
(),
HttpMethod
.
POST
,
requestEntity
,
JsonMessageUtil
.
JsonMessage
.
class
);
JsonMessageUtil
.
JsonMessage
body
=
exchange
.
getBody
();
log
.
info
(
"unid:{},msg:{},count:{}/{}"
,
bodyRecognition
.
getUnid
(),
body
.
getMsg
(),
count
.
incrementAndGet
(),
bodyRecognitions
.
size
());
return
body
;
}
catch
(
Exception
e
)
{
log
.
info
(
""
,
e
);
return
null
;
}
});
responses
.
add
(
submit
);
}
}
finally
{
while
(
threadPoolExecutor
.
getActiveCount
()
>
0
)
{
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
threadPoolExecutor
.
shutdown
();
SEND_DATA
=
false
;
}
}
long
success
=
0
;
long
failed
=
0
;
for
(
Future
<
JsonMessageUtil
.
JsonMessage
>
future
:
responses
)
{
try
{
JsonMessageUtil
.
JsonMessage
jsonMessage
=
future
.
get
(
20
,
TimeUnit
.
SECONDS
);
if
(
jsonMessage
==
null
||
!
jsonMessage
.
isSuccess
())
{
failed
++;
}
else
{
success
++;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success:"
+
success
+
";failed:"
+
failed
);
}
}
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/model/BodyRecognition.java
0 → 100644
View file @
6588593
package
com
.
viontech
.
label
.
tool
.
keliu
.
model
;
import
lombok.Data
;
@Data
public
class
BodyRecognition
{
private
String
personUnid
;
private
String
unid
;
private
String
direction
;
private
String
bodyPic
;
private
String
gateId
;
byte
[]
bodyFeature
;
byte
[]
bodyPicture
;
}
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/model/ImageInfo.java
0 → 100644
View file @
6588593
package
com
.
viontech
.
label
.
tool
.
keliu
.
model
;
import
lombok.Data
;
@Data
public
class
ImageInfo
{
private
String
imageName
;
private
Integer
headX
;
private
Integer
headY
;
private
Integer
footX
;
private
Integer
footY
;
private
Integer
quadrant
;
private
Integer
lefttopX
;
private
Integer
lefttopY
;
}
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/model/ROI.java
0 → 100644
View file @
6588593
package
com
.
viontech
.
label
.
tool
.
keliu
.
model
;
import
lombok.Data
;
@Data
public
class
ROI
{
int
x
;
int
y
;
int
w
;
int
h
;
}
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/service/FileService.java
View file @
6588593
package
com
.
viontech
.
label
.
tool
.
keliu
.
service
;
import
com.viontech.label.tool.keliu.model.BodyRecognition
;
import
java.util.List
;
/**
* .
*
...
...
@@ -10,4 +14,7 @@ public interface FileService {
byte
[]
getFile
(
String
filePath
);
List
<
String
>
getFileContent
(
String
pkgName
);
List
<
BodyRecognition
>
getFaceRecognition
(
String
pkgName
,
String
direction
);
}
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/service/LocalFileServiceImpl.java
View file @
6588593
This diff is collapsed.
Click to expand it.
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/service/OnlineFileServiceImpl.java
View file @
6588593
package
com
.
viontech
.
label
.
tool
.
keliu
.
service
;
import
com.viontech.label.tool.keliu.config.VionConfig
;
import
com.viontech.label.tool.keliu.model.BodyRecognition
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* .
...
...
@@ -28,4 +30,14 @@ public class OnlineFileServiceImpl implements FileService {
public
byte
[]
getFile
(
String
filePath
)
{
return
restTemplate
.
getForObject
(
vionConfig
.
getKeliuImageUrl
()
+
filePath
,
byte
[].
class
);
}
@Override
public
List
<
String
>
getFileContent
(
String
pkgName
)
{
return
null
;
}
@Override
public
List
<
BodyRecognition
>
getFaceRecognition
(
String
pkgName
,
String
direction
)
{
return
null
;
}
}
label-tool-keliu/src/main/resources/application-option.properties
View file @
6588593
...
...
@@ -9,14 +9,15 @@ spring.datasource.password=cdmqYwBq9uAdvLJb
# redis
spring.redis.host
=
127.0.0.1
spring.redis.port
=
6379
spring.redis.password
=
vionredis
spring.redis.password
=
#temporary
logging.level.com.viontech.label.mapper
=
error
debug
=
false
vion.local-
client
=
true
#vion.target-url=http://36.112.68.214:12100/reid/upload
vion.target-
url
=
http://127.0.0.1:12100/reid/upload
vion.keliu-image-
url
=
https://vion-retail.oss-cn-beijing.aliyuncs.com/
#vion.keliu-image-path=/jason/VVAS/jingmao/
#vion.keliu-image-url=https://vion-retail.oss-cn-beijing.aliyuncs.com/
vion.keliu-image-
path
=
/jason/VVAS/jingmao/
vion.keliu.dir
=
D:/Work/data
vion.feature-
url
=
http://182.92.177.43:18500
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