Commit e9e206cc authored by hanfeng's avatar hanfeng

修改违章

parent 960d53ae
......@@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient("xx-third-party")
@RequestMapping("3p/tv")
public interface ITrafficViolationsService {
public interface ITrafficViolationsFeign {
/**
* 获取支持的城市
......
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.service.TrafficViolationsService;
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;
@RestController
@RequestMapping("3p/tv")
public class TrafficViolationsController {
//implements ITrafficViolationsService {
// @Autowired
// TrafficViolationsService tvService;
//
// @Override
// @GetMapping("city")
// public JuheResult getCityInfo(String province) {
// return tvService.getCity(province);
// }
//
// @Override
// @GetMapping("trafficViolations")
// public JuheResult queryTrafficViolations(String city, String hphm, String hpzl, String engineno, String classno) {
// return tvService.queryViolations(city, hphm, hpzl, engineno, classno);
// }
//
// @Override
// @GetMapping("balance")
// public JuheResult getBalance() {
// return tvService.queryBalance();
// }
//
// @Override
// @GetMapping("carPre")
// public JuheResult carPre(String hphm) {
// return tvService.queryCityByHphm(hphm);
// }
@Autowired
TrafficViolationsService tvService;
/**
* 获取支持的城市
* @param province
* @return
*/
@GetMapping("/city/{province}")
public JuheResult getCityInfo(@PathVariable String province) {
return tvService.getCity(province);
}
/**
* 违章车辆查询
* @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);
}
@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;
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 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;
......@@ -14,11 +17,11 @@ import java.util.Map;
/**
* 违章查询
*/
//@Service
@Service
public class TrafficViolationsService {
@Value("${juhe.key}")
private String KEY;
private String CODE;
//支持的城市
private static final String URL_GET_CITY = "http://v.juhe.cn/wz/citys?" +
......@@ -33,6 +36,12 @@ public class TrafficViolationsService {
private static final String URL_CAR_PRE = "http://v.juhe.cn/wz/carPre?" +
"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
RestTemplate restTemplate;
......@@ -45,13 +54,21 @@ public class TrafficViolationsService {
* {"resultcode":"101","reason":"error key","result":null,"error_code":10001}
*/
public JuheResult<Map<String, JuheTrafficViolationsProvinceInfo>> getCity(String province) {
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", "");
return query(URL_GET_CITY, paramsMap);
Map<String, String> headers = new HashMap<String, String>();
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;
}
/**
......@@ -66,7 +83,7 @@ public class TrafficViolationsService {
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("key", KEY);
paramsMap.put("dtype", "json");
paramsMap.put("city", city);
paramsMap.put("hphm", hphm);
......@@ -81,7 +98,7 @@ public class TrafficViolationsService {
*/
public JuheResult<JuheTrafficViolationsBalanceInfo> queryBalance() {
Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("key", KEY);
paramsMap.put("key", CODE);
paramsMap.put("dtype", "json");
return query(URL_BALANCE, paramsMap);
}
......@@ -91,7 +108,7 @@ public class TrafficViolationsService {
*/
public JuheResult<JuheCarPreInfo> queryCityByHphm(String hphm) {
Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("key", KEY);
paramsMap.put("key", CODE);
paramsMap.put("hphm", hphm);
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