| | |
| | | import com.dsh.guns.modular.system.model.*; |
| | | import com.dsh.guns.modular.system.service.ICityService; |
| | | import com.dsh.guns.modular.system.service.IRegionService; |
| | | import com.dsh.guns.modular.system.service.TOperatorService; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.google.maps.internal.ApiResponse; |
| | | import groovyjarjarpicocli.CommandLine; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | @Autowired |
| | | private SiteClient siteClient; |
| | | private String PREFIX = "/system/gateData/"; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private TOperatorService operatorService; |
| | | /** |
| | | * 跳转到充值记录页面 |
| | | */ |
| | | @RequestMapping("") |
| | | public String index(Model model) { |
| | | List<TOperator> list = operatorService.list(new QueryWrapper<TOperator>().ne("state", 3)); |
| | | model.addAttribute("list",list); |
| | | return PREFIX + "GateData.html"; |
| | | } |
| | | /** |
| | | * 获取教练类型列表 |
| | | * 获取闸机数据列表 |
| | | */ |
| | | @RequestMapping("/list") |
| | | @ResponseBody |
| | | public Object list() { |
| | | List<Site> list = siteClient.getList(); |
| | | public Object list(Integer storeId) { |
| | | try { |
| | | for (Site site : list) { |
| | | String apiUrl = "https://try.daowepark.com/v7/user_api/general/spaceDoorData?space_id=" + site.getId(); |
| | | if (storeId!=null){ |
| | | String apiUrl = "https://try.daowepark.com/v7/user_api/general/spaceDoorData?space_id="+storeId; |
| | | URL url = new URL(apiUrl); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | |
| | | System.out.println("请求失败: " + responseCode); |
| | | } |
| | | } |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return new ArrayList<>(); |
| | | } |
| | | /** |
| | | * 获取教练类型列表 |
| | | */ |
| | | @RequestMapping("/totalNum") |
| | | @ResponseBody |
| | | public Object totalNum(Integer storeId) { |
| | | try { |
| | | String apiUrl = "https://try.daowepark.com/v7/user_api/general/spaceDoorData?space_id="+storeId; |
| | | 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(); |
| | | GateDataResponse res = objectMapper.readValue(data, GateDataResponse.class); |
| | | // 访问Java对象中的数据 |
| | | int code = res.getCode(); |
| | | String message = res.getMessage(); |
| | | // 场地总入场人数 |
| | | int totalNum = res.getData().getTotal_num(); |
| | | return totalNum; |
| | | |
| | | } else { |
| | | System.out.println("请求失败: " + responseCode); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |