Commit dd8a3519 authored by 陈龙's avatar 陈龙

fix: 修复抽稀为0的问题

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