service-map集成终端搜索服务

main
topsun 2 years ago
parent 3aabf0c7f7
commit c15224eb51

@ -28,8 +28,8 @@ public class TerminalAroundSearch {
* }
*/
private String desc;
private String tid;
private Long carId;
private String name;
private LocalDateTime locatetime;
private LocalDateTime createtime;

@ -1,6 +1,7 @@
package com.taxi.servicemap.controller;
import com.internal.dto.ResponseResult;
import com.internal.dto.TerminalAroundSearch;
import com.internal.dto.TerminalResponse;
import com.taxi.servicemap.service.TerminalService;
import org.springframework.beans.factory.annotation.Autowired;
@ -8,6 +9,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/terminal")
public class TerminalController {
@ -20,7 +23,7 @@ public class TerminalController {
@PostMapping("/aroundsearch")
public ResponseResult aroundsearch(String center,Integer radius){
public ResponseResult<List<TerminalAroundSearch>> aroundsearch(String center, Integer radius){
return terminalService.aroundsearch(center,radius);
}

@ -12,6 +12,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
@Service
@ -33,7 +34,7 @@ public class TerminalClient {
* @param radius
* @return
*/
public ResponseResult aroundsearch(String center,Integer radius){
public ResponseResult<List<TerminalAroundSearch>> aroundsearch(String center,Integer radius){
//拼接请求的URL
StringBuilder url = new StringBuilder();
url.append(AmapConfigConstant.TERMINAL_AROUND_SEARCH_URL);
@ -52,15 +53,19 @@ public class TerminalClient {
String bodyStr = forEntity.getBody();
JSONObject result = JSONObject.fromObject(bodyStr);
System.out.println("周边搜索终端的结果:"+bodyStr);
List<TerminalAroundSearch> list = new ArrayList<>();
if(result.has("data")){
JSONObject data = result.getJSONObject("data");
// int count = data.getInt("count");
TerminalAroundSearch terminalAroundSearch = new TerminalAroundSearch();
List<TerminalAroundSearch> jsonArray = data.getJSONArray("results");
ResponseResult.success(ResponseResult.success());
JSONArray jsonArray = data.getJSONArray("results");
for (int index = 0 ;index < jsonArray.size();index++){
JSONObject jsonObject = jsonArray.getJSONObject(index);
TerminalAroundSearch terminalAroundSearch = new TerminalAroundSearch();
terminalAroundSearch.setTid(jsonObject.getString("tid"));
terminalAroundSearch.setCarId(jsonObject.getLong("desc"));
list.add(terminalAroundSearch);
}
return ResponseResult.success(list);
}
return ResponseResult.success();
}

@ -1,11 +1,14 @@
package com.taxi.servicemap.service;
import com.internal.dto.ResponseResult;
import com.internal.dto.TerminalAroundSearch;
import com.internal.dto.TerminalResponse;
import com.taxi.servicemap.remote.TerminalClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TerminalService {
@Autowired
@ -15,7 +18,7 @@ public class TerminalService {
return terminalClient.addTerminal(name,desc);
}
public ResponseResult aroundsearch(String center,Integer radius){
public ResponseResult<List<TerminalAroundSearch>> aroundsearch(String center, Integer radius){
return terminalClient.aroundsearch(center,radius);
}
}

Loading…
Cancel
Save