123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 |
- #include "AnalysisPanelWidget.h"
- #include "AnalysisTableWidget.h"
- #include "dbService/DBServiceSet.h"
- #include "dbService/NodeMatrixService.h"
- #include "dbService/DemandWeightService.h"
- #include "ui_AnalysisPanelWidget.h"
- #include <QHeaderView>
- #include <QDebug>
- AnalysisPanelWidget::AnalysisPanelWidget(QWidget *parent) : QWidget(parent), ui(new Ui::AnalysisPanelWidget)
- {
- ui->setupUi(this);
- firstLayout = new QGridLayout;
- firstPlainWidget = nullptr;
- ui->stackedWidget->widget(0)->setLayout(firstLayout);
- secondLayout = new QGridLayout;
- secondPlainWidget = nullptr;
- ui->stackedWidget->widget(1)->setLayout(secondLayout);
- ui->stackedWidget->setCurrentIndex(0);
- }
- AnalysisPanelWidget::~AnalysisPanelWidget()
- {
- if (currentMindNodes) {
- delete currentMindNodes;
- }
- if (classifiedNodes) {
- delete classifiedNodes;
- }
- if (indexsRefClassifiedNodes) {
- delete indexsRefClassifiedNodes;
- }
- delete ui;
- }
- void AnalysisPanelWidget::init(const QStringList indexsRef, const QStringList indexs, int engineerId, int expertId)
- {
- // qDebug() << "AnalysisPanelWidget::init" << indexsRef << indexs <<
- // engineerId << expertId;
- 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;
- }
- ui->toatalPagesLabel->setText(QString("共%1页").arg(getPages()));
- ui->currPageLabel->setText(QString("当前第0页"));
- initPlainWidget(engineerId, expertId, m_table_msg);
- setPage(1);
- }
- // 综合专家页面初始化
- void AnalysisPanelWidget::initComposite(const QStringList indexsRef, const QStringList indexs, int engineerId,
- QList<int> expertIds)
- {
- 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;
- }
- ui->toatalPagesLabel->setText(QString("共%1页").arg(getPages()));
- ui->currPageLabel->setText(QString("当前第0页"));
- initCompositePlainWidget(engineerId, expertIds, m_table_msg);
- setPage(1);
- }
- void AnalysisPanelWidget::setViewTypeAndTableMsg(int type, QString tableMsg)
- {
- analysisViewType = type;
- m_table_msg = tableMsg;
- if (type == 1) {
- ui->prePageBtn->setText("上一级指标");
- ui->nextPageBtn->setText("下一级指标");
- } else if (type == 2) {
- ui->prePageBtn->setText("上一级技术措施");
- ui->nextPageBtn->setText("下一级技术措施");
- } else if (type == 3) {
- ui->prePageBtn->setText("上一级指标");
- ui->nextPageBtn->setText("下一级指标");
- }
- }
- void AnalysisPanelWidget::setArithmeticMethod(QString resultMethod, QString matricesMethod)
- {
- m_resultMethod = resultMethod;
- m_matricesMethod = matricesMethod;
- }
- void AnalysisPanelWidget::sortMindNodes(const MindNodeManager &manager,
- QList<QList<MindNodeManager::NodeMessage>> *classify)
- {
- for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
- QStringList nodePonit = msg.node.split(".");
- // qDebug() << "TAG" << nodePonit << msg.node << msg.name;
- while (nodePonit.count() - 1 > classify->count()) {
- (*classify) << QList<MindNodeManager::NodeMessage>();
- }
- (*classify)[nodePonit.count() - 2] << msg;
- }
- #if 0
- struct ClassifyNode
- {
- MindNodeManager::NodeMessage msg;
- QList<ClassifyNode *> child;
- };
- QList<ClassifyNode *> classifyList;
- for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
- QStringList nodePonit = msg.node.split(".");
- int level = nodePonit.count() - 1;
- if (level == 1) { //第一级
- ClassifyNode *cn = new ClassifyNode;
- cn->msg = msg;
- classifyList << cn;
- } else {
- ClassifyNode *ref = classifyList[nodePonit[1].toInt() - 1];
- for (int i = 2; i < level; ++i) {
- ref = ref->child[nodePonit[i].toInt() - 1];
- }
- ClassifyNode *cn = new ClassifyNode;
- cn->msg = msg;
- ref->child << cn;
- }
- }
- #endif
- }
- void AnalysisPanelWidget::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 AnalysisPanelWidget::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 AnalysisPanelWidget::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;
- }
- int AnalysisPanelWidget::getPages()
- {
- #if 0
- int max = 0;
- for (MindNodeManager::NodeMessage msg : currentMindNodes->getMindNodes()) {
- QStringList nodePonit = msg.node.split(".");
- if (max < nodePonit.count() - 1) { max = nodePonit.count() - 1; }
- }
- return max;
- #else
- if (!classifiedNodes) {
- return 0;
- }
- return classifiedNodes->count();
- #endif
- }
- void AnalysisPanelWidget::setPage(int page)
- {
- if (page < 1 || page > getPages()) {
- return;
- }
- currentPage = page;
- ui->currPageLabel->setText(QString("当前第%1页").arg(currentPage));
- if (currentPage == 1) {
- ui->prePageBtn->setDisabled(true);
- ui->nextPageBtn->setDisabled(false);
- } else if (currentPage == getPages()) {
- ui->prePageBtn->setDisabled(false);
- ui->nextPageBtn->setDisabled(true);
- } else {
- ui->prePageBtn->setDisabled(false);
- ui->nextPageBtn->setDisabled(false);
- }
- paintPlainWidget();
- }
- // 专家初始化数据
- void AnalysisPanelWidget::initPlainWidget(int engineerId, int expertId, QString tableMsg)
- {
- if (getPages() == 0) {
- return;
- }
- // 获取技术措施指标权重
- QList<DemandWeight *> firstDemandList;
- QList<DemandWeight *> secondDemandList;
- DemandWeightService().QueryFirstDemandWeightByEngineerId(&firstDemandList, expertId, engineerId, tableMsg);
- // DBServiceSet().QuerySecondDemandWeightByEngineerId(&secondDemandList, expertId,
- // engineerId,"能力重要度评估指标体系");
- DemandWeightService().QuerySecondDemandWeightByEngineerIdAndMaxPage(&secondDemandList, expertId, engineerId,
- "能力重要度评估指标体系");
- QList<NodeMatrixInfo *> nodeValueInfoList;
- NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertId, engineerId, tableMsg);
- // 准备第一页,非tab的
- AnalysisTableWidget *table = new AnalysisTableWidget;
- table->horizontalHeader()->setStretchLastSection(true);
- table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); // 填充表格
- table->setTableIndexAndTableMsg(0, engineerId, QString::number(expertId), tableMsg);
- connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
- connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
- if (indexsRefClassifiedNodes) {
- for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
- table->addRowNode(msg.node, msg.name, msg.remark);
- }
- }
- for (MindNodeManager::NodeMessage msg : classifiedNodes->first()) {
- table->addColNode(msg.node, msg.name, msg.remark);
- if (indexsRefClassifiedNodes == nullptr) {
- table->addRowNode(msg.node, msg.name, msg.remark);
- }
- }
- table->setTableWeight(firstDemandList, secondDemandList);
- QVector<qreal> firstTableWieghts;
- table->paintMatrixTable(nodeValueInfoList, analysisViewType);
- firstLayout->addWidget(table);
- // 准备第二页,tab组合的
- QTabWidget *tab = new QTabWidget;
- for (int p = 1; p < getPages(); ++p) {
- QTabWidget *tab = new QTabWidget;
- tab->setTabPosition(QTabWidget::South);
- int index = 0;
- for (MindNodeManager::NodeMessage msg : classifiedNodes->at(p - 1)) {
- ++index;
- QString node = msg.node;
- // MatrixTableWidget *table = nullptr;
- table = nullptr;
- for (MindNodeManager::NodeMessage info : classifiedNodes->at(p)) {
- if ((info.node.count('.') == msg.node.count('.') + 1)
- && (info.node.left(msg.node.count()) == msg.node)) {
- if (!table) {
- table = new AnalysisTableWidget;
- connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
- }
- if (table) {
- table->addColNode(info.node, info.name, info.remark);
- if (!indexsRefClassifiedNodes) {
- table->addRowNode(info.node, info.name, info.remark);
- }
- }
- }
- }
- if (indexsRefClassifiedNodes) {
- for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
- table->addRowNode(msg.node, msg.name, msg.remark);
- }
- }
- if (table) {
- firstDemandList.clear();
- if (firstDemandList.size() == 0) {
- DemandWeightService().QueryLastPageDemandWeightByEngineerId(
- &firstDemandList, QString::number(expertId), engineerId, tableMsg, p - 1);
- }
- // qDebug() << p << "=" << p << "===========" << firstDemandList.size();
- table->setTableIndexAndTableMsg(index, engineerId, QString::number(expertId), tableMsg);
- table->setTableWeight(firstDemandList, secondDemandList);
- table->paintSecondMatrixTable(nodeValueInfoList, p, analysisViewType, index);
- tab->addTab(table, msg.name);
- connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
- }
- }
- tabWidgets << tab;
- }
- qDeleteAll(firstDemandList);
- qDeleteAll(secondDemandList);
- // secondLayout->addWidget(tab);
- }
- // 综合专家页面渲染
- void AnalysisPanelWidget::initCompositePlainWidget(int engineerId, QList<int> expertIds, QString tableMsg)
- {
- if (getPages() == 0) {
- return;
- }
- QString experId;
- for (int i = 0; i < expertIds.size(); i++) {
- if (experId == nullptr) {
- experId = QString::number(expertIds.at(i));
- } else {
- experId = experId + "," + QString::number(expertIds.at(i));
- }
- }
- qDebug() << experId;
- // 获取技术措施指标权重
- QList<DemandWeight *> firstDemandList;
- QList<DemandWeight *> secondDemandList;
- DemandWeightService().QueryFirstDemandWeightByEngineerId(&firstDemandList, experId, engineerId, tableMsg);
- DemandWeightService().QuerySecondDemandWeightByEngineerId(&secondDemandList, experId, engineerId,
- "能力重要度评估指标体系");
- QList<NodeMatrixInfo *> compositeNodeValueInfoList;
- computerCompositeValue(compositeNodeValueInfoList, expertIds, engineerId, tableMsg);
- // 准备第一页,非tab的
- AnalysisTableWidget *table = new AnalysisTableWidget;
- connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
- connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
- if (indexsRefClassifiedNodes) {
- for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
- table->addRowNode(msg.node, msg.name, msg.remark);
- }
- }
- for (MindNodeManager::NodeMessage msg : classifiedNodes->first()) {
- table->addColNode(msg.node, msg.name, msg.remark);
- if (indexsRefClassifiedNodes == nullptr) {
- table->addRowNode(msg.node, msg.name, msg.remark);
- }
- }
- table->setTableWeight(firstDemandList, secondDemandList);
- QVector<qreal> firstTableWieghts;
- table->setTableIndexAndTableMsg(0, engineerId, experId, m_table_msg);
- table->paintMatrixTable(compositeNodeValueInfoList, analysisViewType);
- firstLayout->addWidget(table);
- // 准备第二页,tab组合的
- for (int p = 1; p < getPages(); ++p) {
- QTabWidget *tab = new QTabWidget;
- tab->setTabPosition(QTabWidget::South);
- int index = 0;
- for (MindNodeManager::NodeMessage msg : classifiedNodes->at(p - 1)) {
- ++index;
- QString node = msg.node;
- // MatrixTableWidget *table = nullptr;
- table = nullptr;
- for (MindNodeManager::NodeMessage info : classifiedNodes->at(p)) {
- if ((info.node.count('.') == msg.node.count('.') + 1)
- && (info.node.left(msg.node.count()) == msg.node)) {
- if (!table) {
- table = new AnalysisTableWidget;
- table->setTableIndexAndTableMsg(index, engineerId, experId, tableMsg);
- connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
- }
- if (table) {
- table->addColNode(info.node, info.name, info.remark);
- if (!indexsRefClassifiedNodes) {
- table->addRowNode(info.node, info.name, info.remark);
- }
- }
- }
- }
- if (indexsRefClassifiedNodes) {
- for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
- table->addRowNode(msg.node, msg.name, msg.remark);
- }
- }
- if (table) {
- firstDemandList.clear();
- if (firstDemandList.size() == 0) {
- DemandWeightService().QueryLastPageDemandWeightByEngineerId(&firstDemandList, experId, engineerId,
- tableMsg, p - 1);
- }
- table->setTableWeight(firstDemandList, secondDemandList);
- table->paintSecondMatrixTable(compositeNodeValueInfoList, p, analysisViewType, index);
- tab->addTab(table, msg.name);
- connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
- }
- }
- tabWidgets << tab;
- }
- qDeleteAll(firstDemandList);
- }
- // 综合计算
- void AnalysisPanelWidget::computerCompositeValue(QList<NodeMatrixInfo *> &compositeNodeValueInfoList,
- QList<int> expertIds, int engineerId, QString tabMsg)
- {
- qDebug() << m_matricesMethod;
- if (m_matricesMethod == "valueAverage") { // 数值平均
- int expertSize = 0;
- if (tabMsg == "能力重要度评估指标体系" || tabMsg == "方案评估指标体系") {
- for (int i = 0; i < expertIds.size(); i++) {
- QList<NodeMatrixInfo *> nodeValueInfoList;
- NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertIds.at(i),
- engineerId, tabMsg);
- // qDebug() << "nodeValueInfoList.size()==" << nodeValueInfoList.size();
- if (nodeValueInfoList.size() == 0) {
- continue;
- }
- expertSize += 1;
- if (compositeNodeValueInfoList.isEmpty()) {
- compositeNodeValueInfoList = nodeValueInfoList;
- } else {
- for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
- NodeMatrixInfo *nodeInfo = compositeNodeValueInfoList.at(i);
- QStringList list = nodeInfo->nodeValue.split("/");
- int numerator;
- int denominator;
- if (list.size() == 1) {
- numerator = list.at(0).toInt() * list.at(0).toInt();
- denominator = list.at(0).toInt();
- } else {
- numerator = list.at(0).toInt();
- denominator = list.at(1).toInt();
- }
- for (int j = 0; j < nodeValueInfoList.size(); j++) {
- NodeMatrixInfo *info = nodeValueInfoList.at(j);
- if (nodeInfo->node == info->node && nodeInfo->abscissa == info->abscissa
- && nodeInfo->ordinate == info->ordinate) {
- QStringList list2 = info->nodeValue.split("/");
- int numerator2;
- int denominator2;
- if (list2.size() == 1) {
- numerator2 = list2.at(0).toInt() * list2.at(0).toInt();
- denominator2 = list2.at(0).toInt();
- } else {
- numerator2 = list2.at(0).toInt();
- denominator2 = list2.at(1).toInt();
- }
- numerator = numerator * denominator2 + numerator2 * denominator;
- denominator *= denominator2;
- nodeInfo->nodeValue = QString::number(numerator) + "/" + QString::number(denominator);
- }
- }
- }
- }
- }
- // 平均value值
- for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
- QStringList valueList = compositeNodeValueInfoList.at(i)->nodeValue.split("/");
- long int numerator = 1;
- long int denominator = 1;
- if (valueList.size() != 1) {
- denominator = valueList.at(1).toInt();
- }
- numerator = valueList.at(0).toInt();
- numerator = numerator * 1;
- denominator *= expertSize;
- // qDebug() << "---yuefen前" << numerator << "---" << denominator;
- yuefen(numerator, denominator);
- // qDebug() << "---yuefen后" << numerator << "---" << denominator;
- if (denominator == 1) {
- compositeNodeValueInfoList.at(i)->nodeValue = QString::number(numerator);
- } else {
- compositeNodeValueInfoList.at(i)->nodeValue =
- QString::number(numerator) + "/" + QString::number(denominator);
- }
- }
- } else if (tabMsg == "技术措施重要度评估对象") {
- for (int i = 0; i < expertIds.size(); i++) {
- QList<NodeMatrixInfo *> nodeValueInfoList;
- NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertIds.at(i),
- engineerId, tabMsg);
- if (nodeValueInfoList.size() == 0) {
- continue;
- }
- expertSize += 1;
- if (compositeNodeValueInfoList.isEmpty()) {
- compositeNodeValueInfoList = nodeValueInfoList;
- } else {
- for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
- NodeMatrixInfo *nodeInfo = compositeNodeValueInfoList.at(i);
- for (int j = 0; j < nodeValueInfoList.size(); j++) {
- NodeMatrixInfo *info = nodeValueInfoList.at(j);
- if (nodeInfo->node == info->node && nodeInfo->abscissa == info->abscissa
- && nodeInfo->ordinate == info->ordinate) {
- nodeInfo->nodeValue =
- QString::number(nodeInfo->nodeValue.toInt() + info->nodeValue.toInt());
- }
- }
- }
- }
- }
- // 平均value值
- for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
- QStringList valueList = compositeNodeValueInfoList.at(i)->nodeValue.split("/");
- long int numerator = valueList.at(0).toInt();
- long int denominator = 1;
- numerator = numerator * 1;
- denominator *= expertSize;
- // qDebug() << "---yuefen前" << numerator << "---" << denominator;
- yuefen(numerator, denominator);
- // qDebug() << "---yuefen后" << numerator << "---" << denominator;
- if (denominator == 1) {
- compositeNodeValueInfoList.at(i)->nodeValue = QString::number(numerator);
- } else {
- compositeNodeValueInfoList.at(i)->nodeValue =
- QString::number(numerator) + "/" + QString::number(denominator);
- }
- }
- }
- } else {
- if (tabMsg == "能力重要度评估指标体系" || tabMsg == "方案评估指标体系") {
- for (int i = 0; i < expertIds.size(); i++) {
- QList<NodeMatrixInfo *> nodeValueInfoList;
- NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertIds.at(i),
- engineerId, tabMsg);
- // qDebug() << "nodeValueInfoList.size()==" << nodeValueInfoList.size();
- if (nodeValueInfoList.size() == 0) {
- continue;
- }
- if (compositeNodeValueInfoList.isEmpty()) {
- compositeNodeValueInfoList = nodeValueInfoList;
- } else {
- for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
- NodeMatrixInfo *nodeInfo = compositeNodeValueInfoList.at(i);
- QString compostValue = nodeInfo->nodeValue;
- QStringList list = compostValue.split("/");
- long int numerator;
- long int denominator;
- if (list.size() == 1) {
- numerator = list.at(0).toInt() * list.at(0).toInt();
- denominator = list.at(0).toInt();
- } else {
- numerator = list.at(0).toInt();
- denominator = list.at(1).toInt();
- }
- for (int j = 0; j < nodeValueInfoList.size(); j++) {
- NodeMatrixInfo *info = nodeValueInfoList.at(j);
- if (nodeInfo->node == info->node && nodeInfo->abscissa == info->abscissa
- && nodeInfo->ordinate == info->ordinate) {
- QString infoValue = info->nodeValue;
- QStringList list2 = infoValue.split("/");
- int numerator2;
- int denominator2;
- if (list2.size() == 1) {
- numerator2 = list2.at(0).toInt() * list2.at(0).toInt();
- denominator2 = list2.at(0).toInt();
- } else {
- numerator2 = list2.at(0).toInt();
- denominator2 = list2.at(1).toInt();
- }
- // 等级计算
- if (compostValue == infoValue) {
- nodeInfo->nodeValue = compostValue;
- numerator = numerator2;
- denominator = denominator2;
- continue;
- } else if (numerator / denominator == 0 && numerator2 / denominator2 == 0) { // 都小于1
- numerator = 1;
- denominator = (denominator + denominator2) / 2;
- } else if (numerator / denominator == 0 && numerator2 / denominator2 != 0) {
- numerator = 1 + denominator2;
- denominator = 2;
- } else if (numerator / denominator != 0 && numerator2 / denominator2 == 0) {
- numerator = denominator + 1;
- denominator = 2;
- } else if (numerator / denominator != 0 && numerator2 / denominator2 != 0) {
- numerator = abs((numerator / denominator + numerator2 / denominator2));
- denominator = 2;
- }
- yuefen(numerator, denominator);
- if (numerator == denominator) {
- nodeInfo->nodeValue = "1";
- } else {
- nodeInfo->nodeValue =
- QString::number(numerator) + "/" + QString::number(denominator);
- }
- }
- }
- }
- }
- }
- } else if (tabMsg == "技术措施重要度评估对象") {
- }
- }
- }
- // 字母约分处理
- void AnalysisPanelWidget::yuefen(long int &numerator, long int &denominator)
- {
- long int a = numerator, b = denominator;
- long int temp = a % b;
- while (temp) {
- a = b;
- b = temp;
- temp = a % b;
- }
- numerator /= b;
- denominator /= b;
- // qDebug() << "yuefen--" << numerator << "---" << denominator;
- }
- void AnalysisPanelWidget::paintPlainWidget()
- {
- bool firstShow = true;
- if (getPages() == 0) {
- return;
- }
- if (currentPage > 1) {
- firstShow = false;
- }
- if (firstShow) {
- ui->stackedWidget->setCurrentIndex(0);
- } else {
- QTabWidget *newTab = tabWidgets.at(currentPage - 2);
- // qDebug() << secondLayout->count();
- if (secondLayout->count() == 0) {
- secondLayout->addWidget(newTab);
- newTab->show();
- } else {
- QTabWidget *currTab = qobject_cast<QTabWidget *>(secondLayout->itemAt(0)->widget());
- if (newTab == currTab) {
- } else {
- secondLayout->removeWidget(currTab);
- currTab->hide();
- secondLayout->addWidget(newTab);
- newTab->show();
- }
- }
- ui->stackedWidget->setCurrentIndex(1);
- }
- }
- void AnalysisPanelWidget::on_prePageBtn_clicked()
- {
- setPage(currentPage - 1);
- }
- void AnalysisPanelWidget::on_nextPageBtn_clicked()
- {
- setPage(currentPage + 1);
- }
- void AnalysisPanelWidget::getTableModel(QStandardItemModel *item)
- {
- emit returnModel(item);
- }
- void AnalysisPanelWidget::oneTableDataReady(bool status)
- {
- if (status) {
- bool filled = true;
- AnalysisTableWidget *first = qobject_cast<AnalysisTableWidget *>(firstLayout->itemAt(0)->widget());
- if (!first->isDataReady()) {
- filled = false;
- }
- for (QTabWidget *tab : tabWidgets) {
- for (int t = 0; t < tab->count(); ++t) {
- AnalysisTableWidget *table = qobject_cast<AnalysisTableWidget *>(tab->widget(t));
- if (!table->isDataReady()) {
- filled = false;
- }
- }
- }
- emit dataReady(filled);
- } else {
- emit dataReady(false);
- }
- }
|