feat: 前端新增雨量预测准确率
This commit is contained in:
parent
0caa1da229
commit
d78bfd381b
@ -170,20 +170,23 @@ const WeatherApp = {
|
|||||||
try {
|
try {
|
||||||
const hexID = WeatherUtils.decimalToHex(decimalId);
|
const hexID = WeatherUtils.decimalToHex(decimalId);
|
||||||
const stationID = `RS485-${hexID}`;
|
const stationID = `RS485-${hexID}`;
|
||||||
const endPlus3Str = (() => {
|
// 将预报查询范围按小时对齐:from 向下取整到整点;to 向上取整到整点,再 +3h
|
||||||
try {
|
const parseLocal = (s) => { try { return new Date(s); } catch { return null; } };
|
||||||
const d = new Date(endTime);
|
const floorHour = (d) => { const t = new Date(d); t.setMinutes(0,0,0); return t; };
|
||||||
if (!isNaN(d)) {
|
const ceilHour = (d) => { const t = new Date(d); if (t.getMinutes()||t.getSeconds()||t.getMilliseconds()) { t.setHours(t.getHours()+1); } t.setMinutes(0,0,0); return t; };
|
||||||
const d2 = new Date(d.getTime() + 3 * 60 * 60 * 1000);
|
const fmt = (d) => {
|
||||||
return WeatherUtils.formatDatetimeLocal(d2).replace('T', ' ') + ':00';
|
const y=d.getFullYear(); const m=String(d.getMonth()+1).padStart(2,'0'); const da=String(d.getDate()).padStart(2,'0');
|
||||||
}
|
const h=String(d.getHours()).padStart(2,'0'); const mi='00'; const s='00';
|
||||||
} catch (e) {}
|
return `${y}-${m}-${da} ${h}:${mi}:${s}`;
|
||||||
return endTime.replace('T', ' ') + ':00';
|
};
|
||||||
})();
|
const startD = parseLocal(startTime);
|
||||||
|
const endD = parseLocal(endTime);
|
||||||
|
const fromStr = startD && !isNaN(startD) ? fmt(floorHour(startD)) : startTime.replace('T',' ') + ':00';
|
||||||
|
const toStr = endD && !isNaN(endD) ? fmt(new Date(ceilHour(endD).getTime() + 3*60*60*1000)) : endTime.replace('T',' ') + ':00';
|
||||||
const forecastParams = new URLSearchParams({
|
const forecastParams = new URLSearchParams({
|
||||||
station_id: stationID,
|
station_id: stationID,
|
||||||
from: startTime.replace('T', ' ') + ':00',
|
from: fromStr,
|
||||||
to: endPlus3Str,
|
to: toStr,
|
||||||
provider: forecastProvider,
|
provider: forecastProvider,
|
||||||
versions: '3'
|
versions: '3'
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user