fix:修复‘历史事件列表’中‘确认状态’等属性不同状态下没有区分显示的bug
This commit is contained in:
parent
001c4459f0
commit
6c8f2e0618
|
|
@ -26,21 +26,24 @@ public:
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void queryHistoricalEvents(const QDateTime& startTime, const QDateTime& endTime, int confirmStatus = -1);
|
void queryHistoricalEvents(const QDateTime& startTime, const QDateTime& endTime, int confirmStatus = -1);
|
||||||
|
void confirmEvents(const QStringList& uuids);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void realTimeEventReceived(const EventData& event);
|
void realTimeEventReceived(const EventData& event);
|
||||||
void historicalQueryError(const QString& msg);
|
void historicalQueryError(const QString& msg);
|
||||||
void historicalQueryData(const QList<EventData>& events);
|
void historicalQueryData(const QList<EventData>& events);
|
||||||
|
void confirmEventsResult(bool success, const QString& mesg);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onRabbitMQConnected();
|
void onRabbitMQConnected();
|
||||||
void onRabbitMQDisconnected();
|
void onRabbitMQDisconnected();
|
||||||
void onRabbitMQError(QAMQP::Error error);
|
void onRabbitMQError(QAMQP::Error error);
|
||||||
void onRabbitMQSocketError(QAbstractSocket::SocketError error);
|
void onRabbitMQSocketError(QAbstractSocket::SocketError error);
|
||||||
void onAmqpQueueOpend();
|
void onAmqpQueueOpened();
|
||||||
void onMessageReceived();
|
void onMessageReceived();
|
||||||
void onReconnectTimeout();
|
void onReconnectTimeout();
|
||||||
void onHistoricalRequestFinished(QNetworkReply* reply);
|
void onHistoricalRequestFinished(QNetworkReply* reply);
|
||||||
|
void onConfirmEventsRequestFinished(QNetworkReply* reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AlarmEventDataService();
|
explicit AlarmEventDataService();
|
||||||
|
|
@ -61,6 +64,8 @@ private:
|
||||||
QUrl bulidHistoricalQueryUrl(const QDateTime& startTime, const QDateTime& endTime, int confirmStatus);
|
QUrl bulidHistoricalQueryUrl(const QDateTime& startTime, const QDateTime& endTime, int confirmStatus);
|
||||||
void processHistoricalResponse(const QByteArray& data);
|
void processHistoricalResponse(const QByteArray& data);
|
||||||
//QNetworkRequest createHistoricalRequest(const QUrl& url);
|
//QNetworkRequest createHistoricalRequest(const QUrl& url);
|
||||||
|
//事件确认
|
||||||
|
QUrl buildConfirmEventsUrl();
|
||||||
|
|
||||||
ServiceConfig m_config;
|
ServiceConfig m_config;
|
||||||
ServiceStatus m_serviceStatus;
|
ServiceStatus m_serviceStatus;
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ private slots:
|
||||||
void onRealTimeEventReceived(const EventData& event);
|
void onRealTimeEventReceived(const EventData& event);
|
||||||
void onHistoricalEventsReceived(const QList<EventData>& events);
|
void onHistoricalEventsReceived(const QList<EventData>& events);
|
||||||
void onHistoricalQueryError(const QString&);
|
void onHistoricalQueryError(const QString&);
|
||||||
|
void onConfirmEventsResult(bool success, const QString& mesg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void iniHeaderData();
|
void iniHeaderData();
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,29 @@ void AlarmEventDataService::queryHistoricalEvents(const QDateTime& startTime, co
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlarmEventDataService::confirmEvents(const QStringList& uuids)
|
||||||
|
{
|
||||||
|
QUrl url = buildConfirmEventsUrl();
|
||||||
|
if(url.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
//创建网络请求
|
||||||
|
QNetworkRequest request(url);
|
||||||
|
request.setTransferTimeout(m_config.historicalConfig.timeout);
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
//将uuis转换为json数组
|
||||||
|
QJsonArray jsonArray;
|
||||||
|
for(const QString& uuid : uuids)
|
||||||
|
jsonArray.append(uuid);
|
||||||
|
QJsonDocument doc(jsonArray);
|
||||||
|
QByteArray jsonData = doc.toJson();
|
||||||
|
//发送请求
|
||||||
|
QNetworkReply* reply = m_networkManager->post(request, jsonData);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [this, reply](){
|
||||||
|
onConfirmEventsRequestFinished(reply);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void AlarmEventDataService::startRealTimeDataService()
|
void AlarmEventDataService::startRealTimeDataService()
|
||||||
{
|
{
|
||||||
cleanupRabbitMQConnection();
|
cleanupRabbitMQConnection();
|
||||||
|
|
@ -282,6 +305,15 @@ void AlarmEventDataService::processHistoricalResponse(const QByteArray& data)
|
||||||
emit historicalQueryData(historicalEvents);
|
emit historicalQueryData(historicalEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUrl AlarmEventDataService::buildConfirmEventsUrl()
|
||||||
|
{
|
||||||
|
QUrl url = m_config.historicalConfig.baseUrl;
|
||||||
|
QUrlQuery query;
|
||||||
|
query.addQueryItem("status", "3");
|
||||||
|
url.setQuery(query);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 槽函数 ====================
|
// ==================== 槽函数 ====================
|
||||||
void AlarmEventDataService::onRabbitMQConnected()
|
void AlarmEventDataService::onRabbitMQConnected()
|
||||||
{
|
{
|
||||||
|
|
@ -292,7 +324,7 @@ void AlarmEventDataService::onRabbitMQConnected()
|
||||||
m_amqpExchange->declare(QAmqpExchange::FanOut, QAmqpExchange::Durable);
|
m_amqpExchange->declare(QAmqpExchange::FanOut, QAmqpExchange::Durable);
|
||||||
//Queue
|
//Queue
|
||||||
m_amqpQueue = m_amqpClient->createQueue(m_config.rabbitMQConfig.queueName);
|
m_amqpQueue = m_amqpClient->createQueue(m_config.rabbitMQConfig.queueName);
|
||||||
connect(m_amqpQueue, SIGNAL(opened()), this, SLOT(onAmqpQueueOpend()));
|
connect(m_amqpQueue, SIGNAL(opened()), this, SLOT(onAmqpQueueOpened()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmEventDataService::onRabbitMQDisconnected()
|
void AlarmEventDataService::onRabbitMQDisconnected()
|
||||||
|
|
@ -319,7 +351,7 @@ void AlarmEventDataService::onRabbitMQSocketError(QAbstractSocket::SocketError e
|
||||||
scheduleReconnect();
|
scheduleReconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlarmEventDataService::onAmqpQueueOpend()
|
void AlarmEventDataService::onAmqpQueueOpened()
|
||||||
{
|
{
|
||||||
LOG_INFO("RabbitMQ", "AmqpQueue opend");
|
LOG_INFO("RabbitMQ", "AmqpQueue opend");
|
||||||
m_amqpQueue->declare(QAmqpQueue::AutoDelete);
|
m_amqpQueue->declare(QAmqpQueue::AutoDelete);
|
||||||
|
|
@ -369,3 +401,33 @@ void AlarmEventDataService::onHistoricalRequestFinished(QNetworkReply* reply)
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlarmEventDataService::onConfirmEventsRequestFinished(QNetworkReply* reply)
|
||||||
|
{
|
||||||
|
if(reply->error() == QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
QByteArray data = reply->readAll();
|
||||||
|
QJsonParseError parseError;
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(data, &parseError);
|
||||||
|
|
||||||
|
if(parseError.error == QJsonParseError::NoError && doc.isObject())
|
||||||
|
{
|
||||||
|
QJsonObject docObj = doc.object();
|
||||||
|
int code = docObj.value("code").toInt();
|
||||||
|
if(code == 0)
|
||||||
|
emit confirmEventsResult(true, "");
|
||||||
|
else
|
||||||
|
emit confirmEventsResult(false, QString("确认事件失败, error code = %1").arg(QString::number(code)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
emit confirmEventsResult(false, QString("确认事件失败(Json错误)"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString errorMsg = QString("ConfirmEvents error: %1").arg(reply->errorString());
|
||||||
|
LOG_ERROR("Http", errorMsg);
|
||||||
|
emit confirmEventsResult(false, QString("确认事件失败(%1)").arg(errorMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ AlarmEventDataModel::AlarmEventDataModel(AlarmDataMode mode, QObject* parent)
|
||||||
{
|
{
|
||||||
connect(AlarmEventDataService::instance(), &AlarmEventDataService::historicalQueryData, this, &AlarmEventDataModel::onHistoricalEventsReceived);
|
connect(AlarmEventDataService::instance(), &AlarmEventDataService::historicalQueryData, this, &AlarmEventDataModel::onHistoricalEventsReceived);
|
||||||
connect(AlarmEventDataService::instance(), &AlarmEventDataService::historicalQueryError, this, &AlarmEventDataModel::onHistoricalQueryError);
|
connect(AlarmEventDataService::instance(), &AlarmEventDataService::historicalQueryError, this, &AlarmEventDataModel::onHistoricalQueryError);
|
||||||
|
connect(AlarmEventDataService::instance(), &AlarmEventDataService::confirmEventsResult, this, &AlarmEventDataModel::onConfirmEventsResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
//实时数据测试
|
//实时数据测试
|
||||||
|
|
@ -419,6 +420,15 @@ void AlarmEventDataModel::onHistoricalQueryError(const QString& error)
|
||||||
emit loadDataError(error);
|
emit loadDataError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AlarmEventDataModel::onConfirmEventsResult(bool success, const QString& mesg)
|
||||||
|
{
|
||||||
|
if(!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//从列表中进行删除
|
||||||
|
}
|
||||||
|
|
||||||
bool AlarmEventDataModel::setCurrentPage(int page)
|
bool AlarmEventDataModel::setCurrentPage(int page)
|
||||||
{
|
{
|
||||||
if(m_paginationInfo.currentPage != page && page > 0 && page <= m_paginationInfo.totalPages)
|
if(m_paginationInfo.currentPage != page && page > 0 && page <= m_paginationInfo.totalPages)
|
||||||
|
|
|
||||||
|
|
@ -709,8 +709,9 @@ QHeaderView::section
|
||||||
font: 700 12pt "黑体";
|
font: 700 12pt "黑体";
|
||||||
color: rgb(250, 250, 250);
|
color: rgb(250, 250, 250);
|
||||||
background-color:transparent;
|
background-color:transparent;
|
||||||
|
padding-left:-1px;
|
||||||
border: 0px;
|
border: 0px;
|
||||||
border-right: 1px solid rgb(60,60,60);
|
border-right: 1px dotted rgb(60,60,60);
|
||||||
}
|
}
|
||||||
QHeaderView::section:horizontal:last
|
QHeaderView::section:horizontal:last
|
||||||
{
|
{
|
||||||
|
|
@ -726,7 +727,6 @@ QTableView
|
||||||
}
|
}
|
||||||
QTableView::item
|
QTableView::item
|
||||||
{
|
{
|
||||||
color: rgb(250, 250, 250);
|
|
||||||
background-color:transparent;
|
background-color:transparent;
|
||||||
}
|
}
|
||||||
QTableView::item:hover
|
QTableView::item:hover
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue