feat:增加煤量统计值减少数
This commit is contained in:
parent
fefc6c60c4
commit
4189966cae
|
@ -20,9 +20,9 @@ CoalStatisticsChartWidget::CoalStatisticsChartWidget(QWidget* parent)
|
||||||
|
|
||||||
ui->dateTimeEdit_startTime->setDateTime(QDateTime::currentDateTime().addSecs(-8 * 3600));
|
ui->dateTimeEdit_startTime->setDateTime(QDateTime::currentDateTime().addSecs(-8 * 3600));
|
||||||
|
|
||||||
// initCustomCoalStatisticsBarChart();
|
initCustomCoalStatisticsBarChart();
|
||||||
|
|
||||||
initCustomPlotCoalStatisticsBarChart();
|
// initCustomPlotCoalStatisticsBarChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
CoalStatisticsChartWidget::~CoalStatisticsChartWidget() { delete ui; }
|
CoalStatisticsChartWidget::~CoalStatisticsChartWidget() { delete ui; }
|
||||||
|
@ -47,8 +47,8 @@ void CoalStatisticsChartWidget::on_pushButton_coalStatisOk_clicked()
|
||||||
QString startTimestr = "起始时间" + formattedBeginTime;
|
QString startTimestr = "起始时间" + formattedBeginTime;
|
||||||
QString endTimestr = "终止时间" + formattedEndTime;
|
QString endTimestr = "终止时间" + formattedEndTime;
|
||||||
|
|
||||||
emit querySuccessInfo(startTimestr);
|
// emit querySuccessInfo(startTimestr);
|
||||||
emit querySuccessInfo(endTimestr);
|
// emit querySuccessInfo(endTimestr);
|
||||||
|
|
||||||
// 输出格式化后的时间
|
// 输出格式化后的时间
|
||||||
qDebug() << "Formatted Begin Time: " << formattedBeginTime;
|
qDebug() << "Formatted Begin Time: " << formattedBeginTime;
|
||||||
|
@ -328,21 +328,33 @@ void CoalStatisticsChartWidget::getCoalStatisInfoByHttpRequest(
|
||||||
QJsonObject statisticUnitVolum = data["statistic_unit_volum"].toObject();
|
QJsonObject statisticUnitVolum = data["statistic_unit_volum"].toObject();
|
||||||
|
|
||||||
int statisticUnitVolumSize = statisticUnitVolum.count();
|
int statisticUnitVolumSize = statisticUnitVolum.count();
|
||||||
QString statisticUnitVolumSizeString = "查询结果数" + QString::number(statisticUnitVolumSize);
|
// QString statisticUnitVolumSizeString = "查询结果数" + QString::number(statisticUnitVolumSize);
|
||||||
emit querySuccessInfo(statisticUnitVolumSizeString);
|
// emit querySuccessInfo(statisticUnitVolumSizeString);
|
||||||
|
|
||||||
QString totalVolumeString = "总吨数" + QString::number(m_toalValue);
|
// QString totalVolumeString = "总吨数" + QString::number(m_toalValue);
|
||||||
emit querySuccessInfo(totalVolumeString);
|
// emit querySuccessInfo(totalVolumeString);
|
||||||
|
|
||||||
ui->label_totalVolume->clear();
|
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();
|
m_volumeDataMap.clear();
|
||||||
|
|
||||||
|
// 计算整体需要减少的总量
|
||||||
|
double reduction = m_toalValue * 0.5; // 减去50%
|
||||||
|
|
||||||
|
// 计算每个值应该减少的比例
|
||||||
|
double currentReduction = 0;
|
||||||
|
|
||||||
// 遍历 statistic_unit_volum 中的键值对并存入 volumeDataMap
|
// 遍历 statistic_unit_volum 中的键值对并存入 volumeDataMap
|
||||||
for (const QString& key : statisticUnitVolum.keys()) {
|
for (const QString& key : statisticUnitVolum.keys()) {
|
||||||
double value = statisticUnitVolum.value(key).toDouble();
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新查询的数据至图表
|
// 更新查询的数据至图表
|
||||||
|
|
Loading…
Reference in New Issue