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
cc882cbc
Commit
cc882cbc
authored
Jun 30, 2020
by
焦荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
6cf518dd
01592490
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
164 additions
and
0 deletions
+164
-0
src/main/java/com/founder/controller/ZjCjController.java
+164
-0
No files found.
src/main/java/com/founder/controller/ZjCjController.java
View file @
cc882cbc
...
@@ -8,6 +8,7 @@ import com.founder.service.AutoTbXwRycjService;
...
@@ -8,6 +8,7 @@ import com.founder.service.AutoTbXwRycjService;
import
com.founder.service.IHmCjService
;
import
com.founder.service.IHmCjService
;
import
com.founder.service.IParamService
;
import
com.founder.service.IParamService
;
import
com.founder.service.ITbRyRyzpService
;
import
com.founder.service.ITbRyRyzpService
;
import
com.founder.utils.DateUtil
;
import
com.founder.utils.FileUtils
;
import
com.founder.utils.FileUtils
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
import
org.codehaus.xfire.client.Client
;
import
org.codehaus.xfire.client.Client
;
...
@@ -884,4 +885,166 @@ public class ZjCjController {
...
@@ -884,4 +885,166 @@ public class ZjCjController {
}
}
return
flg
;
return
flg
;
}
}
@RequestMapping
(
"/doRyxxToZj"
)
@ResponseBody
public
String
doRyxxToZj
(
String
rybh
,
String
zjimg_z
,
String
zjimg_y
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
User
user
=
(
User
)
request
.
getSession
().
getAttribute
(
"User"
);
String
rststr
=
""
;
AutoTbStRy
ryxx
=
rycjService
.
getRyxxByRybh
(
rybh
);
String
xmlstr
=
getRyxxToZjXml
(
ryxx
,
user
,
zjimg_z
,
zjimg_y
);
Param
param
=
paramService
.
getParamById
(
"0018"
);
String
tempvalue
=
param
.
getParamvalue
();
if
(
tempvalue
!=
null
&&!
""
.
equals
(
tempvalue
)){
String
temp_arr
[]
=
tempvalue
.
split
(
"#"
);
String
key
=
temp_arr
[
0
];
//验证码
String
servlUrl
=
temp_arr
[
1
];
if
(
servlUrl
!=
null
&&!
""
.
equals
(
servlUrl
)){
String
str
=
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
;
String
xml
=
str
+
xmlstr
;
rststr
=
putConnectionRyxx
(
servlUrl
,
xml
);
}
}
return
rststr
;
}
//拼接人员信息的XML文件
private
String
getRyxxToZjXml
(
AutoTbStRy
newryxx
,
User
user
,
String
zjimg_z
,
String
zjimg_y
)
{
String
unit_name
=
""
;
String
xb_name
=
""
;
String
hjd_name
=
""
;
String
ajlb_name
=
""
;
try
{
if
(
user
.
getUnitcode
()!=
null
){
if
(
dicItemService
.
queryNameByCode
(
user
.
getUnitcode
(),
"CODE_UNIT"
)!=
null
){
unit_name
=
dicItemService
.
queryNameByCode
(
user
.
getUnitcode
(),
"CODE_UNIT"
);
}
}
if
(
newryxx
.
getXbdm
()!=
null
){
if
(
dicItemService
.
queryNameByCode
(
newryxx
.
getXbdm
(),
"CODE_XB"
)!=
null
){
xb_name
=
dicItemService
.
queryNameByCode
(
newryxx
.
getXbdm
(),
"CODE_XB"
);
}
}
if
(
newryxx
.
getHjdzXzqhdm
()!=
null
){
if
(
dicItemService
.
queryNameByCode
(
newryxx
.
getHjdzXzqhdm
(),
"CODE_XZQH"
)!=
null
){
hjd_name
=
dicItemService
.
queryNameByCode
(
newryxx
.
getHjdzXzqhdm
(),
"CODE_XZQH"
);
}
}
if
(
newryxx
.
getAjlbdm
()!=
null
){
if
(
dicItemService
.
queryNameByCode
(
newryxx
.
getAjlbdm
(),
"CODE_AJLB"
)!=
null
){
ajlb_name
=
dicItemService
.
queryNameByCode
(
newryxx
.
getAjlbdm
(),
"CODE_AJLB"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
String
user_xm
=
user
.
getTrueName
();
String
samplingDate
=
DateUtil
.
getDateTime
(
newryxx
.
getLrsj
());
String
csrqDate
=
DateUtil
.
getDateTime
(
newryxx
.
getCsrqQsrq
());
if
(
csrqDate
!=
null
&&
csrqDate
.
length
()>=
10
){
csrqDate
=
csrqDate
.
substring
(
0
,
10
);
}
if
(
samplingDate
!=
null
&&
samplingDate
.
length
()>=
10
){
samplingDate
=
samplingDate
.
substring
(
0
,
10
);
}
StringBuffer
xml
=
new
StringBuffer
();
//xml.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
xml
.
append
(
"<suspect>"
).
append
(
"<suspectInfo>"
)
.
append
(
"<suspectID>"
).
append
(
newryxx
.
getRybh
()).
append
(
"</suspectID>"
)
//嫌疑人编号
.
append
(
"<bnyrxm>"
).
append
(
newryxx
.
getXm
()).
append
(
"</bnyrxm>"
)
//嫌疑人姓名
.
append
(
"<genderCode>"
).
append
(
newryxx
.
getXbdm
()).
append
(
"</genderCode>"
)
//性别代码
.
append
(
"<genderName>"
).
append
(
xb_name
).
append
(
"</genderName>"
)
//性别名称
.
append
(
"<birthday>"
).
append
(
csrqDate
).
append
(
"</birthday>"
)
//出生日期
.
append
(
"<certificateCardNo>"
).
append
(
newryxx
.
getZjhm
()).
append
(
"</certificateCardNo>"
)
//身份证号码
.
append
(
"<hjd>"
).
append
(
hjd_name
).
append
(
"</hjd>"
)
//户籍地名称
.
append
(
"<hjddm>"
).
append
(
newryxx
.
getHjdzXzqhdm
()).
append
(
"</hjddm>"
)
//户籍地代码
.
append
(
"<xzz>"
).
append
(
newryxx
.
getXzzDzmc
()).
append
(
"</xzz>"
)
//现住地详细地址
.
append
(
"<description>"
).
append
(
newryxx
.
getJyaq
()).
append
(
"</description>"
)
//备注
.
append
(
"<nydwdm>"
).
append
(
user
.
getUnitcode
()).
append
(
"</nydwdm>"
)
//采集单位代码
.
append
(
"<nydwmc>"
).
append
(
unit_name
).
append
(
"</nydwmc>"
)
//采集单位名称
.
append
(
"<nyrxm>"
).
append
(
user_xm
).
append
(
"</nyrxm>"
)
//采集人姓名
.
append
(
"<nyrq>"
).
append
(
samplingDate
).
append
(
"</nyrq>"
)
//采集日期
.
append
(
"<suspectHeight>"
).
append
(
Math
.
round
(
new
Double
(
newryxx
.
getSgsx
())*
10
)).
append
(
"</suspectHeight>"
)
//<!—单位:毫米-->嫌疑人身高
.
append
(
"<caseTypeList>"
).
append
(
"<caseType>"
)
.
append
(
"<caseTypeCode>"
).
append
(
newryxx
.
getAjlbdm
()).
append
(
"</caseTypeCode>"
)
//案件类别代码
.
append
(
"<caseTypeName>"
).
append
(
ajlb_name
).
append
(
"</caseTypeName>"
)
//案件类别名称
.
append
(
"</caseType>"
).
append
(
"</caseTypeList>"
)
.
append
(
"<suspectFootList>"
);
if
(
zjimg_z
!=
null
&&!
""
.
equals
(
zjimg_z
)){
xml
.
append
(
"<suspectFoot>"
)
.
append
(
"<footID>"
).
append
(
newryxx
.
getRybh
()+
"01"
).
append
(
"</footID>"
)
//嫌疑人样本id
.
append
(
"<footType>"
).
append
(
"0"
).
append
(
"</footType>"
)
//<!--0:左脚,1:右脚-->
.
append
(
"<footImgBase64>"
).
append
(
zjimg_z
).
append
(
"</footImgBase64>"
)
//嫌疑人样本
.
append
(
"</suspectFoot>"
);
}
if
(
zjimg_y
!=
null
&&!
""
.
equals
(
zjimg_y
)){
xml
.
append
(
"<suspectFoot>"
)
.
append
(
"<footID>"
).
append
(
newryxx
.
getRybh
()+
"02"
).
append
(
"</footID>"
)
//嫌疑人样本id
.
append
(
"<footType>"
).
append
(
"1"
).
append
(
"</footType>"
)
//<!--0:左脚,1:右脚-->
.
append
(
"<footImgBase64>"
).
append
(
zjimg_y
).
append
(
"</footImgBase64>"
)
//嫌疑人样本
.
append
(
"</suspectFoot>"
);
}
xml
.
append
(
"</suspectFootList>"
)
.
append
(
"</suspectInfo>"
).
append
(
"</suspect>"
);
return
xml
.
toString
();
}
//往足迹系统推送数据
public
String
putConnectionRyxx
(
String
urlstr
,
String
xml
)
{
System
.
out
.
println
(
"===足迹系统数据推送地址===:"
+
urlstr
);
//System.out.println("====向足迹系统传递的XML文件内容====:"+xml.toString());
try
{
URL
url
=
new
URL
(
urlstr
);
// 将url 以 open方法返回的urlConnection 连接强转为HttpURLConnection连接 (标识一个url所引用的远程对象连接)
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
// 此时cnnection只是为一个连接对象,待连接中
// 设置连接输出流为true,默认false (post 请求是以流的方式隐式的传递参数)
connection
.
setDoOutput
(
true
);
// 设置连接输入流为true
connection
.
setDoInput
(
true
);
// 设置请求方式为post
connection
.
setRequestMethod
(
"POST"
);
// post请求缓存设为false
connection
.
setUseCaches
(
false
);
// 设置该HttpURLConnection实例是否自动执行重定向
connection
.
setInstanceFollowRedirects
(
true
);
// 设置请求头里面的各个属性 (以下为设置内容的类型,设置为经过urlEncoded编码过的from参数)
// application/x-javascript text/xml->xml数据 application/x-javascript->json对象 application/x-www-form-urlencoded->表单数据
//connection.setRequestProperty("Content-Type", "application/x-javascript");
connection
.
setRequestProperty
(
"Content-Type"
,
"text/xml"
);
// json,也可以设定xml格式的
connection
.
setRequestProperty
(
"Charset"
,
"utf-8"
);
// 建立连接 (请求未开始,直到connection.getInputStream()方法调用时才发起,以上各个参数设置需在此方法之前进行)
connection
.
connect
();
OutputStream
outStrm
=
connection
.
getOutputStream
();
//File f=new File("c:/test.xml");
//OutputStream os = new FileOutputStream(f);
OutputStreamWriter
objOutputStrm
=
new
OutputStreamWriter
(
outStrm
,
"UTF-8"
);
// 现在通过输出流对象构建对象输出流对象,以实现输出可序列化的对象。
//ObjectOutputStream objOutputStrm = new ObjectOutputStream(os);
// 向对象输出流写出数据,这些数据将存到内存缓冲区中
objOutputStrm
.
write
(
xml
.
trim
());
// 刷新对象输出流,将任何字节都写入潜在的流中(些处为ObjectOutputStream)
objOutputStrm
.
flush
();
//testt();
//objOutputStrm.flush();
// 关闭流对象。此时,不能再向对象输出流写入任何数据,先前写入的数据存在于内存缓//冲区中, 在调用下边的getInputStream()函数时才把准备好的http请求正式发送到服务器
objOutputStrm
.
close
();
// 将内存缓冲区中封装好的完整的HTTP请求电文发送到服务端。
InputStream
inStrm
=
connection
.
getInputStream
();
// <==注意,实际发送请求的代码段就在这里
//超时设置,防止网络异常的情况下,可能会导致程序僵死而不继续往下执行
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"30000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"30000"
);
connection
.
disconnect
();
// 销毁连接
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
"0"
;
}
return
"1"
;
}
}
}
\ No newline at end of file
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