Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hnxtbaboot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨亮
hnxtbaboot
Commits
13e973b6
Commit
13e973b6
authored
Jul 04, 2019
by
wangyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
声纹采集数据入库
parent
55623687
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
254 additions
and
39 deletions
+254
-39
src/main/java/com/founder/controller/HmCjController.java
+131
-33
src/main/java/com/founder/controller/SwCjController.java
+123
-6
No files found.
src/main/java/com/founder/controller/HmCjController.java
View file @
13e973b6
package
com
.
founder
.
controller
;
import
com.alibaba.fastjson.JSONException
;
import
com.alibaba.fastjson.JSONObject
;
import
com.founder.model.TbStHm
;
import
com.founder.module.redis.service.IDicItemService
;
import
com.founder.service.IHmCjService
;
...
...
@@ -12,6 +14,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
...
...
@@ -30,49 +40,78 @@ public class HmCjController {
/**
* 保存虹膜采集数据
*
* @param tbStHm
* @return
*/
@RequestMapping
(
"/saveHmSjXx"
)
@ResponseBody
private
Map
<
String
,
String
>
saveHmSjXx
(
TbStHm
tbStHm
){
Map
<
String
,
String
>
map
=
new
HashMap
<>();
private
Map
<
String
,
String
>
saveHmSjXx
(
TbStHm
tbStHm
,
BufferedReader
br
)
{
//body部分
String
inputLine
;
String
str
=
""
;
try
{
while
((
inputLine
=
br
.
readLine
())
!=
null
)
{
str
+=
inputLine
;
}
br
.
close
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"IOException: "
+
e
);
}
System
.
out
.
println
(
"str:"
+
str
);
JSONObject
object
=
JSONObject
.
parseObject
(
str
);
tbStHm
.
setRybh
(
object
.
get
(
"rybh"
).
toString
());
tbStHm
.
setXm
(
object
.
get
(
"xm"
).
toString
());
tbStHm
.
setHmywdm
(
object
.
get
(
"hmywdm"
).
toString
());
tbStHm
.
setHmqsqk
(
object
.
get
(
"hmqsqk"
).
toString
());
tbStHm
.
setGmsfhm
(
object
.
get
(
"gmsfhm"
).
toString
());
tbStHm
.
setLrrPolicemanid
(
object
.
get
(
"lrrPolicemanid"
).
toString
());
str
=
object
.
get
(
"hmsjStr"
).
toString
();
try
{
tbStHm
.
setHmsj
(
URLDecoder
.
decode
(
str
).
getBytes
(
"ISO-8859-1"
));
}
catch
(
Exception
e
)
{
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
//判断必填项是否有值
if
(
tbStHm
==
null
||
StringUtils
.
isEmpty
(
tbStHm
.
getRybh
())
)
{
if
(
tbStHm
==
null
||
StringUtils
.
isEmpty
(
tbStHm
.
getRybh
()))
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"人员编号不能为空!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"人员编号不能为空!"
);
return
map
;
}
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getXm
())
)
{
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getXm
()))
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"姓名不能为空!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"姓名不能为空!"
);
return
map
;
}
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getHmywdm
())
)
{
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getHmywdm
()))
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜眼位代码不能为空!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜眼位代码不能为空!"
);
return
map
;
}
if
(
tbStHm
.
getHmsj
()
==
null
||
tbStHm
.
getHmsj
().
length
==
0
)
{
if
(
tbStHm
.
getHmsj
()
==
null
||
tbStHm
.
getHmsj
().
length
==
0
)
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜数据不能为空!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜数据不能为空!"
);
return
map
;
}
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getHmqsqk
())
)
{
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getHmqsqk
()))
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜缺失情况不能为空!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜缺失情况不能为空!"
);
return
map
;
}
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getLrrPolicemanid
())
)
{
if
(
StringUtils
.
isEmpty
(
tbStHm
.
getLrrPolicemanid
()))
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"采集人警号不能为空!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"采集人警号不能为空!"
);
return
map
;
}
...
...
@@ -80,16 +119,16 @@ public class HmCjController {
String
uuid
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
tbStHm
.
setXxzjbh
(
uuid
);
//录入人相关信息
tbStHm
.
setLrr
(
dicItemService
.
queryNameByCode
(
tbStHm
.
getLrrPolicemanid
(),
"CODE_JY"
));
Boolean
b
=
hmCjService
.
saveHmSjXx
(
tbStHm
);
if
(
b
)
{
tbStHm
.
setLrr
(
dicItemService
.
queryNameByCode
(
tbStHm
.
getLrrPolicemanid
(),
"CODE_JY"
));
Boolean
b
=
hmCjService
.
saveHmSjXx
(
tbStHm
);
if
(
b
)
{
//成功
map
.
put
(
"code"
,
"0"
);
map
.
put
(
"msg"
,
"虹膜数据保存成功!"
);
}
else
{
map
.
put
(
"code"
,
"0"
);
map
.
put
(
"msg"
,
"虹膜数据保存成功!"
);
}
else
{
//失败
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜数据保存失败!"
);
map
.
put
(
"code"
,
"1"
);
map
.
put
(
"msg"
,
"虹膜数据保存失败!"
);
}
return
map
;
...
...
@@ -97,7 +136,7 @@ public class HmCjController {
@RequestMapping
(
"/toHmTest"
)
public
ModelAndView
toTest
(
ModelAndView
model
){
public
ModelAndView
toTest
(
ModelAndView
model
)
{
model
.
setViewName
(
"test/Hmtest"
);
return
model
;
}
...
...
@@ -105,14 +144,72 @@ public class HmCjController {
@RequestMapping
(
"/saveHmTest"
)
@ResponseBody
public
Map
saveTest
(
TbStHm
tbStHm
,
@RequestParam
(
"yp"
)
MultipartFile
yp
){
public
Map
saveTest
(
TbStHm
tbStHm
,
@RequestParam
(
"yp"
)
MultipartFile
yp
)
{
try
{
//虹膜数据
tbStHm
.
setHmsj
(
yp
.
getBytes
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
return
saveHmSjXx
(
tbStHm
);
String
data
=
""
;
try
{
data
=
load
(
tbStHm
,
"http://localhost:9100/saveHmSjXx"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"msg"
,
data
);
return
map
;
}
}
public
String
load
(
TbStHm
tbStHm
,
String
url
)
throws
Exception
{
JSONObject
node
=
new
JSONObject
();
try
{
// hmsj 的类型为byte[]
String
str
=
new
String
(
tbStHm
.
getHmsj
(),
"ISO-8859-1"
);
//编码 参数 处理url特殊参数
str
=
URLEncoder
.
encode
(
str
);
node
.
put
(
"rybh"
,
tbStHm
.
getRybh
());
node
.
put
(
"xm"
,
tbStHm
.
getXm
());
node
.
put
(
"gmsfhm"
,
tbStHm
.
getGmsfhm
());
node
.
put
(
"hmywdm"
,
tbStHm
.
getHmywdm
());
node
.
put
(
"hmsjStr"
,
str
);
node
.
put
(
"hmqsqk"
,
tbStHm
.
getHmqsqk
());
node
.
put
(
"lrrPolicemanid"
,
tbStHm
.
getLrrPolicemanid
());
}
catch
(
JSONException
e1
)
{
e1
.
printStackTrace
();
}
URL
restURL
=
new
URL
(
url
);
/*
* 此处的urlConnection对象实际上是根据URL的请求协议(此处是http)生成的URLConnection类 的子类HttpURLConnection
*/
HttpURLConnection
conn
=
(
HttpURLConnection
)
restURL
.
openConnection
();
//请求方式
conn
.
setRequestMethod
(
"POST"
);
//设置是否从httpUrlConnection读入,默认情况下是true; httpUrlConnection.setDoInput(true);
conn
.
setDoOutput
(
true
);
//allowUserInteraction 如果为 true,则在允许用户交互(例如弹出一个验证对话框)的上下文中对此 URL 进行检查。
conn
.
setAllowUserInteraction
(
false
);
//文件流编码设置
OutputStreamWriter
out
=
new
OutputStreamWriter
(
conn
.
getOutputStream
(),
"UTF-8"
);
out
.
write
(
node
.
toString
());
out
.
flush
();
BufferedReader
bReader
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"UTF-8"
));
String
line
,
resultStr
=
""
;
while
(
null
!=
(
line
=
bReader
.
readLine
()))
{
resultStr
+=
line
;
}
bReader
.
close
();
return
resultStr
;
}
}
\ No newline at end of file
src/main/java/com/founder/controller/SwCjController.java
View file @
13e973b6
package
com
.
founder
.
controller
;
import
com.alibaba.fastjson.JSONException
;
import
com.alibaba.fastjson.JSONObject
;
import
com.founder.model.TbStHm
;
import
com.founder.model.TbStSw
;
import
com.founder.model.User
;
import
com.founder.module.redis.service.IDicItemService
;
import
com.founder.service.ISwCjService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,6 +15,15 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
...
...
@@ -36,8 +47,47 @@ public class SwCjController {
*/
@RequestMapping
(
"/saveSwSjXx"
)
@ResponseBody
private
Map
<
String
,
String
>
saveSwSjXx
(
TbStSw
tbStSw
){
private
Map
<
String
,
String
>
saveSwSjXx
(
TbStSw
tbStSw
,
BufferedReader
br
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
//body部分
String
inputLine
;
String
str
=
""
;
try
{
while
((
inputLine
=
br
.
readLine
())
!=
null
)
{
str
+=
inputLine
;
}
br
.
close
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"IOException: "
+
e
);
}
JSONObject
object
=
JSONObject
.
parseObject
(
str
);
tbStSw
.
setRybh
((
String
)
object
.
get
(
"rybh"
));
tbStSw
.
setXm
((
String
)
object
.
get
(
"xm"
));
tbStSw
.
setGmsfhm
((
String
)
object
.
get
(
"gmsfhm"
));
String
ypsjStr
=
(
String
)
object
.
get
(
"ypsjStr"
);
String
swsjStr
=
(
String
)
object
.
get
(
"swsjStr"
);
tbStSw
.
setZsc
((
String
)
object
.
get
(
"zsc"
));
tbStSw
.
setYxsc
((
String
)
object
.
get
(
"yxsc"
));
tbStSw
.
setXzb
((
String
)
object
.
get
(
"xzb"
));
tbStSw
.
setNlz
((
String
)
object
.
get
(
"nlz"
));
tbStSw
.
setCjcd
((
String
)
object
.
get
(
"cjcd"
));
tbStSw
.
setXxzldf
((
String
)
object
.
get
(
"xxzldf"
));
tbStSw
.
setLyyz
((
String
)
object
.
get
(
"lyyz"
));
tbStSw
.
setLysb
((
String
)
object
.
get
(
"lysb"
));
tbStSw
.
setFyfs
((
String
)
object
.
get
(
"fyfs"
));
tbStSw
.
setXd
((
String
)
object
.
get
(
"xd"
));
tbStSw
.
setHyfy
((
String
)
object
.
get
(
"hyfy"
));
tbStSw
.
setLrrPolicemanid
(
object
.
get
(
"lrrPolicemanid"
).
toString
());
try
{
tbStSw
.
setYpsj
(
URLDecoder
.
decode
(
ypsjStr
).
getBytes
(
"ISO-8859-1"
));
tbStSw
.
setSwsj
(
URLDecoder
.
decode
(
swsjStr
).
getBytes
(
"ISO-8859-1"
));
}
catch
(
Exception
e
)
{
}
//判断必填项是否有值
if
(
tbStSw
==
null
||
StringUtils
.
isEmpty
(
tbStSw
.
getRybh
())
){
//失败
...
...
@@ -125,16 +175,83 @@ public class SwCjController {
@RequestMapping
(
"/saveTest"
)
@ResponseBody
public
Map
saveTest
(
TbStSw
tbStSw
,
@RequestParam
(
"yp"
)
MultipartFile
yp
,
@RequestParam
(
"sw"
)
MultipartFile
sw
){
@RequestParam
(
"sw"
)
MultipartFile
sw
,
HttpServletRequest
request
)
{
try
{
tbStSw
.
setSwsj
(
sw
.
getBytes
());
tbStSw
.
setYpsj
(
yp
.
getBytes
());
}
catch
(
Exception
e
){
}
String
data
=
""
;
try
{
data
=
load
(
tbStSw
,
"http://localhost:9100/saveSwSjXx"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"msg"
,
data
);
return
map
;
}
public
String
load
(
TbStSw
tbStSw
,
String
url
)
throws
Exception
{
JSONObject
node
=
new
JSONObject
();
try
{
// swsj 的类型为byte[]
String
swsj
=
new
String
(
tbStSw
.
getSwsj
(),
"ISO-8859-1"
);
//编码 参数 处理url特殊参数
swsj
=
URLEncoder
.
encode
(
swsj
);
// ypsj 的类型为byte[]
String
ypsj
=
new
String
(
tbStSw
.
getYpsj
(),
"ISO-8859-1"
);
//编码 参数 处理url特殊参数
ypsj
=
URLEncoder
.
encode
(
ypsj
);
node
.
put
(
"rybh"
,
tbStSw
.
getRybh
());
node
.
put
(
"xm"
,
tbStSw
.
getXm
());
node
.
put
(
"gmsfhm"
,
tbStSw
.
getGmsfhm
());
node
.
put
(
"zsc"
,
tbStSw
.
getZsc
());
node
.
put
(
"yxsc"
,
tbStSw
.
getYxsc
());
node
.
put
(
"xzb"
,
tbStSw
.
getXzb
());
node
.
put
(
"nlz"
,
tbStSw
.
getNlz
());
node
.
put
(
"cjcd"
,
tbStSw
.
getCjcd
());
node
.
put
(
"xxzldf"
,
tbStSw
.
getXxzldf
());
node
.
put
(
"lyyz"
,
tbStSw
.
getLyyz
());
node
.
put
(
"lysb"
,
tbStSw
.
getLysb
());
node
.
put
(
"fyfs"
,
tbStSw
.
getFyfs
());
node
.
put
(
"xd"
,
tbStSw
.
getXd
());
node
.
put
(
"hyfy"
,
tbStSw
.
getHyfy
());
node
.
put
(
"ypsjStr"
,
ypsj
);
node
.
put
(
"swsjStr"
,
swsj
);
node
.
put
(
"lrrPolicemanid"
,
tbStSw
.
getLrrPolicemanid
());
}
catch
(
JSONException
e1
)
{
e1
.
printStackTrace
();
}
URL
restURL
=
new
URL
(
url
);
/*
* 此处的urlConnection对象实际上是根据URL的请求协议(此处是http)生成的URLConnection类 的子类HttpURLConnection
*/
HttpURLConnection
conn
=
(
HttpURLConnection
)
restURL
.
openConnection
();
//请求方式
conn
.
setRequestMethod
(
"POST"
);
//设置是否从httpUrlConnection读入,默认情况下是true; httpUrlConnection.setDoInput(true);
conn
.
setDoOutput
(
true
);
//allowUserInteraction 如果为 true,则在允许用户交互(例如弹出一个验证对话框)的上下文中对此 URL 进行检查。
conn
.
setAllowUserInteraction
(
false
);
//文件流编码设置
OutputStreamWriter
out
=
new
OutputStreamWriter
(
conn
.
getOutputStream
(),
"UTF-8"
);
out
.
write
(
node
.
toString
());
out
.
flush
();
BufferedReader
bReader
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"UTF-8"
));
String
line
,
resultStr
=
""
;
while
(
null
!=
(
line
=
bReader
.
readLine
()))
{
resultStr
+=
line
;
}
bReader
.
close
();
return
resultStr
;
return
saveSwSjXx
(
tbStSw
);
}
}
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