#include "GroupPanelWidget.h" #include "GroupTableWidget.h" #include "dbService/DBServiceSet.h" #include "dbService/UserService.h" #include "dbService/UserConfigService.h" #include "dbService/NodeMatrixService.h" #include "dbService/DemandWeightService.h" #include "ui_GroupPanelWidget.h" #include GroupPanelWidget::GroupPanelWidget(QWidget *parent) : QWidget(parent), ui(new Ui::GroupPanelWidget) { ui->setupUi(this); firstLayout = new QGridLayout; firstPlainWidget = nullptr; ui->stackedWidget->widget(0)->setLayout(firstLayout); } GroupPanelWidget::~GroupPanelWidget() { if (currentMindNodes) { delete currentMindNodes; } if (classifiedNodes) { delete classifiedNodes; } if (indexsRefClassifiedNodes) { delete indexsRefClassifiedNodes; } delete ui; } void GroupPanelWidget::init(const QStringList &indexsRef, const QStringList &indexs, int engineerId) { indexsRefClassifiedNodes = nullptr; if (!indexsRef.isEmpty()) { MindNodeManager *indexsRefNodes = new MindNodeManager(); //是否参考指标体系 getMindNodes(indexsRefNodes, indexsRef); indexsRefClassifiedNodes = new QList>; sortMindNodes(*indexsRefNodes, indexsRefClassifiedNodes); delete indexsRefNodes; } else { indexsRefClassifiedNodes = nullptr; } if (!indexs.isEmpty()) { currentMindNodes = new MindNodeManager(); classifiedNodes = new QList>; getMindNodes(currentMindNodes, indexs); sortMindNodes(*currentMindNodes, classifiedNodes); } else { currentMindNodes = nullptr; classifiedNodes = nullptr; } initPlainWidget(engineerId); } void GroupPanelWidget::setViewType(int type) { analysisViewType = type; } void GroupPanelWidget::setArithmeticMethod(QString method) { arithmeticMethod = method; } //节点排序 void GroupPanelWidget::sortMindNodes(const MindNodeManager &manager, QList> *classify) { for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) { QStringList nodePonit = msg.node.split("."); while (nodePonit.count() - 1 > classify->count()) { (*classify) << QList(); } (*classify)[nodePonit.count() - 2] << msg; } } //获取脑图节点 void GroupPanelWidget::getMindNodes(MindNodeManager *manager, QStringList listNodes) { int sn[16]; memset(sn, 0, sizeof(int) * 16); int spaceNum = -1; int level = 0; MindNodeManager::NodeMessage temp; manager->setMindName(listNodes[0].trimmed()); for (int i = 1; i < listNodes.count(); i++) { int tempSpace = 0; for (QString s : listNodes[i]) { if (s == " ") { tempSpace++; } else { break; } } tempSpace /= 4; if (tempSpace == 1) { //一级 spaceNum = tempSpace; level = 0; sn[level]++; memset((void *)&sn[1], 0, sizeof(int) * 15); } else { if (spaceNum < tempSpace) { //空格增加 spaceNum = tempSpace; level++; sn[level]++; } else if (spaceNum == tempSpace) { //同一级 sn[level]++; } else { memset((void *)&sn[tempSpace], 0, sizeof(int) * (16 - tempSpace)); level -= spaceNum - tempSpace; spaceNum = tempSpace; sn[level]++; } } QString node = "1"; for (int l : sn) { if (l > 0) { node += QString(".%1").arg(l); } else { break; } } if (listNodes[i].trimmed().isEmpty()) { temp.name = QString("NULL(节点%1)").arg(node); temp.node = node; temp.remark = ""; manager->pushNewMind(temp); } else { temp.name = listNodes[i].trimmed().split("\t")[0]; temp.node = node; temp.remark = listNodes[i].trimmed().split("\t")[1]; manager->pushNewMind(temp); } } } QStringList GroupPanelWidget::getFirstIndexNodes(const MindNodeManager &manager) { QList> classify; for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) { QStringList nodePonit = msg.node.split("."); while (nodePonit.count() - 1 > classify.count()) { classify << QList(); } classify[nodePonit.count() - 2] << msg; } QStringList firstNodes; for (MindNodeManager::NodeMessage msg : classify.first()) { firstNodes << msg.name; } return firstNodes; } QStringList GroupPanelWidget::getLastIndexNodes(const MindNodeManager &manager) { QList> classify; for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) { QStringList nodePonit = msg.node.split("."); while (nodePonit.count() - 1 > classify.count()) { classify << QList(); } classify[nodePonit.count() - 2] << msg; } QStringList lastNodes; for (MindNodeManager::NodeMessage msg : classify.last()) { lastNodes << msg.name; } return lastNodes; } void GroupPanelWidget::initPlainWidget(int engineerId) { demandLists.clear(); technicalImportLists.clear(); //准备第一页,非tab的 GroupTableWidget *table = new GroupTableWidget; connect(table, &GroupTableWidget::returnModel, this, &GroupPanelWidget::getTableModel); //获取专家 QList userInfoList; if (!UserService().QueryUserListByEngineerId(&userInfoList, engineerId)) { // QMessageBox::critical(this, "异常", "数据库访问异常!"); return; } //获取技术措施指标权重 for (int i = 0; i < userInfoList.size(); i++) { const QFUser *user = userInfoList.at(i); QString str = "专家" + QString::number(i + 1) + "-" + user->userName; UserConfig userConfig; UserConfigService().QueryUserConfigListInfoByUserIdAndEngineerId(&userConfig, user->id, engineerId); table->addColNode(QString::number(user->id), str, QString::number(userConfig.weight / 100)); if (analysisViewType == IndexType::IndexTech) { QList nodeValueInfoList; DemandWeightService().QuerySecondDemandWeightByEngineerId(&nodeValueInfoList, userInfoList.at(i)->id, engineerId, "能力重要度评估指标体系"); demandLists.append(nodeValueInfoList); } else if (analysisViewType == IndexType::SchemaEval) { QList nodeValueInfoList; DemandWeightService().QueryLastPageDemandWeightByEngineerId( &nodeValueInfoList, QString::number(userInfoList.at(i)->id), engineerId, "方案评估指标体系", (classifiedNodes->count() - 1)); demandLists.append(nodeValueInfoList); } else { QList nodeValueInfoList; DBServiceSet().QueryTechnicalImportInfoByEngineerId(&nodeValueInfoList, userInfoList.at(i)->id, engineerId); technicalImportLists.append(nodeValueInfoList); } } if (classifiedNodes->isEmpty()) { return; } if (analysisViewType == IndexType::IndexTech || analysisViewType == SchemaEval) { for (MindNodeManager::NodeMessage msg : classifiedNodes->last()) { table->addRowNode(msg.node, msg.name, msg.remark); } table->paintDemandTable(demandLists, arithmeticMethod); } else if (analysisViewType == IndexType::TechMessaure) { for (MindNodeManager::NodeMessage msg : classifiedNodes->first()) { table->addRowNode(msg.node, msg.name, msg.remark); } table->paintTechnicalTable(technicalImportLists, arithmeticMethod); } else { for (MindNodeManager::NodeMessage msg : classifiedNodes->first()) { table->addRowNode(msg.node, msg.name, msg.remark); } table->setTableType(analysisViewType); table->paintDemandTable(demandLists, arithmeticMethod); } firstLayout->addWidget(table); qDeleteAll(userInfoList); } void GroupPanelWidget::getTableModel(QStandardItemModel *item) { emit returnModel(item); }