Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
refined-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
refined-platform
Commits
92d42774
Commit
92d42774
authored
May 10, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加服务追踪
parent
97a6193a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
23 deletions
+130
-23
refined-manager/src/main/java/com/mortals/xhx/busiz/web/HikCallbackController.java
...java/com/mortals/xhx/busiz/web/HikCallbackController.java
+1
-1
refined-manager/src/main/java/com/mortals/xhx/daemon/task/SyncRegisterUserTaskImpl.java
...com/mortals/xhx/daemon/task/SyncRegisterUserTaskImpl.java
+128
-21
refined-manager/src/main/java/com/mortals/xhx/module/hik/face/service/impl/HikFaceServiceImpl.java
.../xhx/module/hik/face/service/impl/HikFaceServiceImpl.java
+1
-1
No files found.
refined-manager/src/main/java/com/mortals/xhx/busiz/web/HikCallbackController.java
View file @
92d42774
...
@@ -23,7 +23,7 @@ public class HikCallbackController {
...
@@ -23,7 +23,7 @@ public class HikCallbackController {
@PostMapping
(
"eventRcv"
)
@PostMapping
(
"eventRcv"
)
@UnAuth
@UnAuth
public
Rest
<
String
>
receivePlanMessage
(
@RequestBody
EventReq
req
)
{
public
Rest
<
String
>
receivePlanMessage
(
@RequestBody
EventReq
req
)
{
log
.
info
(
"【接收人脸计划事件数据】【请求体】--> {}"
,
JSON
.
toJSONString
(
req
));
//
log.info("【接收人脸计划事件数据】【请求体】--> {}", JSON.toJSONString(req));
// EventReq eventReq = JSON.parseObject(req, EventReq.class);
// EventReq eventReq = JSON.parseObject(req, EventReq.class);
try
{
try
{
Rest
<
String
>
rest
=
hikEventService
.
handleEvent
(
req
);
Rest
<
String
>
rest
=
hikEventService
.
handleEvent
(
req
);
...
...
refined-manager/src/main/java/com/mortals/xhx/daemon/task/SyncRegisterUserTaskImpl.java
View file @
92d42774
...
@@ -4,31 +4,16 @@ import cn.hutool.core.date.DateUtil;
...
@@ -4,31 +4,16 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.util.IdcardUtil
;
import
cn.hutool.core.util.IdcardUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.FileUtil
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.busiz.rsp.register.DataItem
;
import
com.mortals.xhx.busiz.rsp.register.DataItem
;
import
com.mortals.xhx.busiz.rsp.register.RegisterDataInfo
;
import
com.mortals.xhx.busiz.rsp.register.RegisterDataInfo
;
import
com.mortals.xhx.common.code.SourceEnum
;
import
com.mortals.xhx.common.code.SourceEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
import
com.mortals.xhx.module.hik.HikApiRest
;
import
com.mortals.xhx.module.hik.door.model.rsp.door.DoorEventDataInfo
;
import
com.mortals.xhx.module.person.model.PersonEntity
;
import
com.mortals.xhx.module.person.model.PersonEntity
;
import
com.mortals.xhx.module.person.model.PersonQuery
;
import
com.mortals.xhx.module.person.model.PersonQuery
;
import
com.mortals.xhx.module.person.service.PersonService
;
import
com.mortals.xhx.module.person.service.PersonService
;
...
@@ -36,10 +21,8 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -36,10 +21,8 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.FileItem
;
import
org.apache.commons.fileupload.FileItemFactory
;
import
org.apache.commons.fileupload.FileItemFactory
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
...
@@ -76,7 +59,8 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
...
@@ -76,7 +59,8 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
@Override
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"同步注册用户任务"
);
log
.
info
(
"同步注册用户任务"
);
syncRegisterUsers
();
//syncRegisterUsers();
syncRegisterUsersTotal
();
log
.
info
(
"同步注册用户任务完成"
);
log
.
info
(
"同步注册用户任务完成"
);
log
.
info
(
"同步注册用户照片任务"
);
log
.
info
(
"同步注册用户照片任务"
);
...
@@ -85,13 +69,136 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
...
@@ -85,13 +69,136 @@ public class SyncRegisterUserTaskImpl implements ITaskExcuteService {
}
}
private
void
syncRegisterUsersTotal
()
{
log
.
info
(
"同步注册用户全量更新"
);
String
registerPath
=
"/inter/Actuary/peopleList"
;
String
url
=
host
+
registerPath
;
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"page"
,
1
);
params
.
put
(
"size"
,
1
);
params
.
put
(
"startid"
,
0
);
String
respJson
=
HttpUtil
.
get
(
url
,
params
);
Rest
<
RegisterDataInfo
>
rest
=
JSON
.
parseObject
(
respJson
,
new
TypeReference
<
Rest
<
RegisterDataInfo
>>()
{
});
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
Integer
total
=
rest
.
getData
().
getTotal
();
if
(
total
>
1
)
{
//todo 分页请求
params
=
new
HashMap
<>();
params
.
put
(
"page"
,
1
);
params
.
put
(
"size"
,
total
);
respJson
=
HttpUtil
.
get
(
url
,
params
);
Rest
<
RegisterDataInfo
>
restTotal
=
JSON
.
parseObject
(
respJson
,
new
TypeReference
<
Rest
<
RegisterDataInfo
>>()
{
});
if
(
restTotal
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
//同步所有用户
List
<
DataItem
>
userList
=
restTotal
.
getData
().
getData
();
log
.
info
(
"注册用户新增数量:{}"
,
userList
.
size
());
if
(!
ObjectUtils
.
isEmpty
(
userList
))
{
List
<
PersonEntity
>
newUserList
=
userList
.
stream
().
map
(
user
->
{
if
(
ObjectUtils
.
isEmpty
(
user
.
getIdcardIDCardNo
()))
{
return
null
;
}
PersonEntity
personEntity
=
new
PersonEntity
();
personEntity
.
initAttrValue
();
personEntity
.
setName
(
user
.
getIdcardName
());
personEntity
.
setGender
(
"男"
.
equals
(
user
.
getIdcardSex
())
?
0
:
1
);
personEntity
.
setIdCard
(
user
.
getIdcardIDCardNo
());
personEntity
.
setPhone
(
user
.
getPhone
());
personEntity
.
setAddress
(
user
.
getIdcardAddress
());
try
{
personEntity
.
setBirthday
(
DateUtil
.
parse
(
IdcardUtil
.
getBirth
(
user
.
getIdcardIDCardNo
()),
"yyyyMMdd"
));
}
catch
(
Exception
e
)
{
}
personEntity
.
setSourceId
(
user
.
getId
());
personEntity
.
setSource
(
SourceEnum
.
排队叫号系统
.
getValue
());
personEntity
.
setSourcePhotoUri
(
user
.
getIdcardDataPhotoFileName
());
return
personEntity
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
List
<
PersonEntity
>
oldUserList
=
personService
.
find
(
new
PersonQuery
());
Map
<
String
,
PersonEntity
>
oldUserMap
=
oldUserList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getIdCard
(),
y
->
y
,
(
o
,
n
)
->
n
));
Map
<
String
,
PersonEntity
>
newUserMap
=
newUserList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getIdCard
(),
y
->
y
,
(
o
,
n
)
->
n
));
List
<
PersonEntity
>
updateUserLsit
=
newUserList
.
stream
().
map
(
item
->
{
if
(
oldUserMap
.
containsKey
(
item
.
getIdCard
()))
{
PersonEntity
personEntity
=
oldUserMap
.
get
(
item
.
getIdCard
());
//校验 如果参数都一样 则不添加更新
Boolean
bool
=
checkFieldSame
(
item
,
personEntity
);
if
(
bool
)
return
null
;
personEntity
.
setName
(
item
.
getName
());
personEntity
.
setGender
(
item
.
getGender
());
personEntity
.
setPhone
(
item
.
getPhone
());
personEntity
.
setAddress
(
item
.
getAddress
());
personEntity
.
setBirthday
(
item
.
getBirthday
());
personEntity
.
setSourcePhotoUri
(
item
.
getSourcePhotoUri
());
personEntity
.
setUpdateUserId
(
1L
);
personEntity
.
setUpdateTime
(
new
Date
());
return
personEntity
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
List
<
PersonEntity
>
saveUserList
=
newUserList
.
stream
().
map
(
item
->
{
if
(!
oldUserMap
.
containsKey
(
item
.
getIdCard
()))
{
item
.
setCreateUserId
(
1L
);
item
.
setCreateUserName
(
"系统管理员"
);
item
.
setCreateTime
(
new
Date
());
return
item
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
//做差集
List
<
Long
>
delUserList
=
oldUserList
.
stream
().
map
(
item
->
{
if
(!
newUserMap
.
containsKey
(
item
.
getIdCard
()))
{
return
item
.
getId
();
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
updateUserLsit
))
{
log
.
info
(
"注册用户更新,size:{}"
,
updateUserLsit
.
size
());
personService
.
update
(
updateUserLsit
);
}
if
(!
ObjectUtils
.
isEmpty
(
saveUserList
))
{
log
.
info
(
"注册用户新增,size:{}"
,
saveUserList
.
size
());
personService
.
save
(
saveUserList
);
}
}
}
}
}
}
private
boolean
checkFieldSame
(
PersonEntity
newPerson
,
PersonEntity
oldPerson
)
{
if
(!
ObjectUtils
.
isEmpty
(
newPerson
.
getSourcePhotoUri
())
&&
!
newPerson
.
getSourcePhotoUri
().
equals
(
oldPerson
.
getSourcePhotoUri
()))
{
return
false
;
}
return
true
;
}
private
void
syncRegisterUsers
()
{
private
void
syncRegisterUsers
()
{
//查询本地最大id
//查询本地最大id
int
count
=
0
;
int
count
=
0
;
List
<
PersonEntity
>
max
=
personService
.
getDao
().
getMax
();
List
<
PersonEntity
>
max
=
personService
.
getDao
().
getMax
();
if
(!
ObjectUtils
.
isEmpty
(
max
))
{
if
(!
ObjectUtils
.
isEmpty
(
max
))
{
count
=
max
.
get
(
0
).
getSourceId
().
intValue
();
count
=
max
.
get
(
0
).
getSourceId
().
intValue
();
}
}
String
registerPath
=
"/inter/Actuary/peopleList"
;
String
registerPath
=
"/inter/Actuary/peopleList"
;
String
url
=
host
+
registerPath
;
String
url
=
host
+
registerPath
;
...
...
refined-manager/src/main/java/com/mortals/xhx/module/hik/face/service/impl/HikFaceServiceImpl.java
View file @
92d42774
...
@@ -228,7 +228,7 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
...
@@ -228,7 +228,7 @@ public class HikFaceServiceImpl extends AbstractHikService implements IHikFaceSe
String
getCamsApi
=
ARTEMIS_PATH
+
"/api/frs/v1/application/picture"
;
String
getCamsApi
=
ARTEMIS_PATH
+
"/api/frs/v1/application/picture"
;
path
.
put
(
protocol
,
getCamsApi
);
path
.
put
(
protocol
,
getCamsApi
);
try
{
try
{
log
.
info
(
"download img req=>{}"
,
JSON
.
toJSONString
(
imgReq
));
//
log.info("download img req=>{}", JSON.toJSONString(imgReq));
String
respJson
=
ArtemisHttpUtil
.
doPostStringArtemis
(
config
,
path
,
JSON
.
toJSONString
(
imgReq
),
null
,
null
,
"application/json"
);
String
respJson
=
ArtemisHttpUtil
.
doPostStringArtemis
(
config
,
path
,
JSON
.
toJSONString
(
imgReq
),
null
,
null
,
"application/json"
);
//log.info("download img resp=>{}", respJson);
//log.info("download img resp=>{}", respJson);
HikApiRest
<
String
>
rest
=
JSON
.
parseObject
(
respJson
,
new
TypeReference
<
HikApiRest
<
String
>>()
{
HikApiRest
<
String
>
rest
=
JSON
.
parseObject
(
respJson
,
new
TypeReference
<
HikApiRest
<
String
>>()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment