fix: 传参最近3个月内(90天)
parent
604549b6a5
commit
89f7726b45
|
@ -1,56 +1,80 @@
|
|||
import axios from 'axios'
|
||||
// 获取今天以及 90 天之前的日期,以 2024-06-01 的格式返回
|
||||
|
||||
function getDatesFormatted() {
|
||||
// 获取今天的日期
|
||||
const today = new Date()
|
||||
|
||||
// 获取90天前的日期
|
||||
const ninetyDaysAgo = new Date(today)
|
||||
ninetyDaysAgo.setDate(today.getDate() - 90)
|
||||
|
||||
// 格式化日期函数
|
||||
function formatDate(date) {
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
// 返回格式化后的日期
|
||||
return {
|
||||
today: formatDate(today),
|
||||
ninetyDaysAgo: formatDate(ninetyDaysAgo)
|
||||
}
|
||||
}
|
||||
|
||||
// 单位机时统计
|
||||
export const getDepartDuration = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopByOrg?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.then(function(response) {
|
||||
.post(`/screen_server/hpc/findTopByOrg?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
// 软件机时统计
|
||||
export const getSoftwareDuration = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopBySoft?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.then(function(response) {
|
||||
.post(`/screen_server/hpc/findTopBySoft?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
// 当前在用软件
|
||||
export const getInUseSoftware = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopSoftList?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.then(function(response) {
|
||||
.post(`/screen_server/hpc/findTopSoftList?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
// 用户机时用量
|
||||
export const getUserUseTrend = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findTopByUser?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.then(function(response) {
|
||||
.post(`/screen_server/hpc/findTopByUser?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
// 软件集成数量
|
||||
export const getSoftwareIntegrate = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findSoftCount?startDate=2024-05-01&endDate=2024-06-30')
|
||||
.then(function(response) {
|
||||
.post(`/screen_server/hpc/findSoftCount?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
|
@ -58,20 +82,20 @@ export const getSoftwareIntegrate = () =>
|
|||
export const getHelp = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/help/query')
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
// 实时利用率
|
||||
export const getRealTimeUtilization = () =>
|
||||
axios
|
||||
.get('/prometheus/api/v1/query?query=avg(1 - avg(rate(node_cpu_seconds_total{mode="idle"}[2m])) by (instance)) * 100')
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
|
@ -79,10 +103,10 @@ export const getRealTimeUtilization = () =>
|
|||
export const getAverageUtilizationTrend = () =>
|
||||
axios
|
||||
.get('/prometheus/api/v1/query_range')
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
||||
|
@ -90,9 +114,9 @@ export const getAverageUtilizationTrend = () =>
|
|||
export const getPlateformSum = () =>
|
||||
axios
|
||||
.post('/screen_server/hpc/findSum')
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue