2024-11-11 22:19:24 +08:00
|
|
|
|
#ifndef COALSTATISTICSCHARTWIDGET_H
|
2024-11-01 17:40:37 +08:00
|
|
|
|
#define COALSTATISTICSCHARTWIDGET_H
|
|
|
|
|
|
2024-11-11 22:19:24 +08:00
|
|
|
|
#include "component/qcustomplot/qcustomplot.h"
|
|
|
|
|
|
2024-11-01 17:40:37 +08:00
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QtCharts>
|
|
|
|
|
|
|
|
|
|
QT_CHARTS_USE_NAMESPACE
|
|
|
|
|
namespace Ui {
|
|
|
|
|
class CoalStatisticsChartWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 17:48:05 +08:00
|
|
|
|
enum TimeUnit {
|
2024-11-12 17:35:54 +08:00
|
|
|
|
Hour = 0, // 时
|
|
|
|
|
Day = 1, // 天
|
|
|
|
|
Month = 2, // 月
|
|
|
|
|
Year = 3 // 年
|
2024-11-05 17:48:05 +08:00
|
|
|
|
};
|
|
|
|
|
|
2024-11-01 17:40:37 +08:00
|
|
|
|
class CoalStatisticsChartWidget : public QWidget {
|
2024-11-12 17:35:54 +08:00
|
|
|
|
Q_OBJECT
|
2024-11-01 17:40:37 +08:00
|
|
|
|
|
|
|
|
|
public:
|
2024-11-12 17:35:54 +08:00
|
|
|
|
explicit CoalStatisticsChartWidget(QWidget* parent = nullptr);
|
|
|
|
|
~CoalStatisticsChartWidget();
|
2024-11-01 17:40:37 +08:00
|
|
|
|
|
2024-11-11 17:48:22 +08:00
|
|
|
|
signals:
|
2024-11-12 17:35:54 +08:00
|
|
|
|
void querySuccessInfo(QString& queryInfo);
|
2024-11-11 17:48:22 +08:00
|
|
|
|
|
2024-11-05 17:48:05 +08:00
|
|
|
|
private slots:
|
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
/**
|
2024-11-11 22:19:24 +08:00
|
|
|
|
* @brief on_pushButton_coalStatisOk_clicked 点击确定按钮
|
|
|
|
|
*/
|
2024-11-12 17:35:54 +08:00
|
|
|
|
void on_pushButton_coalStatisOk_clicked();
|
2024-11-05 17:48:05 +08:00
|
|
|
|
|
2024-11-01 17:40:37 +08:00
|
|
|
|
private:
|
2024-11-12 17:35:54 +08:00
|
|
|
|
/**
|
2024-11-11 22:19:24 +08:00
|
|
|
|
* @brief initCoalStatisticsBarChart 初始化煤量统计柱状图
|
|
|
|
|
*/
|
2024-11-12 17:35:54 +08:00
|
|
|
|
void initCoalStatisticsBarChart();
|
2024-11-11 22:19:24 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
/**
|
2024-11-11 22:19:24 +08:00
|
|
|
|
* @brief formatTimeRange 格式化时间范围
|
|
|
|
|
* @param beginTimeStr
|
|
|
|
|
* @param endTimeStr
|
|
|
|
|
* @param formattedBeginTime
|
|
|
|
|
* @param formattedEndTime
|
|
|
|
|
*/
|
2024-11-12 17:35:54 +08:00
|
|
|
|
void formatTimeRange(const QString& beginTimeStr, const QString& endTimeStr, QString& formattedBeginTime, QString& formattedEndTime);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief getLastSixFullHours 计算前六个整点时间
|
|
|
|
|
* @param currentTime 当前时间
|
|
|
|
|
* @return 六个整点数
|
|
|
|
|
*/
|
|
|
|
|
QList<QString> getLastSixFullHours(const QDateTime& currentTime);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief initCustomCoalStatisticsBarChart 初始化用户自定义柱状图
|
|
|
|
|
*/
|
|
|
|
|
void initCustomCoalStatisticsBarChart();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief initCustomPlotCoalStatisticsBarChart 初始化customPlot柱状图
|
|
|
|
|
*/
|
|
|
|
|
void initCustomPlotCoalStatisticsBarChart();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief getCoalStatisInfoByHttpRequest 通过Http请求获取煤量统计信息
|
|
|
|
|
* @param startTime 请求起始时间
|
|
|
|
|
* @param endTime 请求终止时间
|
|
|
|
|
* @param statisticUnit 统计单位
|
|
|
|
|
* @param volumeDataMap 体积统计结果Map
|
|
|
|
|
*/
|
|
|
|
|
void getCoalStatisInfoByHttpRequest(const QString& startTime,
|
|
|
|
|
const QString& endTime,
|
|
|
|
|
const QString& statisticUnit);
|
|
|
|
|
|
|
|
|
|
/**
|
2024-11-11 22:19:24 +08:00
|
|
|
|
* @brief updateCoalStatisticsChart 更新煤溜统计柱状图数据
|
|
|
|
|
* @param volumeDataMap 统计结果数据
|
|
|
|
|
*/
|
2024-11-12 17:35:54 +08:00
|
|
|
|
void updateCoalStatisticsChart(const QMap<QString, double>& volumeDataMap);
|
2024-11-04 18:11:55 +08:00
|
|
|
|
|
2024-11-01 17:40:37 +08:00
|
|
|
|
private:
|
2024-11-12 17:35:54 +08:00
|
|
|
|
Ui::CoalStatisticsChartWidget* ui;
|
2024-11-11 22:19:24 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
QChart* m_chart;
|
|
|
|
|
QChartView* m_chartView;
|
|
|
|
|
QBarSeries* m_series;
|
|
|
|
|
QBarCategoryAxis* m_axisX;
|
|
|
|
|
// QDateTimeAxis* m_axisX;
|
|
|
|
|
// QValueAxis* m_axisX;
|
|
|
|
|
QValueAxis* m_axisY;
|
2024-11-11 22:19:24 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
QTimer* m_timer;
|
2024-11-01 17:40:37 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
QCustomPlot* m_customPlot;
|
|
|
|
|
QCPBars* m_barGraph;
|
2024-11-05 17:48:05 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
QSettings* m_systemSetting;
|
2024-11-05 17:48:05 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
double m_toalValue = 0.0;
|
2024-11-11 17:48:22 +08:00
|
|
|
|
|
2024-11-12 17:35:54 +08:00
|
|
|
|
/**
|
2024-11-11 22:19:24 +08:00
|
|
|
|
* @brief m_volumeDataMap 查询出煤量数据
|
|
|
|
|
*/
|
2024-11-12 17:35:54 +08:00
|
|
|
|
QMap<QString, double> m_volumeDataMap;
|
2024-11-01 17:40:37 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // COALSTATISTICSCHARTWIDGET_H
|