gacvd 发表于 2017-12-19 09:08:19

solr-geohsah 按照距离搜索分组

SimpleResult groupCargo(LbsSearchRequestDto lbsSearchRequestDto){  try{
  if(lbsSearchRequestDto==null)
  return new SimpleResult("body不能为空", StateCode.VALIDATOR_FAIL, null, false);
  LbsSearchBodyDto lbsBdoy=lbsSearchRequestDto.getBodyDto();
  if(lbsBdoy.getLevel()==null)
  return new SimpleResult("Level不能为空", StateCode.VALIDATOR_FAIL, null, false);
  List<String> fl=new ArrayList<String>();
  //level为省级按照省分组
  if(lbsBdoy.getLevel()==1){
  fl.add("rciShipperCity:notfind");
  fl.add("rciShipperArea:notfind");
  //level为市级按照市分组
  }else if(lbsBdoy.getLevel()==2){
  fl.add("rciShipperArea:notfind");
  fl.add("-rciShipperCity:notfind");
  //level为区县级按照区县分组
  }else if(lbsBdoy.getLevel()==3){
  fl.add("-rciShipperArea:notfind");
  }
  if(lbsBdoy.getPageSize()==null)lbsBdoy.setPageSize(0);
  if(lbsBdoy.getPageNumber()==null)lbsBdoy.setPageNumber(50);
  //按照经纬度和距离查询
  PageData data=solrCargoLLSearch.queryLL(lbsBdoy.getPageSize(), lbsBdoy.getPageNumber(), lbsBdoy.getD(), "geohash", lbsBdoy.getLat(),lbsBdoy.getLon(), fl);
  LbsSearchGroupResponseDto lsgrb=new LbsSearchGroupResponseDto();
  LbsSearchGroupResponseBodyDto lsgrbd=new LbsSearchGroupResponseBodyDto();
  lsgrb.setBodyDto(lsgrbd);
  List<LbsGroupMsg> lbsGroupMsgs=new ArrayList<LbsGroupMsg>();
  String solrMsg=data.getData();
  JSONArray array=JSONArray.parseArray(solrMsg);
  for(int i=0;i<array.size();i++){
  //TODO数据整合
  }
  lsgrbd.setLbsGroupMsgs(lbsGroupMsgs);
  return new SimpleResult("成功", 200, lsgrbd, true);
  }catch(Exception e){
  e.printStackTrace();
  return new SimpleResult("服务器错误", 500, null, true);
  }
  }
页: [1]
查看完整版本: solr-geohsah 按照距离搜索分组