123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- #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 <QDebug>
- 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<QList<MindNodeManager::NodeMessage>>;
- sortMindNodes(*indexsRefNodes, indexsRefClassifiedNodes);
- delete indexsRefNodes;
- } else {
- indexsRefClassifiedNodes = nullptr;
- }
- if (!indexs.isEmpty()) {
- currentMindNodes = new MindNodeManager();
- classifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
- 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<QList<MindNodeManager::NodeMessage>> *classify)
- {
- for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
- QStringList nodePonit = msg.node.split(".");
- while (nodePonit.count() - 1 > classify->count()) {
- (*classify) << QList<MindNodeManager::NodeMessage>();
- }
- (*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<QList<MindNodeManager::NodeMessage>> classify;
- for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
- QStringList nodePonit = msg.node.split(".");
- while (nodePonit.count() - 1 > classify.count()) {
- classify << QList<MindNodeManager::NodeMessage>();
- }
- 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<QList<MindNodeManager::NodeMessage>> classify;
- for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
- QStringList nodePonit = msg.node.split(".");
- while (nodePonit.count() - 1 > classify.count()) {
- classify << QList<MindNodeManager::NodeMessage>();
- }
- 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<QFUser *> 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<DemandWeight *> nodeValueInfoList;
- DemandWeightService().QuerySecondDemandWeightByEngineerId(&nodeValueInfoList, userInfoList.at(i)->id,
- engineerId, "能力重要度评估指标体系");
- demandLists.append(nodeValueInfoList);
- } else if (analysisViewType == IndexType::SchemaEval) {
- QList<DemandWeight *> nodeValueInfoList;
- DemandWeightService().QueryLastPageDemandWeightByEngineerId(
- &nodeValueInfoList, QString::number(userInfoList.at(i)->id), engineerId, "方案评估指标体系",
- (classifiedNodes->count() - 1));
- demandLists.append(nodeValueInfoList);
- } else {
- QList<TechnicalImport *> 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);
- }
|