guonan
2025-06-10 2280e8be717608bb36c3cf921f129db24349396d
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
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"
      ],
      "townCode": data
      // "id": "",
      // "deviceName": "",
      // "deviceCode": "",
      // "deviceClientId": "",
      // "dictDeviceType": "",
      // "hdName": "",
      // "installUnit": "",
      // "rtuUnit": "",
      // "dictDisasterType": "",
      // "dictCommunicationType": "",
      // "dictDeviceStatus": "",
      // "divisionDistrict": "",
    },
    "sortedList": [
      {
        "sorted": "createTime",
        "type": "desc"
      }
    ]
  })
 
  return response.data;
}
 
 
// 获取隐患点信息
export async function getDangerPoint(data) {
 
  const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
 
    filterObject: {
      // divisionCounty其实可以不传
      // "divisionCounty": divisionCounty,
      "divisionTown": data,
      "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;
}
 
// 查询雨量计读数
export async function getYLJData(data) {
  // 获取当前时间
  const now = new Date();
 
  // 计算一小时前的时间
  const oneHourAgo = new Date(now.getTime() - 2 * 60 * 60 * 1000);
 
  // 格式化时间为YYYY-MM-DD HH:mm:ss
  const formatTime = (date) => {
    const pad = (num) => num.toString().padStart(2, '0');
    return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
  };
 
  const response = await axios.post("/hp/ylclyPacket/getData", {
    "currentPage": 1,
    "pageSize": 20,
    "filterObject": {
      "deviceName": "",
      "deviceCode": data,
      "sendTimeList": [
        formatTime(oneHourAgo),  // 一小时前
        formatTime(now)         // 当前时间
      ],
      "divisionDistrict": "110116000000",
      "townCode": "110116110000",
      "dictPacketsDataStatus": "1887255639886540806",
    }
  });
 
  console.log("getYLJData:", response);
  return response.data;
}
 
// 按照北京市code查询行政区code
export async function getAeraCode() {
  const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getHiddenDangerCountByDistrict", {
    "dictDisasterGrade": "",
    "dictDisasterType": "",
    "dictRiskLevel": "",
    "districtCode": "110000000000",
    "dictThreatObj": "",
    "year": "2025"
  });
  return response.data;
}
 
// 按照行政区code查询乡镇code
export async function getAeraTownCode(data) {
  const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getHiddenDangerTownCount", {
    "dictDisasterGrade": "",
    "dictDisasterType": "",
    "dictRiskLevel": "",
    "districtCode": data,
    "dictThreatObj": "",
    "year": "2025"
  });
  return response.data;
}