wangjuncheng
6 天以前 bf0eb543e2deab8a1629dd2a46f8e1cd191531e1
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
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;
}
 
// 按照北京市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;
}
 
// 根据乡镇Code获取隐患点(此接口包含隐患点数量查询)
export async function getDangerPoint(data) {
  const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
    filterObject: {
      "divisionTown": data,
      "year": 2025
    },
    "pageSize": 10000
  });
  return response.data;
}
 
 
// 分页获取行政区划隐患点信息
export async function getDangerPointByPage(data, pageNum) {
  const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", {
    filterObject: {
      "divisionCounty": data,
      "year": 2025
    },
    "pageSize": 50,
    "pageNum": pageNum,
  });
  return response.data;
}
 
 
// 监测设备接口
/**
 * @param {string} data - 雨量计设备类型id
 * @param {string} townCode - 乡镇code,可以查询乡镇监测设备信息
 */
export async function getDeviceInfo(data, townCode) {
  const response = await axios.post("/hp/deviceInfo/getData", {
    filterObject: {
      "dictCommunicationType": data,
      "townCodeList": [townCode],
      "year": 2025,
      // 所属项目
      "belongObjList": [
        "1797461961110261762"
      ],
    },
    "pageSize": 10000
  });
  return response.data;
}
 
// 接口多写几个应该无妨吧
export async function getDeviceNWJ(data, townCode) {
  const response = await axios.post("/hp/deviceInfo/getData", {
    filterObject: {
      "dictDeviceTypeList": [data],
      "townCodeList": [townCode],
      "year": 2025,
    },
    "pageSize": 10000
  });
  return response.data;
}
 
// 查询孙胡沟监测设备,dictCommunicationType为查询孙胡沟的雨量计
export async function getDeviceInfoSHG(data) {
  const response = await axios.post("/hp/deviceInfo/getData", {
    filterObject: {
      "dictCommunicationType": data,
      "townCodeList": ["110116110000"],
      "year": 2025,
    },
    "pageSize": 10000
 
  });
  return response.data;
}
 
 
// 分页查询行政区划监测设备信息
export async function getDeviceInfoByPage(data, pageNum) {
  const response = await axios.post("/hp/deviceInfo/getData", {
    filterObject: {
      "divisionDistrictList": [data],
      // 所属项目
      // 如果不加这个,则返回的全是强震仪(1933099069385355265)
      "belongObjList": [
        "1797461961110261762"
      ],
    },
    "pageSize": 50,
    "pageNum": pageNum
  });
  return response.data;
}
 
 
// 根据年份获取雨量数据
export async function getRainfallDataYears(data) {
  const response = await axios.post("/hp/rainfallCountyCity/getData", {
    filterObject: {
      year: data
    },
    "pageSize": 1000
  });
  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;
}
 
 
 
// 查询北京市监测设备的数量
export async function getDeviceCount(params = {}) {
  const response = await axios.get("/hp/device/statisticsCountyByDeviceType", {
    params
  });
  return response.data;
}
 
// 查询北京市避险场所
export async function getSafePoint(data) {
  const response = await axios.get("/hp/safeHavenLocation/getDataSelect", {
    params: {
      divisionId: data
    }
  });
  return response.data;
}
// 110116110218
 
 
 
// 查询北京市
export async function getAllCode() {
  const response = await axios.get("/hp/district/getAll");
  return response.data;
}
 
// 获取天气预报
export async function getWeather() {
  // 获取当前时间戳
  const currentTimestamp = Date.now();
 
  // 创建Date对象
  const currentDate = new Date(currentTimestamp);
 
  // 格式化为年-月-日(YYYY-MM-DD)
  const year = currentDate.getFullYear();
  const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以要+1
  const day = String(currentDate.getDate()).padStart(2, '0');
  const formattedDate = `${year}-${month}-${day}`;
 
  const response = await axios.get("/hp/weatherForecast/getSevenDaysWeather", {
    params: {
      inputDate: formattedDate
    }
  });
  return response.data;
}
 
// 监测设备中关联的隐患点的具体信息
export async function hdByDevice(data) {
  const response = await axios.get("/hp/sinoDzHiddenDangerPoint/getDetail", {
    params: {
      unifiedCode: data
    }
  });
  return response.data;
}