From 5df006aac405fe996fff71f7854e37c324892367 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期一, 09 十月 2023 18:27:48 +0800 Subject: [PATCH] 后台代码提交 --- cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/GameDataController.java | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 100 insertions(+), 19 deletions(-) diff --git a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/GameDataController.java b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/GameDataController.java index 609b06e..51c79c4 100644 --- a/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/GameDataController.java +++ b/cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/GameDataController.java @@ -102,8 +102,60 @@ } return new ArrayList<>(); } + + @RequestMapping("/listAll1") + @ResponseBody + public Object listAll1(String spaceId,String type,String date,String cityCode){ + if(spaceId==null){ + spaceId=""; + } + if(type==null){ + type="y"; + } + if(date==null){ + date=""; + } + if(cityCode==null){ + cityCode=""; + } +// String apiUrl1 = "https://try.daowepark.com/v7/user_api/general/accuracyGameRanking?space_id=1001"+spaceId+"&type="+type+"&date="+date+"&city_code="+cityCode; + String apiUrl1 = "https://try.daowepark.com/v7/user_api/general/accuracyGameRanking?space_id="+spaceId+"&type="+type+"&date="+date+"&city_code="+cityCode; + URL url1 = null; + try { + url1 = new URL(apiUrl1); + HttpURLConnection connection1 = (HttpURLConnection) url1.openConnection(); + connection1.setRequestMethod("GET"); + // 发送请求并获取响应 + int responseCode1 = connection1.getResponseCode(); + if (responseCode1 == HttpURLConnection.HTTP_OK) { + BufferedReader reader1 = new BufferedReader(new InputStreamReader(connection1.getInputStream())); + String line1; + StringBuilder response1 = new StringBuilder(); + while ((line1 = reader1.readLine()) != null) { + response1.append(line1); + } + reader1.close(); + // 处理响应数据 + String data1 = response1.toString(); + // 使用Jackson库将JSON字符串转换为Java对象 + ObjectMapper objectMapper1 = new ObjectMapper(); + AccuracyGameOne res1 = objectMapper1.readValue(data1, AccuracyGameOne.class); + List<AccuracyGameDataOne> data2 = res1.getData(); + return data2; + } + } catch (ProtocolException e) { + e.printStackTrace(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return new ArrayList<>(); + } /** - * 跳转到充值记录页面 + * 跳转到智慧球场数据统计页面 */ @RequestMapping("") public String index(Model model) { @@ -153,7 +205,7 @@ */ @RequestMapping("/list") @ResponseBody - public Object list(Integer storeId) { + public Object list(String storeId) { Map<String, Object> result = new HashMap<>(); try { // 年度数据 @@ -162,7 +214,7 @@ // 创建 POST 请求 HttpPost httpPost = new HttpPost("https://try.daowepark.com/v7/user_api/general/getBatterData"); // 设置请求体数据 - String postData = "sign=0DB011836143EEE2C2E072967C9F4E4B&space_id="+""+"&date_type=y"; + String postData = "sign=0DB011836143EEE2C2E072967C9F4E4B&space_id="+storeId+"&date_type=y"+"&year="; StringEntity entity = new StringEntity(postData, ContentType.APPLICATION_FORM_URLENCODED); httpPost.setEntity(entity); @@ -196,7 +248,7 @@ // 创建 POST 请求 HttpPost httpPost1 = new HttpPost("https://try.daowepark.com/v7/user_api/general/getBatterData"); // 设置请求体数据 - String postData1 = "sign=0DB011836143EEE2C2E072967C9F4E4B&space_id=1001&date_type=m&year=2022"; + String postData1 = "sign=0DB011836143EEE2C2E072967C9F4E4B&space_id=1001"+""+"&date_type=m"+"&year="+year; StringEntity entity1 = new StringEntity(postData1, ContentType.APPLICATION_FORM_URLENCODED); httpPost1.setEntity(entity1); // 执行请求 @@ -204,13 +256,12 @@ // 处理响应 HttpEntity responseEntity1 = response1.getEntity(); if (responseEntity1 != null) { - String responseData = EntityUtils.toString(responseEntity1); + String responseData1 = EntityUtils.toString(responseEntity1); ObjectMapper objectMapper = new ObjectMapper(); - Batter batter = objectMapper.readValue(responseData, Batter.class); + Batter batter = objectMapper.readValue(responseData1, Batter.class); result.put("totalNumber", batter.getData().getAll_batter_num()); result.put("totalTime", batter.getData().getAll_batter_time()); List<BatterData> dataList = batter.getData().getList(); - // 月度数据 result.put("mDataList", dataList); } @@ -351,7 +402,44 @@ return result; } /** - * 获取跨城赛统计 + * 获取90°准度赛全球总数 + */ + @RequestMapping("/cityGameOne") + @ResponseBody + public Object cityGameOne() { + Map<String, Object> result = new HashMap<>(); + try { + String apiUrl = "https://try.daowepark.com/v7/user_api/general/getAccuracyGameCount?space_id="; + URL url = new URL(apiUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + // 发送请求并获取响应 + int responseCode = connection.getResponseCode(); + if (responseCode == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder response = new StringBuilder(); + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + // 处理响应数据 + String data = response.toString(); + // 使用Jackson库将JSON字符串转换为Java对象 + ObjectMapper objectMapper = new ObjectMapper(); + CityGame res = objectMapper.readValue(data, CityGame.class); + result.put("totalNum", res.getData().getTotal_num()); + return result; + } + } + catch (IOException e) { + e.printStackTrace(); + } + return result; + } + + /** + * 获取跨城赛统计全球总数 */ @RequestMapping("/cityGame") @ResponseBody @@ -377,18 +465,11 @@ // 使用Jackson库将JSON字符串转换为Java对象 ObjectMapper objectMapper = new ObjectMapper(); CityGame res = objectMapper.readValue(data, CityGame.class); - // 场地总入场人数 - String totalNum = ""; - for (CityGameData datum : res.getData()) { - totalNum = datum.getTotal_num(); - } - result.put("totalNum", totalNum); - - - return result; - } + result.put("totalNum", res.getData().getTotal_num()); + return result; } - catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); } return result; -- Gitblit v1.7.1