封装/poi/search到open
This commit is contained in:
+59
-4
@@ -1,6 +1,7 @@
|
|||||||
package com.fangjia.open.controllers;
|
package com.fangjia.open.controllers;
|
||||||
|
|
||||||
import com.fangjia.core.RegionData;
|
import com.fangjia.core.RegionData;
|
||||||
|
import com.fangjia.core.util.HttpRequest;
|
||||||
import com.fangjia.dal.mongo.model.AmapPoi;
|
import com.fangjia.dal.mongo.model.AmapPoi;
|
||||||
import com.fangjia.dal.mongo.model.CbmRegion;
|
import com.fangjia.dal.mongo.model.CbmRegion;
|
||||||
import com.fangjia.dal.mongo.model.elastic.CbmAmapPoi;
|
import com.fangjia.dal.mongo.model.elastic.CbmAmapPoi;
|
||||||
@@ -8,10 +9,7 @@ import com.fangjia.dal.seaweed.model.District;
|
|||||||
import com.fangjia.open.dto.UniversalDto;
|
import com.fangjia.open.dto.UniversalDto;
|
||||||
import com.fangjia.open.interceptors.Authority;
|
import com.fangjia.open.interceptors.Authority;
|
||||||
import com.fangjia.open.interceptors.Role;
|
import com.fangjia.open.interceptors.Role;
|
||||||
import com.fangjia.open.model.AntiFraudQuestionModel;
|
import com.fangjia.open.model.*;
|
||||||
import com.fangjia.open.model.BasicModel;
|
|
||||||
import com.fangjia.open.model.PoiSuggestModel;
|
|
||||||
import com.fangjia.open.model.RestfulModelAndView;
|
|
||||||
import com.fangjia.service.address.AddressParserService;
|
import com.fangjia.service.address.AddressParserService;
|
||||||
import com.fangjia.service.address.AddressParserUtil;
|
import com.fangjia.service.address.AddressParserUtil;
|
||||||
import com.fangjia.service.address.mode.Address;
|
import com.fangjia.service.address.mode.Address;
|
||||||
@@ -19,6 +17,7 @@ import com.fangjia.service.api.AmapPoiService;
|
|||||||
import com.fangjia.service.bo.Point;
|
import com.fangjia.service.bo.Point;
|
||||||
import com.fangjia.service.datastore.DistrictService;
|
import com.fangjia.service.datastore.DistrictService;
|
||||||
import com.fangjia.service.mongo.fangjia.CbmRegionService;
|
import com.fangjia.service.mongo.fangjia.CbmRegionService;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@@ -213,6 +212,62 @@ public class PoiController {
|
|||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POI搜索服务
|
||||||
|
*
|
||||||
|
* @param model
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object searchAction(AddressModel model) {
|
||||||
|
|
||||||
|
RestfulModelAndView mav = new RestfulModelAndView();
|
||||||
|
if (StringUtils.isBlank(model.getLocation()) || StringUtils.isBlank(model.getCity())) {
|
||||||
|
mav.setModel(BasicModel.buildBadRequestModel("城市和经纬度为必填项"));
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest();
|
||||||
|
JSONObject json = null;
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("city", model.getCity());
|
||||||
|
params.put("location", model.getLocation());
|
||||||
|
params.put("types", StringUtils.isNotBlank(model.getTypes()) ? model.getTypes() : null);
|
||||||
|
Integer radius = model.getRadius();
|
||||||
|
if (radius != null && radius > 0) {
|
||||||
|
params.put("radius", radius.toString());
|
||||||
|
}
|
||||||
|
Integer offset = model.getOffset();
|
||||||
|
if (offset != null && offset > 0) {
|
||||||
|
params.put("offset", offset.toString());
|
||||||
|
}
|
||||||
|
Integer page = model.getPage();
|
||||||
|
if (page != null && page > 0) {
|
||||||
|
params.put("page", page.toString());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/poi/search", params, "UTF-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/poi/search", params, "UTF-8");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json != null) {
|
||||||
|
int code = json.getInt("msgCode");
|
||||||
|
String msg = json.getString("msg");
|
||||||
|
BasicModel basicModel = new BasicModel(code, msg);
|
||||||
|
if (json.containsKey("result")) {
|
||||||
|
basicModel.setResult(json.get("result"));
|
||||||
|
}
|
||||||
|
mav.setModel(basicModel);
|
||||||
|
} else {
|
||||||
|
mav.setModel(BasicModel.buildServerErrorModel().setMsg("服务升级中..."));
|
||||||
|
}
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAmapPoiService(AmapPoiService amapPoiService) {
|
public void setAmapPoiService(AmapPoiService amapPoiService) {
|
||||||
this.amapPoiService = amapPoiService;
|
this.amapPoiService = amapPoiService;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ public class AddressModel extends FangjiaApiModel {
|
|||||||
private Integer radius;
|
private Integer radius;
|
||||||
// 查询数量
|
// 查询数量
|
||||||
private Integer number;
|
private Integer number;
|
||||||
|
private Integer offset;
|
||||||
// 查询页码
|
// 查询页码
|
||||||
private Integer pageNo;
|
private Integer pageNo;
|
||||||
|
private Integer page;
|
||||||
// 是否用于检查
|
// 是否用于检查
|
||||||
private String dataLevel;
|
private String dataLevel;
|
||||||
|
|
||||||
@@ -49,6 +51,9 @@ public class AddressModel extends FangjiaApiModel {
|
|||||||
|
|
||||||
private String lat;
|
private String lat;
|
||||||
private String lng;
|
private String lng;
|
||||||
|
|
||||||
|
private String location;
|
||||||
|
private String types;
|
||||||
public boolean isContainsLocation() {
|
public boolean isContainsLocation() {
|
||||||
return containsLocation;
|
return containsLocation;
|
||||||
}
|
}
|
||||||
@@ -297,4 +302,36 @@ public class AddressModel extends FangjiaApiModel {
|
|||||||
public void setLng(String lng) {
|
public void setLng(String lng) {
|
||||||
this.lng = lng;
|
this.lng = lng;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(String location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypes() {
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypes(String types) {
|
||||||
|
this.types = types;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(Integer offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(Integer page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user