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
8b653a1d
Commit
8b653a1d
authored
Dec 05, 2022
by
panaichi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询科通接口对外提供
parent
98afdbc6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
360 additions
and
2 deletions
+360
-2
pom.xml
+40
-0
src/main/java/com/founder/controller/XxcxController.java
+0
-0
src/main/java/com/founder/model/Params.java
+85
-0
src/main/java/com/founder/service/XxcxService.java
+19
-0
src/main/java/com/founder/service/impl/XxcxServiceImpl.java
+112
-2
src/main/java/com/founder/util/KtInterfaceUtils.java
+103
-0
src/main/resources/application-dev.yml
+1
-0
No files found.
pom.xml
View file @
8b653a1d
...
...
@@ -115,7 +115,47 @@
<artifactId>
dom4j
</artifactId>
<version>
1.6.1
</version>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-rs-client
</artifactId>
<version>
3.1.11
</version>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-frontend-jaxrs
</artifactId>
<version>
3.1.11
</version>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-rs-extension-providers
</artifactId>
<version>
3.1.11
</version>
</dependency>
<!--zhangsh add by 2021-01-11 benin 全国请求服务专用jar-->
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-rs-client
</artifactId>
<version>
3.1.11
</version>
</dependency>
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-transports-http
</artifactId>
<version>
3.1.11
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxrs -->
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-frontend-jaxrs
</artifactId>
<version>
3.1.11
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-rs-extension-providers -->
<dependency>
<groupId>
org.apache.cxf
</groupId>
<artifactId>
cxf-rt-rs-extension-providers
</artifactId>
<version>
3.1.11
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/founder/controller/XxcxController.java
View file @
8b653a1d
This diff is collapsed.
Click to expand it.
src/main/java/com/founder/model/Params.java
0 → 100644
View file @
8b653a1d
package
com
.
founder
.
model
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @autohor liuyx
* @date 2021年07月07日17:04
*/
public
class
Params
implements
Serializable
{
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
startDate
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
endDate
;
private
String
sfzh
;
private
String
ccrSfzh
;
//乘车人身份证号
private
String
dprSfzh
;
//订票人身份证号
private
String
cph
;
//车牌号
private
String
kkbh
;
//卡口编号
public
Date
getStartDate
()
{
return
startDate
;
}
public
void
setStartDate
(
Date
startDate
)
{
this
.
startDate
=
startDate
;
}
public
Date
getEndDate
()
{
return
endDate
;
}
public
void
setEndDate
(
Date
endDate
)
{
this
.
endDate
=
endDate
;
}
public
String
getSfzh
()
{
return
sfzh
;
}
public
void
setSfzh
(
String
sfzh
)
{
this
.
sfzh
=
sfzh
;
}
public
String
getCcrSfzh
()
{
return
ccrSfzh
;
}
public
void
setCcrSfzh
(
String
ccrSfzh
)
{
this
.
ccrSfzh
=
ccrSfzh
;
}
public
String
getDprSfzh
()
{
return
dprSfzh
;
}
public
void
setDprSfzh
(
String
dprSfzh
)
{
this
.
dprSfzh
=
dprSfzh
;
}
public
String
getCph
()
{
return
cph
;
}
public
void
setCph
(
String
cph
)
{
this
.
cph
=
cph
;
}
public
String
getKkbh
()
{
return
kkbh
;
}
public
void
setKkbh
(
String
kkbh
)
{
this
.
kkbh
=
kkbh
;
}
}
src/main/java/com/founder/service/XxcxService.java
View file @
8b653a1d
...
...
@@ -3,6 +3,7 @@ package com.founder.service;
import
com.founder.model.*
;
import
java.util.List
;
import
java.util.Map
;
public
interface
XxcxService
{
...
...
@@ -18,4 +19,22 @@ public interface XxcxService {
List
<
TbZhzxJjxxView
>
queryJjxx
(
TbZhzxJjxxView
param
);
List
<
TbZhzxCjxxView
>
queryCjxx
(
TbZhzxCjxxView
param
);
//航班出行信息查询
String
getHbcxxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
;
//航班订票信息查询
String
getHbdpxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
;
//火车订票信息查询
String
getHcdpxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
;
//港口出行信息查询
String
getGkxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
;
//客运出行信息查询
String
getKyxxBySfzh
(
String
ccrSfzh
,
String
dprSfzh
,
String
dateStr
)
throws
Exception
;
//车辆经过卡口过车信息查询
String
getGcxx
(
String
cph
,
String
dateStr
)
throws
Exception
;
//车辆经卡口最后过车信息查询
String
getZhgcxx
(
String
cph
)
throws
Exception
;
//卡口编号过车信息查询
String
getKkxx
(
String
kkbh
,
String
dateStr
)
throws
Exception
;
}
src/main/java/com/founder/service/impl/XxcxServiceImpl.java
View file @
8b653a1d
package
com
.
founder
.
service
.
impl
;
import
com.alibaba.fastjson.JSONException
;
import
com.alibaba.fastjson.JSONObject
;
import
com.founder.dao.XxcxDao
;
import
com.founder.model.*
;
import
com.founder.service.XxcxService
;
import
com.founder.util.KtInterfaceUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.*
;
@Service
public
class
XxcxServiceImpl
implements
XxcxService
{
...
...
@@ -202,4 +204,112 @@ public class XxcxServiceImpl implements XxcxService {
}
return
result
;
}
@Override
public
String
getHbcxxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"expr"
,
"FORM_ZJHM='"
+
sfzh
+
"'"
);
param
.
put
(
"btw"
,
dateStr
);
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
HBCX
,
param
.
toString
());
return
resultJson
;
}
@Override
public
String
getHbdpxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"expr"
,
"FORM_ZJHM='"
+
sfzh
+
"'"
);
param
.
put
(
"btw"
,
dateStr
);
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
HBDP
,
param
.
toString
());
return
resultJson
;
}
@Override
public
String
getHcdpxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"expr"
,
"FORM_ID_NO='"
+
sfzh
+
"'"
);
param
.
put
(
"btw"
,
dateStr
);
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
HCDP
,
param
.
toString
());
return
resultJson
;
}
@Override
public
String
getGkxxBySfzh
(
String
sfzh
,
String
dateStr
)
throws
Exception
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"expr"
,
"FORM_ZJHM='"
+
sfzh
+
"'"
);
param
.
put
(
"btw"
,
dateStr
);
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
GKCX
,
param
.
toString
());
return
resultJson
;
}
@Override
public
String
getKyxxBySfzh
(
String
ccrSfzh
,
String
dprSfzh
,
String
dateStr
)
throws
Exception
{
JSONObject
param
=
new
JSONObject
();
int
flag
=
0
;
if
(!
StringUtils
.
isEmpty
(
ccrSfzh
))
{
param
.
put
(
"expr"
,
"FORM_ZJHM='"
+
ccrSfzh
+
"'"
);
flag
++;
}
if
(!
StringUtils
.
isEmpty
(
dprSfzh
))
{
param
.
put
(
"expr"
,
"FORM_O_ZJHM='"
+
ccrSfzh
+
"'"
);
flag
++;
}
if
(
flag
==
0
)
{
throw
new
Exception
(
"请输入订票人或乘车人身份证号"
);
}
else
if
(
flag
==
2
)
{
throw
new
Exception
(
"订票人和乘车人身份证号不能同时存在"
);
}
param
.
put
(
"btw"
,
dateStr
);
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
KYCX
,
param
.
toString
());
return
resultJson
;
}
/**
* 车辆经过卡口过车信息
* 车牌号码+时间段(THROUGH_TIME+2小时)
* PLATE_NUMBER='琼B56556'
FORM_THROUGH_TIME
*/
@Override
public
String
getGcxx
(
String
cph
,
String
dateStr
)
throws
Exception
{
JSONObject
ret
=
new
JSONObject
();
try
{
ret
.
put
(
"expr"
,
"PLATE_NUMBER="
+
cph
);
ret
.
put
(
"btw"
,
dateStr
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
CLJGKKXX
,
ret
.
toString
());
return
resultJson
;
}
@Override
public
String
getZhgcxx
(
String
cph
)
throws
Exception
{
JSONObject
ret
=
new
JSONObject
();
try
{
ret
.
put
(
"expr"
,
"PLATE_NUMBER="
+
cph
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
CLJGKKZHGCXX
,
ret
.
toString
());
return
resultJson
;
}
/**
* 卡口过车信息
* 卡口编号(POINT_ID)+时间段(THROUGH_TIME+2小时)
* POINT_ID='469007140000515759'
*/
@Override
public
String
getKkxx
(
String
kkbh
,
String
dateStr
)
throws
Exception
{
JSONObject
ret
=
new
JSONObject
();
try
{
ret
.
put
(
"expr"
,
"POINT_ID="
+
kkbh
);
ret
.
put
(
"btw"
,
dateStr
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
String
resultJson
=
KtInterfaceUtils
.
getDateByJsonParam
(
KtInterfaceUtils
.
KKXX
,
ret
.
toString
());
return
resultJson
;
}
}
src/main/java/com/founder/util/KtInterfaceUtils.java
0 → 100644
View file @
8b653a1d
package
com
.
founder
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Service
;
import
org.apache.cxf.jaxrs.client.WebClient
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 科信接口查询工具类
*/
@Slf4j
@Service
public
class
KtInterfaceUtils
{
public
static
final
String
HBCX
=
"00454"
;
//航班出行查询
public
static
final
String
HBDP
=
"00455"
;
//航班订票查询
public
static
final
String
HCDP
=
"00456"
;
//火车订票查询
public
static
final
String
GKCX
=
"00457"
;
//港口出行查询
public
static
final
String
KYCX
=
"00458"
;
//客运出行查询
public
static
final
String
CLJGKKXX
=
"00463"
;
//车辆经过卡口过车信息查询
public
static
final
String
CLJGKKZHGCXX
=
"00464"
;
//车辆经卡口最后过车信息查询
public
static
final
String
KKXX
=
"00465"
;
//卡口编号过车信息查询
private
static
String
ktUrl
;
@Value
(
"${ktUrl}"
)
private
void
setKtUrl
(
String
ktUrl
)
{
KtInterfaceUtils
.
ktUrl
=
ktUrl
;
}
public
static
String
getDateByJsonParam
(
String
pathNum
,
String
param
)
{
try
{
System
.
out
.
println
(
param
);
WebClient
client
=
WebClient
.
create
(
ktUrl
);
//请求地址
client
.
header
(
"apikey"
,
"AZNB46000000000000032"
);
//刑总三期APIKEY
client
.
accept
(
String
.
valueOf
(
MediaType
.
APPLICATION_JSON
)).
path
(
"S-460000000000-ZNB-22-"
+
pathNum
).
query
(
"param"
,
param
);
String
rets
=
client
.
get
(
String
.
class
);
System
.
out
.
println
(
rets
);
client
.
close
();
return
rets
;
}
catch
(
Exception
e
)
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"result"
,
"fail"
);
json
.
put
(
"errorcode"
,
"201"
);
json
.
put
(
"errordescription"
,
e
.
getMessage
());
return
json
.
toString
();
}
}
public
static
List
<
Map
<
String
,
String
>>
getMapByJson
(
String
json
)
throws
Exception
{
List
<
Map
<
String
,
String
>>
resultList
=
new
ArrayList
<>();
JSONObject
jsonObject
=
JSON
.
parseObject
(
json
);
Object
result
=
jsonObject
.
get
(
"result"
);
if
(
"fail"
.
equals
(
result
.
toString
()))
{
throw
new
Exception
(
jsonObject
.
get
(
"errordescription"
).
toString
());
}
JSONArray
datas
=
jsonObject
.
getJSONArray
(
"datas"
);
JSONArray
fields
=
jsonObject
.
getJSONArray
(
"fields"
);
if
(
datas
==
null
||
datas
.
size
()
==
0
)
{
return
null
;
}
for
(
int
i
=
0
;
i
<
datas
.
size
();
i
++)
{
JSONArray
data
=
datas
.
getJSONArray
(
i
);
HashMap
<
String
,
String
>
resultMap
=
new
HashMap
<>();
for
(
int
j
=
0
;
j
<
fields
.
size
();
j
++)
{
resultMap
.
put
(
fields
.
get
(
j
).
toString
(),
data
.
get
(
j
).
toString
());
}
resultList
.
add
(
resultMap
);
}
return
resultList
;
}
public
static
List
<
Map
<
String
,
String
>>
getMapByJson2
(
String
json
)
throws
Exception
{
List
<
Map
<
String
,
String
>>
resultList
=
new
ArrayList
<>();
JSONObject
jsonObject
=
JSON
.
parseObject
(
json
);
Object
result
=
jsonObject
.
get
(
"result"
);
if
(
"fail"
.
equals
(
result
.
toString
()))
{
throw
new
Exception
(
jsonObject
.
get
(
"errordescription"
).
toString
());
}
JSONArray
datas
=
jsonObject
.
getJSONArray
(
"datas"
);
JSONArray
fields
=
jsonObject
.
getJSONArray
(
"fields"
);
if
(
datas
==
null
||
datas
.
size
()
==
0
)
{
return
null
;
}
HashMap
<
String
,
String
>
resultMap
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
resultMap
.
put
(
fields
.
get
(
i
).
toString
(),
datas
.
get
(
i
).
toString
());
}
resultList
.
add
(
resultMap
);
return
resultList
;
}
}
src/main/resources/application-dev.yml
View file @
8b653a1d
...
...
@@ -73,3 +73,4 @@ codemsg:
-
code
:
"
010104"
name
:
"
用户身份证信息有误"
ktUrl
:
http://74.6.57.208:30030/
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