1、修改启迪中台对接接口

This commit is contained in:
yitonglei 2022-05-09 09:44:50 +08:00
parent 0fef3344ec
commit aac56928dd
2 changed files with 223 additions and 157 deletions

View File

@ -230,16 +230,8 @@ public class Controller {
//道路统计数据与排名 //道路统计数据与排名
@RequestMapping("roadData") @RequestMapping("roadData")
public List<Map> roadData( public List<Map> roadData(){
@RequestParam(value="groupId") String groupId, return monitorService.roadData();
@RequestParam(value="timeType") String timeType,
@RequestParam(value="dt") String dt
){
Map<String,String> map = new HashMap<>();
map.put("groupId",groupId);
map.put("timeType",timeType);
map.put("dt",dt);
return monitorService.roadData(map);
} }
//启迪中台 //启迪中台
//登录 //登录

View File

@ -30,6 +30,9 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
@ -74,7 +77,7 @@ public class MonitorService {
static int keepaliveCount = 16; static int keepaliveCount = 16;
@PostConstruct // @PostConstruct
public void init(){ public void init(){
String loginUrl = monitorDomain + "/videoService/accounts/authorize"; String loginUrl = monitorDomain + "/videoService/accounts/authorize";
@ -447,9 +450,16 @@ public class MonitorService {
} }
public List<Map> roadData(Map<String,String> map){ //道路统计数据与排名
public List<Map> roadData(){
String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}"; String url = "http://outerdata.novaecs.com/api/qingdaoData/roadData?groupId={groupId}&timeType={timeType}&dt={dt}";
Map<String,Object> map = new HashMap<>();
map.put("dt",this.dateTimeStr());
map.put("groupId",1);
map.put("timeType","");
ResponseEntity<JSONObject> responseEntity; ResponseEntity<JSONObject> responseEntity;
List<Map> list = new ArrayList<>(); List<Map> list = new ArrayList<>();
try { try {
@ -469,176 +479,240 @@ public class MonitorService {
} }
} }
//启迪数据中台相关 //启迪数据中台相关
//1.登录 //1.登录
public String qidiToken () { public String qidiToken () {
String url = "http://120.221.95.13:9090/apin/authorization/oauth/token"; String url = "http://120.221.95.13:9090/apin/authorization/oauth/token";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ="); headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ=");
headers.add("Content-Type", "application/x-www-form-urlencoded"); headers.add("Content-Type", "application/x-www-form-urlencoded");
MultiValueMap map = new LinkedMultiValueMap(); MultiValueMap map = new LinkedMultiValueMap();
map.add("username", "dlwr"); map.add("username", "dlwr");
map.add("password", "C61026E841A2F96E17564AB7333D92E8");//dlwr123!,需要MD5加密 map.add("password", "C61026E841A2F96E17564AB7333D92E8");//dlwr123!,需要MD5加密
map.add("scope", "read"); map.add("scope", "read");
map.add("grant_type", "password"); map.add("grant_type", "password");
map.add("vc", "NO"); map.add("vc", "NO");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
ResponseEntity<JSONObject> responseEntity; ResponseEntity<JSONObject> responseEntity;
try { try {
responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class); responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
JSONObject jsonObject = responseEntity.getBody(); JSONObject jsonObject = responseEntity.getBody();
if (jsonObject.getBooleanValue("success") == true) { if (jsonObject.getBooleanValue("success") == true) {
JSONObject resultJson = jsonObject.getJSONObject("result"); JSONObject resultJson = jsonObject.getJSONObject("result");
return resultJson.getString("accessToken"); return resultJson.getString("accessToken");
} else { } else {
return null;
}
} catch (Exception e) {
log.info("[qidiToken] exception:{}", e.getMessage());
return null; return null;
} }
} catch (Exception e) {
log.info("[qidiToken] exception:{}", e.getMessage());
return null;
} }
}
//渣土车轨迹数据 //渣土车轨迹数据
public List<Map> resCatalogApplyZTYS () { public List<Map> resCatalogApplyZTYS () {
String token = this.qidiToken(); String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2"; HttpHeaders headers = new HttpHeaders();
HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + token);
headers.add("Authorization", "Bearer " + token);
HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(null, headers); Map<String,Object> map = new HashMap<>();
ResponseEntity<JSONObject> responseEntity; JSONObject search = new JSONObject();
try { search.put("opt","LIKE");
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class); search.put("key","UPLOADTIME");
JSONObject jsonObject = responseEntity.getBody(); search.put("val",this.dateStr());
JSONArray jsonArray = jsonObject.getJSONArray("list");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); // search.put("opt","EQ");
} catch (Exception e) { // search.put("key","SPEED");
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage()); // search.put("val","0");
return null; map.put("json",search);
}
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000022_2?search=[{json}]";
HttpEntity<Map> httpEntity = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
log.info("[resCatalogApplyZTYS] 返回数据的数量:{}",jsonArray.size());
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
} catch (Exception e) {
log.info("[resCatalogApplyZTYS] exception:{}", e.getMessage());
return null;
} }
}
//环卫车轨迹数据 //环卫车轨迹数据
public List<Map> resCatalogApplyHJWS () { public List<Map> resCatalogApplyHJWS () {
String token = this.qidiToken(); String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1"; String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000442_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token); headers.add("Authorization", "Bearer " + token);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers); Map<String,Object> map = new HashMap<>();
ResponseEntity<JSONObject> responseEntity; JSONObject search = new JSONObject();
try { search.put("opt","LIKE");
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); search.put("key","updatetime");
JSONObject jsonObject = responseEntity.getBody(); search.put("val",this.dateStr());
JSONArray jsonArray = jsonObject.getJSONArray("list"); // search.put("opt","EQ");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); // search.put("key","SIMKH");
} catch (Exception e) { // search.put("val","13302959786");
log.info("[resCatalogApplyHJWS] exception:{}", e.getMessage()); map.put("json",search);
return null;
} HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
} catch (Exception e) {
log.info("[resCatalogApplyHJWS] exception:{}", e.getMessage());
return null;
} }
}
//工地信息 //工地信息
public List<Map> resCatalogApplyGDYS () { public List<Map> resCatalogApplyGDYS () {
String token = this.qidiToken(); String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1"; //String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders(); String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_ZTYS_307013600000000025_1";
headers.add("Authorization", "Bearer " + token); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers); // Map<String,Object> map = new HashMap<>();
ResponseEntity<JSONObject> responseEntity; // JSONObject search = new JSONObject();
try { // search.put("opt","LIKE");
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); // search.put("key","updatetime");
JSONObject jsonObject = responseEntity.getBody(); // search.put("val",this.dateStr());
JSONArray jsonArray = jsonObject.getJSONArray("list"); // search.put("opt","EQ");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); // search.put("key","SSDQ");
} catch (Exception e) { // search.put("val","西海岸新区");
log.info("[resCatalogApplyGDYS] exception:{}", e.getMessage()); // map.put("json",search);
return null;
} HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
} catch (Exception e) {
log.info("[resCatalogApplyGDYS] exception:{}", e.getMessage());
return null;
} }
}
//环卫车辆数据1基础 //环卫车辆数据1基础
public List<Map> resCatalogApplyHJWSBase () { public List<Map> resCatalogApplyHJWSBase () {
String token = this.qidiToken(); String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1"; String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token); headers.add("Authorization", "Bearer " + token);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers); Map<String,Object> map = new HashMap<>();
ResponseEntity<JSONObject> responseEntity; JSONObject search = new JSONObject();
try { search.put("opt","LIKE");
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); search.put("key","updatetime");
JSONObject jsonObject = responseEntity.getBody(); search.put("val",this.dateStr());
JSONArray jsonArray = jsonObject.getJSONArray("list"); // search.put("opt","EQ");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); // search.put("key","SSQY");
} catch (Exception e) { // search.put("val","胶州市");
log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage()); map.put("json",search);
return null;
} HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
} catch (Exception e) {
log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage());
return null;
} }
}
//环卫车辆数据2,作业 //环卫车辆数据2,作业
public List<Map> resCatalogApplyHJWSZY () { public List<Map> resCatalogApplyHJWSZY () {
String token = this.qidiToken(); String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1"; String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token); headers.add("Authorization", "Bearer " + token);
MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); Map<String,Object> map = new HashMap<>();
map.add("pageNo", "1"); JSONObject search = new JSONObject();
map.add("pageSize", "1000"); search.put("opt","LIKE");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers); search.put("key","ZYRQ");
ResponseEntity<JSONObject> responseEntity; search.put("val",this.dateStr());
List<Map> result; // search.put("opt","EQ");
try { // search.put("key","CPH");
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); // search.put("val","鲁BW7681");
JSONObject jsonObject = responseEntity.getBody(); map.put("json",search);
int count = jsonObject.getIntValue("count");
result = new ArrayList<>(count); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
JSONArray jsonArray = jsonObject.getJSONArray("list"); ResponseEntity<JSONObject> responseEntity;
result.addAll(JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class)); try {
if (count > 1000) { responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
int i = count / 1000; JSONObject jsonObject = responseEntity.getBody();
for (int j = 2; j <= i + 1; j++) { JSONArray jsonArray = jsonObject.getJSONArray("list");
map.add("pageNo", String.valueOf(j)); return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); } catch (Exception e) {
JSONObject jsonObject1 = responseEntity.getBody(); log.info("[resCatalogApplyHJWSBase] exception:{}", e.getMessage());
JSONArray jsonArray1 = jsonObject.getJSONArray("list"); return null;
result.addAll(JSONObject.parseArray(JSONObject.toJSONString(jsonArray1), Map.class));
}
}
return result;
} catch (Exception e) {
log.info("[resCatalogApplyHJWSZY] exception:{}", e.getMessage());
return null;
}
} }
}
//环卫道路明细数据 //环卫道路明细数据
public List<Map> resCatalogApplyHJWSRoad () { public List<Map> resCatalogApplyHJWSRoad () {
String token = this.qidiToken(); String token = this.qidiToken();
String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2"; String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Bearer " + token); headers.add("Authorization", "Bearer " + token);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers); Map<String,Object> map = new HashMap<>();
ResponseEntity<JSONObject> responseEntity; JSONObject search = new JSONObject();
try { search.put("opt","LIKE");
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); search.put("key","updatetime");
JSONObject jsonObject = responseEntity.getBody(); search.put("val",this.dateStr());
JSONArray jsonArray = jsonObject.getJSONArray("list"); // search.put("opt","EQ");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); // search.put("key","QDLKDLMC");
} catch (Exception e) { // search.put("val","宜昌路");
log.info("[resCatalogApplyHJWSRoad] exception:{}", e.getMessage()); map.put("json",search);
return null;
} HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
ResponseEntity<JSONObject> responseEntity;
try {
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
JSONObject jsonObject = responseEntity.getBody();
JSONArray jsonArray = jsonObject.getJSONArray("list");
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
} catch (Exception e) {
log.info("[resCatalogApplyHJWSRoad] exception:{}", e.getMessage());
return null;
} }
}
//获取当前日期的时间串2022-05-08 00:00:00
private String dateTimeStr(){
LocalDate localDate = LocalDate.now();
LocalDate yestDay = localDate.minusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(),yestDay.getMonth(),yestDay.getDayOfMonth(),0,0,0);
return dateTime.format(formatter);
}
//获取当前日期的时间串2022-05-08
private String dateStr(){
LocalDate localDate = LocalDate.now();
LocalDate yestDay = localDate.minusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return yestDay.format(formatter);
}
} }