liujie
2023-10-26 e030255c23c7ba3e2cbad1036a810d6d72fa864f
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/code/GameDataController.java
@@ -205,7 +205,7 @@
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object list(String storeId) {
    public Object list(String range,String storeId) {
        Map<String, Object> result = new HashMap<>();
        try {
            // 年度数据
@@ -214,7 +214,7 @@
            // 创建 POST 请求
            HttpPost httpPost = new HttpPost("https://try.daowepark.com/v7/user_api/general/getBatterData");
            // 设置请求体数据
            String postData = "sign=0DB011836143EEE2C2E072967C9F4E4B&space_id="+storeId+"&date_type=y"+"&year=";
            String postData = "sign=0DB011836143EEE2C2E072967C9F4E4B&space_id="+storeId+"&date_type="+range+"&year=";
            StringEntity entity = new StringEntity(postData, ContentType.APPLICATION_FORM_URLENCODED);
            httpPost.setEntity(entity);
@@ -238,33 +238,7 @@
                // 年度数据
                result.put("yDataList", dataList);
            }
            // 获取月度数据 (今年的十二个月数据)
            Calendar calendar = Calendar.getInstance();
            // 当前年份
            int year = calendar.get(Calendar.YEAR);
            // 月度数据
            // 创建 HttpClient 实例
            HttpClient httpClient1 = HttpClients.createDefault();
            // 创建 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="+year;
            StringEntity entity1 = new StringEntity(postData1, ContentType.APPLICATION_FORM_URLENCODED);
            httpPost1.setEntity(entity1);
            // 执行请求
            HttpResponse response1 = httpClient1.execute(httpPost1);
            // 处理响应
            HttpEntity responseEntity1 = response1.getEntity();
            if (responseEntity1 != null) {
                String responseData1 = EntityUtils.toString(responseEntity1);
                ObjectMapper objectMapper = new ObjectMapper();
                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);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -322,10 +296,10 @@
     */
    @RequestMapping("/listSUTU1")
    @ResponseBody
    public Object listSUTU1(String gameId, String time, String spaceId, String cityCode) {
    public Object listSUTU1(String range,String gameId, String time, String spaceId, String cityCode) {
        Map<String, Object> result = new HashMap<>();
        try {
            String apiUrl = "https://try.daowepark.com/v7/user_api/general/getSingleGameData?game_id=" + gameId + "&date_type=" + "y" + "&date=" + "" + "&space_id=" + spaceId + "&city_code=" + cityCode;
            String apiUrl = "https://try.daowepark.com/v7/user_api/general/getSingleGameData?game_id=" + gameId + "&date_type=" + range + "&date=" + time + "&space_id=" + spaceId + "&city_code=" + cityCode;
            URL url = new URL(apiUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
@@ -352,42 +326,6 @@
                }
                result.put("data1", list);
                result.put("years", years);
                String monthUrl = "";
                // 月度
                if (!time.contains("-")) {
                    monthUrl = "https://try.daowepark.com/v7/user_api/general/getSingleGameData?game_id=" + gameId + "&date_type=" + "m" + "&date=" + time + "&space_id=" + spaceId + "&city_code=" + cityCode;
                } else {
                    monthUrl = "https://try.daowepark.com/v7/user_api/general/getSingleGameData?game_id=" + gameId + "&date_type=" + "d" + "&date=" + time + "&space_id=" + spaceId + "&city_code=" + cityCode;
                }
                URL url1 = new URL(monthUrl);
                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();
                    SUTUOne res1 = objectMapper1.readValue(data1, SUTUOne.class);
                    List<SUTUDataOne> list2 = res1.getData().getList();
                    List<String> monthOrDays = new ArrayList<>();
                    for (SUTUDataOne sutuDataOne : list2) {
                        monthOrDays.add(sutuDataOne.getDate());
                    }
                    result.put("data2", list2);
                    result.put("monthOrDays", monthOrDays);
                    return result;
                } else {
                    System.out.println("请求失败: " + responseCode1);
                }
            }
            return result;
        } catch (ProtocolException e) {