Commit e9e206cc authored by hanfeng's avatar hanfeng

修改违章

parent 960d53ae
...@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient("xx-third-party") @FeignClient("xx-third-party")
@RequestMapping("3p/tv") @RequestMapping("3p/tv")
public interface ITrafficViolationsService { public interface ITrafficViolationsFeign {
/** /**
* 获取支持的城市 * 获取支持的城市
......
package com.xxfc.platform.universal.controller; package com.xxfc.platform.universal.controller;
import com.xxfc.platform.universal.api.ITrafficViolationsService;
import com.xxfc.platform.universal.model.JuheResult; import com.xxfc.platform.universal.model.JuheResult;
import com.xxfc.platform.universal.service.TrafficViolationsService; import com.xxfc.platform.universal.service.TrafficViolationsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("3p/tv") @RequestMapping("3p/tv")
public class TrafficViolationsController { public class TrafficViolationsController {
//implements ITrafficViolationsService {
@Autowired
// @Autowired TrafficViolationsService tvService;
// TrafficViolationsService tvService;
// /**
// @Override * 获取支持的城市
// @GetMapping("city") * @param province
// public JuheResult getCityInfo(String province) { * @return
// return tvService.getCity(province); */
// } @GetMapping("/city/{province}")
// public JuheResult getCityInfo(@PathVariable String province) {
// @Override return tvService.getCity(province);
// @GetMapping("trafficViolations") }
// public JuheResult queryTrafficViolations(String city, String hphm, String hpzl, String engineno, String classno) {
// return tvService.queryViolations(city, hphm, hpzl, engineno, classno); /**
// } * 违章车辆查询
// * @param city
// @Override * @param hphm
// @GetMapping("balance") * @param hpzl
// public JuheResult getBalance() { * @param engineno
// return tvService.queryBalance(); * @param classno
// } * @return
// */
// @Override @GetMapping("trafficViolations")
// @GetMapping("carPre") public JuheResult queryTrafficViolations(String city, String hphm, String hpzl, String engineno, String classno) {
// public JuheResult carPre(String hphm) { return tvService.queryViolations(city, hphm, hpzl, engineno, classno);
// return tvService.queryCityByHphm(hphm); }
// }
@GetMapping("balance")
public JuheResult getBalance() {
return tvService.queryBalance();
}
@GetMapping("/carPre/{hphm}")
public JuheResult carPre(@PathVariable String hphm) {
return tvService.queryCityByHphm(hphm);
}
} }
...@@ -2,8 +2,11 @@ package com.xxfc.platform.universal.service; ...@@ -2,8 +2,11 @@ package com.xxfc.platform.universal.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.xxfc.platform.universal.model.*; 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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -14,11 +17,11 @@ import java.util.Map; ...@@ -14,11 +17,11 @@ import java.util.Map;
/** /**
* 违章查询 * 违章查询
*/ */
//@Service @Service
public class TrafficViolationsService { public class TrafficViolationsService {
@Value("${juhe.key}") @Value("${juhe.key}")
private String KEY; private String CODE;
//支持的城市 //支持的城市
private static final String URL_GET_CITY = "http://v.juhe.cn/wz/citys?" + private static final String URL_GET_CITY = "http://v.juhe.cn/wz/citys?" +
...@@ -33,6 +36,12 @@ public class TrafficViolationsService { ...@@ -33,6 +36,12 @@ public class TrafficViolationsService {
private static final String URL_CAR_PRE = "http://v.juhe.cn/wz/carPre?" + private static final String URL_CAR_PRE = "http://v.juhe.cn/wz/carPre?" +
"hphm={hphm}&key={key}"; "hphm={hphm}&key={key}";
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";
@Autowired @Autowired
RestTemplate restTemplate; RestTemplate restTemplate;
...@@ -45,13 +54,21 @@ public class TrafficViolationsService { ...@@ -45,13 +54,21 @@ public class TrafficViolationsService {
* {"resultcode":"101","reason":"error key","result":null,"error_code":10001} * {"resultcode":"101","reason":"error key","result":null,"error_code":10001}
*/ */
public JuheResult<Map<String, JuheTrafficViolationsProvinceInfo>> getCity(String province) { public JuheResult<Map<String, JuheTrafficViolationsProvinceInfo>> getCity(String province) {
Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("key", KEY); Map<String, String> headers = new HashMap<String, String>();
paramsMap.put("province", province == null ? "" : province); headers.put("Authorization", "APPCODE " + CODE);
paramsMap.put("dtype", "json"); Map<String, String> querys = new HashMap<String, String>();
paramsMap.put("format", ""); querys.put("type", "JSON");
paramsMap.put("callback", "");
return query(URL_GET_CITY, paramsMap); // 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;
} }
/** /**
...@@ -66,7 +83,7 @@ public class TrafficViolationsService { ...@@ -66,7 +83,7 @@ public class TrafficViolationsService {
public JuheResult<JuheTrafficViolationsInfo> queryViolations(String city, String hphm, String hpzl, public JuheResult<JuheTrafficViolationsInfo> queryViolations(String city, String hphm, String hpzl,
String engineno, String classno) { String engineno, String classno) {
Map<String, String> paramsMap = new HashMap<>(); Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("key", KEY); // paramsMap.put("key", KEY);
paramsMap.put("dtype", "json"); paramsMap.put("dtype", "json");
paramsMap.put("city", city); paramsMap.put("city", city);
paramsMap.put("hphm", hphm); paramsMap.put("hphm", hphm);
...@@ -81,7 +98,7 @@ public class TrafficViolationsService { ...@@ -81,7 +98,7 @@ public class TrafficViolationsService {
*/ */
public JuheResult<JuheTrafficViolationsBalanceInfo> queryBalance() { public JuheResult<JuheTrafficViolationsBalanceInfo> queryBalance() {
Map<String, String> paramsMap = new HashMap<>(); Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("key", KEY); paramsMap.put("key", CODE);
paramsMap.put("dtype", "json"); paramsMap.put("dtype", "json");
return query(URL_BALANCE, paramsMap); return query(URL_BALANCE, paramsMap);
} }
...@@ -91,7 +108,7 @@ public class TrafficViolationsService { ...@@ -91,7 +108,7 @@ public class TrafficViolationsService {
*/ */
public JuheResult<JuheCarPreInfo> queryCityByHphm(String hphm) { public JuheResult<JuheCarPreInfo> queryCityByHphm(String hphm) {
Map<String, String> paramsMap = new HashMap<>(); Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("key", KEY); paramsMap.put("key", CODE);
paramsMap.put("hphm", hphm); paramsMap.put("hphm", hphm);
return query(URL_CAR_PRE, paramsMap); return query(URL_CAR_PRE, paramsMap);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment