feat:增加煤量统计值减少数

This commit is contained in:
徐超 2024-11-13 11:21:09 +08:00
parent fefc6c60c4
commit 4189966cae
1 changed files with 22 additions and 10 deletions

View File

@ -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;
}
// 更新查询的数据至图表