|
@@ -1,9 +1,11 @@
|
|
#include "blastprojectpage.h"
|
|
#include "blastprojectpage.h"
|
|
|
|
|
|
|
|
+#include <QJsonArray>
|
|
|
|
+#include <QJsonObject>
|
|
#include <QUrl>
|
|
#include <QUrl>
|
|
-#include <iostream>
|
|
|
|
|
|
|
|
#include "../components/buttondelegate.h"
|
|
#include "../components/buttondelegate.h"
|
|
|
|
+#include "../components/loadingWidget.h"
|
|
#include "../utils/backendapimanager.h"
|
|
#include "../utils/backendapimanager.h"
|
|
#include "../utils/databasemanager.h"
|
|
#include "../utils/databasemanager.h"
|
|
#include "../utils/global.h"
|
|
#include "../utils/global.h"
|
|
@@ -11,7 +13,6 @@
|
|
|
|
|
|
#define BLASTER_ROLE_ID 4
|
|
#define BLASTER_ROLE_ID 4
|
|
#define OPERATOR_ROLE_ID 7
|
|
#define OPERATOR_ROLE_ID 7
|
|
-#define SAFEGUARD_ROLE_ID 5
|
|
|
|
|
|
|
|
BlastProjectPage::BlastProjectPage(QWidget *parent)
|
|
BlastProjectPage::BlastProjectPage(QWidget *parent)
|
|
: QWidget(parent), ui(new Ui::BlastProjectPage), dao(DatabaseManager::getInstance().getDatabase()) {
|
|
: QWidget(parent), ui(new Ui::BlastProjectPage), dao(DatabaseManager::getInstance().getDatabase()) {
|
|
@@ -29,6 +30,7 @@ BlastProjectPage::BlastProjectPage(QWidget *parent)
|
|
addressOptions(pcs);
|
|
addressOptions(pcs);
|
|
|
|
|
|
QJsonArray allUsers = backendAPIManager::getSysUsers();
|
|
QJsonArray allUsers = backendAPIManager::getSysUsers();
|
|
|
|
+
|
|
for (const QJsonValue &value : allUsers) {
|
|
for (const QJsonValue &value : allUsers) {
|
|
if (value.isObject()) {
|
|
if (value.isObject()) {
|
|
QJsonObject obj = value.toObject();
|
|
QJsonObject obj = value.toObject();
|
|
@@ -49,11 +51,14 @@ void BlastProjectPage::refreshData() {
|
|
}
|
|
}
|
|
|
|
|
|
void BlastProjectPage::loadDataFromSource(int currentPage, int pageSize) {
|
|
void BlastProjectPage::loadDataFromSource(int currentPage, int pageSize) {
|
|
- PaginatedHProjectResult result = dao.getAllHProjects(currentPage, pageSize);
|
|
|
|
|
|
+ LoadingWidget::showLoading(this, "正在加载数据...");
|
|
|
|
+ QJsonObject extParams({{"blast_status", QJsonArray({"2", "1"})}});
|
|
|
|
+ QJsonObject result = backendAPIManager::getHProjects(currentPage, pageSize, extParams);
|
|
|
|
|
|
- QList<QSharedPointer<HProject>> projectList = result.projects;
|
|
|
|
|
|
+ QList<QSharedPointer<HProject>> projectList =
|
|
|
|
+ dao.getHProjectsFromJsonArray(result["data"].toObject()["list"].toArray());
|
|
|
|
|
|
- totalCount = result.totalCount;
|
|
|
|
|
|
+ totalCount = result["data"].toObject()["count"].toInt();
|
|
pageWidget->setMaxPage(ceil(static_cast<double>(totalCount) / pageSize));
|
|
pageWidget->setMaxPage(ceil(static_cast<double>(totalCount) / pageSize));
|
|
QStandardItemModel *model;
|
|
QStandardItemModel *model;
|
|
model = new QStandardItemModel(this);
|
|
model = new QStandardItemModel(this);
|
|
@@ -61,7 +66,6 @@ void BlastProjectPage::loadDataFromSource(int currentPage, int pageSize) {
|
|
// 定义表头信息
|
|
// 定义表头信息
|
|
QList<HeaderInfo> headers = {
|
|
QList<HeaderInfo> headers = {
|
|
{"工程名称", "name"},
|
|
{"工程名称", "name"},
|
|
- {"安全员", "safetyInspectorIdentity"},
|
|
|
|
{"井上爆破员", "operatorIdentity"},
|
|
{"井上爆破员", "operatorIdentity"},
|
|
{"井下爆破员", "blasterIdentity"},
|
|
{"井下爆破员", "blasterIdentity"},
|
|
{"井下地址", "addressPath"},
|
|
{"井下地址", "addressPath"},
|
|
@@ -97,14 +101,9 @@ void BlastProjectPage::loadDataFromSource(int currentPage, int pageSize) {
|
|
item = new QStandardItem(statusText);
|
|
item = new QStandardItem(statusText);
|
|
item->setForeground(QColor("#e7c66b"));
|
|
item->setForeground(QColor("#e7c66b"));
|
|
} else if (value.toString() == BlastStatus::Registered) {
|
|
} else if (value.toString() == BlastStatus::Registered) {
|
|
- statusText = "待安全确认";
|
|
|
|
- item = new QStandardItem(statusText);
|
|
|
|
- item->setForeground(QColor("#f3a361"));
|
|
|
|
- } else if (value.toString() == BlastStatus::SafeChecked) {
|
|
|
|
- statusText = "待起爆";
|
|
|
|
|
|
+ statusText = "已注册";
|
|
item = new QStandardItem(statusText);
|
|
item = new QStandardItem(statusText);
|
|
item->setForeground(QColor("#f3a361"));
|
|
item->setForeground(QColor("#f3a361"));
|
|
-
|
|
|
|
} else if (value.toString() == BlastStatus::Blasted) {
|
|
} else if (value.toString() == BlastStatus::Blasted) {
|
|
statusText = "起爆完成";
|
|
statusText = "起爆完成";
|
|
item = new QStandardItem(statusText);
|
|
item = new QStandardItem(statusText);
|
|
@@ -112,13 +111,19 @@ void BlastProjectPage::loadDataFromSource(int currentPage, int pageSize) {
|
|
} else {
|
|
} else {
|
|
item = new QStandardItem(value.toString());
|
|
item = new QStandardItem(value.toString());
|
|
}
|
|
}
|
|
- } else if (QStringList({"safetyInspectorIdentity", "operatorIdentity", "blasterIdentity"})
|
|
|
|
- .contains(prop)) {
|
|
|
|
- item = new QStandardItem(getUserNameByIds(value.toString().split(",")));
|
|
|
|
|
|
+ } else if (prop == "operatorIdentity" || prop == "blasterIdentity") {
|
|
|
|
+ QJsonArray userInfoArray = getUserInfoByIds(value.toString().split(","));
|
|
|
|
+ QStringList userNames;
|
|
|
|
+ for (const QJsonValue &value : userInfoArray) {
|
|
|
|
+ if (value.isObject()) {
|
|
|
|
+ QJsonObject obj = value.toObject();
|
|
|
|
+ userNames.append(obj["name"].toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ item = new QStandardItem(userNames.join(","));
|
|
} else {
|
|
} else {
|
|
item = new QStandardItem(value.toString());
|
|
item = new QStandardItem(value.toString());
|
|
}
|
|
}
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
item = new QStandardItem("操作");
|
|
item = new QStandardItem("操作");
|
|
item->setTextAlignment(Qt::AlignCenter);
|
|
item->setTextAlignment(Qt::AlignCenter);
|
|
@@ -148,6 +153,7 @@ void BlastProjectPage::loadDataFromSource(int currentPage, int pageSize) {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
ui->tableView->setItemDelegateForColumn(headerCount - 1, delegate);
|
|
ui->tableView->setItemDelegateForColumn(headerCount - 1, delegate);
|
|
|
|
+ LoadingWidget::hideLoading();
|
|
}
|
|
}
|
|
|
|
|
|
void BlastProjectPage::PageChanged(int page) {
|
|
void BlastProjectPage::PageChanged(int page) {
|
|
@@ -166,7 +172,6 @@ void BlastProjectPage::onComboBoxIndexChanged(int index) {
|
|
void BlastProjectPage::initUserAndDialogOptions(const QJsonArray &dataArray) {
|
|
void BlastProjectPage::initUserAndDialogOptions(const QJsonArray &dataArray) {
|
|
QJsonArray blasterDeployerArray;
|
|
QJsonArray blasterDeployerArray;
|
|
QJsonArray operatorArray;
|
|
QJsonArray operatorArray;
|
|
- QJsonArray safeGuardArray;
|
|
|
|
for (const QJsonValue &value : dataArray) {
|
|
for (const QJsonValue &value : dataArray) {
|
|
if (value.isObject()) {
|
|
if (value.isObject()) {
|
|
QJsonObject obj = value.toObject();
|
|
QJsonObject obj = value.toObject();
|
|
@@ -179,16 +184,12 @@ void BlastProjectPage::initUserAndDialogOptions(const QJsonArray &dataArray) {
|
|
if (roleIdsArray.contains(OPERATOR_ROLE_ID)) { // 井上爆破员
|
|
if (roleIdsArray.contains(OPERATOR_ROLE_ID)) { // 井上爆破员
|
|
operatorArray.append(obj);
|
|
operatorArray.append(obj);
|
|
}
|
|
}
|
|
- if (roleIdsArray.contains(SAFEGUARD_ROLE_ID)) { // 安全员
|
|
|
|
- safeGuardArray.append(obj);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
m_dialog->initComboBoxBlaster(blasterDeployerArray);
|
|
m_dialog->initComboBoxBlaster(blasterDeployerArray);
|
|
m_dialog->initComboBoxOperator(operatorArray);
|
|
m_dialog->initComboBoxOperator(operatorArray);
|
|
- m_dialog->initComboBoxSafetyInspectors(safeGuardArray);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void BlastProjectPage::addressOptions(const QJsonArray &dataArrayAddress) {
|
|
void BlastProjectPage::addressOptions(const QJsonArray &dataArrayAddress) {
|
|
@@ -203,11 +204,13 @@ void BlastProjectPage::parseJsonString(const QJsonDocument &jsonDoc) {
|
|
}
|
|
}
|
|
|
|
|
|
void BlastProjectPage::on_pushButton_clicked() {
|
|
void BlastProjectPage::on_pushButton_clicked() {
|
|
- m_dialog->setModal(false);
|
|
|
|
- m_dialog->clearFormData();
|
|
|
|
- m_dialog->setOperationType(0);
|
|
|
|
- int ref = m_dialog->exec();
|
|
|
|
- if (ref == QDialog::Accepted) {};
|
|
|
|
|
|
+ // m_dialog->setModal(false);
|
|
|
|
+ // m_dialog->clearFormData();
|
|
|
|
+ // m_dialog->setOperationType(0);
|
|
|
|
+ // int ref = m_dialog->exec();
|
|
|
|
+ // if (ref == QDialog::Accepted) {};
|
|
|
|
+
|
|
|
|
+ refreshData();
|
|
}
|
|
}
|
|
|
|
|
|
void BlastProjectPage::createProject(const QMap<QString, QString> &data) {
|
|
void BlastProjectPage::createProject(const QMap<QString, QString> &data) {
|
|
@@ -218,7 +221,6 @@ void BlastProjectPage::createProject(const QMap<QString, QString> &data) {
|
|
project.setAddressPath(data.value("addressPath"));
|
|
project.setAddressPath(data.value("addressPath"));
|
|
project.setBlasterIdentity(data.value("blasterIdentity"));
|
|
project.setBlasterIdentity(data.value("blasterIdentity"));
|
|
project.setOperatorIdentity(data.value("operatorIdentity"));
|
|
project.setOperatorIdentity(data.value("operatorIdentity"));
|
|
- project.setSafetyInspectorIdentity(data.value("safetyInspectorIdentity"));
|
|
|
|
project.setLevel4Address(data.value("level4Address"));
|
|
project.setLevel4Address(data.value("level4Address"));
|
|
project.setBlastCount(data.value("blastCount"));
|
|
project.setBlastCount(data.value("blastCount"));
|
|
project.setBlastStatus("1");
|
|
project.setBlastStatus("1");
|
|
@@ -242,25 +244,36 @@ QJsonArray BlastProjectPage::getUserInfoByIds(const QStringList &userIds) {
|
|
userInfo["identity"] = userId;
|
|
userInfo["identity"] = userId;
|
|
userInfoArray.append(userInfo);
|
|
userInfoArray.append(userInfo);
|
|
} else {
|
|
} else {
|
|
- QMessageBox::critical(this, "错误", QString("用户(身份证: %1)不存在").arg(userId));
|
|
|
|
|
|
+ // TODO
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return userInfoArray;
|
|
return userInfoArray;
|
|
}
|
|
}
|
|
|
|
|
|
void BlastProjectPage::publishAllPendingBlastProjects() {
|
|
void BlastProjectPage::publishAllPendingBlastProjects() {
|
|
- QJsonArray jsonArray;
|
|
|
|
- QList<QSharedPointer<HProject>> projectsReg = dao.getAllHProjectsReg();
|
|
|
|
- for (const auto &projectPtr : projectsReg) {
|
|
|
|
- if (projectPtr) {
|
|
|
|
- QJsonObject projectJson = projectPtr->ProjectToJson(*projectPtr);
|
|
|
|
- projectJson["undergroundBlasters"] = getUserInfoByIds(projectPtr->getBlasterIdentity().split(","));
|
|
|
|
- projectJson["groundBlasters"] = getUserInfoByIds(projectPtr->getOperatorIdentity().split(","));
|
|
|
|
- // projectJson["safetyInspectors"] = getUserInfoByIds(projectPtr->getSafetyInspectorIdentity().split(","));
|
|
|
|
- jsonArray.append(projectJson);
|
|
|
|
- }
|
|
|
|
|
|
+ QJsonObject extParams{{"blast_status", QJsonArray({"1", "2"})}};
|
|
|
|
+ QJsonObject result = backendAPIManager::getHProjects(currentPage, pageSize, extParams);
|
|
|
|
+
|
|
|
|
+ QJsonArray jsonArray = result["data"].toObject()["list"].toArray();
|
|
|
|
+ for (int i = 0; i < jsonArray.size(); ++i) {
|
|
|
|
+ QJsonObject projectObj = jsonArray[i].toObject();
|
|
|
|
+ QStringList blasterIds = projectObj["blasterIdentity"].toString().split(",");
|
|
|
|
+ QStringList operatorIds = projectObj["operatorIdentity"].toString().split(",");
|
|
|
|
+ // remove blasterIdentity and operatorIdentity from projectObj
|
|
|
|
+ projectObj.remove("blasterIdentity");
|
|
|
|
+ projectObj.remove("operatorIdentity");
|
|
|
|
+ projectObj.remove("blasterName");
|
|
|
|
+ projectObj.remove("operatorName");
|
|
|
|
+
|
|
|
|
+ QJsonArray blasterInfo = getUserInfoByIds(blasterIds);
|
|
|
|
+ QJsonArray operatorInfo = getUserInfoByIds(operatorIds);
|
|
|
|
+
|
|
|
|
+ projectObj["underground_blasters"] = blasterInfo;
|
|
|
|
+ projectObj["ground_blasters"] = operatorInfo;
|
|
|
|
+
|
|
|
|
+ jsonArray[i] = QJsonValue(projectObj);
|
|
}
|
|
}
|
|
-
|
|
|
|
QJsonDocument jsonDoc(jsonArray);
|
|
QJsonDocument jsonDoc(jsonArray);
|
|
QByteArray jsonData = jsonDoc.toJson(QJsonDocument::Indented);
|
|
QByteArray jsonData = jsonDoc.toJson(QJsonDocument::Indented);
|
|
|
|
|