Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
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
常超
map-parent
Commits
b0405913
Commit
b0405913
authored
Dec 06, 2022
by
yangyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
关联关系、4G轨迹提交(湖南)
parent
c3cd21b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
5 deletions
+64
-5
common/common_utils/src/main/java/com/founder/commonutils/util/HttpUtil.java
+60
-1
service/publicapi/src/main/java/com/founder/publicapi/controller/SkDataOperation/SkTrailController.java
+4
-4
service/publicapi/src/main/java/com/founder/publicapi/controller/SkInterface/GlgxInterface.java
+0
-0
No files found.
common/common_utils/src/main/java/com/founder/commonutils/util/HttpUtil.java
View file @
b0405913
...
...
@@ -2,9 +2,11 @@ package com.founder.commonutils.util;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
...
...
@@ -27,7 +29,19 @@ import java.util.*;
import
java.util.Map.Entry
;
public
class
HttpUtil
{
private
static
RequestConfig
requestConfig
=
null
;
private
static
String
tokenPath
=
""
;
static
{
// 设置请求和传输超时时间
//setConnectTimeout:设置连接超时时间,单位毫秒。
//setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
//setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒
requestConfig
=
RequestConfig
.
custom
().
setSocketTimeout
(
60000
)
.
setConnectTimeout
(
60000
)
.
setConnectionRequestTimeout
(
60000
)
.
setStaleConnectionCheckEnabled
(
true
)
.
build
();
}
/**
* 获取网安数据
* @param url
...
...
@@ -397,4 +411,49 @@ public class HttpUtil {
public
static
boolean
ckeckEmpty
(
String
string
)
{
return
(
null
==
string
)
||
(
""
.
equals
(
string
));
}
/**
* 请求的参数类型为json
* @param url
* @param json
* @return {username:"",pass:""}
*/
public
static
String
doPostJsonHunan
(
String
url
,
Map
<
String
,
String
>
headers
,
String
json
)
throws
Exception
{
// post请求返回结果
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
String
jsonResult
=
null
;
System
.
out
.
println
(
url
);
HttpPost
httpPost
=
new
HttpPost
(
url
);
// 设置请求和传输超时时间
httpPost
.
setConfig
(
requestConfig
);
if
(
headers
!=
null
)
{
for
(
String
key
:
headers
.
keySet
())
{
httpPost
.
setHeader
(
key
,
headers
.
get
(
key
));
}
}
try
{
//设置参数解决中文乱码
if
(
null
!=
json
){
StringEntity
entity
=
new
StringEntity
(
json
,
"utf-8"
);
entity
.
setContentEncoding
(
"UTF-8"
);
entity
.
setContentType
(
"application/json"
);
httpPost
.
setEntity
(
entity
);
}
//发送请求
CloseableHttpResponse
result
=
httpClient
.
execute
(
httpPost
);
if
(
result
.
getStatusLine
().
getStatusCode
()
==
HttpStatus
.
SC_OK
){
// 读取服务器返回的json数据(然后解析)
jsonResult
=
EntityUtils
.
toString
(
result
.
getEntity
(),
"utf-8"
);
}
else
{
return
null
;
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
throw
new
Exception
();
}
finally
{
httpPost
.
releaseConnection
();
}
return
jsonResult
;
}
}
service/publicapi/src/main/java/com/founder/publicapi/controller/SkDataOperation/SkTrailController.java
View file @
b0405913
...
...
@@ -197,7 +197,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
public
MapRestResult
query
(
@RequestBody
SkTrailParam
sktrailParam
,
HttpServletRequest
request
)
{
List
<
SkTrailVO
>
list
=
new
ArrayList
<>();
// 根据标识号查看是否为演示数据 演示数据直接走数据库
/*
if(SkTextUtilServiceImpl.queryText(sktrailParam.getLikeValue()).size()>0){
if
(
SkTextUtilServiceImpl
.
queryText
(
sktrailParam
.
getLikeValue
()).
size
()>
0
){
//分页
Page
page
=
new
Page
(
sktrailParam
.
getPage
(),
sktrailParam
.
getPageSize
());
QueryWrapper
queryWrapper
=
new
QueryWrapper
();
...
...
@@ -226,7 +226,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
for
(
SkTrail
skTrail
:
records
)
{
list
.
add
(
new
SkTrailVO
(
skTrail
,
findByBh
(
skTrail
.
getObjectvalue
(),
skTrail
.
getObjecttype
())));
}
}
*/
}
// 真实API
if
(
sktrailParam
.
getLikeField
().
equals
(
"wbgj"
)){
list
=
interfaceAPI
.
getWbXx
(
sktrailParam
.
getLikeValue
(),
sktrailParam
.
getKssj
(),
sktrailParam
.
getJssj
(),
request
,
sktrailParam
.
getPage
(),
sktrailParam
.
getPageSize
());
...
...
@@ -519,7 +519,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
public
void
export
(
HttpServletResponse
response
,
@RequestBody
SkTrailParam
sktrailParam
,
HttpServletRequest
request
)
throws
Exception
{
List
<
SkTrailVO
>
list
=
new
ArrayList
<>();
// 根据标识号查看是否为演示数据 演示数据直接走数据库
/*
if(SkTextUtilServiceImpl.queryText(sktrailParam.getLikeValue()).size()>0){
if
(
SkTextUtilServiceImpl
.
queryText
(
sktrailParam
.
getLikeValue
()).
size
()>
0
){
//分页
Page
page
=
new
Page
(
sktrailParam
.
getPage
(),
sktrailParam
.
getPageSize
());
QueryWrapper
queryWrapper
=
new
QueryWrapper
();
...
...
@@ -543,7 +543,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
for
(
SkTrail
skTrail
:
records
)
{
list
.
add
(
new
SkTrailVO
(
skTrail
,
findByBh
(
skTrail
.
getObjectvalue
(),
skTrail
.
getObjecttype
())));
}
}
*/
}
// 真实API
if
(
sktrailParam
.
getLikeField
().
equals
(
"wbgj"
)){
list
=
interfaceAPI
.
getWbXx
(
sktrailParam
.
getLikeValue
(),
sktrailParam
.
getKssj
(),
sktrailParam
.
getJssj
(),
request
,
sktrailParam
.
getPage
(),
sktrailParam
.
getPageSize
());
...
...
service/publicapi/src/main/java/com/founder/publicapi/controller/SkInterface/GlgxInterface.java
View file @
b0405913
This diff is collapsed.
Click to expand it.
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