166 lines
3.8 KiB
JavaScript
166 lines
3.8 KiB
JavaScript
import { httpget } from "../../utils/request";
|
|
import apiurl from "../apiurl";
|
|
import appconsts from "../appconsts";
|
|
import { shdrp } from "../_/st";
|
|
|
|
export const TmLenMap = {
|
|
'5mi': 'YYYY-MM-DD HH:mm'.length,
|
|
'15mi': 'YYYY-MM-DD HH:mm'.length,
|
|
'30mi': 'YYYY-MM-DD HH:mm'.length,
|
|
h: 'YYYY-MM-DD HH'.length,
|
|
d: 'YYYY-MM-DD'.length,
|
|
t: 'YYYY-MM-DD'.length,
|
|
m: 'YYYY-MM'.length,
|
|
y: 'YYYY'.length,
|
|
};
|
|
|
|
export async function shDrpSearch(stcd, tmtype, resultTm) {
|
|
const stm = resultTm[0].substr(0, TmLenMap[tmtype]);
|
|
const etm = resultTm[1].substr(0, TmLenMap[tmtype]);
|
|
|
|
const searchJson = {
|
|
type: tmtype,
|
|
adcd: appconsts.ADCD12,
|
|
stm,
|
|
etm,
|
|
stcds: JSON.stringify([stcd]),
|
|
debug: 0,
|
|
};
|
|
|
|
const data = await httpget(`${apiurl.pubapi}/sh/data/dsv4/rain`, searchJson);
|
|
if (data.code !== 200 && !data.data) {
|
|
return [];
|
|
}
|
|
|
|
return data.data.sort((o1, o2) => o1.tm > o2.tm ? 1 : -1);
|
|
}
|
|
|
|
export async function drpSearch(type, stcd, tmtype, resultTm) {
|
|
const stm = resultTm[0].substr(0, TmLenMap[tmtype]);
|
|
const etm = resultTm[1].substr(0, TmLenMap[tmtype]);
|
|
|
|
const searchJson = {
|
|
// type: tmtype,
|
|
adcd: appconsts.ADCD6,
|
|
stm,
|
|
etm,
|
|
stcd,
|
|
};
|
|
|
|
let url;
|
|
switch (type) {
|
|
case 'sk': url = `${apiurl.pubapi}/hbsk/pphis`; break;
|
|
case 'sw': url = `${apiurl.pubapi}/swqx/swpphis`; break;
|
|
case 'qx': url = `${apiurl.pubapi}/swqx/qxpphis`; break;
|
|
default: return [];
|
|
}
|
|
|
|
const data = await httpget(url, searchJson);
|
|
if (data.code !== 200 && !data.data) {
|
|
return [];
|
|
}
|
|
|
|
return data.data.sort((o1, o2) => o1.tm > o2.tm ? 1 : -1);
|
|
}
|
|
|
|
export async function shDrpSearchEx(stcds, tmtype, resultTm, yoy) {
|
|
const stm = resultTm[0].substr(0, TmLenMap[tmtype]);
|
|
const etm = resultTm[1].substr(0, TmLenMap[tmtype]);
|
|
|
|
const searchJson = {
|
|
type: tmtype,
|
|
adcd: appconsts.ADCD12,
|
|
stm,
|
|
etm,
|
|
stcds: JSON.stringify(stcds),
|
|
debug: 0,
|
|
};
|
|
if (yoy && (tmtype !== 't' && tmtype !== 'm' && tmtype !== 'y')) {
|
|
searchJson.yoy = yoy;
|
|
}
|
|
|
|
const data = await httpget(`${apiurl.pubapi}/sh/data/dsv4/rain`, searchJson);
|
|
if (data.code !== 200 && !data.data) {
|
|
return [];
|
|
}
|
|
|
|
return data.data.sort((o1, o2) => o1.tm > o2.tm ? 1 : -1);
|
|
}
|
|
|
|
export async function shStTotal(stcds, tmtype, resultTm) {
|
|
const stm = resultTm[0].substr(0, TmLenMap[tmtype]);
|
|
const etm = resultTm[1].substr(0, TmLenMap[tmtype]);
|
|
|
|
const searchJson = {
|
|
type: tmtype,
|
|
adcd: appconsts.ADCD12,
|
|
stm,
|
|
etm,
|
|
stcds: JSON.stringify(stcds),
|
|
};
|
|
|
|
const data = await httpget(`${apiurl.pubapi_old}/shquery/totalrain`, searchJson);
|
|
if (!data.obj) {
|
|
return [];
|
|
}
|
|
|
|
return data.obj;
|
|
}
|
|
|
|
export async function shDrpAdStat(tmtype, resultTm) {
|
|
const stm = resultTm[0].substr(0, TmLenMap[tmtype]);
|
|
const etm = resultTm[1].substr(0, TmLenMap[tmtype]);
|
|
|
|
const searchJson = {
|
|
type: tmtype,
|
|
adcd: appconsts.ADCD12,
|
|
stm,
|
|
etm,
|
|
};
|
|
|
|
const data = await httpget(`${apiurl.pubapi_old}/shquery/adcdrain`, searchJson);
|
|
if (!data.obj) {
|
|
return [];
|
|
}
|
|
|
|
return data.obj;
|
|
}
|
|
|
|
export async function shDrpExValues() {
|
|
const searchJson = {
|
|
adcd: appconsts.ADCD12,
|
|
};
|
|
|
|
const data = await httpget(`${apiurl.pubapi_old}/shquery/extremerain`, searchJson);
|
|
if (!data.obj) {
|
|
return [];
|
|
}
|
|
|
|
return data.obj;
|
|
}
|
|
|
|
export async function shDrpSearchAll(resultTm) {
|
|
const stm = resultTm[0].substr(0, TmLenMap.h);
|
|
const etm = resultTm[1].substr(0, TmLenMap.h);
|
|
|
|
const sts = await shdrp() || [];
|
|
const stcds = sts.map(o => o.stcd);
|
|
|
|
const searchJson = {
|
|
type: 'h',
|
|
adcd: appconsts.ADCD12,
|
|
stm,
|
|
etm,
|
|
stcds: JSON.stringify(stcds),
|
|
debug: 0,
|
|
};
|
|
|
|
const data = await httpget(`${apiurl.pubapi}/sh/data/dsv4/rain`, searchJson);
|
|
if (data.code !== 200 && !data.data) {
|
|
return [];
|
|
}
|
|
|
|
return data.data.sort((o1, o2) => o1.tm > o2.tm ? 1 : -1);
|
|
}
|
|
|