Commit dd8a3519 authored by 陈龙's avatar 陈龙

fix: 修复抽稀为0的问题

parent 536d7df1
...@@ -3,12 +3,13 @@ import HistoryView from '../index'; ...@@ -3,12 +3,13 @@ import HistoryView from '../index';
import {MobileHistoryChart} from "../mobile"; import {MobileHistoryChart} from "../mobile";
const deviceParams = [ const deviceParams = [
/* { {
deviceCode: 'EGBF00000141', deviceCode: 'EGBF00000141',
sensors: '进水压力,出水瞬时流量,出水累计流量', // sensors: '进水压力,出水瞬时流量,出水累计流量',
sensors: '进水压力',
deviceType: '二供泵房', deviceType: '二供泵房',
pointAddressID: 208, pointAddressID: 208,
},*/ },
/* { /* {
// deviceCode: 'EGBF00000002', // deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018', // deviceCode: 'EGBF00000018',
...@@ -20,17 +21,17 @@ const deviceParams = [ ...@@ -20,17 +21,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": "进水压力,是否在线",
......
...@@ -610,7 +610,6 @@ const HistoryView = (props) => { ...@@ -610,7 +610,6 @@ const HistoryView = (props) => {
// 格式化时间对齐数据, 生成行数 // 格式化时间对齐数据, 生成行数
const timeData = {}; const timeData = {};
const buildDefaultData = (time) => { const buildDefaultData = (time) => {
const obj = {key: time, time: time}; const obj = {key: time, time: time};
data.forEach((item, index) => { data.forEach((item, index) => {
...@@ -683,11 +682,11 @@ const HistoryView = (props) => { ...@@ -683,11 +682,11 @@ const HistoryView = (props) => {
return Promise.resolve(); return Promise.resolve();
}); });
}; };
const handleTime = (diffDays, base = 1000) => { /* const handleTime = (diffDays, base = 1000) => {
let unit = 'min', zoom = 0; let unit = 'min', zoom = 0;
zoom = Math.ceil(diffDays * 24 * 60 / 1000).toFixed(); zoom = Math.ceil((diffDays || 1) * 24 * 60 / base).toFixed(0);
return {unit, zoom}; return {unit, zoom};
} }*/
const handleDataThinKey = (diffDays) => { const handleDataThinKey = (diffDays) => {
// edit by zy 根据选择的时长控制抽稀频度 // edit by zy 根据选择的时长控制抽稀频度
if (diffDays >= 7 && diffDays < 15) { if (diffDays >= 7 && diffDays < 15) {
...@@ -723,7 +722,7 @@ const HistoryView = (props) => { ...@@ -723,7 +722,7 @@ const HistoryView = (props) => {
if (i.sensors && i.deviceCode && i.deviceCode) if (i.sensors && i.deviceCode && i.deviceCode)
acrossTables.push(_.omit(i, ['pointAddressID'])); acrossTables.push(_.omit(i, ['pointAddressID']));
}); });
if (!acrossTables?.length||!dateRange.length) { if (!acrossTables?.length || !dateRange.length) {
handleTableData([]); handleTableData([]);
setChartDataSource([]); setChartDataSource([]);
return; return;
...@@ -740,8 +739,8 @@ const HistoryView = (props) => { ...@@ -740,8 +739,8 @@ const HistoryView = (props) => {
isBoxPlots: isBoxPlots, isBoxPlots: isBoxPlots,
}; };
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days'); let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
// let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {}; let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
let zoomParam = activeTabKey === 'curve' ? handleTime(diffDays,50) : {}; // let zoomParam = activeTabKey === 'curve' ? handleTime(diffDays, 100) : {}; // 备用方案
requestArr.push(getHistoryInfo({...param, ...zoomParam})); requestArr.push(getHistoryInfo({...param, ...zoomParam}));
}); });
setLoading(true); setLoading(true);
......
...@@ -88,9 +88,7 @@ const nameFormatter = (data, contrast, contrastOption, nameWithSensor) => { ...@@ -88,9 +88,7 @@ const nameFormatter = (data, contrast, contrastOption, nameWithSensor) => {
*/ */
const dataAccessor = (data, contrast, contrastOption) => { const dataAccessor = (data, contrast, contrastOption) => {
const dataModel = data?.dataModel ?? []; const dataModel = data?.dataModel ?? [];
let _currentYear = moment().format('YYYY'); const formatStr = contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00';
const formatStr =
contrastOption === 'day' ? `${_currentYear}-01-01 HH:mm:00` : `${_currentYear}-01-DD HH:mm:00`;
return dataModel return dataModel
.filter((item) => item.sensorName !== '是否在线') .filter((item) => item.sensorName !== '是否在线')
.map((item) => { .map((item) => {
...@@ -304,10 +302,10 @@ export const buildDefaultLegend = (option) => { ...@@ -304,10 +302,10 @@ export const buildDefaultLegend = (option) => {
}; };
}; };
const headTemplate = (param) => { const headTemplate = (param, opt) => {
if (!param) return ''; if (!param) return '';
const {name, axisValueLabel, axisType, axisValue} = param; const {name, axisValueLabel, axisType, axisValue} = param;
const timeFormat = 'YYYY-MM-DD HH:mm:ss'; const timeFormat = opt && opt.contrast ? (opt.contrastOption === 'day' ? 'HH:mm:ss' : 'YYYY-MM-DD') : 'YYYY-MM-DD HH:mm:ss';
const text = const text =
axisType === 'xAxis.time' ? moment(axisValue).format(timeFormat) : name || axisValueLabel; axisType === 'xAxis.time' ? moment(axisValue).format(timeFormat) : name || axisValueLabel;
return `<div style="border-bottom: 1px solid #F0F0F0; color: #808080; margin-bottom:${handlePx(5, 'px')}; padding-bottom: ${handlePx(5, 'px')};">${text}</div>`; return `<div style="border-bottom: 1px solid #F0F0F0; color: #808080; margin-bottom:${handlePx(5, 'px')}; padding-bottom: ${handlePx(5, 'px')};">${text}</div>`;
...@@ -354,18 +352,18 @@ const seriesTemplate = (param, unit) => { ...@@ -354,18 +352,18 @@ const seriesTemplate = (param, unit) => {
</div> </div>
`; `;
}; };
const tooltipAccessor = (unit) => { const tooltipAccessor = (unit, contrastOption) => {
return { return {
formatter: function (params, ticket, callback) { formatter: function (params, ticket, callback) {
let tooltipHeader = ''; let tooltipHeader = '';
let tooltipContent = ''; let tooltipContent = '';
if (isArray(params)) { if (isArray(params)) {
tooltipHeader = headTemplate(params[0]); tooltipHeader = headTemplate(params[0], contrastOption);
params.forEach((param) => { params.forEach((param) => {
tooltipContent += seriesTemplate(param, unit?.[param?.seriesIndex]); tooltipContent += seriesTemplate(param, unit?.[param?.seriesIndex]);
}); });
} else { } else {
tooltipHeader = headTemplate(params); tooltipHeader = headTemplate(params, contrastOption);
tooltipContent += seriesTemplate(params, unit?.[params?.seriesIndex]); tooltipContent += seriesTemplate(params, unit?.[params?.seriesIndex]);
} }
return ` return `
...@@ -725,7 +723,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth ...@@ -725,7 +723,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
}; };
} }
} else { } else {
tooltip = tooltipAccessor(series.map(item => item.unit)); tooltip = tooltipAccessor(series.map(item => item.unit), {contrastOption, contrast});
} }
tooltip.timeFormat = tooltipTimeFormat; tooltip.timeFormat = tooltipTimeFormat;
let _legendData = series.filter(item => !['最大值', '最小值'].includes(item.name)).map(item => item.name); let _legendData = series.filter(item => !['最大值', '最小值'].includes(item.name)).map(item => item.name);
......
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