Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
HaiNaAIFaceToFace
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
霍传世
HaiNaAIFaceToFace
Commits
3b568b1f
Commit
3b568b1f
authored
Jan 21, 2025
by
霍传世
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HaiNa---接口
parent
f17e0f2c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
21 deletions
+39
-21
src/main/java/com/yuda/hainafacetofaceai/controller/FaceMatchController.java
...uda/hainafacetofaceai/controller/FaceMatchController.java
+39
-21
No files found.
src/main/java/com/yuda/hainafacetofaceai/controller/FaceMatchController.java
View file @
3b568b1f
...
...
@@ -10,6 +10,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
@RestController
@RequestMapping
(
"/faceMatchApi"
)
...
...
@@ -45,42 +47,58 @@ public class FaceMatchController {
JSONObject
object
=
new
JSONObject
(
picName
);
picName
=
object
.
getString
(
"picName"
);
log
.
info
(
"faceMatch正在校验-》身份证号:"
+
idCard
+
"参加面试编号:"
+
examConnectionCode
+
"_人脸照片"
);
String
message
=
""
;
if
(
check
(
examConnectionCode
,
idCard
,
message
)){
if
(
check
(
examConnectionCode
,
idCard
).
get
(
"result"
).
equals
(
"fail"
)){
JSONObject
responseBody
=
new
JSONObject
();
responseBody
.
put
(
"code"
,
500
);
responseBody
.
put
(
"message"
,
message
);
responseBody
.
put
(
"message"
,
check
(
examConnectionCode
,
idCard
).
get
(
"message"
).
toString
()
);
return
ResponseEntity
.
badRequest
().
body
(
responseBody
.
toString
());
}
try
{
String
[]
result
=
faceMatch
.
faceMatchBaidu
(
idCard
,
picName
);
JSONObject
responseBody
=
new
JSONObject
();
responseBody
.
put
(
"code"
,
200
);
if
(
result
[
0
].
equals
(
"1"
)){
stringRedisTemplate
.
opsForValue
().
increment
(
"face_success:"
+
examConnectionCode
+
"_"
+
idCard
);
DBOperator
.
update
(
"update candidate_exam set status_face = 1 where exam_connection_code = ? and zkz_num = ?"
,
new
Object
[]{
examConnectionCode
,
zkzNum
});
log
.
info
(
"身份证:"
+
idCard
+
"参加面试编号:"
+
examConnectionCode
+
"人脸验证成功"
);
responseBody
.
put
(
"message"
,
"检测成功"
);
responseBody
.
put
(
"result"
,
true
);
}
else
{
stringRedisTemplate
.
opsForValue
().
increment
(
"face_error:"
+
examConnectionCode
+
"_"
+
idCard
);
log
.
info
(
"身份证:"
+
idCard
+
"参加面试编号:"
+
examConnectionCode
+
"人脸验证失败"
);
responseBody
.
put
(
"message"
,
"检测成功"
);
responseBody
.
put
(
"result"
,
false
);
}
JSONObject
responseBody
=
new
JSONObject
();
responseBody
.
put
(
"code"
,
200
);
responseBody
.
put
(
"message"
,
"校验成功"
);
return
ResponseEntity
.
ok
(
responseBody
.
toString
());
}
catch
(
Exception
e
){
e
.
printStackTrace
();
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"code"
,
500
);
data
.
put
(
"message"
,
"检测失败"
);
return
ResponseEntity
.
ok
(
data
.
toString
());
}
}
private
boolean
check
(
String
examConnectionCode
,
String
idCard
,
String
message
)
{
private
HashMap
<
String
,
Object
>
check
(
String
examConnectionCode
,
String
idCard
)
{
String
success
=
stringRedisTemplate
.
opsForValue
().
get
(
"face_success:"
+
examConnectionCode
+
"_"
+
idCard
);
if
(!
StringUtils
.
isEmpty
(
success
))
{
if
(
Integer
.
parseInt
(
success
)
>=
1
)
{
message
=
"请勿重复提交"
;
return
true
;
return
new
HashMap
<
String
,
Object
>(){{
put
(
"result"
,
"fail"
);
put
(
"message"
,
"请勿重复上传"
);
}};
}
}
String
s
=
stringRedisTemplate
.
opsForValue
().
get
(
"face_error:"
+
examConnectionCode
+
"_"
+
idCard
);
if
(!
StringUtils
.
isEmpty
(
s
))
{
if
(
Integer
.
parseInt
(
s
)
>=
3
)
{
message
=
"失败次数超3次"
;
return
true
;
return
new
HashMap
<
String
,
Object
>(){{
put
(
"result"
,
"fail"
);
put
(
"message"
,
"失败次数超过三次"
);
}};
}
}
return
false
;
return
new
HashMap
<
String
,
Object
>(){{
put
(
"result"
,
"success"
);
}};
}
}
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