13 changed files with 584 additions and 2712 deletions
@ -0,0 +1,147 @@ |
|||||||
|
import { http } from "@/api/http"; |
||||||
|
import { ModuleTypeEnum, RequestHttpEnum } from "@/enums/httpEnum"; |
||||||
|
import { ProjectDetail } from "@/api/path/project"; |
||||||
|
import { getLocalStorage, httpErrorHandle } from "@/utils"; |
||||||
|
import { RequestDataSourceConfig } from '@/store/modules/chartEditStore/chartEditStore.d' |
||||||
|
import { StorageEnum } from "@/enums/storageEnum"; |
||||||
|
import { SystemStoreEnum } from '@/store/modules/systemStore/systemStore.d' |
||||||
|
import { SelectDataSourceTypeAPIObj } from "@/enums/dataSourceEnum"; |
||||||
|
|
||||||
|
/* |
||||||
|
* 获取站点 |
||||||
|
*/ |
||||||
|
export const fetchDataSite = async (data: object) => { |
||||||
|
try { |
||||||
|
return await http(RequestHttpEnum.GET)<ProjectDetail>(`${ModuleTypeEnum.DATA}/get-site`) |
||||||
|
} catch { |
||||||
|
httpErrorHandle() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 获取设备 |
||||||
|
* @param data { |
||||||
|
* siteId // 站点
|
||||||
|
* } |
||||||
|
*/ |
||||||
|
|
||||||
|
export const fetchDataDevice = async (data: object) => { |
||||||
|
try { |
||||||
|
return await http(RequestHttpEnum.GET)<ProjectDetail>(`${ModuleTypeEnum.DATA}/get-entity`,data) |
||||||
|
} catch { |
||||||
|
httpErrorHandle() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 获取点位 |
||||||
|
* @param data { |
||||||
|
* siteId // 站点
|
||||||
|
* entityId // 设备
|
||||||
|
* } |
||||||
|
*/ |
||||||
|
export const fetchDataPoint = async (data: object) => { |
||||||
|
try { |
||||||
|
return await http(RequestHttpEnum.GET)<ProjectDetail>(`${ModuleTypeEnum.DATA}/get-point`, data) |
||||||
|
} catch { |
||||||
|
httpErrorHandle() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// {
|
||||||
|
// "queryType": 2,
|
||||||
|
// "site": "53",
|
||||||
|
// "width": "1d",
|
||||||
|
// "tenantId": 169,
|
||||||
|
// "interval":"1h",
|
||||||
|
// "points":[]
|
||||||
|
// }
|
||||||
|
|
||||||
|
/* |
||||||
|
* 收益参数 |
||||||
|
* @param params { |
||||||
|
* queryType = 2 |
||||||
|
* siteId // 站点
|
||||||
|
* entityId // 设备
|
||||||
|
* width = 1d |
||||||
|
* tenantId |
||||||
|
* interval |
||||||
|
* points = [] |
||||||
|
* } |
||||||
|
*/ |
||||||
|
|
||||||
|
export async function test (){ |
||||||
|
// const params = {
|
||||||
|
// "queryType": 1,
|
||||||
|
// "site": 56,
|
||||||
|
// "with": 30,
|
||||||
|
// "deviceSn": 454,
|
||||||
|
// "points": [
|
||||||
|
// 4,
|
||||||
|
// 7
|
||||||
|
// ],
|
||||||
|
// "tenantId": 169
|
||||||
|
// }
|
||||||
|
|
||||||
|
const params = { |
||||||
|
"queryType": 2, |
||||||
|
"site": 56, |
||||||
|
"with": "6h", |
||||||
|
"interval": "20m", |
||||||
|
"points": [], |
||||||
|
"tenantId": 169 |
||||||
|
} |
||||||
|
try { |
||||||
|
return await http(RequestHttpEnum.POST)<ProjectDetail>(`${ModuleTypeEnum.DATA}/get-by-iot`, params) |
||||||
|
} catch { |
||||||
|
httpErrorHandle() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function getPointParams(requestSource:RequestDataSourceConfig) { |
||||||
|
let params:any = { |
||||||
|
queryType: SelectDataSourceTypeAPIObj[requestSource.dataSourceType], |
||||||
|
site: requestSource.station, |
||||||
|
with: requestSource.recentTimeRange, |
||||||
|
deviceSn: String(requestSource.device), |
||||||
|
points: requestSource.points, |
||||||
|
tenantId: getToken() |
||||||
|
} |
||||||
|
|
||||||
|
return params |
||||||
|
} |
||||||
|
|
||||||
|
function getEarningParams(requestSource:RequestDataSourceConfig){ |
||||||
|
let params: any = { |
||||||
|
queryType: SelectDataSourceTypeAPIObj[requestSource.dataSourceType], |
||||||
|
site:requestSource.station, |
||||||
|
with: requestSource.recentTimeRange, |
||||||
|
interval: '20m', |
||||||
|
points: [], |
||||||
|
tenantId: getToken() |
||||||
|
} |
||||||
|
|
||||||
|
return params |
||||||
|
} |
||||||
|
|
||||||
|
export const fetchDataByIot = async (requestSource:RequestDataSourceConfig) => { |
||||||
|
let params:any = {} |
||||||
|
if(requestSource.dataSourceType === 'point') { |
||||||
|
params = getPointParams(requestSource) |
||||||
|
} else if(requestSource.dataSourceType === 'earning') { |
||||||
|
params = getEarningParams(requestSource) |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
return await http(RequestHttpEnum.POST)<ProjectDetail>(`${ModuleTypeEnum.DATA}/get-by-iot`, params) |
||||||
|
} catch { |
||||||
|
httpErrorHandle() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function getToken() { |
||||||
|
const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE) |
||||||
|
return info ? info[SystemStoreEnum.TENANT_INFO]['tenantId'] : undefined |
||||||
|
} |
||||||
@ -0,0 +1,85 @@ |
|||||||
|
|
||||||
|
/** |
||||||
|
* @description: 请求数据类型 |
||||||
|
*/ |
||||||
|
export enum DataSourceTypeEnum { |
||||||
|
// 收益
|
||||||
|
EARNING = 'earning', |
||||||
|
// 分
|
||||||
|
POINT = 'point' |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @description: 数据类型名称 |
||||||
|
*/ |
||||||
|
export const SelectDataSourceTypeNameObj = { |
||||||
|
[DataSourceTypeEnum.EARNING]: '收益数据', |
||||||
|
[DataSourceTypeEnum.POINT]: '点位数据', |
||||||
|
} |
||||||
|
|
||||||
|
export const SelectDataSourceTypeAPIObj = { |
||||||
|
[DataSourceTypeEnum.EARNING]: 2, |
||||||
|
[DataSourceTypeEnum.POINT]: 1, |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @description: 点位时间范围 |
||||||
|
*/ |
||||||
|
|
||||||
|
export enum EarningTimeRangeEnum { |
||||||
|
LAST_6h= '6h', |
||||||
|
LAST_12h= '12h', |
||||||
|
LAST_1d= '1d', |
||||||
|
LAST_2d= '2d', |
||||||
|
LAST_3d = '3d', |
||||||
|
LAST_4d = '4d', |
||||||
|
LAST_5d = '5d', |
||||||
|
LAST_6d = '6d', |
||||||
|
LAST_7d = '7d', |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @description: 点位时间范围名称 |
||||||
|
*/ |
||||||
|
export const EarningTimeRangeNameObj = { |
||||||
|
[EarningTimeRangeEnum.LAST_6h]: '最近6小时', |
||||||
|
[EarningTimeRangeEnum.LAST_12h]: '最近12小时', |
||||||
|
[EarningTimeRangeEnum.LAST_1d]: '最近1天', |
||||||
|
[EarningTimeRangeEnum.LAST_2d]: '最近2天', |
||||||
|
[EarningTimeRangeEnum.LAST_3d]: '最近3天', |
||||||
|
[EarningTimeRangeEnum.LAST_4d]: '最近4天', |
||||||
|
[EarningTimeRangeEnum.LAST_5d]: '最近5天', |
||||||
|
[EarningTimeRangeEnum.LAST_6d]: '最近6天', |
||||||
|
[EarningTimeRangeEnum.LAST_7d]: '最近7天', |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @description: 收益时间范围 |
||||||
|
*/ |
||||||
|
|
||||||
|
export enum PointsTimeRangeEnum { |
||||||
|
// 收益
|
||||||
|
LAST_30= '30m', |
||||||
|
LAST_25= '25m', |
||||||
|
LAST_20 = '20m', |
||||||
|
LAST_15 = '15m', |
||||||
|
LAST_10 = '10m', |
||||||
|
LAST_5 = '5m', |
||||||
|
LAST_1 = '1m', |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @description: // 收益时间范围名称
|
||||||
|
*/ |
||||||
|
export const PointsTimeRangeNameObj = { |
||||||
|
[PointsTimeRangeEnum.LAST_30]: '最近30分钟', |
||||||
|
[PointsTimeRangeEnum.LAST_25]: '最近25分钟', |
||||||
|
[PointsTimeRangeEnum.LAST_20]: '最近20分钟', |
||||||
|
[PointsTimeRangeEnum.LAST_15]: '最近15分钟', |
||||||
|
[PointsTimeRangeEnum.LAST_10]: '最近10分钟', |
||||||
|
[PointsTimeRangeEnum.LAST_5 ]: '最近5分钟', |
||||||
|
[PointsTimeRangeEnum.LAST_1 ]: '最近1分钟', |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue