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 a5067a9d
authored
Sep 08, 2021
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优质todo,合并后再搜索时进行隐藏
1 parent
124ae36c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
11 deletions
label-core/src/main/java/com/viontech/label/core/constant/SubTaskStatus.java
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-tool-keliu/src/main/java/com/viontech/label/tool/keliu/controller/KeliuController.java
label-core/src/main/java/com/viontech/label/core/constant/SubTaskStatus.java
View file @
a5067a9
...
@@ -13,6 +13,8 @@ public enum SubTaskStatus {
...
@@ -13,6 +13,8 @@ public enum SubTaskStatus {
LABELING
(
2
),
LABELING
(
2
),
/** 完成标注 */
/** 完成标注 */
FINISH_LABELING
(
3
),
FINISH_LABELING
(
3
),
/** todo标注 */
TODO
(
4
),
/** 已回收 */
/** 已回收 */
recycled
(-
1
);
recycled
(-
1
);
public
int
val
;
public
int
val
;
...
...
label-platform/src/main/java/com/viontech/label/platform/controller/web/ReidController.java
View file @
a5067a9
...
@@ -142,6 +142,19 @@ public class ReidController {
...
@@ -142,6 +142,19 @@ public class ReidController {
}
}
}
}
@GetMapping
(
"/mergeAndTodo"
)
public
Object
mergeAndTodo
(
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
[]
personUnidArr
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
Long
[]
subTaskIdArr
,
@RequestParam
Long
packId
,
@RequestParam
String
currentPerson
)
{
try
{
reidService
.
mergeAndTodo
(
personUnidArr
,
subTaskIdArr
,
packId
,
currentPerson
);
}
catch
(
Exception
e
)
{
return
JsonMessageUtil
.
getErrorJsonMsg
(
e
.
getMessage
());
}
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
);
}
/**
/**
* 标记某个人已经被清理干净了
* 标记某个人已经被清理干净了
*
*
...
@@ -162,8 +175,10 @@ public class ReidController {
...
@@ -162,8 +175,10 @@ public class ReidController {
* @param size 获取相似的人的数量
* @param size 获取相似的人的数量
*/
*/
@GetMapping
(
"/getSimilarPerson"
)
@GetMapping
(
"/getSimilarPerson"
)
public
Object
getSimilarPerson
(
@RequestParam
Long
[]
picIdArr
,
@RequestParam
Long
packId
,
@RequestParam
Long
size
,
@RequestParam
(
required
=
false
)
Integer
timeInterval
)
{
public
Object
getSimilarPerson
(
@RequestParam
Long
[]
picIdArr
,
@RequestParam
Long
packId
,
Map
<
String
,
List
<
SubTask
>>
similarPerson
=
reidService
.
getSimilarPerson
(
picIdArr
,
packId
,
size
,
timeInterval
);
@RequestParam
Long
size
,
@RequestParam
(
required
=
false
)
Integer
timeInterval
,
@RequestParam
(
required
=
false
)
String
currentPerson
)
{
Map
<
String
,
Map
<
String
,
List
<
SubTask
>>>
similarPerson
=
reidService
.
getSimilarPerson
(
picIdArr
,
packId
,
size
,
timeInterval
,
currentPerson
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
,
similarPerson
);
return
JsonMessageUtil
.
getSuccessJsonMsg
(
"success"
,
similarPerson
);
}
}
...
...
label-platform/src/main/java/com/viontech/label/platform/service/main/ReidService.java
View file @
a5067a9
...
@@ -21,7 +21,9 @@ import com.viontech.label.platform.vo.PicVo;
...
@@ -21,7 +21,9 @@ import com.viontech.label.platform.vo.PicVo;
import
com.viontech.label.platform.vo.ReidUploadData
;
import
com.viontech.label.platform.vo.ReidUploadData
;
import
com.viontech.label.platform.websocket.ReidWebsocket
;
import
com.viontech.label.platform.websocket.ReidWebsocket
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.redisson.api.RMap
;
import
org.redisson.api.RMap
;
import
org.redisson.api.RSet
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
@@ -138,7 +140,7 @@ public class ReidService {
...
@@ -138,7 +140,7 @@ public class ReidService {
/**
/**
* 将多个人合并
* 将多个人合并
*/
*/
public
void
mergePerson
(
String
[]
personUnidArr
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
public
String
mergePerson
(
String
[]
personUnidArr
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
String
newPersonUnid
;
String
newPersonUnid
;
ArrayList
<
String
>
needMergePersonUnidList
=
new
ArrayList
<>(
Arrays
.
asList
(
personUnidArr
));
ArrayList
<
String
>
needMergePersonUnidList
=
new
ArrayList
<>(
Arrays
.
asList
(
personUnidArr
));
if
(
currentPerson
!=
null
&&
needMergePersonUnidList
.
contains
(
currentPerson
))
{
if
(
currentPerson
!=
null
&&
needMergePersonUnidList
.
contains
(
currentPerson
))
{
...
@@ -199,13 +201,15 @@ public class ReidService {
...
@@ -199,13 +201,15 @@ public class ReidService {
logMergePerson
(
personUnidArr
);
logMergePerson
(
personUnidArr
);
// websocket
// websocket
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergePerson"
).
setData
(
needMergePersonUnidList
));
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergePerson"
).
setData
(
needMergePersonUnidList
));
return
newPersonUnid
;
}
}
/**
/**
* 合并多张图作为新人
* 合并多张图作为新人
*/
*/
public
void
mergeAsNewPerson
(
Long
[]
subTaskIds
,
Long
packId
)
throws
Exception
{
public
String
mergeAsNewPerson
(
Long
[]
subTaskIds
,
Long
packId
)
throws
Exception
{
String
poolName
=
Constants
.
getReidPoolName
(
packId
);
String
poolName
=
Constants
.
getReidPoolName
(
packId
);
// 获取被合并的图片对应的personUnid集合
// 获取被合并的图片对应的personUnid集合
SubTaskExample
subTaskExample
=
new
SubTaskExample
();
SubTaskExample
subTaskExample
=
new
SubTaskExample
();
...
@@ -264,12 +268,14 @@ public class ReidService {
...
@@ -264,12 +268,14 @@ public class ReidService {
logMergeAsNewPerson
(
subTaskIds
);
logMergeAsNewPerson
(
subTaskIds
);
// websocket
// websocket
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergeAsNewPerson"
).
setData
(
message
));
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergeAsNewPerson"
).
setData
(
message
));
return
newPersonUnid
;
}
}
/**
/**
* 将多张图与某个人合并
* 将多张图与某个人合并
*/
*/
public
void
mergeTo
(
Long
[]
subTaskIdArr
,
String
personUnid
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
public
String
mergeTo
(
Long
[]
subTaskIdArr
,
String
personUnid
,
String
currentPerson
,
Long
packId
)
throws
Exception
{
if
(!
Objects
.
equals
(
personUnid
,
currentPerson
))
{
if
(!
Objects
.
equals
(
personUnid
,
currentPerson
))
{
if
(
isLabeling
(
personUnid
,
packId
)
!=
null
)
{
if
(
isLabeling
(
personUnid
,
packId
)
!=
null
)
{
throw
new
RuntimeException
(
"有标注中的人被选择"
);
throw
new
RuntimeException
(
"有标注中的人被选择"
);
...
@@ -302,6 +308,11 @@ public class ReidService {
...
@@ -302,6 +308,11 @@ public class ReidService {
for
(
Long
picId
:
picIdSet
)
{
for
(
Long
picId
:
picIdSet
)
{
storageUtils
.
removePicCache
(
picId
);
storageUtils
.
removePicCache
(
picId
);
}
}
// 合并后将 personUnid 放入到redis 的过滤列表中
if
(
currentPerson
.
equals
(
personUnid
))
{
addMatchFilter
(
personUnid
,
packId
,
originalPersonUnidSet
);
}
// 写入日志
// 写入日志
logMergeTo
(
subTaskIdArr
,
personUnid
);
logMergeTo
(
subTaskIdArr
,
personUnid
);
// websocket
// websocket
...
@@ -309,6 +320,61 @@ public class ReidService {
...
@@ -309,6 +320,61 @@ public class ReidService {
body
.
put
(
"subTaskIdArr"
,
subTaskIdArr
);
body
.
put
(
"subTaskIdArr"
,
subTaskIdArr
);
body
.
put
(
"personUnid"
,
personUnid
);
body
.
put
(
"personUnid"
,
personUnid
);
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergeTo"
).
setData
(
body
));
ReidWebsocket
.
sendInfo
(
packId
,
new
ReidWebsocket
.
Message
().
setCommand
(
"mergeTo"
).
setData
(
body
));
return
personUnid
;
}
/**
* 按规则合并,并跟新为todo 状态
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
mergeAndTodo
(
String
[]
personUnidArr
,
Long
[]
subTaskIdArr
,
Long
packId
,
String
currentPerson
)
throws
Exception
{
log
.
info
(
"mergeAndTodo:[{}]-[{}]-[{}]-[{}]"
,
Arrays
.
toString
(
personUnidArr
),
Arrays
.
toString
(
subTaskIdArr
),
packId
,
currentPerson
);
int
i
=
ArrayUtils
.
indexOf
(
personUnidArr
,
currentPerson
);
if
(
i
!=
-
1
)
{
personUnidArr
=
ArrayUtils
.
remove
(
personUnidArr
,
i
);
}
String
type
=
""
;
if
(
personUnidArr
.
length
>
1
&&
subTaskIdArr
.
length
>
1
)
{
throw
new
RuntimeException
(
"参数不正确"
);
}
if
(
personUnidArr
.
length
==
1
)
{
if
(
subTaskIdArr
.
length
>
0
)
{
type
=
"mergeTo"
;
}
else
{
type
=
"update"
;
}
}
else
if
(
personUnidArr
.
length
==
0
&&
subTaskIdArr
.
length
>
0
)
{
type
=
"mergeAsNewPerson"
;
}
else
if
(
personUnidArr
.
length
>
1
&&
subTaskIdArr
.
length
==
0
)
{
type
=
"mergePerson"
;
}
String
personUnid
;
switch
(
type
)
{
case
"mergeTo"
:
personUnid
=
mergeTo
(
subTaskIdArr
,
personUnidArr
[
0
],
currentPerson
,
packId
);
break
;
case
"mergeAsNewPerson"
:
personUnid
=
mergeAsNewPerson
(
subTaskIdArr
,
packId
);
break
;
case
"mergePerson"
:
personUnid
=
mergePerson
(
personUnidArr
,
currentPerson
,
packId
);
break
;
case
"update"
:
personUnid
=
personUnidArr
[
0
];
break
;
default
:
throw
new
RuntimeException
(
"未知原因"
);
}
SubTaskExample
subTaskExample
=
new
SubTaskExample
();
subTaskExample
.
createCriteria
().
andPersonUnidEqualTo
(
personUnid
).
andPackIdEqualTo
(
packId
);
SubTask
subTask
=
new
SubTask
();
subTask
.
setStatus
(
SubTaskStatus
.
TODO
.
val
);
subTaskService
.
updateByExampleSelective
(
subTask
,
subTaskExample
);
}
}
/**
/**
...
@@ -352,7 +418,7 @@ public class ReidService {
...
@@ -352,7 +418,7 @@ public class ReidService {
/**
/**
* 根据所选择的图片获取相似的人
* 根据所选择的图片获取相似的人
*/
*/
public
Map
<
String
,
List
<
SubTask
>>
getSimilarPerson
(
Long
[]
subTaskIdArr
,
Long
packId
,
Long
size
,
Integer
timeInterval
)
{
public
Map
<
String
,
Map
<
String
,
List
<
SubTask
>>>
getSimilarPerson
(
Long
[]
subTaskIdArr
,
Long
packId
,
Long
size
,
Integer
timeInterval
,
String
currentPerson
)
{
List
<
BodyFeature
>
bodyFeatures
=
new
ArrayList
<>();
List
<
BodyFeature
>
bodyFeatures
=
new
ArrayList
<>();
String
reidPoolName
=
Constants
.
getReidPoolName
(
packId
);
String
reidPoolName
=
Constants
.
getReidPoolName
(
packId
);
Date
countTimeGTE
=
null
;
Date
countTimeGTE
=
null
;
...
@@ -402,16 +468,28 @@ public class ReidService {
...
@@ -402,16 +468,28 @@ public class ReidService {
subTaskExample
.
createCriteria
().
andPersonUnidIn
(
personUnidList
);
subTaskExample
.
createCriteria
().
andPersonUnidIn
(
personUnidList
);
subTasks
=
subTaskService
.
selectByExample
(
subTaskExample
);
subTasks
=
subTaskService
.
selectByExample
(
subTaskExample
);
final
Set
<
String
>
matchFilter
=
currentPerson
==
null
?
Collections
.
emptySet
()
:
getMatchFilter
(
currentPerson
,
packId
);
Map
<
String
,
List
<
SubTask
>>
collect
=
subTasks
.
stream
().
collect
(
Collectors
.
groupingBy
(
SubTask:
:
getPersonUnid
,
Collectors
.
toList
()));
Map
<
String
,
List
<
SubTask
>>
collect
=
subTasks
.
stream
().
collect
(
Collectors
.
groupingBy
(
SubTask:
:
getPersonUnid
,
Collectors
.
toList
()));
HashMap
<
String
,
Map
<
String
,
List
<
SubTask
>>>
ret
=
new
HashMap
<>();
Map
<
String
,
List
<
SubTask
>>
hideMap
=
new
HashMap
<>();
Map
<
String
,
List
<
SubTask
>>
displayMap
=
new
HashMap
<>();
ret
.
put
(
"hide"
,
hideMap
);
ret
.
put
(
"display"
,
displayMap
);
for
(
Map
.
Entry
<
String
,
List
<
SubTask
>>
entry
:
collect
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
SubTask
>>
entry
:
collect
.
entrySet
())
{
SubTask
pic
=
entry
.
getValue
().
get
(
0
);
SubTask
pic
=
entry
.
getValue
().
get
(
0
);
if
(
pic
.
getStatus
()
==
SubTaskStatus
.
FINISH_LABELING
.
val
&&
entry
.
getValue
().
size
()
>
3
)
{
if
(
pic
.
getStatus
()
==
SubTaskStatus
.
FINISH_LABELING
.
val
&&
entry
.
getValue
().
size
()
>
3
)
{
entry
.
setValue
(
entry
.
getValue
().
subList
(
0
,
3
));
entry
.
setValue
(
entry
.
getValue
().
subList
(
0
,
3
));
}
}
if
(
matchFilter
.
contains
(
pic
.
getPersonUnid
()))
{
hideMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
else
{
displayMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
}
return
collec
t
;
return
re
t
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
""
,
e
);
log
.
info
(
""
,
e
);
return
null
;
return
null
;
...
@@ -734,6 +812,19 @@ public class ReidService {
...
@@ -734,6 +812,19 @@ public class ReidService {
}
}
}
}
private
void
addMatchFilter
(
String
personUnid
,
Long
packId
,
Collection
<
String
>
filters
)
{
if
(
filters
.
size
()
>
0
)
{
RSet
<
String
>
set
=
redissonClient
.
getSet
(
"matchFilter:"
+
packId
+
":"
+
personUnid
);
set
.
addAll
(
filters
);
set
.
expire
(
1
,
TimeUnit
.
DAYS
);
}
}
private
Set
<
String
>
getMatchFilter
(
String
personUnid
,
Long
packId
)
{
RSet
<
String
>
set
=
redissonClient
.
getSet
(
"matchFilter:"
+
packId
+
":"
+
personUnid
);
return
set
.
readAll
();
}
public
LogService
getLogService
()
{
public
LogService
getLogService
()
{
return
logService
;
return
logService
;
}
}
...
...
label-platform/src/main/java/com/viontech/label/platform/utils/StorageUtils.java
View file @
a5067a9
...
@@ -75,7 +75,7 @@ public class StorageUtils {
...
@@ -75,7 +75,7 @@ public class StorageUtils {
// 获取并缓存 image
// 获取并缓存 image
Long
packId
=
picVo
.
getPackId
();
Long
packId
=
picVo
.
getPackId
();
String
picImageKey
=
Constants
.
getRedisKeyPicImage
(
picId
);
String
picImageKey
=
Constants
.
getRedisKeyPicImage
(
picId
);
RBucket
<
byte
[]>
picImageBucket
=
redissonClient
.
<
byte
[]>
getBucket
(
picImageKey
);
RBucket
<
byte
[]>
picImageBucket
=
redissonClient
.
getBucket
(
picImageKey
);
byte
[]
bytes
=
picImageBucket
.
get
();
byte
[]
bytes
=
picImageBucket
.
get
();
if
(
bytes
==
null
)
{
if
(
bytes
==
null
)
{
try
{
try
{
...
@@ -86,7 +86,7 @@ public class StorageUtils {
...
@@ -86,7 +86,7 @@ public class StorageUtils {
}
}
picImageBucket
.
set
(
bytes
);
picImageBucket
.
set
(
bytes
);
}
}
picImageBucket
.
expire
(
12
,
TimeUnit
.
HOURS
);
picImageBucket
.
expire
(
4
,
TimeUnit
.
HOURS
);
picVo
.
setImage
(
bytes
);
picVo
.
setImage
(
bytes
);
return
picVo
;
return
picVo
;
...
...
label-tool-keliu/src/main/java/com/viontech/label/tool/keliu/controller/KeliuController.java
View file @
a5067a9
...
@@ -26,6 +26,7 @@ import java.util.concurrent.Future;
...
@@ -26,6 +26,7 @@ import java.util.concurrent.Future;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
/**
* .
* .
...
@@ -63,6 +64,7 @@ public class KeliuController {
...
@@ -63,6 +64,7 @@ public class KeliuController {
SEND_DATA
=
true
;
SEND_DATA
=
true
;
ThreadPoolExecutor
threadPoolExecutor
=
new
ThreadPoolExecutor
(
20
,
20
,
1
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>(
10000
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
ThreadPoolExecutor
threadPoolExecutor
=
new
ThreadPoolExecutor
(
20
,
20
,
1
,
TimeUnit
.
MINUTES
,
new
LinkedBlockingDeque
<>(
10000
),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
try
{
try
{
AtomicLong
count
=
new
AtomicLong
();
List
<
FaceRecognition
>
faceRecognitions
=
keliuRepository
.
getFaceRecognitionsByDateAndMallId
(
date
,
mallId
);
List
<
FaceRecognition
>
faceRecognitions
=
keliuRepository
.
getFaceRecognitionsByDateAndMallId
(
date
,
mallId
);
for
(
FaceRecognition
faceRecognition
:
faceRecognitions
)
{
for
(
FaceRecognition
faceRecognition
:
faceRecognitions
)
{
Future
<
JsonMessageUtil
.
JsonMessage
>
submit
=
threadPoolExecutor
.
submit
(()
->
{
Future
<
JsonMessageUtil
.
JsonMessage
>
submit
=
threadPoolExecutor
.
submit
(()
->
{
...
@@ -72,7 +74,7 @@ public class KeliuController {
...
@@ -72,7 +74,7 @@ public class KeliuController {
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
getRequestEntity
(
faceRecognition
,
bodyPic
,
bodyFeature
,
packId
,
taskId
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
getRequestEntity
(
faceRecognition
,
bodyPic
,
bodyFeature
,
packId
,
taskId
);
ResponseEntity
<
JsonMessageUtil
.
JsonMessage
>
exchange
=
restTemplate
.
exchange
(
vionConfig
.
getTargetUrl
(),
HttpMethod
.
POST
,
requestEntity
,
JsonMessageUtil
.
JsonMessage
.
class
);
ResponseEntity
<
JsonMessageUtil
.
JsonMessage
>
exchange
=
restTemplate
.
exchange
(
vionConfig
.
getTargetUrl
(),
HttpMethod
.
POST
,
requestEntity
,
JsonMessageUtil
.
JsonMessage
.
class
);
JsonMessageUtil
.
JsonMessage
body
=
exchange
.
getBody
();
JsonMessageUtil
.
JsonMessage
body
=
exchange
.
getBody
();
log
.
info
(
"unid:{},msg:{}
"
,
faceRecognition
.
getUnid
(),
body
.
getMsg
());
log
.
info
(
"unid:{},msg:{}
,count:{}/{}"
,
faceRecognition
.
getUnid
(),
body
.
getMsg
(),
count
.
incrementAndGet
(),
faceRecognitions
.
size
());
return
body
;
return
body
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
""
,
e
);
log
.
info
(
""
,
e
);
...
...
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