Commit e22b257e authored by 陈龙's avatar 陈龙

feat: 提交曲线版本

parent b6846e0f
...@@ -30,7 +30,7 @@ path: / ...@@ -30,7 +30,7 @@ path: /
## 多图表 ## 多图表
[//]: # (<code src="./demos/GridDemo.js"></code>) <code src="./demos/GridDemo.js"></code>
## API ## API
......
import {request} from '@wisdom-utils/utils'; import {instanceRequest, request} from '@wisdom-utils/utils';
const REQUEST_METHOD_GET = 'get'; const REQUEST_METHOD_GET = 'get';
const REQUEST_METHOD_POST = 'post'; const REQUEST_METHOD_POST = 'post';
...@@ -7,6 +7,10 @@ const baseUrl = typeof DUMI_TYPE !== 'undefined' && DUMI_TYPE === 'dumi' ? '/api ...@@ -7,6 +7,10 @@ const baseUrl = typeof DUMI_TYPE !== 'undefined' && DUMI_TYPE === 'dumi' ? '/api
const monitorDeviceUrl = `${baseUrl}/PandaMonitor/Monitor/Device`; const monitorDeviceUrl = `${baseUrl}/PandaMonitor/Monitor/Device`;
let _customRequest = (data) => {
return request({...data, headers: {spe: 1111}})
}
// 获取历史数据 // 获取历史数据
export function getHistoryInfo(data) { export function getHistoryInfo(data) {
return request({ return request({
......
...@@ -3,18 +3,18 @@ import HistoryView from '../index'; ...@@ -3,18 +3,18 @@ import HistoryView from '../index';
import {MobileHistoryChart} from "../mobile"; import {MobileHistoryChart} from "../mobile";
const deviceParams = [ const deviceParams = [
/* { /* {
deviceCode: 'EGBF00000141', deviceCode: 'EGBF00000141',
// sensors: '进水压力,出水瞬时流量,出水累计流量', // sensors: '进水压力,出水瞬时流量,出水累计流量',
sensors: '进水压力', sensors: '进水压力',
deviceType: '二供泵房', deviceType: '二供泵房',
pointAddressID: 208, pointAddressID: 208,
},*/
/* {
"deviceCode": "SYJ00000008",
"sensors": "瞬时流量",
"deviceType": "水源井"
},*/ },*/
/* {
"deviceCode": "SYJ00000008",
"sensors": "瞬时流量",
"deviceType": "水源井"
},*/
/* { /* {
// deviceCode: 'EGBF00000002', // deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018', // deviceCode: 'EGBF00000018',
...@@ -26,17 +26,17 @@ const deviceParams = [ ...@@ -26,17 +26,17 @@ const deviceParams = [
deviceType: '熊猫压力表', deviceType: '熊猫压力表',
pointAddressID: 4, pointAddressID: 4,
},*/ },*/
/* { /* {
deviceCode: 'EGJZ00000226', deviceCode: 'EGJZ00000226',
sensors: '出水压力', sensors: '出水压力',
deviceType: '二供机组', deviceType: '二供机组',
pointAddressID: 4, pointAddressID: 4,
},*/ },*/
/* { /* {
"deviceCode": "LLJ00000055", "deviceCode": "LLJ00000055",
"sensors": "正累计流量,瞬时流量,是否在线", "sensors": "正累计流量,瞬时流量,是否在线",
"deviceType": "流量计" "deviceType": "流量计"
}*/ }*/
/* { /* {
"deviceCode": "EGJZ00000163", "deviceCode": "EGJZ00000163",
"sensors": "进水压力,是否在线", "sensors": "进水压力,是否在线",
...@@ -48,11 +48,11 @@ const deviceParams = [ ...@@ -48,11 +48,11 @@ const deviceParams = [
"sensors": "出水累计流量", "sensors": "出水累计流量",
"deviceType": "流量计" "deviceType": "流量计"
} }
/* { /* {
"deviceCode": "JFJ00000001", "deviceCode": "JFJ00000001",
"sensors": "沉淀池投矾量瞬时,是否在线", "sensors": "沉淀池投矾量瞬时,是否在线",
"deviceType": "加矾间" "deviceType": "加矾间"
}*/ }*/
]; ];
const Demo = () => { const Demo = () => {
return ( return (
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
Tabs, Tabs,
Tooltip, Tooltip,
Button, Button,
message message, Segmented
} from 'antd'; } from 'antd';
import { import {
CloseCircleFilled, CloseCircleFilled,
...@@ -254,6 +254,7 @@ const HistoryView = (props) => { ...@@ -254,6 +254,7 @@ const HistoryView = (props) => {
const [timeOrder, setTimeOrder] = useState('descend'); const [timeOrder, setTimeOrder] = useState('descend');
const [chartType, setChartType] = useState('lineChart'); const [chartType, setChartType] = useState('lineChart');
const [showBoxOption, setShowBoxOption] = useState(true); const [showBoxOption, setShowBoxOption] = useState(true);
const [lineDataType, setLineDataType] = useState('特征曲线');
// 选择的时间范围值 // 选择的时间范围值
const dateRange = useMemo(() => { const dateRange = useMemo(() => {
if (timeValue === 'customer') { if (timeValue === 'customer') {
...@@ -298,6 +299,10 @@ const HistoryView = (props) => { ...@@ -298,6 +299,10 @@ const HistoryView = (props) => {
// 自定义模式: 快速选择 // 自定义模式: 快速选择
const onCustomerTimeChange = (key) => { const onCustomerTimeChange = (key) => {
if (key === 'oneMonth' && lineDataType === '原始曲线') {
setLineDataType('特征曲线');
message.info('时间区间超过7天,已切换为特征曲线')
}
setCustomerChecked(key); setCustomerChecked(key);
!!customerTime && setCustomerTime(null); !!customerTime && setCustomerTime(null);
}; };
...@@ -310,6 +315,11 @@ const HistoryView = (props) => { ...@@ -310,6 +315,11 @@ const HistoryView = (props) => {
setCustomerTime(value); setCustomerTime(value);
} else { } else {
setCustomerChecked(null); setCustomerChecked(null);
let diffDays = moment(value[1]).diff(moment(value[0]), 'days');
if (diffDays > 7 && lineDataType === '原始曲线') {
setLineDataType('特征曲线');
message.info('时间区间超过7天,已切换为特征曲线');
}
setCustomerTime(value); setCustomerTime(value);
} }
}; };
...@@ -461,7 +471,16 @@ const HistoryView = (props) => { ...@@ -461,7 +471,16 @@ const HistoryView = (props) => {
const onTimeIntervalChange = (value) => { const onTimeIntervalChange = (value) => {
setDataThinKey(value); setDataThinKey(value);
}; };
// 切换数据类型
const switchLineDataType = (e) => {
let _startDate = dateRange[0]?.dateFrom;
let _endDate = dateRange[0]?.dateTo;
let diffDays = moment(_endDate).diff(moment(_startDate), 'days');
if (e === '原始曲线' && diffDays > 7) {
return message.info('查阅原始曲线时,请选择小于或等于7天的时间间隔');
}
setLineDataType(e)
};
const renderCheckbox = (child, showJustLine) => { const renderCheckbox = (child, showJustLine) => {
const curveAccess = activeTabKey === 'curve' && child.showInCurve; const curveAccess = activeTabKey === 'curve' && child.showInCurve;
const tableAccess = activeTabKey === 'table' && child.showInTable; const tableAccess = activeTabKey === 'table' && child.showInTable;
...@@ -492,6 +511,12 @@ const HistoryView = (props) => { ...@@ -492,6 +511,12 @@ const HistoryView = (props) => {
> >
{isChart && isSingle && showBoxOption ? ( {isChart && isSingle && showBoxOption ? (
<> <>
<div key={''} className={`${prefixCls}-cover-item`}>
<Segmented value={lineDataType} options={['特征曲线', '原始曲线']} onChange={switchLineDataType}/>
<Tooltip title={'原始曲线数据量较大,请查阅小于7天的数据~'}>
<QuestionCircleFilled style={{marginLeft: 6}} className={`${prefixCls}-question`}/>
</Tooltip>
</div>
<div className={classNames(`${prefixCls}-label`)}>曲线形态</div> <div className={classNames(`${prefixCls}-label`)}>曲线形态</div>
<Radio.Group <Radio.Group
value={chartType} value={chartType}
...@@ -677,7 +702,10 @@ const HistoryView = (props) => { ...@@ -677,7 +702,10 @@ const HistoryView = (props) => {
return Promise.resolve(); return Promise.resolve();
}); });
}; };
const handleDataThinKey = (diffYears, diffDays, diffHours) => { const handleDataThinKey = (diffYears, diffDays, diffHours, lineDataType) => {
if (lineDataType === '原始曲线') {
return {unit: '', zoom: ''}
}
// edit by zy 根据选择的时长控制抽稀频度 // edit by zy 根据选择的时长控制抽稀频度
if (diffYears > 0) { if (diffYears > 0) {
return {unit: 'h', zoom: '48'} return {unit: 'h', zoom: '48'}
...@@ -732,7 +760,7 @@ const HistoryView = (props) => { ...@@ -732,7 +760,7 @@ const HistoryView = (props) => {
let diffYears = moment(item.dateTo).diff(moment(item.dateFrom), 'years'); let diffYears = moment(item.dateTo).diff(moment(item.dateFrom), 'years');
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days'); let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
let diffHours = moment(item.dateTo).diff(moment(item.dateFrom), 'hours'); let diffHours = moment(item.dateTo).diff(moment(item.dateFrom), 'hours');
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffYears, diffDays, diffHours) : {}; let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffYears, diffDays, diffHours, lineDataType) : {};
requestArr.push(getHistoryInfo({...param, ...zoomParam})); requestArr.push(getHistoryInfo({...param, ...zoomParam}));
}); });
setLoading(true); setLoading(true);
...@@ -788,7 +816,7 @@ const HistoryView = (props) => { ...@@ -788,7 +816,7 @@ const HistoryView = (props) => {
isBoxPlots: isBoxPlots, isBoxPlots: isBoxPlots,
}); });
}); });
}, [dateRange, dataConfig, deviceParams, chartType]); }, [dateRange, dataConfig, deviceParams, chartType, lineDataType]);
const handleChange = (pagination, filter, sort) => { const handleChange = (pagination, filter, sort) => {
if (sort.field === 'time') { if (sort.field === 'time') {
setTimeOrder(sort.order) setTimeOrder(sort.order)
...@@ -876,6 +904,8 @@ const HistoryView = (props) => { ...@@ -876,6 +904,8 @@ const HistoryView = (props) => {
}; };
// 获取字段配置 // 获取字段配置
const getDefaultOptions = () => { const getDefaultOptions = () => {
// 非单曲线、单指标不执行
if (deviceParams?.length !== 1 || (deviceParams?.length === 1 && deviceParams?.[0]?.sensors?.split(',')?.length > 1)) return;
getDictionaryInfoAll({ getDictionaryInfoAll({
level: '组件_ec_historyview' level: '组件_ec_historyview'
}).then(res => { }).then(res => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment