Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
da8c57a7
Commit
da8c57a7
authored
Apr 03, 2023
by
张瑶
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 曲线优化
parent
cf0d048d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
50 deletions
+133
-50
SingleChart.js
packages/extend-components/EC_HistoryView/src/SingleChart.js
+1
-0
index.js
packages/extend-components/EC_HistoryView/src/apis/index.js
+9
-0
index.js
packages/extend-components/EC_HistoryView/src/index.js
+92
-42
utils.js
packages/extend-components/EC_HistoryView/src/utils.js
+31
-8
No files found.
packages/extend-components/EC_HistoryView/src/SingleChart.js
View file @
da8c57a7
...
@@ -76,6 +76,7 @@ const SimgleChart = memo((props) => {
...
@@ -76,6 +76,7 @@ const SimgleChart = memo((props) => {
const
axisConfig
=
{
const
axisConfig
=
{
minorTick
:
{
minorTick
:
{
show
:
showGridLine
,
show
:
showGridLine
,
splitNumber
:
2
,
},
},
minorSplitLine
:
{
minorSplitLine
:
{
show
:
showGridLine
,
show
:
showGridLine
,
...
...
packages/extend-components/EC_HistoryView/src/apis/index.js
View file @
da8c57a7
...
@@ -23,3 +23,12 @@ export function getDeviceAlarmScheme(option) {
...
@@ -23,3 +23,12 @@ export function getDeviceAlarmScheme(option) {
...
option
,
...
option
,
});
});
}
}
// 导出设备指标历史数据
export
function
getExportDeviceHistoryUrl
(
data
)
{
return
request
({
url
:
`
${
monitorDeviceUrl
}
/ExportDeviceHistoryInfo`
,
method
:
REQUEST_METHOD_POST
,
data
,
});
}
packages/extend-components/EC_HistoryView/src/index.js
View file @
da8c57a7
import
React
,
{
useContext
,
useEffect
,
useMemo
,
useState
}
from
'react'
;
import
React
,
{
useContext
,
useEffect
,
useMemo
,
useState
}
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
PropTypes
from
'prop-types'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
{
Checkbox
,
ConfigProvider
,
DatePicker
,
Radio
,
Select
,
Spin
,
Tabs
,
Tooltip
}
from
'antd'
;
import
{
import
{
CloseCircleFilled
,
PlusCircleOutlined
,
QuestionCircleFilled
}
from
'@ant-design/icons'
;
Checkbox
,
ConfigProvider
,
DatePicker
,
Radio
,
Select
,
Spin
,
Tabs
,
Tooltip
,
Button
,
}
from
'antd'
;
import
{
CloseCircleFilled
,
PlusCircleOutlined
,
QuestionCircleFilled
,
DownloadOutlined
,
}
from
'@ant-design/icons'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
TimeRangePicker
from
'@wisdom-components/timerangepicker'
;
import
TimeRangePicker
from
'@wisdom-components/timerangepicker'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
BasicTable
from
'@wisdom-components/basictable'
;
import
BasicTable
from
'@wisdom-components/basictable'
;
import
{
getHistoryInfo
,
getDeviceAlarmScheme
}
from
'./apis'
;
import
{
getHistoryInfo
,
getDeviceAlarmScheme
,
getExportDeviceHistoryUrl
}
from
'./apis'
;
import
SimgleChart
from
'./SingleChart'
;
import
SimgleChart
from
'./SingleChart'
;
import
GridChart
from
'./GridChart'
;
import
GridChart
from
'./GridChart'
;
import
'./index.less'
;
import
'./index.less'
;
import
{
globalConfig
}
from
'antd/lib/config-provider'
;
const
{
RangePicker
}
=
DatePicker
;
const
{
RangePicker
}
=
DatePicker
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
...
@@ -19,16 +35,9 @@ const { Option } = Select;
...
@@ -19,16 +35,9 @@ const { Option } = Select;
const
startFormat
=
'YYYY-MM-DD 00:00:00'
;
const
startFormat
=
'YYYY-MM-DD 00:00:00'
;
const
endFormat
=
'YYYY-MM-DD 23:59:59'
;
const
endFormat
=
'YYYY-MM-DD 23:59:59'
;
const
timeFormat
=
'YYYY-MM-DD HH:mm:ss'
;
const
timeFormat
=
'YYYY-MM-DD HH:mm:ss'
;
const
dateFormat
=
'YYYYMMDD'
;
const
timeList
=
[
const
timeList
=
[
{
key
:
'oneHour'
,
name
:
'近1小时'
,
},
{
key
:
'fourHour'
,
name
:
'近4小时'
,
},
{
{
key
:
'twelveHours'
,
key
:
'twelveHours'
,
name
:
'近12小时'
,
name
:
'近12小时'
,
...
@@ -38,8 +47,12 @@ const timeList = [
...
@@ -38,8 +47,12 @@ const timeList = [
name
:
'近24小时'
,
name
:
'近24小时'
,
},
},
{
{
key
:
'yesterday'
,
key
:
'oneWeek'
,
name
:
'昨天'
,
name
:
'近1周'
,
},
{
key
:
'oneMonth'
,
name
:
'近1月'
,
},
},
];
];
...
@@ -54,7 +67,7 @@ const CheckboxData = [
...
@@ -54,7 +67,7 @@ const CheckboxData = [
{
{
key
:
'chartGrid'
,
key
:
'chartGrid'
,
label
:
'图表网格'
,
label
:
'图表网格'
,
checked
:
fals
e
,
checked
:
tru
e
,
showInCurve
:
true
,
showInCurve
:
true
,
showInTable
:
false
,
showInTable
:
false
,
},
},
...
@@ -108,6 +121,12 @@ const timeIntervalList = [
...
@@ -108,6 +121,12 @@ const timeIntervalList = [
unit
:
'h'
,
unit
:
'h'
,
name
:
'2小时'
,
name
:
'2小时'
,
},
},
{
key
:
'4'
,
zoom
:
'4'
,
unit
:
'h'
,
name
:
'4小时'
,
},
{
{
key
:
'6'
,
key
:
'6'
,
zoom
:
'6'
,
zoom
:
'6'
,
...
@@ -131,14 +150,6 @@ const updateTime = (key) => {
...
@@ -131,14 +150,6 @@ const updateTime = (key) => {
end
=
moment
(
key
[
1
]).
format
(
timeFormat
);
end
=
moment
(
key
[
1
]).
format
(
timeFormat
);
}
else
{
}
else
{
switch
(
key
)
{
switch
(
key
)
{
case
'oneHour'
:
start
=
moment
().
subtract
(
1
,
'hour'
).
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
break
;
case
'fourHour'
:
start
=
moment
().
subtract
(
4
,
'hour'
).
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
break
;
case
'twelveHours'
:
case
'twelveHours'
:
start
=
moment
().
subtract
(
12
,
'hour'
).
format
(
timeFormat
);
start
=
moment
().
subtract
(
12
,
'hour'
).
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
...
@@ -147,9 +158,13 @@ const updateTime = (key) => {
...
@@ -147,9 +158,13 @@ const updateTime = (key) => {
start
=
moment
().
subtract
(
24
,
'hour'
).
format
(
timeFormat
);
start
=
moment
().
subtract
(
24
,
'hour'
).
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
break
;
break
;
case
'yesterday'
:
case
'oneWeek'
:
start
=
moment
().
subtract
(
1
,
'days'
).
format
(
startFormat
);
start
=
moment
().
subtract
(
7
,
'day'
).
format
(
timeFormat
);
end
=
moment
().
subtract
(
1
,
'days'
).
format
(
endFormat
);
end
=
moment
().
format
(
timeFormat
);
break
;
case
'oneMonth'
:
start
=
moment
().
subtract
(
30
,
'day'
).
format
(
timeFormat
);
end
=
moment
().
format
(
timeFormat
);
break
;
break
;
}
}
}
}
...
@@ -466,7 +481,32 @@ const HistoryView = (props) => {
...
@@ -466,7 +481,32 @@ const HistoryView = (props) => {
);
);
};
};
const
exportExcelBtn
=
()
=>
{};
const
exportExcelBtn
=
()
=>
{
deviceParams
.
forEach
((
i
,
r
)
=>
{
let
timeFrom
=
dateRange
[
r
]?.
dateFrom
||
moment
().
format
(
startFormat
);
let
timeTo
=
dateRange
[
r
]?.
dateTo
||
moment
().
format
(
timeFormat
);
let
fileName
=
`数据报表-
${
i
.
deviceType
}
-
${
i
.
deviceCode
}
-
${
moment
(
timeFrom
).
format
(
dateFormat
,
)}
至
${
moment
(
timeTo
).
format
(
dateFormat
)}
`
;
getExportDeviceHistoryUrl
({
deviceType
:
i
.
deviceType
,
deviceCode
:
i
.
deviceCode
,
quotas
:
i
.
sensors
,
startTime
:
timeFrom
,
endTime
:
timeTo
,
fileName
:
fileName
,
})
.
then
((
res
)
=>
{
if
(
res
&&
res
.
code
===
-
1
)
return
message
.
error
(
res
.
msg
);
const
url
=
`
${
window
.
location
.
origin
}
/PandaCore/GCK/FileHandleContoller/Download/name?name=
${
res
.
data
}
&_site=
${
globalConfig
?.
userInfo
?.
site
}
`;
const aDom = document.createElement('a');
aDom.href = url;
aDom.click();
aDom.remove();
})
.catch((err) => {});
});
};
const handleTableData = (data) => {
const handleTableData = (data) => {
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
...
@@ -575,18 +615,32 @@ const HistoryView = (props) => {
...
@@ -575,18 +615,32 @@ const HistoryView = (props) => {
});
});
};
};
const handleDataThinKey = (diffDays) => {
// edit by zy 根据选择的时长控制抽稀频度
if (diffDays >= 7 && diffDays < 15) {
return { unit: 'h', zoom: '2' };
} else if (diffDays >= 15 && diffDays < 30) {
return { unit: 'h', zoom: '4' };
} else if (diffDays >= 30) {
return { unit: 'h', zoom: '6' };
} else {
return {};
}
};
// 处理接口服务参数的变化
// 处理接口服务参数的变化
const onChangeParams = (value = {}) => {
const onChangeParams = (value = {}) => {
const { dateRange, isDilute, ignoreOutliers, zoom, unit } = value;
const { dateRange, isDilute, ignoreOutliers, zoom, unit } = value;
const requestArr = [];
const requestArr = [];
const
acrossTables
=
[]
const acrossTables = []
;
deviceParams.forEach((i) => {
deviceParams.forEach((i) => {
if
(
i
.
sensors
&&
i
.
deviceCode
&&
i
.
deviceCode
)
acrossTables
.
push
(
_
.
omit
(
i
,
[
'pointAddressID'
]))
if (i.sensors && i.deviceCode && i.deviceCode)
acrossTables.push(_.omit(i, ['pointAddressID']));
});
});
if
(
!
acrossTables
?.
length
)
{
if
(!acrossTables?.length)
{
handleTableData([]);
handleTableData([]);
setChartDataSource
([])
setChartDataSource([])
;
return
return
;
}
}
dateRange.forEach((item) => {
dateRange.forEach((item) => {
const param = {
const param = {
...
@@ -599,7 +653,9 @@ const HistoryView = (props) => {
...
@@ -599,7 +653,9 @@ const HistoryView = (props) => {
dateTo: item.dateTo,
dateTo: item.dateTo,
acrossTables,
acrossTables,
};
};
requestArr
.
push
(
getHistoryInfo
(
param
));
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
requestArr.push(getHistoryInfo({ ...param, ...zoomParam }));
});
});
setLoading(true);
setLoading(true);
Promise.all(requestArr).then((results) => {
Promise.all(requestArr).then((results) => {
...
@@ -722,12 +778,12 @@ const HistoryView = (props) => {
...
@@ -722,12 +778,12 @@ const HistoryView = (props) => {
left: <h3>{title}</h3>,
left: <h3>{title}</h3>,
right: (
right: (
<div className={`
$
{
prefixCls
}
-
extra
-
right
`}>
<div className={`
$
{
prefixCls
}
-
extra
-
right
`}>
{
/* {
activeTabKey === 'table' && (
{activeTabKey === 'table' && (
<Button onClick={exportExcelBtn}>
<Button
type="link"
onClick={exportExcelBtn}>
<DownloadOutlined />
<DownloadOutlined />
下载
下载
</Button>
</Button>
)}
*/
}
)}
</div>
</div>
),
),
}}
}}
...
@@ -748,13 +804,7 @@ const HistoryView = (props) => {
...
@@ -748,13 +804,7 @@ const HistoryView = (props) => {
HistoryView.propTypes = {
HistoryView.propTypes = {
grid: PropTypes.bool,
grid: PropTypes.bool,
title: PropTypes.string,
title: PropTypes.string,
defaultChecked
:
PropTypes
.
oneOf
([
defaultChecked: PropTypes.oneOf(['twelveHours', 'roundClock', 'oneWeek', 'oneMonth']),
'oneHour'
,
'fourHour'
,
'twelveHours'
,
'roundClock'
,
'yesterday'
,
]),
tableProps: PropTypes.object,
tableProps: PropTypes.object,
deviceParams: PropTypes.arrayOf(
deviceParams: PropTypes.arrayOf(
PropTypes.objectOf({
PropTypes.objectOf({
...
...
packages/extend-components/EC_HistoryView/src/utils.js
View file @
da8c57a7
...
@@ -128,10 +128,37 @@ export const minMaxMarkPoint = (dataItem, index, dataSource) => {
...
@@ -128,10 +128,37 @@ export const minMaxMarkPoint = (dataItem, index, dataSource) => {
// 只有一个数据曲线时显示markline
// 只有一个数据曲线时显示markline
if
(
!
dataItem
||
dataSource
.
length
!==
1
)
return
{};
if
(
!
dataItem
||
dataSource
.
length
!==
1
)
return
{};
const
data
=
[];
const
data
=
[];
data
.
push
({
type
:
'min'
,
name
:
'最小
值'
,
label
:
{
color
:
'#FFFFFF'
}
});
data
.
push
({
type
:
'min'
,
name
:
'最小
: '
});
data
.
push
({
type
:
'max'
,
name
:
'最大
值'
,
label
:
{
color
:
'#FFFFFF'
}
});
data
.
push
({
type
:
'max'
,
name
:
'最大
: '
});
return
{
return
{
symbol
:
'pin'
,
symbolSize
:
1
,
symbolOffset
:
[
0
,
'50%'
],
label
:
{
formatter
:
'{b|{b} }{c|{c}}'
,
backgroundColor
:
window
.
globalConfig
&&
window
.
globalConfig
&&
window
.
globalConfig
.
variableTheme
?.
primaryColor
?
window
.
globalConfig
.
variableTheme
.
primaryColor
:
'#0087F7'
,
borderColor
:
'#ccc'
,
borderWidth
:
1
,
borderRadius
:
4
,
padding
:
[
2
,
10
],
lineHeight
:
22
,
position
:
'top'
,
distance
:
10
,
rich
:
{
b
:
{
color
:
'#fff'
,
},
c
:
{
color
:
'#fff'
,
fontSize
:
16
,
fontWeight
:
700
,
},
},
},
data
,
data
,
};
};
};
};
...
@@ -149,6 +176,7 @@ export const decorateAxisGridLine = (axis, showGrid) => {
...
@@ -149,6 +176,7 @@ export const decorateAxisGridLine = (axis, showGrid) => {
},
},
...(
axis
.
minorTick
||
{}),
...(
axis
.
minorTick
||
{}),
show
:
showGrid
,
show
:
showGrid
,
splitNumber
:
2
,
};
};
axis
.
minorSplitLine
=
{
axis
.
minorSplitLine
=
{
lineStyle
:
{
lineStyle
:
{
...
@@ -162,11 +190,6 @@ export const decorateAxisGridLine = (axis, showGrid) => {
...
@@ -162,11 +190,6 @@ export const decorateAxisGridLine = (axis, showGrid) => {
...(
axis
.
splitLine
||
{}),
...(
axis
.
splitLine
||
{}),
show
:
showGrid
,
show
:
showGrid
,
};
};
// axis.minorTick ? (axis.minorTick.show = true) : (axis.minorTick = { show: true });
// axis.minorSplitLine
// ? (axis.minorSplitLine.show = true)
// : (axis.minorSplitLine = { show: true });
// axis.splitLine ? (axis.splitLine.show = true) : (axis.splitLine = { show: true });
};
};
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment