From 4189966cae6c0e80beda4498184890eb17e5502d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=B6=85?= Date: Wed, 13 Nov 2024 11:21:09 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=E7=85=A4?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E5=80=BC=E5=87=8F=E5=B0=91=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/coalstatisticschartwidget.cpp | 32 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/view/coalstatisticschartwidget.cpp b/view/coalstatisticschartwidget.cpp index da08292..542a59e 100644 --- a/view/coalstatisticschartwidget.cpp +++ b/view/coalstatisticschartwidget.cpp @@ -20,9 +20,9 @@ CoalStatisticsChartWidget::CoalStatisticsChartWidget(QWidget* parent) ui->dateTimeEdit_startTime->setDateTime(QDateTime::currentDateTime().addSecs(-8 * 3600)); - // initCustomCoalStatisticsBarChart(); + initCustomCoalStatisticsBarChart(); - initCustomPlotCoalStatisticsBarChart(); + // initCustomPlotCoalStatisticsBarChart(); } CoalStatisticsChartWidget::~CoalStatisticsChartWidget() { delete ui; } @@ -47,8 +47,8 @@ void CoalStatisticsChartWidget::on_pushButton_coalStatisOk_clicked() QString startTimestr = "起始时间" + formattedBeginTime; QString endTimestr = "终止时间" + formattedEndTime; - emit querySuccessInfo(startTimestr); - emit querySuccessInfo(endTimestr); + // emit querySuccessInfo(startTimestr); + // emit querySuccessInfo(endTimestr); // 输出格式化后的时间 qDebug() << "Formatted Begin Time: " << formattedBeginTime; @@ -328,21 +328,33 @@ void CoalStatisticsChartWidget::getCoalStatisInfoByHttpRequest( QJsonObject statisticUnitVolum = data["statistic_unit_volum"].toObject(); int statisticUnitVolumSize = statisticUnitVolum.count(); - QString statisticUnitVolumSizeString = "查询结果数" + QString::number(statisticUnitVolumSize); - emit querySuccessInfo(statisticUnitVolumSizeString); + // QString statisticUnitVolumSizeString = "查询结果数" + QString::number(statisticUnitVolumSize); + // emit querySuccessInfo(statisticUnitVolumSizeString); - QString totalVolumeString = "总吨数" + QString::number(m_toalValue); - emit querySuccessInfo(totalVolumeString); + // QString totalVolumeString = "总吨数" + QString::number(m_toalValue); + // emit querySuccessInfo(totalVolumeString); ui->label_totalVolume->clear(); - ui->label_totalVolume->setText(QString("煤量总计:%1吨").arg(m_toalValue)); + ui->label_totalVolume->setText(QString("煤量总计:%1吨").arg(m_toalValue * m_systemSetting->value("system/different").toDouble())); m_volumeDataMap.clear(); + // 计算整体需要减少的总量 + double reduction = m_toalValue * 0.5; // 减去50% + + // 计算每个值应该减少的比例 + double currentReduction = 0; + // 遍历 statistic_unit_volum 中的键值对并存入 volumeDataMap for (const QString& key : statisticUnitVolum.keys()) { double value = statisticUnitVolum.value(key).toDouble(); - m_volumeDataMap.insert(key, value); + + // 计算每个值所减少的比例 + double proportionalReduction = (value / m_toalValue) * reduction; + + m_volumeDataMap.insert(key, value - proportionalReduction); + + currentReduction += proportionalReduction; } // 更新查询的数据至图表