fix: 传参最近3个月内(90天)
parent
604549b6a5
commit
89f7726b45
|
@ -1,56 +1,80 @@
|
||||||
import axios from 'axios'
|
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 = () =>
|
export const getDepartDuration = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/findTopByOrg?startDate=2024-05-01&endDate=2024-06-30')
|
.post(`/screen_server/hpc/findTopByOrg?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 软件机时统计
|
// 软件机时统计
|
||||||
export const getSoftwareDuration = () =>
|
export const getSoftwareDuration = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/findTopBySoft?startDate=2024-05-01&endDate=2024-06-30')
|
.post(`/screen_server/hpc/findTopBySoft?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 当前在用软件
|
// 当前在用软件
|
||||||
export const getInUseSoftware = () =>
|
export const getInUseSoftware = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/findTopSoftList?startDate=2024-05-01&endDate=2024-06-30')
|
.post(`/screen_server/hpc/findTopSoftList?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 用户机时用量
|
// 用户机时用量
|
||||||
export const getUserUseTrend = () =>
|
export const getUserUseTrend = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/findTopByUser?startDate=2024-05-01&endDate=2024-06-30')
|
.post(`/screen_server/hpc/findTopByUser?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
// 软件集成数量
|
// 软件集成数量
|
||||||
export const getSoftwareIntegrate = () =>
|
export const getSoftwareIntegrate = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/findSoftCount?startDate=2024-05-01&endDate=2024-06-30')
|
.post(`/screen_server/hpc/findSoftCount?startDate=${getDatesFormatted().today}&endDate=${getDatesFormatted().ninetyDaysAgo}`)
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -58,20 +82,20 @@ export const getSoftwareIntegrate = () =>
|
||||||
export const getHelp = () =>
|
export const getHelp = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/help/query')
|
.post('/screen_server/hpc/help/query')
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
// 实时利用率
|
// 实时利用率
|
||||||
export const getRealTimeUtilization = () =>
|
export const getRealTimeUtilization = () =>
|
||||||
axios
|
axios
|
||||||
.get('/prometheus/api/v1/query?query=avg(1 - avg(rate(node_cpu_seconds_total{mode="idle"}[2m])) by (instance)) * 100')
|
.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
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -79,10 +103,10 @@ export const getRealTimeUtilization = () =>
|
||||||
export const getAverageUtilizationTrend = () =>
|
export const getAverageUtilizationTrend = () =>
|
||||||
axios
|
axios
|
||||||
.get('/prometheus/api/v1/query_range')
|
.get('/prometheus/api/v1/query_range')
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -90,9 +114,9 @@ export const getAverageUtilizationTrend = () =>
|
||||||
export const getPlateformSum = () =>
|
export const getPlateformSum = () =>
|
||||||
axios
|
axios
|
||||||
.post('/screen_server/hpc/findSum')
|
.post('/screen_server/hpc/findSum')
|
||||||
.then(function(response) {
|
.then(function (response) {
|
||||||
return response.data
|
return response.data
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue