From 2d60b17fbe022014d7e039a1b37a43f2df2555be Mon Sep 17 00:00:00 2001 From: lishenfeng Date: Mon, 3 Mar 2025 17:37:19 +0800 Subject: [PATCH] =?UTF-8?q?feat():=20=E9=A2=84=E6=B5=8B=E6=B0=B4=E4=BD=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/TestLine/drpOption.js | 1567 +++-------------------------- src/views/TestLine/index.js | 1385 +++---------------------- src/views/TestLine/toolbar.js | 42 +- src/views/TestLine/watersTools.js | 35 + 4 files changed, 293 insertions(+), 2736 deletions(-) create mode 100644 src/views/TestLine/watersTools.js diff --git a/src/views/TestLine/drpOption.js b/src/views/TestLine/drpOption.js index 20b954b..26fa204 100644 --- a/src/views/TestLine/drpOption.js +++ b/src/views/TestLine/drpOption.js @@ -1,1416 +1,67 @@ import * as echarts from 'echarts'; import moment, { min } from 'moment'; -export default function drpOption(time = '', tabArr) { +export default function drpOption(predict = [], history = []) { + console.log("predict", predict); - const deadWaterData = [ - 88.25, - 88.25, - 88.25, - 88.26, - 88.28, - 88.28, - 88.29, - 88.29, - 88.25, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.3, - 88.3, - 88.31, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.33, - 88.34, - 88.36, - 88.37, - 88.38, - 88.39, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.41, - 88.42, - 88.43, - 88.44, - 88.45, - 88.46, - 88.46, - 88.47, - 88.47, - 88.48, - 88.48, - 88.48, - 88.48, - 88.49, - 88.5, - 88.51, - 88.52, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.54, - 88.55, - 88.57, - 88.58, - 88.59, - 88.61, - 88.62, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.64, - 88.65, - 88.66, - 88.67, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.67, - 88.67, - 88.67, - 88.67, - 88.68, - 88.69, - 88.7, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.71, - 88.71, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.78, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.81, - 88.82, - 88.82, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.84, - 88.86, - 88.87, - 88.89, - 88.89, - 88.9, - 88.9, - 88.9, - 88.9, - 88.9, - 88.9, - 88.9, - 88.92, - 88.94, - 88.95, - 88.96, - 88.97, - 88.96, - 88.97, - 88.97, - 88.97, - 88.98, - 88.99, - 89, - 89, - 89.02, - 89.02, - 89.03, - 89.03, - 89.03, - 89.03, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.03, - 89.04, - 89.05, - 89.05, - 89.06, - 89.06, - 89.06, - 89.06, - 89.06, - 89.06, - 89.05, - 89.05, - 89.04, - 89.03, - 89.03, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.01, - 89.01, - 89, - 89, - 88.99, - 88.98, - 88.97, - 88.97, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.97, - 88.98, - 88.99, - 89, - 89, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.02, - 89.03, - 89.05, - 89.05, - 89.06, - 89.06, - 89.08, - 89.08, - 89.09, - 89.1, - 89.12, - 89.12, - 89.13, - 89.13, - 89.14, - 89.14, - 89.15, - 89.15, - 89.16, - 89.17, - 89.18, - 89.18, - 89.2, - 89.2, - 89.2, - 89.19, - 89.18, - 89.16, - 89.14, - 89.14, - 89.14, - 89.14, - 89.13, - 89.12, - 89.11, - 89.09, - 89.08, - 89.06, - 89.05, - 89.03, - 89.01, - 89, - 88.98, - 88.98, - 88.97, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.93, - 88.93, - 88.92, - 88.93, - 88.94, - 88.95, - 88.96, - 88.97, - 88.97, - 88.98, - 88.98, - 88.99, - 88.99, - 88.99, - 88.99, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.02, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89, - 89, - 89, - 89, - 89, - 88.99, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.97, - 88.97, - 88.96, - 88.96, - 88.96, - 88.96, - 88.95, - 88.95, - 88.95, - 88.95, - 88.95, - 88.95, - 88.96, - 88.96, - 88.97, - 88.97, - 88.98, - 88.98, - 88.99, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 88.99, - 88.99, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.97, - 88.97, - 88.97, - 88.97, - 88.96, - 88.96, - 88.96, - 88.95, - 88.95, - 88.94, - 88.94, - 88.94, - 88.94, - 88.93, - 88.93, - 88.93, - 88.93, - 88.93, - 88.93, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92 - ]; - const deadRainData = [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 2, - 0.5, - 0, - 0.5, - 2, - 2.5, - 1.5, - 0, - 0.5, - 0.5, - 1, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 1.5, - 0.5, - 0, - 1.5, - 1.5, - 0, - 0, - 0, - 0, - 2, - 0.5, - 1, - 2, - 0.5, - 1.5, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 0, - 2, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0.5, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 3, - 1.5, - 2, - 4, - 2.5, - 3, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0.5, - 0, - 0, - 0, - 0.5, - 0, - 0.5, - 0, - 0, - 0.5, - 0, - 0.5, - 0, - 0.5, - 0, - 0, - 0.5, - 0, - 1, - 0.5, - 1.5, - 1.5, - 1.5, - 1, - 0.5, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0.5, - 0.5, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ]; - const h1DrpData = tabArr.find(item => item.tm == '1小时'); - const minRz = Math.floor(Math.min(...tabArr.map(item => item.rz),...deadWaterData)) - const maxRz = Math.ceil(Math.max(...tabArr.map(item => item.rz),...deadWaterData)) - const mindrp = Math.floor(Math.min(...tabArr.map(item => item.drp),...deadRainData)) - const maxdrp = Math.ceil(Math.max(...tabArr.map(item => item.drp),...deadRainData)) - console.log(minRz,maxRz); - - const upDeadWaterData = deadWaterData.map((item, i) => ({ - time: i + 1, - value: item - })) - const upDeadrainData = deadRainData.map((item, i) => ({ - time: i + 1, - value: item - })) - - const data = JSON.parse(JSON.stringify(upDeadWaterData)); - const ydata = JSON.parse(JSON.stringify(upDeadrainData)); - if (time == "1h") { - data.push( - { time: 601, value: h1DrpData?.rz, predict: true }, - ...Array(30).fill(0).map((item, i) => ({ - time: i + 1 + 601, - value: '', - predict: true - })) - ) - ydata.push({ time: 601, value: h1DrpData?.drp, predict: true }) - } else if (time == "3h") { - const wData = [ - { time: 603, value: 420, predict: true }, - { time: 604, value: 450, predict: true }, - { time: 605, value: 480, predict: true }, - ] - const rData = [ - { time: 603, value: tabArr.find(item => item.tm == '1小时')?.drp, predict: true }, - { time: 604, value: tabArr.find(item => item.tm == '2小时')?.drp, predict: true }, - { time: 605, value: tabArr.find(item => item.tm == '3小时')?.drp, predict: true }, - ] - data.push(...wData) - ydata.push(...rData) - } else if (time == "6h") { - const h6WData = [ - { time: "12-24 16:00", value: 420, predict: true }, - { time: "12-24 17:00", value: 450, predict: true }, - { time: "12-24 18:00", value: 480, predict: true }, - { time: "12-24 19:00", value: 510, predict: true }, - { time: "12-24 20:00", value: 540, predict: true }, - { time: "12-24 21:00", value: 480, predict: true }, - ] - const h6RData = [ - { time: "12-24 16:00", value: tabArr.find(item => item.tm == '1小时')?.drp, predict: true }, - { time: "12-24 17:00", value: tabArr.find(item => item.tm == '2小时')?.dr, predict: true }, - { time: "12-24 18:00", value: tabArr.find(item => item.tm == '3小时')?.dr, predict: true }, - { time: "12-24 19:00", value: tabArr.find(item => item.tm == '4小时')?.dr, predict: true }, - { time: "12-24 20:00", value: tabArr.find(item => item.tm == '5小时')?.dr, predict: true }, - { time: "12-24 21:00", value: tabArr.find(item => item.tm == '6小时')?.dr, predict: true }, - ] - - data.push(...h6WData) - ydata.push(...h6RData) - } else if (time == "12h") { - const h12WData = [ - { time: "12-24 16:00", value: 420, predict: true }, - { time: "12-24 17:00", value: 450, predict: true }, - { time: "12-24 18:00", value: 480, predict: true }, - { time: "12-24 19:00", value: 510, predict: true }, - { time: "12-24 20:00", value: 540, predict: true }, - { time: "12-24 21:00", value: 480, predict: true }, - { time: "12-24 22:00", value: 420, predict: true }, - { time: "12-24 23:00", value: 450, predict: true }, - { time: "12-24 24:00", value: 480, predict: true }, - { time: "12-25 00:00", value: 510, predict: true }, - { time: "12-25 01:00", value: 540, predict: true }, - { time: "12-25 02:00", value: 480, predict: true }, - ] - const h12RData = [ - { time: "12-24 16:00", value: tabArr.find(item => item.tm == '1小时')?.drp, predict: true }, - { time: "12-24 17:00", value: tabArr.find(item => item.tm == '2小时')?.drp, predict: true }, - { time: "12-24 18:00", value: tabArr.find(item => item.tm == '3小时')?.drp, predict: true }, - { time: "12-24 19:00", value: tabArr.find(item => item.tm == '4小时')?.drp, predict: true }, - { time: "12-24 20:00", value: tabArr.find(item => item.tm == '5小时')?.drp, predict: true }, - { time: "12-24 21:00", value: tabArr.find(item => item.tm == '6小时')?.drp, predict: true }, - { time: "12-24 22:00", value: tabArr.find(item => item.tm == '7小时')?.drp, predict: true }, - { time: "12-24 23:00", value: tabArr.find(item => item.tm == '8小时')?.drp, predict: true }, - { time: "12-24 24:00", value: tabArr.find(item => item.tm == '9小时')?.drp, predict: true }, - { time: "12-25 00:00", value: tabArr.find(item => item.tm == '10小时')?.drp, predict: true }, - { time: "12-25 01:00", value: tabArr.find(item => item.tm == '11小时')?.drp, predict: true }, - { time: "12-25 02:00", value: tabArr.find(item => item.tm == '12小时')?.drp, predict: true }, - ] - - data.push(...h12WData) - ydata.push(...h12RData) - } else if (time == "24h") { - const h24WData = [ - { time: "12-24 16:00", value: 420, predict: true }, - { time: "12-24 17:00", value: 450, predict: true }, - { time: "12-24 18:00", value: 480, predict: true }, - { time: "12-24 19:00", value: 510, predict: true }, - { time: "12-24 20:00", value: 540, predict: true }, - { time: "12-24 21:00", value: 480, predict: true }, - { time: "12-24 22:00", value: 420, predict: true }, - { time: "12-24 23:00", value: 450, predict: true }, - { time: "12-24 24:00", value: 480, predict: true }, - { time: "12-25 00:00", value: 510, predict: true }, - { time: "12-25 01:00", value: 540, predict: true }, - { time: "12-25 02:00", value: 480, predict: true }, - - { time: "12-25 03:00", value: 420, predict: true }, - { time: "12-25 04:00", value: 450, predict: true }, - { time: "12-25 05:00", value: 480, predict: true }, - { time: "12-25 06:00", value: 510, predict: true }, - { time: "12-25 07:00", value: 540, predict: true }, - { time: "12-25 08:00", value: 480, predict: true }, - { time: "12-25 09:00", value: 420, predict: true }, - { time: "12-25 10:00", value: 450, predict: true }, - { time: "12-25 11:00", value: 480, predict: true }, - { time: "12-25 12:00", value: 510, predict: true }, - { time: "12-25 13:00", value: 540, predict: true }, - { time: "12-25 14:00", value: 480, predict: true }, - ] - const h24RData = [ - { time: "12-24 16:00", value: tabArr.find(item => item.tm == '1小时')?.drp, predict: true }, - { time: "12-24 17:00", value: tabArr.find(item => item.tm == '2小时')?.drp, predict: true }, - { time: "12-24 18:00", value: tabArr.find(item => item.tm == '3小时')?.drp, predict: true }, - { time: "12-24 19:00", value: tabArr.find(item => item.tm == '4小时')?.drp, predict: true }, - { time: "12-24 20:00", value: tabArr.find(item => item.tm == '5小时')?.drp, predict: true }, - { time: "12-24 21:00", value: tabArr.find(item => item.tm == '6小时')?.drp, predict: true }, - { time: "12-24 22:00", value: tabArr.find(item => item.tm == '7小时')?.drp, predict: true }, - { time: "12-24 23:00", value: tabArr.find(item => item.tm == '8小时')?.drp, predict: true }, - { time: "12-24 24:00", value: tabArr.find(item => item.tm == '9小时')?.drp, predict: true }, - { time: "12-25 00:00", value: tabArr.find(item => item.tm == '10小时')?.drp, predict: true }, - { time: "12-25 01:00", value: tabArr.find(item => item.tm == '11小时')?.drp, predict: true }, - { time: "12-25 02:00", value: tabArr.find(item => item.tm == '12小时')?.drp, predict: true }, - - { time: "12-25 03:00", value: tabArr.find(item => item.tm == '13小时')?.drp, predict: true }, - { time: "12-25 04:00", value: tabArr.find(item => item.tm == '14小时')?.drp, predict: true }, - { time: "12-25 05:00", value: tabArr.find(item => item.tm == '15小时')?.drp, predict: true }, - { time: "12-25 06:00", value: tabArr.find(item => item.tm == '16小时')?.drp, predict: true }, - { time: "12-25 07:00", value: tabArr.find(item => item.tm == '17小时')?.drp, predict: true }, - { time: "12-25 08:00", value: tabArr.find(item => item.tm == '18小时')?.drp, predict: true }, - { time: "12-25 09:00", value: tabArr.find(item => item.tm == '19小时')?.drp, predict: true }, - { time: "12-25 10:00", value: tabArr.find(item => item.tm == '20小时')?.drp, predict: true }, - { time: "12-25 11:00", value: tabArr.find(item => item.tm == '21小时')?.drp, predict: true }, - { time: "12-25 12:00", value: tabArr.find(item => item.tm == '22小时')?.drp, predict: true }, - { time: "12-25 13:00", value: tabArr.find(item => item.tm == '23小时')?.drp, predict: true }, - { time: "12-25 14:00", value: tabArr.find(item => item.tm == '24小时')?.drp, predict: true }, - ] - data.push(...h24WData) - ydata.push(...h24RData) - } - - - let data1 = []; //历史水量数据 - let data2 = []; //预测水量数据 - let data3 = []; //历史雨量数据 - let data4 = []; //预测雨量数据 - data.forEach((item) => { - if (item.predict && time) { - data2.push([item.time, item.value]); - } else { - data1.push([item.time, item.value]); - } - }); - - ydata.forEach((item) => { - if (item.predict && time) { - data4.push([item.time, item.value]); - } else { - data3.push([item.time, item.value]); - } - }); - - const splitLineData1 = data1.at(-1); - const splitLineData = data1.at(-1); - const splitLineData2 = data3.at(-1); - - // 如果是折线图,此处需要追加实际数据的最后一组数据,如果是柱状图,则不需要。 - data2.unshift(splitLineData1); - // console.log("splitLineData",splitLineData); - - data4.unshift(splitLineData2); + // 水位 + const minRz = Math.floor(Math.min(...history.map(item => item.waters), ...predict.map(item => item.predict))) + const maxRz = Math.ceil(Math.max(...history.map(item => item.waters), ...predict.map(item => item.predict))) + // 雨量 + const mindrp = Math.floor(Math.min(...history.map(item => item.rains))) + const maxdrp = Math.ceil(Math.max(...history.map(item => item.rains))) + console.log(minRz, maxRz); return { grid: { left: 0, - top: "22%", - right: "0", - bottom: 0, + top: "20%", + right: "3%", + bottom: "10%", containLabel: true, }, tooltip: { trigger: 'axis', }, legend: { - right: "0", + right: "center", top: "4%", }, + toolbox: { + show: true, + top: "15%", + right: "1%", + orient: 'vertical', + feature: { + dataZoom: { + show: true, + title: { + zoom: '区域缩放', + back: '区域缩放还原', + } + }, + magicType: { + show: true, + title: { + line: '切换为折线图', + bar: '切换为柱状图', + }, + type: ['line', 'bar'] + }, + restore: { + show: true, + title: '还原' + }, + saveAsImage: { + show: true, + name: '日到报率详情', + title: '保存为图片' + } + } + }, xAxis: { type: "category", - // data: data.map(item => item.time), - axisLabel: { - interval: 100 - }, + // data: history.map(item => item.tm), axisTick: { show: false, }, @@ -1420,7 +71,7 @@ export default function drpOption(time = '', tabArr) { type: "value", name: '水位', min: minRz, - max:maxRz, + max: maxRz, splitLine: { show: true, }, @@ -1437,7 +88,7 @@ export default function drpOption(time = '', tabArr) { type: "value", name: '雨量', min: mindrp, - max:maxdrp, + max: maxdrp, splitLine: { show: true, }, @@ -1452,77 +103,95 @@ export default function drpOption(time = '', tabArr) { }, ], dataZoom: [{ - type: 'slider',//图表下方的伸缩条 - show: true, //是否显示 - realtime: true, //拖动时,是否实时更新系列的视图 - start: 1, //伸缩条开始位置(1-100),可以随时更改 - end: 100, //伸缩条结束位置(1-100),可以随时更改 - // y:100 + type: 'inside', + start: 0, + end: 100 + }, { + start: 0, + end: 10, + handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z', + handleSize: '80%', + handleStyle: { + color: '#fff', + shadowBlur: 3, + shadowColor: 'rgba(0, 0, 0, 0.6)', + shadowOffsetX: 2, + shadowOffsetY: 2 + } }], series: [ { - name: "历史水量", + name: "实时水位", type: "line", showSymbol: false, - data: data1, + data: history.map(item => [item.tm, item.waters]), smooth: true, }, { - name: "历史雨量", + name: "实时雨量", type: "line", color: '#F59A23', yAxisIndex: 1, showSymbol: false, - data: data3, + data: history.map(item => [item.tm, item.rains]), smooth: true, }, { - name: "预测水量", + name: "预测水位", + type: "line", + color: '#1fbcd2', yAxisIndex: 0, - type: "line", - showSymbol: true, - data:[...data2], + showSymbol: false, + data: predict.map(item => [item.tm, item.predict]), smooth: true, - itemStyle: { normal: { label: { show: true } } } }, - { - name: "预测雨量", - yAxisIndex: 1, - type: "line", - showSymbol: true, - data: data4, - smooth: true, - itemStyle: { normal: { label: { show: true } } } - }, - { - type: "line", - data: [], - markLine: { - symbol: "none", - lineStyle: { - type: "solid", - width: 2, - }, - data: [ - // 下面绿色线 - [ - // 下面半截绿色的线 - { - xAxis: 599, - yAxis: minRz, - lineStyle: { - color: "rgba(46, 224, 85, 1)", - }, - }, - { - xAxis: 599, - yAxis: splitLineData[1], - }, - ], - ], - }, + // { + // name: "预测水量", + // yAxisIndex: 0, + // type: "line", + // showSymbol: true, + // data:[...data2], + // smooth: true, + // itemStyle: { normal: { label: { show: true } } } + // }, + // { + // name: "预测雨量", + // yAxisIndex: 1, + // type: "line", + // showSymbol: true, + // data: data4, + // smooth: true, + // itemStyle: { normal: { label: { show: true } } } + // }, + // { + // type: "line", + // data: [], + // markLine: { + // symbol: "none", + // lineStyle: { + // type: "solid", + // width: 2, + // }, + // data: [ + // // 下面绿色线 + // [ + // // 下面半截绿色的线 + // { + // xAxis: 599, + // yAxis: minRz, + // lineStyle: { + // color: "rgba(46, 224, 85, 1)", + // }, + // }, + // { + // xAxis: 599, + // yAxis: splitLineData[1], + // }, + // ], + // ], + // }, - }, + // }, ], } } \ No newline at end of file diff --git a/src/views/TestLine/index.js b/src/views/TestLine/index.js index f006d43..7c80065 100644 --- a/src/views/TestLine/index.js +++ b/src/views/TestLine/index.js @@ -6,8 +6,8 @@ import './index.less' import drpOption from './drpOption.js' import { httppost2 } from '../../utils/request'; import TestApp from './createData.js' - -const TableE = ({count,setEditData,tableData}) => { +import { getAllHydroBatches, responseData } from './watersTools' +const TableE = ({ count, setEditData, tableData }) => { const EditableCell = ({ editing, dataIndex, @@ -19,7 +19,7 @@ const TableE = ({count,setEditData,tableData}) => { ...restProps }) => { const inputNode = ; - + return ( {editing ? ( @@ -48,14 +48,14 @@ const TableE = ({count,setEditData,tableData}) => { title: '预见期', dataIndex: 'tm', width: '30%', - + }, { title: '雨量', dataIndex: 'drp', width: '30%', editable: true, - align:'center' + align: 'center' }, { title: '水位', @@ -63,9 +63,9 @@ const TableE = ({count,setEditData,tableData}) => { width: '20%', }, { - title: '操作', key: 'operation', width: "20%", fixed: 'right',align: 'center', + title: '操作', key: 'operation', width: "20%", fixed: 'right', align: 'center', render: (_, record) => { - const editable = isEditing(record); + const editable = isEditing(record); return editable ? ( { > 完成 - + ) : ( -
- edit1(record)}> - 编辑 +
+ edit1(record)}> + 编辑 -
- +
+ ); }, }, - ] + ] const [form1] = Form.useForm() const edit1 = (record) => { form1.setFieldsValue({ @@ -121,13 +121,13 @@ const TableE = ({count,setEditData,tableData}) => { console.log('Validate Failed:', errInfo); } }; - + useEffect(() => { - if (tableData.length > 0) { + if (tableData.length > 0) { setDetails(tableData) } }, [tableData]) - + const mergedColumns = columns.map((col) => { if (!col.editable) { @@ -162,24 +162,24 @@ const TableE = ({count,setEditData,tableData}) => { handleAddRow(count) } }, [count]) - + return ( <> -
- - + +
+ ) } @@ -194,1237 +194,22 @@ export default function TestLine() { const [tmCount, setTmCount] = useState('') const [tableForm, setTableForm] = useState({}) const [tableData, setTableData] = useState([]) + const [historyData, setHistoryData] = useState(responseData) + const [predictData, setPredictData] = useState([]) + // const options = useMemo(() => { + // return drpOption(tableForm.time || '1h', tableForm.tabArr || []) + // }, [tableForm]) + const options = useMemo(() => { - return drpOption(tableForm.time || '1h',tableForm.tabArr || []) - }, [tableForm]) - const getPrejectRain = async(name) => { - try { - const res = await httppost2('http://202.103.169.18:10100/api/v1/bot/water_infer', - { - "name": name, - "waters": [ - 88.25, - 88.25, - 88.25, - 88.26, - 88.28, - 88.28, - 88.29, - 88.29, - 88.25, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.29, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.28, - 88.3, - 88.3, - 88.31, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.32, - 88.33, - 88.34, - 88.36, - 88.37, - 88.38, - 88.39, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.4, - 88.41, - 88.42, - 88.43, - 88.44, - 88.45, - 88.46, - 88.46, - 88.47, - 88.47, - 88.48, - 88.48, - 88.48, - 88.48, - 88.49, - 88.5, - 88.51, - 88.52, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.53, - 88.54, - 88.55, - 88.57, - 88.58, - 88.59, - 88.61, - 88.62, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.63, - 88.64, - 88.65, - 88.66, - 88.67, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.68, - 88.67, - 88.67, - 88.67, - 88.67, - 88.68, - 88.69, - 88.7, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.7, - 88.71, - 88.71, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.72, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.71, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.78, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.77, - 88.78, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.8, - 88.81, - 88.82, - 88.82, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.83, - 88.84, - 88.86, - 88.87, - 88.89, - 88.89, - 88.9, - 88.9, - 88.9, - 88.9, - 88.9, - 88.9, - 88.9, - 88.92, - 88.94, - 88.95, - 88.96, - 88.97, - 88.96, - 88.97, - 88.97, - 88.97, - 88.98, - 88.99, - 89, - 89, - 89.02, - 89.02, - 89.03, - 89.03, - 89.03, - 89.03, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.03, - 89.04, - 89.05, - 89.05, - 89.06, - 89.06, - 89.06, - 89.06, - 89.06, - 89.06, - 89.05, - 89.05, - 89.04, - 89.03, - 89.03, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.02, - 89.01, - 89.01, - 89, - 89, - 88.99, - 88.98, - 88.97, - 88.97, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.97, - 88.98, - 88.99, - 89, - 89, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.02, - 89.03, - 89.05, - 89.05, - 89.06, - 89.06, - 89.08, - 89.08, - 89.09, - 89.1, - 89.12, - 89.12, - 89.13, - 89.13, - 89.14, - 89.14, - 89.15, - 89.15, - 89.16, - 89.17, - 89.18, - 89.18, - 89.2, - 89.2, - 89.2, - 89.19, - 89.18, - 89.16, - 89.14, - 89.14, - 89.14, - 89.14, - 89.13, - 89.12, - 89.11, - 89.09, - 89.08, - 89.06, - 89.05, - 89.03, - 89.01, - 89, - 88.98, - 88.98, - 88.97, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.96, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.94, - 88.93, - 88.93, - 88.92, - 88.93, - 88.94, - 88.95, - 88.96, - 88.97, - 88.97, - 88.98, - 88.98, - 88.99, - 88.99, - 88.99, - 88.99, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89.02, - 89.01, - 89.01, - 89.01, - 89.01, - 89.01, - 89, - 89, - 89, - 89, - 89, - 88.99, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.97, - 88.97, - 88.96, - 88.96, - 88.96, - 88.96, - 88.95, - 88.95, - 88.95, - 88.95, - 88.95, - 88.95, - 88.96, - 88.96, - 88.97, - 88.97, - 88.98, - 88.98, - 88.99, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 89, - 88.99, - 88.99, - 88.98, - 88.98, - 88.98, - 88.98, - 88.98, - 88.97, - 88.97, - 88.97, - 88.97, - 88.96, - 88.96, - 88.96, - 88.95, - 88.95, - 88.94, - 88.94, - 88.94, - 88.94, - 88.93, - 88.93, - 88.93, - 88.93, - 88.93, - 88.93, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92, - 88.92 - ], - "rains": [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 2, - 0.5, - 0, - 0.5, - 2, - 2.5, - 1.5, - 0, - 0.5, - 0.5, - 1, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 1.5, - 0.5, - 0, - 1.5, - 1.5, - 0, - 0, - 0, - 0, - 2, - 0.5, - 1, - 2, - 0.5, - 1.5, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 0, - 2, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0.5, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 3, - 1.5, - 2, - 4, - 2.5, - 3, - 1, - 1, - 1, - 1, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0.5, - 0, - 0, - 0, - 0.5, - 0, - 0.5, - 0, - 0, - 0.5, - 0, - 0.5, - 0, - 0.5, - 0, - 0, - 0.5, - 0, - 1, - 0.5, - 1.5, - 1.5, - 1.5, - 1, - 0.5, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0.5, - 0.5, - 0.5, - 0, - 0.5, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - } - ) - if (res.code == 0) { - const newArr = res.data?.water_predicts.map(item => ({ drp: '', rz: item?.toFixed(2), tm: '1小时' })) - setTableData(newArr) - setTableForm({...tableForm,tabArr:newArr}) - } - } catch (error) { - console.log(error); - - } - } + return drpOption(predictData,historyData) + }, [predictData,historyData]) + + // useEffect(() => { + // if (searchVal) { + // getPrejectRain(searchVal.code) + // } + // }, [searchVal]) - useEffect(() => { - if (searchVal) { - getPrejectRain(searchVal.code) - } - }, [searchVal]) - useEffect(() => { let count; if (type?.time) { @@ -1441,7 +226,7 @@ export default function TestLine() { }, [type]) - + const rowObj = { "1小时": 420, "2小时": 450, @@ -1467,8 +252,8 @@ export default function TestLine() { "22小时": 510, "23小时": 540, "24小时": 480, - -} + + } const save = async () => { // const all = editData.some(item => !item.drp) // if (all) { @@ -1482,11 +267,68 @@ export default function TestLine() { })) setTableForm({ tabArr: newTabl, time: type.time }) setTableData(newTabl) - + } catch (errInfo) { console.log('Validate Failed:', errInfo); } }; + // 测试 + + const getHistoryData = async (params) => { + try { + const allBatches = getAllHydroBatches(responseData); + const res =await processPredictions(allBatches, params.code) + if (res.length > 0) { + setPredictData(res) + } + + } catch (error) { + + } + + // try { + // const res = await httppost2('/api/hydrology/history'); + // if (res.code == 200) { + // const allBatches = getAllHydroBatches(res.data); + // if (allBatches.length) { + // processPredictions(allBatches,params.code) + // } + // } else { + // const allBatches = getAllHydroBatches(responseData); + // } + // } catch (error) { + // console.log(error); + // } + } + /** + * 处理预测结果 + * @param {Array} batches - 批次数据 + * @param {Array} predictions - 预测结果数组 + * @returns {Array} - 返回处理后的预测结果 + */ const processPredictions = async (batches, name) => { + const results = []; + + for (const batch of batches) { + const prediction = await httppost2('http://202.96.165.23:10100/api/v1/bot/water_infer', { + rains: batch.rains, + waters: batch.waters, + name + }); + results.push({ + predict: prediction?.data?.water_predicts[0], // 预测水位 + tm: batch.lastTm // 对应的时间点 + }); + } + + return results; + }; + + useEffect(() => { + if (searchVal) { + getHistoryData(searchVal) + } + }, [searchVal]) + return ( <> @@ -1501,16 +343,15 @@ export default function TestLine() { />
- +
-
- +
+
-
+ {/*
- {/* */} -
+
*/}
diff --git a/src/views/TestLine/toolbar.js b/src/views/TestLine/toolbar.js index a4e47ea..ef434a7 100644 --- a/src/views/TestLine/toolbar.js +++ b/src/views/TestLine/toolbar.js @@ -1,11 +1,11 @@ -import React, { useEffect,useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Form, Input, Button, DatePicker, InputNumber } from 'antd'; import NormalSelect from '../../components/Form/NormalSelect'; import moment from 'moment'; const { RangePicker } = DatePicker; const ToolBar = ({ setSearchVal, setType, save, form1 }) => { - + const types = [ { label: "hjw", @@ -51,7 +51,7 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => { value: "24h" } ] - + const [form] = Form.useForm(); const onFinish = (values) => { @@ -63,14 +63,13 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => { } } delete values.tm - // setSearchVal({...values, dateTimeRangeSo}); - save() + setSearchVal({...values, start: dateTimeRangeSo.start,end: dateTimeRangeSo.end}); } - const onValuesChange = (val,o) =>{ + const onValuesChange = (val, o) => { if ('time' in val) { - setSearchVal({time: val.time}) - setType({time: val.time}) + setSearchVal({ time: val.time }) + setType({ time: val.time }) form1.resetFields() } if ('code' in val) { @@ -81,28 +80,41 @@ const ToolBar = ({ setSearchVal, setType, save, form1 }) => { } } useEffect(() => { + const start = moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00') + const end = moment().format('YYYY-MM-DD 23:59:59') const params = { code: "hjw", - time:'1h' + time: '1h', + start, + end } - form.setFieldsValue(params) + form.setFieldValue('name', params.code); + form.setFieldValue('tm', [moment(start), moment(end)]); setSearchVal(params) setType({ time: "1h" }) }, []) - return ( <> -
+
- + - + {/* + */} + + - {/* + + {/* */} diff --git a/src/views/TestLine/watersTools.js b/src/views/TestLine/watersTools.js new file mode 100644 index 0000000..ad87c41 --- /dev/null +++ b/src/views/TestLine/watersTools.js @@ -0,0 +1,35 @@ +import moment from "moment"; +/** + * 使用滑动窗口获取水文数据批次 + * @param {Array} data - 后端返回的数据数组 + * @returns {Array} - 返回数组,每个元素包含600个点的数据 + */ +export const getAllHydroBatches = (data) => { + if (!Array.isArray(data) || data.length < 600) { + return []; + } + + const batches = []; + let startIndex = 0; + + // 当剩余数据量大于等于600时继续处理 + while (startIndex + 600 <= data.length) { + const slicedData = data.slice(startIndex, startIndex + 600); + batches.push({ + rains: slicedData.map(item => item.rains), + waters: slicedData.map(item => item.waters), + lastTm: slicedData[599].tm // 记录第600个点的时间 + }); + + // 每次向后移动1个位置 + startIndex += 1; + } + + return batches; +}; + +export const responseData = new Array(800).fill(0).map((item,index) => ({ + rains: (Math.random() * 1).toFixed(2), + waters: (Math.random() * 100).toFixed(2), + tm:moment().clone().add(index, 'hours').format("YYYY-MM-DD HH:00:00") +})) \ No newline at end of file