Commit 6f5b036e authored by 涂茜's avatar 涂茜

fix: bug

parent eccb9363
Pipeline #27760 passed with stages
in 5 minutes 5 seconds
......@@ -212,7 +212,6 @@ const HistoryInfo = (props) => {
const [dataThinKey, setDataThinKey] = useState(timeIntervalList[0].key);
const [options, setOptions] = useState({});
const [colors, setColors] = useState(defaultColors);
const [params, setParams] = useState(historyInfoParams);
const [tableData, setTableData] = useState([]);
const [pageSize, setPageSize] = useState(20);
const [series, setSeries] = useState([]);
......@@ -237,9 +236,21 @@ const HistoryInfo = (props) => {
const seriesData = [];
resData.forEach((item) => {
const data = [];
item.dataModel.forEach((child) => {
data.push([moment(child.pt).valueOf(), child.pv]);
});
if (item.dataModel.length) {
if (timeValue === 'contrast') {
// 同期对比
item.dataModel.forEach((child) => {
const formatTime = moment(child.pt).format(
contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00',
);
data.push([moment(formatTime).valueOf(), child.pv]);
});
} else {
item.dataModel.forEach((child) => {
data.push([moment(child.pt).valueOf(), child.pv]);
});
}
}
const obj = {
name: item.equipmentName + '-' + item.sensorName,
sensorName: item.sensorName,
......@@ -274,8 +285,11 @@ const HistoryInfo = (props) => {
// 处理采集时间
resData.forEach((item) => {
item.dataModel.forEach((data) => {
if (!timeData.includes(data.pt)) {
timeData.push(data.pt);
const formatTime = moment(data.pt).format(
contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00',
);
if (!timeData.includes(formatTime)) {
timeData.push(formatTime);
}
});
});
......@@ -301,7 +315,10 @@ const HistoryInfo = (props) => {
tableData.forEach((item, i) => {
resData.forEach((child, index) => {
child.dataModel.forEach((value, j) => {
if (timeData[i] === value.pt) item[`value${index + 1}`] = value.pv;
const formatTime = moment(value.pt).format(
contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00',
);
if (timeData[i] === formatTime) item[`value${index + 1}`] = value.pv;
});
});
});
......@@ -315,8 +332,8 @@ const HistoryInfo = (props) => {
const requestArr = [];
dateRange.forEach((item) => {
const param = {
...params,
stream: params.stream.map((child) => ({
...historyInfoParams,
stream: historyInfoParams.stream.map((child) => ({
...child,
dateFrom: item.dateFrom,
dateTo: item.dateTo,
......
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