guonan
2025-06-06 cf4ed06dea0076e518319de24c5120bb3fe0dae9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import axios from "./requestHT";
 
// 获取Token
export async function fetchToken() {
  try {
    const response = await axios.post("/hp/auth/getToken", {
      username: "yunweiyonghu",
      password: "c2d6bba7f0a67701a97550684e39fa5f",
      systemName: "RS_SYSTEM",
    });
    const token = response.data.data.token;
    // console.log("Token fetched:", token);
    localStorage.setItem("HPToken", token);
    return token;
  } catch (error) {
    console.error("Failed to fetch token:", error);
  }
}
// 自动重新获取token
export function setupTokenRefresh() {
  const intervalTime = 28 * 60 * 1000;
  fetchToken().catch((error) => {
    console.error("Initial token fetch failed:", error);
  });
  setInterval(() => {
    fetchToken().catch((error) => {
      console.error("Periodic token fetch failed:", error);
    });
  }, intervalTime);
}
 
// 获取避险位置
export async function getSafeLocation(data) {
  const response = await axios.post("/hp/safeHavenLocation/getData", {
    filterObject: {
      year: 2024, // 动态传入的年份参数
    },
  });
  console.log("getSafeLocation:", response);
  return response.data;
}
// 获取避险线路
export async function getEscapeRoute(data) {
  const response = await axios.post("/hp/escapeRoute/getData", {
    filterObject: {
      year: 2024, // 动态传入的年份参数
    },
  });
  console.log("getEscapeRoute:", response);
  return response.data;
}
// 获取传感器列表
export async function getSensor(data) {
  const response = await axios.post("/hp/sensor/getData", {
    filterObject: {
      year: 2024, // 动态传入的年份参数
    },
  });
  console.log("getSensor:", response);
  return response.data;
}
// 获取雨量数据
export async function getRainfallData() {
  const response = await axios.post("/hp/rainfallCountyCity/getData", {
    filterObject: {},
    "pageSize": 1000
  });
  console.log("getRainfallData:", response);
  return response.data;
}
 
// 获取琉璃庙镇监测设备信息
export async function getDeviceInfoShg(data) {
  const response = await axios.post("/hp/deviceInfo/getData", {
    filterObject: {
      "dictDeviceType": data,
      "townCode": "110116110000"
    },
    "pageSize": 10000
  });
  return response.data;
}
 
// 获取北京市监测设备信息
export async function getDeviceInfo(data) {
  const response = await axios.post("/hp/deviceInfo/getData", {
 
    "currentPage": 1,
    "pageSize": 10000,
    "filterObject": {
      "belongObjList": [
        "1797461961110261762"
      ]
      // "id": "",
      // "deviceName": "",
      // "deviceCode": "",
      // "deviceClientId": "",
      // "dictDeviceType": "",
      // "hdName": "",
      // "installUnit": "",
      // "rtuUnit": "",
      // "dictDisasterType": "",
      // "dictCommunicationType": "",
      // "dictDeviceStatus": "",
      // "divisionDistrict": "",
      // "townCode": ""
    },
    "sortedList": [
      {
        "sorted": "createTime",
        "type": "desc"
      }
    ]
  })
 
  return response.data;
}
 
 
// 获取隐患点信息
export async function getDangerPoint(data) {
  const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
    filterObject: {
      "divisionCounty": "110116000000",
      "divisionTown": "110116110000",
      // "divisionCounty": null,
      // "divisionTown": null,
      "year": 2025
    },
    "pageSize": 10000
  });
  return response.data;
}
 
export async function fetchAndLoadDangerPoints(loadCallback) {
  let currentPage = 1;
  const pageSize = 100; // 每次请求的数据量
 
  while (true) {
    try {
      const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
        filterObject: {
          divisionCounty: "110111000000",
          divisionTown: null,
          year: 2025
        },
        pageSize: pageSize,
        currentPage: currentPage // 添加当前页码参数
      });
 
      const pageData = response.data?.data?.pageData;
 
      if (!Array.isArray(pageData)) {
        console.error("Expected an array in 'pageData', but got:", typeof pageData, pageData);
        break;
      }
 
      if (pageData.length === 0) break; // 没有更多数据了
 
      // 调用传入的回调函数,用于更新页面内容
      loadCallback(pageData);
 
      if (pageData.length < pageSize) break; // 如果本次返回的数据少于pageSize,说明已获取完所有数据
 
      currentPage++; // 更新下一页的页码
    } catch (error) {
      console.error("Error fetching danger points:", error);
      break;
    }
  }
}
 
 
 
// 根据年份获取雨量数据
export async function getRainfallDataYears(data) {
  const response = await axios.post("/hp/rainfallCountyCity/getData", {
    filterObject: {
      year: data
    },
    "pageSize": 1000
  });
  console.log("getRainfallData:", response);
  return response.data;
}