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 06c5932e
authored
Jul 23, 2021
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
为feature添加属性,提供下载接口
1 parent
cca6ea2d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
3 deletions
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
label-platform/src/main/java/com/viontech/label/platform/utils/StorageUtils.java
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
View file @
06c5932
...
...
@@ -7,9 +7,13 @@ import com.viontech.label.platform.model.Pic;
import
com.viontech.label.platform.service.adapter.PicService
;
import
com.viontech.label.platform.service.main.ReidService
;
import
com.viontech.label.platform.vo.ReidUploadData
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.util.*
;
/**
...
...
@@ -151,7 +155,7 @@ public class ReidController {
*/
@GetMapping
(
"/getSimilarPerson"
)
public
Object
getSimilarPerson
(
@RequestParam
Long
[]
picIdArr
,
@RequestParam
Long
packId
,
@RequestParam
Long
size
,
@RequestParam
(
required
=
false
)
Integer
timeInterval
)
{
Map
<
String
,
List
<
Pic
>>
similarPerson
=
reidService
.
getSimilarPerson
(
picIdArr
,
packId
,
size
,
timeInterval
);
Map
<
String
,
List
<
Pic
>>
similarPerson
=
reidService
.
getSimilarPerson
(
picIdArr
,
packId
,
size
,
timeInterval
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
,
similarPerson
);
}
...
...
@@ -189,4 +193,19 @@ public class ReidController {
reidService
.
exitLabeling
(
personUnid
,
packId
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
);
}
@GetMapping
(
"downloadLabeledPicAsZip"
)
public
void
downloadLabeledPicAsZip
(
@RequestParam
Long
packId
,
HttpServletResponse
response
)
throws
Exception
{
File
file
=
reidService
.
downloadLabeledPicAsZip
(
packId
);
response
.
setContentType
(
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
packId
+
".zip"
);
FileUtils
.
copyFile
(
file
,
response
.
getOutputStream
());
Thread
.
sleep
(
1000L
);
boolean
delete
=
file
.
delete
();
if
(!
delete
)
{
file
.
deleteOnExit
();
}
}
}
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
View file @
06c5932
...
...
@@ -29,10 +29,14 @@ import org.springframework.stereotype.Service;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
/**
* .
...
...
@@ -338,7 +342,7 @@ public class ReidService {
CompletableFuture
<
AlgResult
>
future
=
matchClient
.
matchPerson
(
2
,
person
,
reidPoolName
,
Collections
.
emptyList
(),
options
);
AlgResult
result
=
future
.
get
();
List
<
Person
>
matchBodies
=
result
.
getMatchBodies
();
List
<
String
>
personUnidList
=
matchBodies
.
stream
().
map
(
Person:
:
getPersonId
).
filter
(
x
->
!
personUnidSet
.
contains
(
x
)).
collect
(
Collectors
.
toList
());
List
<
String
>
personUnidList
=
matchBodies
.
stream
().
filter
(
x
->
x
.
getScore
()
>
60
F
).
map
(
Person:
:
getPersonId
).
filter
(
x
->
!
personUnidSet
.
contains
(
x
)).
collect
(
Collectors
.
toList
());
PicExample
picExample
=
new
PicExample
();
picExample
.
createCriteria
().
andPersonUnidIn
(
personUnidList
);
...
...
@@ -540,4 +544,34 @@ public class ReidService {
return
labelingSet
.
get
(
personUnid
);
}
public
File
downloadLabeledPicAsZip
(
Long
packId
)
throws
Exception
{
File
tempFile
=
File
.
createTempFile
(
"label-"
+
packId
,
".zip"
);
try
(
ZipOutputStream
zipOutputStream
=
new
ZipOutputStream
(
new
FileOutputStream
(
tempFile
)))
{
PicExample
picExample
=
new
PicExample
();
picExample
.
createCriteria
().
andPackIdEqualTo
(
packId
).
andStatusEqualTo
(
PicStatus
.
FINISH_LABELING
.
val
);
List
<
Pic
>
allPic
=
picService
.
selectByExample
(
picExample
);
Map
<
String
,
List
<
Pic
>>
collect
=
allPic
.
stream
().
collect
(
Collectors
.
groupingBy
(
Pic:
:
getPersonUnid
,
Collectors
.
toList
()));
byte
[]
bytes
;
for
(
Map
.
Entry
<
String
,
List
<
Pic
>>
entry
:
collect
.
entrySet
())
{
String
personUnid
=
entry
.
getKey
();
List
<
Pic
>
pics
=
entry
.
getValue
();
for
(
Pic
pic
:
pics
)
{
try
{
bytes
=
storageUtils
.
getFile
(
packId
,
pic
.
getName
());
}
catch
(
Exception
e
)
{
log
.
error
(
"打包文件时出错,packId:{},picId:{}"
,
packId
,
pic
.
getId
());
log
.
error
(
""
,
e
);
continue
;
}
if
(
bytes
!=
null
)
{
zipOutputStream
.
putNextEntry
(
new
ZipEntry
(
personUnid
+
"/"
+
pic
.
getName
()));
zipOutputStream
.
write
(
bytes
);
}
}
}
}
return
tempFile
;
}
}
label-platform/src/main/java/com/viontech/label/platform/utils/StorageUtils.java
View file @
06c5932
...
...
@@ -126,6 +126,7 @@ public class StorageUtils {
public
BodyFeature
getBodyFeature
(
Long
picId
)
{
Feature
featureByPic
=
getFeatureByPic
(
picId
);
PicVo
pic
=
getPic
(
picId
);
List
<
Data
>
datas
=
featureByPic
.
getDatas
();
if
(
datas
==
null
||
datas
.
size
()
==
0
)
{
return
null
;
...
...
@@ -135,7 +136,7 @@ public class StorageUtils {
return
null
;
}
Double
[]
featureData
=
data
.
getData
();
return
new
BodyFeature
().
setFeature
(
featureData
).
setBid
(
featureByPic
.
getFilename
());
return
new
BodyFeature
().
setFeature
(
featureData
).
setBid
(
featureByPic
.
getFilename
())
.
setCounttime
(
pic
.
getCreateTime
())
;
}
...
...
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