AnalysisPanelWidget.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. #include "AnalysisPanelWidget.h"
  2. #include "AnalysisTableWidget.h"
  3. #include "dbService/DBServiceSet.h"
  4. #include "dbService/NodeMatrixService.h"
  5. #include "dbService/DemandWeightService.h"
  6. #include "ui_AnalysisPanelWidget.h"
  7. #include <QHeaderView>
  8. #include <QDebug>
  9. AnalysisPanelWidget::AnalysisPanelWidget(QWidget *parent) : QWidget(parent), ui(new Ui::AnalysisPanelWidget)
  10. {
  11. ui->setupUi(this);
  12. firstLayout = new QGridLayout;
  13. firstPlainWidget = nullptr;
  14. ui->stackedWidget->widget(0)->setLayout(firstLayout);
  15. secondLayout = new QGridLayout;
  16. secondPlainWidget = nullptr;
  17. ui->stackedWidget->widget(1)->setLayout(secondLayout);
  18. ui->stackedWidget->setCurrentIndex(0);
  19. }
  20. AnalysisPanelWidget::~AnalysisPanelWidget()
  21. {
  22. if (currentMindNodes) {
  23. delete currentMindNodes;
  24. }
  25. if (classifiedNodes) {
  26. delete classifiedNodes;
  27. }
  28. if (indexsRefClassifiedNodes) {
  29. delete indexsRefClassifiedNodes;
  30. }
  31. delete ui;
  32. }
  33. void AnalysisPanelWidget::init(const QStringList indexsRef, const QStringList indexs, int engineerId, int expertId)
  34. {
  35. // qDebug() << "AnalysisPanelWidget::init" << indexsRef << indexs <<
  36. // engineerId << expertId;
  37. indexsRefClassifiedNodes = nullptr;
  38. if (!indexsRef.isEmpty()) {
  39. MindNodeManager *indexsRefNodes = new MindNodeManager(); // 是否参考指标体系
  40. getMindNodes(indexsRefNodes, indexsRef);
  41. indexsRefClassifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
  42. sortMindNodes(*indexsRefNodes, indexsRefClassifiedNodes);
  43. delete indexsRefNodes;
  44. } else {
  45. indexsRefClassifiedNodes = nullptr;
  46. }
  47. if (!indexs.isEmpty()) {
  48. currentMindNodes = new MindNodeManager();
  49. classifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
  50. getMindNodes(currentMindNodes, indexs);
  51. sortMindNodes(*currentMindNodes, classifiedNodes);
  52. } else {
  53. currentMindNodes = nullptr;
  54. classifiedNodes = nullptr;
  55. }
  56. ui->toatalPagesLabel->setText(QString("共%1页").arg(getPages()));
  57. ui->currPageLabel->setText(QString("当前第0页"));
  58. initPlainWidget(engineerId, expertId, m_table_msg);
  59. setPage(1);
  60. }
  61. // 综合专家页面初始化
  62. void AnalysisPanelWidget::initComposite(const QStringList indexsRef, const QStringList indexs, int engineerId,
  63. QList<int> expertIds)
  64. {
  65. indexsRefClassifiedNodes = nullptr;
  66. if (!indexsRef.isEmpty()) {
  67. MindNodeManager *indexsRefNodes = new MindNodeManager(); // 是否参考指标体系
  68. getMindNodes(indexsRefNodes, indexsRef);
  69. indexsRefClassifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
  70. sortMindNodes(*indexsRefNodes, indexsRefClassifiedNodes);
  71. delete indexsRefNodes;
  72. } else {
  73. indexsRefClassifiedNodes = nullptr;
  74. }
  75. if (!indexs.isEmpty()) {
  76. currentMindNodes = new MindNodeManager();
  77. classifiedNodes = new QList<QList<MindNodeManager::NodeMessage>>;
  78. getMindNodes(currentMindNodes, indexs);
  79. sortMindNodes(*currentMindNodes, classifiedNodes);
  80. } else {
  81. currentMindNodes = nullptr;
  82. classifiedNodes = nullptr;
  83. }
  84. ui->toatalPagesLabel->setText(QString("共%1页").arg(getPages()));
  85. ui->currPageLabel->setText(QString("当前第0页"));
  86. initCompositePlainWidget(engineerId, expertIds, m_table_msg);
  87. setPage(1);
  88. }
  89. void AnalysisPanelWidget::setViewTypeAndTableMsg(int type, QString tableMsg)
  90. {
  91. analysisViewType = type;
  92. m_table_msg = tableMsg;
  93. if (type == 1) {
  94. ui->prePageBtn->setText("上一级指标");
  95. ui->nextPageBtn->setText("下一级指标");
  96. } else if (type == 2) {
  97. ui->prePageBtn->setText("上一级技术措施");
  98. ui->nextPageBtn->setText("下一级技术措施");
  99. } else if (type == 3) {
  100. ui->prePageBtn->setText("上一级指标");
  101. ui->nextPageBtn->setText("下一级指标");
  102. }
  103. }
  104. void AnalysisPanelWidget::setArithmeticMethod(QString resultMethod, QString matricesMethod)
  105. {
  106. m_resultMethod = resultMethod;
  107. m_matricesMethod = matricesMethod;
  108. }
  109. void AnalysisPanelWidget::sortMindNodes(const MindNodeManager &manager,
  110. QList<QList<MindNodeManager::NodeMessage>> *classify)
  111. {
  112. for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
  113. QStringList nodePonit = msg.node.split(".");
  114. // qDebug() << "TAG" << nodePonit << msg.node << msg.name;
  115. while (nodePonit.count() - 1 > classify->count()) {
  116. (*classify) << QList<MindNodeManager::NodeMessage>();
  117. }
  118. (*classify)[nodePonit.count() - 2] << msg;
  119. }
  120. #if 0
  121. struct ClassifyNode
  122. {
  123. MindNodeManager::NodeMessage msg;
  124. QList<ClassifyNode *> child;
  125. };
  126. QList<ClassifyNode *> classifyList;
  127. for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
  128. QStringList nodePonit = msg.node.split(".");
  129. int level = nodePonit.count() - 1;
  130. if (level == 1) { //第一级
  131. ClassifyNode *cn = new ClassifyNode;
  132. cn->msg = msg;
  133. classifyList << cn;
  134. } else {
  135. ClassifyNode *ref = classifyList[nodePonit[1].toInt() - 1];
  136. for (int i = 2; i < level; ++i) {
  137. ref = ref->child[nodePonit[i].toInt() - 1];
  138. }
  139. ClassifyNode *cn = new ClassifyNode;
  140. cn->msg = msg;
  141. ref->child << cn;
  142. }
  143. }
  144. #endif
  145. }
  146. void AnalysisPanelWidget::getMindNodes(MindNodeManager *manager, QStringList listNodes)
  147. {
  148. int sn[16];
  149. memset(sn, 0, sizeof(int) * 16);
  150. int spaceNum = -1;
  151. int level = 0;
  152. MindNodeManager::NodeMessage temp;
  153. manager->setMindName(listNodes[0].trimmed());
  154. for (int i = 1; i < listNodes.count(); i++) {
  155. int tempSpace = 0;
  156. for (QString s : listNodes[i]) {
  157. if (s == " ") {
  158. tempSpace++;
  159. } else {
  160. break;
  161. }
  162. }
  163. tempSpace /= 4;
  164. if (tempSpace == 1) { // 一级
  165. spaceNum = tempSpace;
  166. level = 0;
  167. sn[level]++;
  168. memset((void *)&sn[1], 0, sizeof(int) * 15);
  169. } else {
  170. if (spaceNum < tempSpace) { // 空格增加
  171. spaceNum = tempSpace;
  172. level++;
  173. sn[level]++;
  174. } else if (spaceNum == tempSpace) { // 同一级
  175. sn[level]++;
  176. } else {
  177. memset((void *)&sn[tempSpace], 0, sizeof(int) * (16 - tempSpace));
  178. level -= spaceNum - tempSpace;
  179. spaceNum = tempSpace;
  180. sn[level]++;
  181. }
  182. }
  183. QString node = "1";
  184. for (int l : sn) {
  185. if (l > 0) {
  186. node += QString(".%1").arg(l);
  187. } else {
  188. break;
  189. }
  190. }
  191. if (listNodes[i].trimmed().isEmpty()) {
  192. temp.name = QString("NULL(节点%1)").arg(node);
  193. temp.node = node;
  194. temp.remark = "";
  195. manager->pushNewMind(temp);
  196. } else {
  197. temp.name = listNodes[i].trimmed().split("\t")[0];
  198. temp.node = node;
  199. temp.remark = listNodes[i].trimmed().split("\t")[1];
  200. manager->pushNewMind(temp);
  201. }
  202. }
  203. }
  204. QStringList AnalysisPanelWidget::getFirstIndexNodes(const MindNodeManager &manager)
  205. {
  206. QList<QList<MindNodeManager::NodeMessage>> classify;
  207. for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
  208. QStringList nodePonit = msg.node.split(".");
  209. while (nodePonit.count() - 1 > classify.count()) {
  210. classify << QList<MindNodeManager::NodeMessage>();
  211. }
  212. classify[nodePonit.count() - 2] << msg;
  213. }
  214. QStringList firstNodes;
  215. for (MindNodeManager::NodeMessage msg : classify.first()) {
  216. firstNodes << msg.name;
  217. }
  218. return firstNodes;
  219. }
  220. QStringList AnalysisPanelWidget::getLastIndexNodes(const MindNodeManager &manager)
  221. {
  222. QList<QList<MindNodeManager::NodeMessage>> classify;
  223. for (MindNodeManager::NodeMessage msg : manager.getMindNodes()) {
  224. QStringList nodePonit = msg.node.split(".");
  225. while (nodePonit.count() - 1 > classify.count()) {
  226. classify << QList<MindNodeManager::NodeMessage>();
  227. }
  228. classify[nodePonit.count() - 2] << msg;
  229. }
  230. QStringList lastNodes;
  231. for (MindNodeManager::NodeMessage msg : classify.last()) {
  232. lastNodes << msg.name;
  233. }
  234. return lastNodes;
  235. }
  236. int AnalysisPanelWidget::getPages()
  237. {
  238. #if 0
  239. int max = 0;
  240. for (MindNodeManager::NodeMessage msg : currentMindNodes->getMindNodes()) {
  241. QStringList nodePonit = msg.node.split(".");
  242. if (max < nodePonit.count() - 1) { max = nodePonit.count() - 1; }
  243. }
  244. return max;
  245. #else
  246. if (!classifiedNodes) {
  247. return 0;
  248. }
  249. return classifiedNodes->count();
  250. #endif
  251. }
  252. void AnalysisPanelWidget::setPage(int page)
  253. {
  254. if (page < 1 || page > getPages()) {
  255. return;
  256. }
  257. currentPage = page;
  258. ui->currPageLabel->setText(QString("当前第%1页").arg(currentPage));
  259. if (currentPage == 1) {
  260. ui->prePageBtn->setDisabled(true);
  261. ui->nextPageBtn->setDisabled(false);
  262. } else if (currentPage == getPages()) {
  263. ui->prePageBtn->setDisabled(false);
  264. ui->nextPageBtn->setDisabled(true);
  265. } else {
  266. ui->prePageBtn->setDisabled(false);
  267. ui->nextPageBtn->setDisabled(false);
  268. }
  269. paintPlainWidget();
  270. }
  271. // 专家初始化数据
  272. void AnalysisPanelWidget::initPlainWidget(int engineerId, int expertId, QString tableMsg)
  273. {
  274. if (getPages() == 0) {
  275. return;
  276. }
  277. // 获取技术措施指标权重
  278. QList<DemandWeight *> firstDemandList;
  279. QList<DemandWeight *> secondDemandList;
  280. DemandWeightService().QueryFirstDemandWeightByEngineerId(&firstDemandList, expertId, engineerId, tableMsg);
  281. // DBServiceSet().QuerySecondDemandWeightByEngineerId(&secondDemandList, expertId,
  282. // engineerId,"能力重要度评估指标体系");
  283. DemandWeightService().QuerySecondDemandWeightByEngineerIdAndMaxPage(&secondDemandList, expertId, engineerId,
  284. "能力重要度评估指标体系");
  285. QList<NodeMatrixInfo *> nodeValueInfoList;
  286. NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertId, engineerId, tableMsg);
  287. // 准备第一页,非tab的
  288. AnalysisTableWidget *table = new AnalysisTableWidget;
  289. table->horizontalHeader()->setStretchLastSection(true);
  290. table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); // 填充表格
  291. table->setTableIndexAndTableMsg(0, engineerId, QString::number(expertId), tableMsg);
  292. connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
  293. connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
  294. if (indexsRefClassifiedNodes) {
  295. for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
  296. table->addRowNode(msg.node, msg.name, msg.remark);
  297. }
  298. }
  299. for (MindNodeManager::NodeMessage msg : classifiedNodes->first()) {
  300. table->addColNode(msg.node, msg.name, msg.remark);
  301. if (indexsRefClassifiedNodes == nullptr) {
  302. table->addRowNode(msg.node, msg.name, msg.remark);
  303. }
  304. }
  305. table->setTableWeight(firstDemandList, secondDemandList);
  306. QVector<qreal> firstTableWieghts;
  307. table->paintMatrixTable(nodeValueInfoList, analysisViewType);
  308. firstLayout->addWidget(table);
  309. // 准备第二页,tab组合的
  310. QTabWidget *tab = new QTabWidget;
  311. for (int p = 1; p < getPages(); ++p) {
  312. QTabWidget *tab = new QTabWidget;
  313. tab->setTabPosition(QTabWidget::South);
  314. int index = 0;
  315. for (MindNodeManager::NodeMessage msg : classifiedNodes->at(p - 1)) {
  316. ++index;
  317. QString node = msg.node;
  318. // MatrixTableWidget *table = nullptr;
  319. table = nullptr;
  320. for (MindNodeManager::NodeMessage info : classifiedNodes->at(p)) {
  321. if ((info.node.count('.') == msg.node.count('.') + 1)
  322. && (info.node.left(msg.node.count()) == msg.node)) {
  323. if (!table) {
  324. table = new AnalysisTableWidget;
  325. connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
  326. }
  327. if (table) {
  328. table->addColNode(info.node, info.name, info.remark);
  329. if (!indexsRefClassifiedNodes) {
  330. table->addRowNode(info.node, info.name, info.remark);
  331. }
  332. }
  333. }
  334. }
  335. if (indexsRefClassifiedNodes) {
  336. for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
  337. table->addRowNode(msg.node, msg.name, msg.remark);
  338. }
  339. }
  340. if (table) {
  341. firstDemandList.clear();
  342. if (firstDemandList.size() == 0) {
  343. DemandWeightService().QueryLastPageDemandWeightByEngineerId(
  344. &firstDemandList, QString::number(expertId), engineerId, tableMsg, p - 1);
  345. }
  346. // qDebug() << p << "=" << p << "===========" << firstDemandList.size();
  347. table->setTableIndexAndTableMsg(index, engineerId, QString::number(expertId), tableMsg);
  348. table->setTableWeight(firstDemandList, secondDemandList);
  349. table->paintSecondMatrixTable(nodeValueInfoList, p, analysisViewType, index);
  350. tab->addTab(table, msg.name);
  351. connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
  352. }
  353. }
  354. tabWidgets << tab;
  355. }
  356. qDeleteAll(firstDemandList);
  357. qDeleteAll(secondDemandList);
  358. // secondLayout->addWidget(tab);
  359. }
  360. // 综合专家页面渲染
  361. void AnalysisPanelWidget::initCompositePlainWidget(int engineerId, QList<int> expertIds, QString tableMsg)
  362. {
  363. if (getPages() == 0) {
  364. return;
  365. }
  366. QString experId;
  367. for (int i = 0; i < expertIds.size(); i++) {
  368. if (experId == nullptr) {
  369. experId = QString::number(expertIds.at(i));
  370. } else {
  371. experId = experId + "," + QString::number(expertIds.at(i));
  372. }
  373. }
  374. qDebug() << experId;
  375. // 获取技术措施指标权重
  376. QList<DemandWeight *> firstDemandList;
  377. QList<DemandWeight *> secondDemandList;
  378. DemandWeightService().QueryFirstDemandWeightByEngineerId(&firstDemandList, experId, engineerId, tableMsg);
  379. DemandWeightService().QuerySecondDemandWeightByEngineerId(&secondDemandList, experId, engineerId,
  380. "能力重要度评估指标体系");
  381. QList<NodeMatrixInfo *> compositeNodeValueInfoList;
  382. computerCompositeValue(compositeNodeValueInfoList, expertIds, engineerId, tableMsg);
  383. // 准备第一页,非tab的
  384. AnalysisTableWidget *table = new AnalysisTableWidget;
  385. connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
  386. connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
  387. if (indexsRefClassifiedNodes) {
  388. for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
  389. table->addRowNode(msg.node, msg.name, msg.remark);
  390. }
  391. }
  392. for (MindNodeManager::NodeMessage msg : classifiedNodes->first()) {
  393. table->addColNode(msg.node, msg.name, msg.remark);
  394. if (indexsRefClassifiedNodes == nullptr) {
  395. table->addRowNode(msg.node, msg.name, msg.remark);
  396. }
  397. }
  398. table->setTableWeight(firstDemandList, secondDemandList);
  399. QVector<qreal> firstTableWieghts;
  400. table->setTableIndexAndTableMsg(0, engineerId, experId, m_table_msg);
  401. table->paintMatrixTable(compositeNodeValueInfoList, analysisViewType);
  402. firstLayout->addWidget(table);
  403. // 准备第二页,tab组合的
  404. for (int p = 1; p < getPages(); ++p) {
  405. QTabWidget *tab = new QTabWidget;
  406. tab->setTabPosition(QTabWidget::South);
  407. int index = 0;
  408. for (MindNodeManager::NodeMessage msg : classifiedNodes->at(p - 1)) {
  409. ++index;
  410. QString node = msg.node;
  411. // MatrixTableWidget *table = nullptr;
  412. table = nullptr;
  413. for (MindNodeManager::NodeMessage info : classifiedNodes->at(p)) {
  414. if ((info.node.count('.') == msg.node.count('.') + 1)
  415. && (info.node.left(msg.node.count()) == msg.node)) {
  416. if (!table) {
  417. table = new AnalysisTableWidget;
  418. table->setTableIndexAndTableMsg(index, engineerId, experId, tableMsg);
  419. connect(table, &AnalysisTableWidget::returnModel, this, &AnalysisPanelWidget::getTableModel);
  420. }
  421. if (table) {
  422. table->addColNode(info.node, info.name, info.remark);
  423. if (!indexsRefClassifiedNodes) {
  424. table->addRowNode(info.node, info.name, info.remark);
  425. }
  426. }
  427. }
  428. }
  429. if (indexsRefClassifiedNodes) {
  430. for (MindNodeManager::NodeMessage msg : indexsRefClassifiedNodes->last()) {
  431. table->addRowNode(msg.node, msg.name, msg.remark);
  432. }
  433. }
  434. if (table) {
  435. firstDemandList.clear();
  436. if (firstDemandList.size() == 0) {
  437. DemandWeightService().QueryLastPageDemandWeightByEngineerId(&firstDemandList, experId, engineerId,
  438. tableMsg, p - 1);
  439. }
  440. table->setTableWeight(firstDemandList, secondDemandList);
  441. table->paintSecondMatrixTable(compositeNodeValueInfoList, p, analysisViewType, index);
  442. tab->addTab(table, msg.name);
  443. connect(table, &AnalysisTableWidget::dataReady, this, &AnalysisPanelWidget::oneTableDataReady);
  444. }
  445. }
  446. tabWidgets << tab;
  447. }
  448. qDeleteAll(firstDemandList);
  449. }
  450. // 综合计算
  451. void AnalysisPanelWidget::computerCompositeValue(QList<NodeMatrixInfo *> &compositeNodeValueInfoList,
  452. QList<int> expertIds, int engineerId, QString tabMsg)
  453. {
  454. qDebug() << m_matricesMethod;
  455. if (m_matricesMethod == "valueAverage") { // 数值平均
  456. int expertSize = 0;
  457. if (tabMsg == "能力重要度评估指标体系" || tabMsg == "方案评估指标体系") {
  458. for (int i = 0; i < expertIds.size(); i++) {
  459. QList<NodeMatrixInfo *> nodeValueInfoList;
  460. NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertIds.at(i),
  461. engineerId, tabMsg);
  462. // qDebug() << "nodeValueInfoList.size()==" << nodeValueInfoList.size();
  463. if (nodeValueInfoList.size() == 0) {
  464. continue;
  465. }
  466. expertSize += 1;
  467. if (compositeNodeValueInfoList.isEmpty()) {
  468. compositeNodeValueInfoList = nodeValueInfoList;
  469. } else {
  470. for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
  471. NodeMatrixInfo *nodeInfo = compositeNodeValueInfoList.at(i);
  472. QStringList list = nodeInfo->nodeValue.split("/");
  473. int numerator;
  474. int denominator;
  475. if (list.size() == 1) {
  476. numerator = list.at(0).toInt() * list.at(0).toInt();
  477. denominator = list.at(0).toInt();
  478. } else {
  479. numerator = list.at(0).toInt();
  480. denominator = list.at(1).toInt();
  481. }
  482. for (int j = 0; j < nodeValueInfoList.size(); j++) {
  483. NodeMatrixInfo *info = nodeValueInfoList.at(j);
  484. if (nodeInfo->node == info->node && nodeInfo->abscissa == info->abscissa
  485. && nodeInfo->ordinate == info->ordinate) {
  486. QStringList list2 = info->nodeValue.split("/");
  487. int numerator2;
  488. int denominator2;
  489. if (list2.size() == 1) {
  490. numerator2 = list2.at(0).toInt() * list2.at(0).toInt();
  491. denominator2 = list2.at(0).toInt();
  492. } else {
  493. numerator2 = list2.at(0).toInt();
  494. denominator2 = list2.at(1).toInt();
  495. }
  496. numerator = numerator * denominator2 + numerator2 * denominator;
  497. denominator *= denominator2;
  498. nodeInfo->nodeValue = QString::number(numerator) + "/" + QString::number(denominator);
  499. }
  500. }
  501. }
  502. }
  503. }
  504. // 平均value值
  505. for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
  506. QStringList valueList = compositeNodeValueInfoList.at(i)->nodeValue.split("/");
  507. long int numerator = 1;
  508. long int denominator = 1;
  509. if (valueList.size() != 1) {
  510. denominator = valueList.at(1).toInt();
  511. }
  512. numerator = valueList.at(0).toInt();
  513. numerator = numerator * 1;
  514. denominator *= expertSize;
  515. // qDebug() << "---yuefen前" << numerator << "---" << denominator;
  516. yuefen(numerator, denominator);
  517. // qDebug() << "---yuefen后" << numerator << "---" << denominator;
  518. if (denominator == 1) {
  519. compositeNodeValueInfoList.at(i)->nodeValue = QString::number(numerator);
  520. } else {
  521. compositeNodeValueInfoList.at(i)->nodeValue =
  522. QString::number(numerator) + "/" + QString::number(denominator);
  523. }
  524. }
  525. } else if (tabMsg == "技术措施重要度评估对象") {
  526. for (int i = 0; i < expertIds.size(); i++) {
  527. QList<NodeMatrixInfo *> nodeValueInfoList;
  528. NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertIds.at(i),
  529. engineerId, tabMsg);
  530. if (nodeValueInfoList.size() == 0) {
  531. continue;
  532. }
  533. expertSize += 1;
  534. if (compositeNodeValueInfoList.isEmpty()) {
  535. compositeNodeValueInfoList = nodeValueInfoList;
  536. } else {
  537. for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
  538. NodeMatrixInfo *nodeInfo = compositeNodeValueInfoList.at(i);
  539. for (int j = 0; j < nodeValueInfoList.size(); j++) {
  540. NodeMatrixInfo *info = nodeValueInfoList.at(j);
  541. if (nodeInfo->node == info->node && nodeInfo->abscissa == info->abscissa
  542. && nodeInfo->ordinate == info->ordinate) {
  543. nodeInfo->nodeValue =
  544. QString::number(nodeInfo->nodeValue.toInt() + info->nodeValue.toInt());
  545. }
  546. }
  547. }
  548. }
  549. }
  550. // 平均value值
  551. for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
  552. QStringList valueList = compositeNodeValueInfoList.at(i)->nodeValue.split("/");
  553. long int numerator = valueList.at(0).toInt();
  554. long int denominator = 1;
  555. numerator = numerator * 1;
  556. denominator *= expertSize;
  557. // qDebug() << "---yuefen前" << numerator << "---" << denominator;
  558. yuefen(numerator, denominator);
  559. // qDebug() << "---yuefen后" << numerator << "---" << denominator;
  560. if (denominator == 1) {
  561. compositeNodeValueInfoList.at(i)->nodeValue = QString::number(numerator);
  562. } else {
  563. compositeNodeValueInfoList.at(i)->nodeValue =
  564. QString::number(numerator) + "/" + QString::number(denominator);
  565. }
  566. }
  567. }
  568. } else {
  569. if (tabMsg == "能力重要度评估指标体系" || tabMsg == "方案评估指标体系") {
  570. for (int i = 0; i < expertIds.size(); i++) {
  571. QList<NodeMatrixInfo *> nodeValueInfoList;
  572. NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&nodeValueInfoList, expertIds.at(i),
  573. engineerId, tabMsg);
  574. // qDebug() << "nodeValueInfoList.size()==" << nodeValueInfoList.size();
  575. if (nodeValueInfoList.size() == 0) {
  576. continue;
  577. }
  578. if (compositeNodeValueInfoList.isEmpty()) {
  579. compositeNodeValueInfoList = nodeValueInfoList;
  580. } else {
  581. for (int i = 0; i < compositeNodeValueInfoList.size(); i++) {
  582. NodeMatrixInfo *nodeInfo = compositeNodeValueInfoList.at(i);
  583. QString compostValue = nodeInfo->nodeValue;
  584. QStringList list = compostValue.split("/");
  585. long int numerator;
  586. long int denominator;
  587. if (list.size() == 1) {
  588. numerator = list.at(0).toInt() * list.at(0).toInt();
  589. denominator = list.at(0).toInt();
  590. } else {
  591. numerator = list.at(0).toInt();
  592. denominator = list.at(1).toInt();
  593. }
  594. for (int j = 0; j < nodeValueInfoList.size(); j++) {
  595. NodeMatrixInfo *info = nodeValueInfoList.at(j);
  596. if (nodeInfo->node == info->node && nodeInfo->abscissa == info->abscissa
  597. && nodeInfo->ordinate == info->ordinate) {
  598. QString infoValue = info->nodeValue;
  599. QStringList list2 = infoValue.split("/");
  600. int numerator2;
  601. int denominator2;
  602. if (list2.size() == 1) {
  603. numerator2 = list2.at(0).toInt() * list2.at(0).toInt();
  604. denominator2 = list2.at(0).toInt();
  605. } else {
  606. numerator2 = list2.at(0).toInt();
  607. denominator2 = list2.at(1).toInt();
  608. }
  609. // 等级计算
  610. if (compostValue == infoValue) {
  611. nodeInfo->nodeValue = compostValue;
  612. numerator = numerator2;
  613. denominator = denominator2;
  614. continue;
  615. } else if (numerator / denominator == 0 && numerator2 / denominator2 == 0) { // 都小于1
  616. numerator = 1;
  617. denominator = (denominator + denominator2) / 2;
  618. } else if (numerator / denominator == 0 && numerator2 / denominator2 != 0) {
  619. numerator = 1 + denominator2;
  620. denominator = 2;
  621. } else if (numerator / denominator != 0 && numerator2 / denominator2 == 0) {
  622. numerator = denominator + 1;
  623. denominator = 2;
  624. } else if (numerator / denominator != 0 && numerator2 / denominator2 != 0) {
  625. numerator = abs((numerator / denominator + numerator2 / denominator2));
  626. denominator = 2;
  627. }
  628. yuefen(numerator, denominator);
  629. if (numerator == denominator) {
  630. nodeInfo->nodeValue = "1";
  631. } else {
  632. nodeInfo->nodeValue =
  633. QString::number(numerator) + "/" + QString::number(denominator);
  634. }
  635. }
  636. }
  637. }
  638. }
  639. }
  640. } else if (tabMsg == "技术措施重要度评估对象") {
  641. }
  642. }
  643. }
  644. // 字母约分处理
  645. void AnalysisPanelWidget::yuefen(long int &numerator, long int &denominator)
  646. {
  647. long int a = numerator, b = denominator;
  648. long int temp = a % b;
  649. while (temp) {
  650. a = b;
  651. b = temp;
  652. temp = a % b;
  653. }
  654. numerator /= b;
  655. denominator /= b;
  656. // qDebug() << "yuefen--" << numerator << "---" << denominator;
  657. }
  658. void AnalysisPanelWidget::paintPlainWidget()
  659. {
  660. bool firstShow = true;
  661. if (getPages() == 0) {
  662. return;
  663. }
  664. if (currentPage > 1) {
  665. firstShow = false;
  666. }
  667. if (firstShow) {
  668. ui->stackedWidget->setCurrentIndex(0);
  669. } else {
  670. QTabWidget *newTab = tabWidgets.at(currentPage - 2);
  671. // qDebug() << secondLayout->count();
  672. if (secondLayout->count() == 0) {
  673. secondLayout->addWidget(newTab);
  674. newTab->show();
  675. } else {
  676. QTabWidget *currTab = qobject_cast<QTabWidget *>(secondLayout->itemAt(0)->widget());
  677. if (newTab == currTab) {
  678. } else {
  679. secondLayout->removeWidget(currTab);
  680. currTab->hide();
  681. secondLayout->addWidget(newTab);
  682. newTab->show();
  683. }
  684. }
  685. ui->stackedWidget->setCurrentIndex(1);
  686. }
  687. }
  688. void AnalysisPanelWidget::on_prePageBtn_clicked()
  689. {
  690. setPage(currentPage - 1);
  691. }
  692. void AnalysisPanelWidget::on_nextPageBtn_clicked()
  693. {
  694. setPage(currentPage + 1);
  695. }
  696. void AnalysisPanelWidget::getTableModel(QStandardItemModel *item)
  697. {
  698. emit returnModel(item);
  699. }
  700. void AnalysisPanelWidget::oneTableDataReady(bool status)
  701. {
  702. if (status) {
  703. bool filled = true;
  704. AnalysisTableWidget *first = qobject_cast<AnalysisTableWidget *>(firstLayout->itemAt(0)->widget());
  705. if (!first->isDataReady()) {
  706. filled = false;
  707. }
  708. for (QTabWidget *tab : tabWidgets) {
  709. for (int t = 0; t < tab->count(); ++t) {
  710. AnalysisTableWidget *table = qobject_cast<AnalysisTableWidget *>(tab->widget(t));
  711. if (!table->isDataReady()) {
  712. filled = false;
  713. }
  714. }
  715. }
  716. emit dataReady(filled);
  717. } else {
  718. emit dataReady(false);
  719. }
  720. }