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
70d93ba9
Commit
70d93ba9
authored
Jul 11, 2023
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增移动版本
parent
977a05fc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
226 additions
and
47 deletions
+226
-47
EC_HistoryView.md
...es/extend-components/EC_HistoryView/src/EC_HistoryView.md
+31
-11
index.js
packages/extend-components/EC_HistoryView/src/demos/index.js
+34
-27
index.js
packages/extend-components/EC_HistoryView/src/index.js
+0
-0
mobile.js
packages/extend-components/EC_HistoryView/src/mobile.js
+159
-0
utils.js
packages/extend-components/EC_HistoryView/src/utils.js
+2
-9
No files found.
packages/extend-components/EC_HistoryView/src/EC_HistoryView.md
View file @
70d93ba9
---
title
:
EC_HistoryView - 历史曲线
nav
:
title
:
业务组件
path
:
/extend-components
title
:
业务组件
path
:
/extend-components
group
:
path
:
/
path
:
/
---
# HistoryView 历史数据查看
...
...
@@ -12,9 +12,9 @@ group:
基础业务组件
-
曲线模式
-
数据强制自动抽稀
-
数据强制自动抽稀
-
表格模式
-
默认开启抽稀模式,可选择抽稀
-
默认开启抽稀模式,可选择抽稀
## 何时使用
...
...
@@ -45,11 +45,31 @@ group:
```
javascript
[
{
deviceCode
:
'EGBF00000146'
,
// 设备编码
sensors
:
'进水压力,出水瞬时流量'
,
// 设备查询指标
deviceCode
:
'二供泵房'
,
// 设备类型
},
...
{
deviceCode
:
'EGBF00000146'
,
// 设备编码
sensors
:
'进水压力,出水瞬时流量'
,
// 设备查询指标
deviceCode
:
'二供泵房'
,
// 设备类型
},
...
]
```
移动端参数
```
javascript
{
// date
date
:{
dateFrom
:
'2022-02-02 00:00:00'
,
dateTo
:
'2022-02-02 23:59:59'
,
}
// deviceParams
deviceParams
:[{
deviceCode
:
'EGBF00000146'
,
// 设备编码
sensors
:
'进水压力,出水瞬时流量'
,
// 设备查询指标
deviceCode
:
'二供泵房'
,
// 设备类型
},...],
// chartType
chartType
:
'lineChart'
||
'boxChart'
}
```
packages/extend-components/EC_HistoryView/src/demos/index.js
View file @
70d93ba9
import
React
from
'react'
;
import
HistoryView
from
'../index'
;
import
{
MobileHistoryChart
}
from
"../mobile"
;
const
deviceParams
=
[
// {
// deviceCode: 'EGBF00000146',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceType: '二供泵房',
// pointAddressID: 4,
// },
{
// deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018',
deviceCode
:
'XMYL00000345'
,
// deviceCode: 'EGBF00000014',
// sensors: '今日供水量,今日用电量,1#水箱液位,是否在线',
sensors
:
'进水压力'
,
deviceType
:
'熊猫压力表'
,
pointAddressID
:
4
,
},
// {
// deviceCode: 'EGJZ00001113',
// sensors: '出水压力',
// deviceType: '二供机组',
// pointAddressID: 4,
// },
// {
// deviceCode: 'EGBF00000146',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceType: '二供泵房',
// pointAddressID: 4,
// },
{
// deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018',
deviceCode
:
'XMYL00000345'
,
// deviceCode: 'EGBF00000014',
// sensors: '今日供水量,今日用电量,1#水箱液位,是否在线',
sensors
:
'进水压力'
,
deviceType
:
'熊猫压力表'
,
pointAddressID
:
4
,
},
// {
// deviceCode: 'EGJZ00001113',
// sensors: '出水压力',
// deviceType: '二供机组',
// pointAddressID: 4,
// },
];
const
Demo
=
()
=>
{
return
(
<
div
style
=
{{
height
:
700
}}
>
<
HistoryView
deviceParams
=
{
deviceParams
}
defaultModel
=
"table"
/>
<
/div
>
);
return
(
<
div
>
<
div
style
=
{{
height
:
700
}}
>
<
HistoryView
deviceParams
=
{
deviceParams
}
defaultModel
=
"curve"
/>
<
/div
>
<
div
style
=
{{
height
:
300
}}
>
<
MobileHistoryChart
deviceParams
=
{
deviceParams
}
chartType
=
{
'lineChart'
}
/
>
<
/div
>
<
/div
>
);
};
export
default
Demo
;
packages/extend-components/EC_HistoryView/src/index.js
View file @
70d93ba9
This diff is collapsed.
Click to expand it.
packages/extend-components/EC_HistoryView/src/mobile.js
0 → 100644
View file @
70d93ba9
import
React
,
{
useEffect
,
useMemo
,
useState
,
useContext
}
from
'react'
;
import
GridChart
from
"./GridChart"
;
import
{
ConfigProvider
}
from
"antd"
;
import
moment
from
"moment"
;
import
{
getDeviceAlarmScheme
,
getHistoryInfo
}
from
"./apis"
;
import
SimgleChart
from
"./SingleChart"
;
// deviceAlarmSchemes 用来获取对应的 方案的最大值/最小值 标记状态
// dataSource 获取的报警信息
// deviceParams,
// defaultDate,
// {
// deviceCode: 'XMYL00000345',
// sensors: '进水压力',
// deviceType: '熊猫压力表',
// pointAddressID: 4,
// },
//{
// "isDilute": true, // 抽稀
// "zoom": "30",// 抽稀
// "unit": "min",// 抽稀
// "ignoreOutliers": false, // 滤波
// "dateFrom": "2023-07-09 16:38:32",
// "dateTo": "2023-07-10 16:38:32",
// "acrossTables": [
// {
// "deviceCode": "XMYL00000297",
// "sensors": "进水压力,是否在线",
// "deviceType": "熊猫压力表"
// }
// ],
// "isBoxPlots": true // 箱线图
// }
const
DATE_FORMAT
=
'YYYY-MM-DD'
;
const
MobileHistoryChart
=
(
{
date
=
{
dateFrom
:
moment
().
format
(
`
${
DATE_FORMAT
}
00:00:00`
),
dateTo
:
moment
().
format
(
`
${
DATE_FORMAT
}
23:59:59`
)
},
deviceParams
=
[],
ignoreOutliers
=
true
,
isDilute
=
true
,
needMarkLine
=
true
,
showBoxOption
=
true
,
//
chartGrid
=
true
,
chartType
=
'lineChart'
,
// lineChart boxChart
}
)
=>
{
const
[
deviceAlarmSchemes
,
setDeviceAlarmSchemes
]
=
useState
(
null
);
const
[
chartDataSource
,
setChartDataSource
]
=
useState
(
null
);
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'history-view'
);
const
isBoxPlots
=
deviceParams
?.
length
===
1
&&
deviceParams
[
0
]?.
sensors
?.
split
(
','
).
length
===
1
;
const
handleDataThinKey
=
(
diffDays
)
=>
{
// 移动端缩放的抽稀一倍
if
(
diffDays
>=
7
&&
diffDays
<
15
)
{
return
{
unit
:
'h'
,
zoom
:
'4'
};
}
else
if
(
diffDays
>=
15
&&
diffDays
<
30
)
{
return
{
unit
:
'h'
,
zoom
:
'8'
};
}
else
if
(
diffDays
>=
30
)
{
return
{
unit
:
'h'
,
zoom
:
'12'
};
}
else
if
(
diffDays
<
7
&&
diffDays
>=
2
)
{
return
{
unit
:
'min'
,
zoom
:
'80'
};
}
else
if
(
diffDays
<
2
&&
diffDays
>=
1
)
{
return
{
unit
:
'min'
,
zoom
:
'60'
};
}
else
{
return
{
unit
:
'min'
,
zoom
:
'20'
};
}
};
const
getDataSource
=
()
=>
{
let
diffDays
=
moment
(
date
.
dateTo
).
diff
(
moment
(
date
.
dateFrom
),
'days'
);
const
thinKey
=
handleDataThinKey
(
diffDays
);
const
acrossTables
=
deviceParams
.
map
(
item
=>
{
let
_item
=
{...
item
};
let
_sensorArr
=
_item
.
sensors
.
split
(
','
);
if
(
!
_sensorArr
.
includes
(
'是否在线'
))
{
_sensorArr
.
push
(
'是否在线'
)
}
return
_item
;
});
let
_params
=
{
...
date
,
isBoxPlots
,
ignoreOutliers
,
isDilute
,
...
thinKey
,
acrossTables
};
getHistoryInfo
({...
_params
}).
then
(
res
=>
{
let
data
=
[];
const
{
dateFrom
,
dateTo
}
=
date
;
if
(
res
.
code
===
0
&&
res
.
data
.
length
)
{
res
.
data
.
forEach
((
d
)
=>
{
d
.
dateFrom
=
dateFrom
||
''
;
d
.
dateTo
=
dateTo
||
''
;
});
deviceParams
.
forEach
((
p
)
=>
{
// 返回数据按查询指标顺序排序
const
sensors
=
p
.
sensors
?.
split
(
','
)
??
[];
const
list
=
sensors
.
map
((
s
)
=>
{
const
dataItem
=
res
.
data
.
find
(
(
d
)
=>
d
.
stationCode
===
p
.
deviceCode
&&
d
.
sensorName
===
s
,
);
if
(
dataItem
)
{
dataItem
.
dateFrom
=
dateFrom
||
''
;
dataItem
.
dateTo
=
dateTo
||
''
;
return
dataItem
;
}
else
{
return
{};
}
});
data
=
data
.
concat
(
list
);
});
}
setChartDataSource
(
data
);
})
};
const
getScheme
=
()
=>
{
getDeviceAlarmScheme
({
data
:
deviceParams
.
map
((
item
)
=>
({
deviceType
:
item
.
deviceType
,
deviceCode
:
item
.
deviceCode
,
pointAddressID
:
item
.
pointAddressID
,
sensorName
:
item
.
sensors
,
})),
}).
then
((
res
)
=>
{
if
(
res
.
code
===
0
)
setDeviceAlarmSchemes
(
res
.
data
||
[]);
else
setDeviceAlarmSchemes
([]);
return
Promise
.
resolve
();
}).
catch
((
err
)
=>
{
setDeviceAlarmSchemes
([]);
return
Promise
.
resolve
();
});
}
useEffect
(()
=>
{
getDataSource
();
getScheme
();
},
[])
return
deviceAlarmSchemes
&&
chartDataSource
?
<
SimgleChart
showBoxOption
=
{
showBoxOption
}
curveCenter
=
{
true
}
chartGrid
=
{
chartGrid
}
prefixCls
=
{
prefixCls
}
dataSource
=
{
chartDataSource
}
chartType
=
{
isBoxPlots
?
chartType
:
null
}
deviceAlarmSchemes
=
{
deviceAlarmSchemes
}
/> : nul
l
}
export
{
MobileHistoryChart
}
\ No newline at end of file
packages/extend-components/EC_HistoryView/src/utils.js
View file @
70d93ba9
import
moment
from
'moment'
;
import
_
,
{
isArray
}
from
'lodash'
;
import
_
,
{
isArray
}
from
'lodash'
;
/** 轴宽度, 用于计算多轴显示时, 轴线偏移和绘图区域尺寸 */
const
axisWidth
=
40
;
...
...
@@ -265,7 +265,6 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
const
showBoxOption
=
_
.
get
(
config
,
'showBoxOption'
,
false
);
// 自定义属性
const
restOption
=
_
.
pick
(
cusOption
,
[
'title'
,
'legend'
]);
// 一种指标一个y轴
const
yAxisMap
=
new
Map
();
dataSource
.
forEach
((
item
,
index
)
=>
{
...
...
@@ -336,7 +335,6 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
};
const
seriesTemplate
=
(
param
,
unit
)
=>
{
if
(
!
param
)
return
''
;
console
.
log
(
param
);
const
{
value
,
encode
}
=
param
;
// const val = value[encode.y[0]];
const
_unit
=
unit
||
'Mpa'
;
...
...
@@ -535,13 +533,8 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
let _unit = '';
series = series.map((item) => {
_unit = item.unit;
let _item = { ...item, symbol: 'none' };
/* _item.data = _item?.data?.map(d => {
return d[1] || null
}) || [];*/
return _item;
return {...item, symbol: 'none'};
});
console.log(series);
[[..._minData], [..._maxData]].forEach((item, index) => {
series.push({
name: index === 0 ? '最小值' : '最大值',
...
...
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