diff --git a/src/api/perfManage/goldTarget.ts b/src/api/perfManage/goldTarget.ts index 36ded63f..e72c223c 100644 --- a/src/api/perfManage/goldTarget.ts +++ b/src/api/perfManage/goldTarget.ts @@ -8,7 +8,7 @@ import { parseObjLineToHump } from '@/utils/parse-utils'; * @returns object */ export async function listgoldData(query: Record) { - console.log(query); + //console.log(query); let totalSQL = 'select count(*) as total from gold_kpi where 1=1 '; let rowsSQL = 'SELECT gold_kpi.*,kpi_title.en_title FROM gold_kpi LEFT JOIN kpi_title on gold_kpi.kpi_id=kpi_title.kpi_id where 1=1 '; @@ -76,3 +76,85 @@ export async function listgoldData(query: Record) { } return result; } + + + + + + +/** + * 查询黄金指标数据 + * @param query 查询参数 + * @returns object + */ +export async function goldData(query: Record) { + //console.log(query); + // 发起请求 + let insertKpiId: string[]=[]; + let insertWhere: string[]=[]; + query.goldArr.forEach((item: any)=> { + insertKpiId.push(`SUM(CASE WHEN kpi_id = '${item}' THEN value ELSE 0 END) AS ${item.split(".")[0]+'_'+item.split(".")[1]} `); + insertWhere.push(`'${item}'`); + }) + const result = await request({ + url: `/api/rest/databaseManagement/v1/select/omc_db/gold_kpi`, + method: 'get', + params: { + rowsSQL:`SELECT CONCAT(DATE_FORMAT(start_time, '%Y-%m-%d %H:'), LPAD(FLOOR(MINUTE(start_time) / ${query.particle}) * ${query.particle}, 2, '0'), ':00') AS time_interval,`+ + insertKpiId.join(",")+ + " FROM gold_kpi"+ + ` WHERE ne_type='UPF' and kpi_id in (${insertWhere.join(",")}) and start_time BETWEEN '${query.beginTime}' AND '${query.endTime}'`+ + ` GROUP BY DATE_FORMAT(start_time, '%Y-%m-%d %H:'), FLOOR(MINUTE(start_time) / ${query.particle})`+ + " ORDER BY start_time", + }, + timeout: 60_000, + }); + + // 解析数据 + if (result.code === RESULT_CODE_SUCCESS) { + const data: DataList = { + total: 0, + rows: [], + code: result.code, + msg: result.msg, + }; + result.data.data.forEach((item: any) => { + const itemData = item['gold_kpi']; + if (Array.isArray(itemData)) { + if (itemData.length === 1 && itemData[0]['total'] >= 0) { + data.total = itemData[0]['total']; + } else { + data.rows = itemData.map(v => parseObjLineToHump(v)); + } + } + }); + return data; + } + return result; +} + + +/** + * 查询网元可用黄金指标 + * @param neType 网元类型 + * @returns object + */ +export async function getGoldTitleByNE(neType: string) { + // 发起请求 + const result = await request({ + url: `/api/rest/databaseManagement/v1/elementType/omc_db/objectType/kpi_title`, + method: 'get', + params: { + SQL: `select * from kpi_title where ne_type = '${neType}' `, + }, + }); + // 解析数据 + if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) { + let data = result.data.data[0]; + return Object.assign(result, { + data: parseObjLineToHump(data['kpi_title']), + }); + } + return result; +} + diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 151e976d..5a7673a9 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -628,6 +628,8 @@ export default { value:'Value', startTime:'Start Time', endTime:'End Time', + particle: 'Particle Ssize', + timeFrame: 'Time Range', } }, traceManage: { diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 5d168c85..ad2dc2b4 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -627,7 +627,9 @@ export default { enTitle:'黄金指标项', value:'值', startTime:'开始时间', - endTime:'结束时间' + endTime:'结束时间', + particle:'颗粒度', + timeFrame:'时间范围', } }, traceManage: { diff --git a/src/views/perfManage/goldTarget/index.vue b/src/views/perfManage/goldTarget/index.vue index b717f13e..1e65dc2b 100644 --- a/src/views/perfManage/goldTarget/index.vue +++ b/src/views/perfManage/goldTarget/index.vue @@ -1,334 +1,245 @@ - +