国信接口
This commit is contained in:
+112
-24
@@ -312,6 +312,46 @@ public class AddrSvcController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址联想
|
||||
*/
|
||||
public Object tipsAction(AddressModel model) {
|
||||
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
if (StringUtils.isBlank(model.getKeywords())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("搜索关键字不能为空"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
HttpRequest request = new HttpRequest();
|
||||
JSONObject json = null;
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("keywords", model.getKeywords());
|
||||
params.put("city", StringUtils.isNotBlank(model.getCity()) ? model.getCity() : "");
|
||||
params.put("max", model.getMax() != 0 ? String.valueOf(model.getMax()) : "");
|
||||
try {
|
||||
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/tips", params, "UTF-8");
|
||||
if (json != null) {
|
||||
int code = json.getInt("msgCode");
|
||||
String msg = json.getString("msg");
|
||||
BasicModel basicModel = new BasicModel(code, msg);
|
||||
if (json.containsKey("result")) {
|
||||
JSONArray jsonArray = json.getJSONArray("result");
|
||||
if (jsonArray.size() > 0) {
|
||||
basicModel.setResult(jsonArray);
|
||||
}
|
||||
}
|
||||
mav.setModel(basicModel);
|
||||
} else {
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||
}
|
||||
return mav;
|
||||
}
|
||||
|
||||
public Object avgPriceAction(AddressModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
if (StringUtils.isBlank(model.getAddress())) {
|
||||
@@ -1048,11 +1088,21 @@ public class AddrSvcController {
|
||||
for (Object o : jsonArray) {
|
||||
JSONObject result = (JSONObject) o;
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("id", result.getString("id"));
|
||||
map.put("province", result.getString("province"));
|
||||
map.put("provinceCode", result.getString("tjjProvinceCode"));
|
||||
map.put("city", result.getString("city"));
|
||||
map.put("cityCode", result.getString("tjjCityCode"));
|
||||
if (result.containsKey("id")) {
|
||||
map.put("id", result.getString("id"));
|
||||
}
|
||||
if (result.containsKey("province")) {
|
||||
map.put("province", result.getString("province"));
|
||||
}
|
||||
if (result.containsKey("provinceCode")) {
|
||||
map.put("provinceCode", result.getString("tjjProvinceCode"));
|
||||
}
|
||||
if (result.containsKey("city")) {
|
||||
map.put("city", result.getString("city"));
|
||||
}
|
||||
if (result.containsKey("cityCode")) {
|
||||
map.put("cityCode", result.getString("tjjCityCode"));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
@@ -1096,9 +1146,15 @@ public class AddrSvcController {
|
||||
for (Object o : jsonArray) {
|
||||
JSONObject result = (JSONObject) o;
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("id", result.getString("id"));
|
||||
map.put("province", result.getString("province"));
|
||||
map.put("provinceCode", result.getString("mzbProvinceCode"));
|
||||
if (result.containsKey("id")) {
|
||||
map.put("id", result.getString("id"));
|
||||
}
|
||||
if (result.containsKey("province")) {
|
||||
map.put("province", result.getString("province"));
|
||||
}
|
||||
if (result.containsKey("provinceCode")) {
|
||||
map.put("provinceCode", result.getString("mzbProvinceCode"));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
@@ -1145,13 +1201,27 @@ public class AddrSvcController {
|
||||
for (Object o : jsonArray) {
|
||||
JSONObject result = (JSONObject) o;
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("id", result.getString("id"));
|
||||
map.put("province", result.getString("province"));
|
||||
map.put("provinceCode", result.getString("tjjProvinceCode"));
|
||||
map.put("city", result.getString("city"));
|
||||
map.put("cityCode", result.getString("tjjCityCode"));
|
||||
map.put("district", result.getString("district"));
|
||||
map.put("districtCode", result.getString("tjjDistrictCode"));
|
||||
if (result.containsKey("id")) {
|
||||
map.put("id", result.getString("id"));
|
||||
}
|
||||
if (result.containsKey("province")) {
|
||||
map.put("province", result.getString("province"));
|
||||
}
|
||||
if (result.containsKey("provinceCode")) {
|
||||
map.put("provinceCode", result.getString("tjjProvinceCode"));
|
||||
}
|
||||
if (result.containsKey("city")) {
|
||||
map.put("city", result.getString("city"));
|
||||
}
|
||||
if (result.containsKey("cityCode")) {
|
||||
map.put("cityCode", result.getString("tjjCityCode"));
|
||||
}
|
||||
if (result.containsKey("district")) {
|
||||
map.put("district", result.getString("district"));
|
||||
}
|
||||
if (result.containsKey("districtCode")) {
|
||||
map.put("districtCode", result.getString("tjjDistrictCode"));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
@@ -1193,15 +1263,33 @@ public class AddrSvcController {
|
||||
for (Object o : jsonArray) {
|
||||
JSONObject result = (JSONObject) o;
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("id", result.getString("id"));
|
||||
map.put("province", result.getString("province"));
|
||||
map.put("provinceCode", result.getString("tjjProvinceCode"));
|
||||
map.put("city", result.getString("city"));
|
||||
map.put("cityCode", result.getString("tjjCityCode"));
|
||||
map.put("district", result.getString("district"));
|
||||
map.put("districtCode", result.getString("tjjDistrictCode"));
|
||||
map.put("street", result.getString("street"));
|
||||
map.put("streetCode", result.getString("tjjStreetCode"));
|
||||
if (result.containsKey("id")) {
|
||||
map.put("id", result.getString("id"));
|
||||
}
|
||||
if (result.containsKey("province")) {
|
||||
map.put("province", result.getString("province"));
|
||||
}
|
||||
if (result.containsKey("provinceCode")) {
|
||||
map.put("provinceCode", result.getString("tjjProvinceCode"));
|
||||
}
|
||||
if (result.containsKey("city")) {
|
||||
map.put("city", result.getString("city"));
|
||||
}
|
||||
if (result.containsKey("cityCode")) {
|
||||
map.put("cityCode", result.getString("tjjCityCode"));
|
||||
}
|
||||
if (result.containsKey("district")) {
|
||||
map.put("district", result.getString("district"));
|
||||
}
|
||||
if (result.containsKey("districtCode")) {
|
||||
map.put("districtCode", result.getString("tjjDistrictCode"));
|
||||
}
|
||||
if (result.containsKey("street")) {
|
||||
map.put("street", result.getString("street"));
|
||||
}
|
||||
if (result.containsKey("streetCode")) {
|
||||
map.put("streetCode", result.getString("tjjStreetCode"));
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user