Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
76cf6c7b
Commit
76cf6c7b
authored
Jun 26, 2019
by
hanfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改违章2
parent
8c3fa797
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
123 deletions
+103
-123
TrafficViolationsController.java
...orm/universal/controller/TrafficViolationsController.java
+30
-23
TrafficViolationsService.java
.../platform/universal/service/TrafficViolationsService.java
+63
-89
application.properties
...niversal-server/src/main/resources/application.properties
+10
-11
No files found.
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/TrafficViolationsController.java
View file @
76cf6c7b
package
com
.
xxfc
.
platform
.
universal
.
controller
;
import
com.
xxfc.platform.universal.model.JuheResult
;
import
com.
github.wxiaoqi.security.common.msg.ObjectRestResponse
;
import
com.xxfc.platform.universal.service.TrafficViolationsService
;
import
com.xxfc.platform.universal.vo.TrafficViolations
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"3p/tv"
)
...
...
@@ -21,35 +19,44 @@ public class TrafficViolationsController {
* @return
*/
@GetMapping
(
"/city/{province}"
)
public
JuheResult
getCityInfo
(
@PathVariable
String
province
)
{
return
tvService
.
getCity
(
province
);
public
ObjectRestResponse
getCityInfo
(
@PathVariable
String
province
)
{
try
{
return
ObjectRestResponse
.
succ
(
tvService
.
getCity
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createDefaultFail
();
}
}
/**
* 违章车辆查询
* @param city
* @param hphm
* @param hpzl
* @param engineno
* @param classno
* @return
*/
@GetMapping
(
"trafficViolations"
)
public
JuheResult
queryTrafficViolations
(
String
city
,
String
hphm
,
String
hpzl
,
String
engineno
,
String
classno
)
{
return
tvService
.
queryViolations
(
city
,
hphm
,
hpzl
,
engineno
,
classno
);
@PostMapping
(
"/trafficViolations"
)
public
ObjectRestResponse
queryTrafficViolations
(
@RequestBody
TrafficViolations
trafficViolations
)
{
try
{
return
ObjectRestResponse
.
succ
(
tvService
.
queryViolations
(
trafficViolations
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createDefaultFail
();
}
}
@GetMapping
(
"balance"
)
public
JuheResult
getBalance
()
{
return
tvService
.
queryBalance
();
/**
* 车辆类型查询
* @return
*/
@GetMapping
(
"/LicensePlateType"
)
public
ObjectRestResponse
getLicensePlateType
()
{
try
{
return
ObjectRestResponse
.
succ
(
tvService
.
getLicensePlateType
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
createDefaultFail
();
}
}
@GetMapping
(
"/carPre/{hphm}"
)
public
JuheResult
carPre
(
@PathVariable
String
hphm
)
{
return
tvService
.
queryCityByHphm
(
hphm
);
}
}
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/TrafficViolationsService.java
View file @
76cf6c7b
package
com
.
xxfc
.
platform
.
universal
.
service
;
import
com.alibaba.fastjson.JSON
;
import
com.xxfc.platform.universal.model.*
;
import
com.xxfc.platform.universal.utils.CertifHttpUtils
;
import
org.apache.http.client.methods.HttpGet
;
import
org.
springframework.beans.factory.annotation.Autowired
;
import
com.xxfc.platform.universal.vo.TrafficViolations
;
import
org.
apache.http.HttpResponse
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestClientException
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -20,109 +15,88 @@ import java.util.Map;
@Service
public
class
TrafficViolationsService
{
@Value
(
"${
juhe.key
}"
)
@Value
(
"${
ALIYUN.CODE
}"
)
private
String
CODE
;
@Value
(
"${RETURN.TYPE}"
)
private
String
TYPE
;
//支持的城市
private
static
final
String
URL_GET_CITY
=
"http://v.juhe.cn/wz/citys?"
+
"province={province}&dtype={dtype}&format={format}&callback={callback}&key={key}"
;
//查违章
private
static
final
String
URL_QUERY_WZ
=
"http://v.juhe.cn/wz/query?"
+
"dtype={dtype}&city={city}&hphm={hphm}&hpzl={hpzl}&engineno={engineno}&classno={classno}&key={key}"
;
//剩余次数
private
static
final
String
URL_BALANCE
=
"http://v.juhe.cn/wz/status?"
+
"dtype={dtype}&key={key}"
;
//根据车牌查城市
private
static
final
String
URL_CAR_PRE
=
"http://v.juhe.cn/wz/carPre?"
+
"hphm={hphm}&key={key}"
;
private
static
final
String
CITY_HOST
=
"https://weizhang.market.alicloudapi.com"
;
private
static
final
String
CITY_PATH
=
"/wz/province"
;
private
static
final
String
CITY_METHOD
=
"GET"
;
private
static
final
String
VIOLATIONS_HOST
=
"https://weizhang.market.alicloudapi.com"
;
private
static
final
String
VIOLATIONS_PATH
=
"/wz/type"
;
private
static
final
String
VIOLATIONS_METHOD
=
"GET"
;
private
static
final
String
host
=
"https://weizhang.market.alicloudapi.com"
;
private
static
final
String
path
=
"/wz/province"
;
private
static
final
String
method
=
"GET"
;
private
static
final
String
appcode
=
"你自己的AppCode"
;
private
static
final
String
GET_LICENSE_PLATE_TYPE_HOST
=
"https://weizhang.market.alicloudapi.com"
;
private
static
final
String
GET_LICENSE_PLATE_TYPE_PATH
=
"/wz/type"
;
private
static
final
String
GET_LICENSE_PLATE_TYPE_METHOD
=
"GET"
;
private
static
final
String
TYPE_NAME
=
"type"
;
private
static
final
String
PLATENO_NAME
=
"plateno"
;
private
static
final
String
ENGINENO_NAME
=
"engineno"
;
private
static
final
String
FRAMENO_NAME
=
"frameno"
;
private
static
final
String
AUTHORIZATION
=
"Authorization"
;
@Autowired
RestTemplate
restTemplate
;
/**
* 获取支持城市
* province string N 默认全部,省份简写,如:ZJ、JS
* dtype string N 返回数据格式:json或xml或jsonp,默认json
* format int N 格式选择1或2,默认1
* callback String N 返回格式选择jsonp时,必须传递
* {"resultcode":"101","reason":"error key","result":null,"error_code":10001}
* 支持城市
*
* @return
* @throws Exception type 返回参数类型
*/
public
JuheResult
<
Map
<
String
,
JuheTrafficViolationsProvinceInfo
>>
getCity
(
String
province
)
{
public
String
getCity
()
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
"APPCODE "
+
CODE
);
headers
.
put
(
AUTHORIZATION
,
"APPCODE "
+
CODE
);
Map
<
String
,
String
>
querys
=
new
HashMap
<
String
,
String
>();
querys
.
put
(
"type"
,
"JSON"
);
// Map<String, String> paramsMap = new HashMap<>();
// paramsMap.put("key", KEY);
// paramsMap.put("province", province == null ? "" : province);
// paramsMap.put("dtype", "json");
// paramsMap.put("format", "");
// paramsMap.put("callback", "");
// CertifHttpUtils.doGet(host,path,method,headers,querys);
//// return (URL_GET_CITY, paramsMap);
return
null
;
}
querys
.
put
(
TYPE_NAME
,
TYPE
);
HttpResponse
httpResponse
=
CertifHttpUtils
.
doGet
(
CITY_HOST
,
CITY_PATH
,
CITY_METHOD
,
headers
,
querys
);
String
provinceJSON
=
httpResponse
.
toString
();
/**
* 查违章
* dtype string 否 返回数据格式:默认:json
* city String 是 城市代码 *
* hphm String 是 号牌号码 完整7位 ,需要utf8 urlencode*
* hpzl String 是 号牌类型,默认02:小型车,01:大型车
* engineno String 否 发动机号 (具体是否需要根据城市接口中的参数填写)
* classno String 否 车架号 (具体是否需要根据城市接口中的参数填写)
*/
public
JuheResult
<
JuheTrafficViolationsInfo
>
queryViolations
(
String
city
,
String
hphm
,
String
hpzl
,
String
engineno
,
String
classno
)
{
Map
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
// paramsMap.put("key", KEY);
paramsMap
.
put
(
"dtype"
,
"json"
);
paramsMap
.
put
(
"city"
,
city
);
paramsMap
.
put
(
"hphm"
,
hphm
);
paramsMap
.
put
(
"hpzl"
,
hpzl
);
paramsMap
.
put
(
"engineno"
,
engineno
);
paramsMap
.
put
(
"classno"
,
classno
);
return
query
(
URL_QUERY_WZ
,
paramsMap
);
return
provinceJSON
;
}
/**
* 查询剩余次数
* 违章车辆查询
*
* @param trafficViolations
* @return
*/
public
JuheResult
<
JuheTrafficViolationsBalanceInfo
>
queryBalance
()
{
Map
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"key"
,
CODE
);
paramsMap
.
put
(
"dtype"
,
"json"
);
return
query
(
URL_BALANCE
,
paramsMap
);
public
String
queryViolations
(
TrafficViolations
trafficViolations
)
throws
Exception
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
AUTHORIZATION
,
"APPCODE "
+
CODE
);
Map
<
String
,
String
>
querys
=
new
HashMap
<
String
,
String
>();
querys
.
put
(
TYPE_NAME
,
trafficViolations
.
getType
());
querys
.
put
(
PLATENO_NAME
,
trafficViolations
.
getPlateno
());
querys
.
put
(
ENGINENO_NAME
,
trafficViolations
.
getEngineno
());
querys
.
put
(
FRAMENO_NAME
,
trafficViolations
.
getFrameno
());
HttpResponse
httpResponse
=
CertifHttpUtils
.
doGet
(
VIOLATIONS_HOST
,
VIOLATIONS_PATH
,
VIOLATIONS_METHOD
,
headers
,
querys
);
String
provinceJSON
=
httpResponse
.
toString
();
return
provinceJSON
;
}
/**
* 根据车牌前缀查城市参数
* 查询车牌类型
*
* @return
* @throws Exception
*/
public
JuheResult
<
JuheCarPreInfo
>
queryCityByHphm
(
String
hphm
)
{
Map
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"key"
,
CODE
);
paramsMap
.
put
(
"hphm"
,
hphm
);
return
query
(
URL_CAR_PRE
,
paramsMap
);
}
public
String
getLicensePlateType
()
throws
Exception
{
private
JuheResult
query
(
String
url
,
Map
<
String
,
String
>
paramsMap
)
{
try
{
String
responseStr
=
restTemplate
.
getForObject
(
url
,
String
.
class
,
paramsMap
);
return
JSON
.
parseObject
(
responseStr
,
JuheResult
.
class
);
}
catch
(
RestClientException
ex
)
{
JuheResult
result
=
new
JuheResult
();
result
.
setReason
(
"请求错误"
);
result
.
setResultcode
(
"500"
);
return
result
;
}
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
AUTHORIZATION
,
"APPCODE "
+
CODE
);
HttpResponse
httpResponse
=
CertifHttpUtils
.
doGet
(
GET_LICENSE_PLATE_TYPE_HOST
,
GET_LICENSE_PLATE_TYPE_PATH
,
GET_LICENSE_PLATE_TYPE_METHOD
,
headers
,
new
HashMap
<
String
,
String
>()
);
String
provinceJSON
=
httpResponse
.
toString
(
);
return
provinceJSON
;
}
...
...
xx-universal/xx-universal-server/src/main/resources/application.properties
View file @
76cf6c7b
#\u8BA4\u8BC1\u63A5\u53E3\u9700\u8981\u643A\u5E26\u7684\u53C2\u6570
#A\u8BA4\u8BC1
#A-\u8BA4\u8BC1
certif.cHost
=
https://idcert.market.alicloudapi.com
certif.cPath
=
/idcard
certif.cMethod
=
GET
certif.cAppcode
=
acea1c8811f748b3a65815f11db357c4
#1.\u8BF7\u6C42
#\u8EAB\u4EFD\u8BC1\u53F7\u5B57\u6BB5\u540D\u79F0
certif.idCardName
=
idCard
#\u59D3\u540D\u5B57\u6BB5\u540D\u79F0
certif.cName
=
name
#2.\u54CD\u5E94
#\u9519\u8BEF\u7801\u5B57\u6BB5\u540D
certif.certifRet
=
status
#\u8BA4\u8BC1\u6210\u529F\u7801
certif.certifResultCode
=
01
#B\u56FE\u7247\u89E3\u6790
#B-\u56FE\u7247\u89E3\u6790
certif.iHost
=
https://ocridcard.market.alicloudapi.com
certif.iPath
=
/idimages
certif.iPath
=
/idimages
certif.iMethod
=
POST
certif.iAppcode
=
acea1c8811f748b3a65815f11db357c4
certif.iAppcode
=
acea1c8811f748b3a65815f11db357c4
#1.\u8BF7\u6C42
#\u56FE\u7247url\u5B57\u6BB5\u540D
certif.picName
=
image
...
...
@@ -34,7 +28,6 @@ certif.typeName=idCardSide
certif.frontParameter
=
front
#\u56FE\u7247\u80CC\u9762\u6807\u8BC6\u53C2\u6570
certif.backParameter
=
back
#2.\u54CD\u5E94
#\u56FE\u7247\u89E3\u6790\u54CD\u5E94\u643A\u5E26\u9519\u8BEF\u7801\u5B57\u6BB5\u540D
certif.imageRet
=
code
...
...
@@ -48,3 +41,9 @@ certif.numberName=code
certif.iName
=
name
#\u8EAB\u4EFD\u8BC1\u5230\u671F\u65F6\u95F4\u5B57\u6BB5\u540D
certif.expirationDateName
=
expiryDate
#C-\u8FDD\u7AE0\u8F66\u8F86\u67E5\u8BE2
#\u63A5\u53E3appcode
ALIYUN.CODE
=
acea1c8811f748b3a65815f11db357c4
#\u8FD4\u56DE\u53C2\u6570\u7C7B\u578B(HTML/JSON/JSONP/XML)
RETURN.TYPE
=
JSON
\ 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