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