Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-api-report
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
雷紫添
xzxt-api-report
Commits
22617e9a
Commit
22617e9a
authored
May 24, 2022
by
liulianglang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
火车,民航接口
parent
8566db70
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
188 additions
and
5 deletions
+188
-5
pom.xml
+5
-0
src/main/java/com/founder/controller/GjController.java
+0
-0
src/main/java/com/founder/model/XyrParam.java
+22
-5
src/main/java/com/founder/service/GjService.java
+31
-0
src/main/java/com/founder/service/impl/GjServiceImpl.java
+0
-0
src/main/java/com/founder/util/EasyUIPage.java
+128
-0
src/main/java/com/founder/util/EsUtils.java
+2
-0
No files found.
pom.xml
View file @
22617e9a
...
...
@@ -122,6 +122,11 @@
<version>
1.2.35
</version>
</dependency>
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
<version>
3.1
</version>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
1.3.2
</version>
...
...
src/main/java/com/founder/controller/GjController.java
0 → 100644
View file @
22617e9a
This diff is collapsed.
Click to expand it.
src/main/java/com/founder/model/XyrParam.java
View file @
22617e9a
...
...
@@ -5,11 +5,14 @@ package com.founder.model;
import
lombok.Data
;
@Data
public
class
XyrParam
{
private
String
xm
;
/**
* 证件号码
*/
private
String
zjhm
;
private
String
xbdm
;
...
...
@@ -17,7 +20,14 @@ public class XyrParam {
private
String
zhrqKssj
;
private
String
zhrqJssj
;
/**
* 开始时间
*/
private
String
kssj
;
/**
* 结束时间
*/
private
String
jssj
;
private
String
zhdwdm
;
private
String
xzzmc
;
...
...
@@ -33,8 +43,15 @@ public class XyrParam {
private
String
hjdqhdm
;
private
String
hjdmc
;
private
int
page
;
private
int
limit
;
/**
*车牌号码
*/
private
String
cphm
;
/**
* 手机号码
*/
private
String
sjhm
;
private
int
page
=
1
;
private
int
limit
=
10
;
}
src/main/java/com/founder/service/GjService.java
0 → 100644
View file @
22617e9a
package
com
.
founder
.
service
;
import
com.founder.model.XyrParam
;
import
com.founder.model.ZtryParam
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Map
;
public
interface
GjService
{
Map
<
String
,
Object
>
getWbxx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getCzxx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getMhXx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getHcxx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getLgxx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getThr
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getPoxx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getClxxByZjhm
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getDzwz
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getJjwfjl
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
Map
<
String
,
Object
>
getXnSfxx
(
HttpServletRequest
request
,
XyrParam
xyrParam
)
throws
Exception
;
}
src/main/java/com/founder/service/impl/GjServiceImpl.java
0 → 100644
View file @
22617e9a
This diff is collapsed.
Click to expand it.
src/main/java/com/founder/util/EasyUIPage.java
0 → 100644
View file @
22617e9a
package
com
.
founder
.
util
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
EasyUIPage
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
EasyUIPage
()
{
}
private
int
page
=
1
;
private
int
begin
;
private
int
end
;
private
int
total
=
0
;
private
String
sort
;
private
String
order
;
private
int
rownum
=
20
;
private
List
<?>
rows
=
new
ArrayList
();
private
String
flag
;
private
String
pagePara
;
public
String
getFlag
()
{
return
flag
;
}
public
void
setFlag
(
String
flag
)
{
this
.
flag
=
flag
;
}
public
int
getTotal
()
{
return
total
;
}
public
void
setTotal
(
int
total
)
{
this
.
total
=
total
;
}
public
void
setRows
(
List
<?>
rows
)
{
this
.
rows
=
rows
;
}
public
int
getPage
()
{
return
page
;
}
public
void
setPage
(
int
page
)
{
this
.
page
=
page
;
}
public
int
getBegin
()
{
return
begin
;
}
public
int
getEnd
()
{
return
end
;
}
public
List
<?>
getRows
()
{
return
rows
;
}
public
String
getSort
()
{
return
sort
;
}
public
void
setSort
(
String
sort
)
{
this
.
sort
=
sort
;
}
public
String
getOrder
()
{
return
order
;
}
public
void
setOrder
(
String
order
)
{
this
.
order
=
order
;
}
public
void
setPagePara
(
Integer
rows
)
{
if
(
rows
!=
null
)
{
this
.
begin
=
(
this
.
page
-
1
)
*
rows
;
this
.
end
=
rows
;
}
else
{
this
.
begin
=
(
this
.
page
-
1
)
*
rownum
;
this
.
end
=
rownum
;
}
}
public
void
setPageParaOracle
(
Integer
rows
)
{
if
(
rows
!=
null
)
{
this
.
begin
=
(
this
.
page
-
1
)
*
rows
;
this
.
end
=
this
.
page
*
rows
;
}
else
{
this
.
begin
=
(
this
.
page
-
1
)
*
rownum
;
this
.
end
=
this
.
page
*
rownum
;
}
}
public
int
getRownum
()
{
return
rownum
;
}
public
void
setRownum
(
int
rownum
)
{
this
.
rownum
=
rownum
;
}
/**
* @return the pagePara
*/
public
String
getPagePara
()
{
return
pagePara
;
}
/**
* @param pagePara the pagePara to set
*/
public
void
setPagePara
(
String
pagePara
)
{
this
.
pagePara
=
pagePara
;
}
}
src/main/java/com/founder/util/EsUtils.java
0 → 100644
View file @
22617e9a
package
com
.
founder
.
util
;
import
java.util.*
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.client.params.CookiePolicy
;
import
javax.servlet.http.HttpServletRequest
;
import
java.net.URLEncoder
;
/** * @auther wangyang * @date 2019/12/24 2:40 PM */
public
class
EsUtils
{
//es登陆URI private static final String ES_LOGIN_URI = "http://10.142.77.46:8001/login2?username=xz&password=123456"; //es查询URI private static final String ES_QUERY_URI = "http://10.142.77.46:8001/sql"; /** * 新版查询ES * @param request * @param sql * @return */ public static Map<String,Object> newQueryEs(HttpServletRequest request,String sql){ String cookie = (String) request.getSession().getAttribute("EsCookie"); if(StringUtils.isBlank(cookie)){ //进行Es登录 cookie = newLoginEs(); request.getSession().setAttribute("EsCookie",cookie); } Map<String, Object> result = query(sql, cookie); return result; } /** * 将查询参数转义 * * @param json * @return */ public static String getTaskCreateJsonReq(String json) { String req = ""; try { String encode = URLEncoder.encode(json, "UTF-8"); req = "?sql=" + encode; } catch (Exception e) { req = "?sql="; } return req.replaceAll("\\+", "%20"); } /** * 登录ES并返回cookie * @return */ public static String newLoginEs() { String result = ""; HttpClient httpClient = new HttpClient(); // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式 GetMethod postMethod = new GetMethod(ES_LOGIN_URI); try { // 设置 HttpClient 接收 Cookie,用与浏览器一样的策略 postMethod.addRequestHeader( "Connection", "close"); httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); httpClient.executeMethod(postMethod); // 获得登陆后的 Cookie org.apache.commons.httpclient.Cookie[] cookies = httpClient.getState().getCookies(); StringBuffer tmpcookies = new StringBuffer(); for (org.apache.commons.httpclient.Cookie c : cookies) { tmpcookies.append(c.toString() + ";"); } result = postMethod.getResponseBodyAsString(); System.out.println("模拟登录成功"); result = tmpcookies.toString(); } catch (Exception e) { e.printStackTrace(); }finally { postMethod.releaseConnection();//释放资源 //释放HttpClient 资源防止报 java.net.socketexception:connection reset 错误 } return result; } /** * 根据cookie查询ES * @param sql * @param tmpcookies * @return */ public static Map<String,Object> query(String sql,String tmpcookies){ String queryParam = getTaskCreateJsonReq(sql); String queryUrl = ES_QUERY_URI+queryParam; String result = ""; HttpClient httpClient = new HttpClient(); GetMethod getMethod = null; try{ getMethod = new GetMethod(queryUrl); // 设置关闭 getMethod.addRequestHeader( "Connection", "close"); // 每次访问需授权的网址时需带上前面的 cookie 作为通行证 getMethod.setRequestHeader("cookie", tmpcookies); // 你还可以通过 PostMethod/GetMethod 设置更多的请求后数据 // 例如,referer 从哪里来的,UA 像搜索引擎都会表名自己是谁,无良搜索引擎除外 httpClient.executeMethod(getMethod); //获取返回数据 result = getMethod.getResponseBodyAsString(); System.out.println("result---"+result); }catch (Exception e){ System.out.println("查询失败:"+e); System.out.println("查询SQL:"+sql); }finally{ getMethod.releaseConnection();//释放资源 //释放HttpClient 资源防止报 java.net.socketexception:connection reset 错误 httpClient.getHttpConnectionManager().closeIdleConnections(0); } Map<String,Object> map = (Map<String,Object>)JSONObject.parse(result); return map; } }
\ 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