DataCollectionWidget.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #include "DataCollectionWidget.h"
  2. #include "DataTableWidget.h"
  3. #include "ConfigExpertDataWidget.h"
  4. #include "ConfigMeasureDataWidget.h"
  5. #include "EvalDataManager.h"
  6. #include "algorithm/HierarchicalAnalysis.h"
  7. #include "GreyClusteringConfigWidget.h" // 灰色聚类配置
  8. #include "GreyClusteringSampleTable.h" // 灰色聚类评估
  9. #include "MatterElementConfigWidget.h" // 物元分析配置
  10. #include "dbService/SchemeProcessService.h"
  11. #include "dbService/ClassSet.h"
  12. #include "dbService/CNodeDataService.h"
  13. #include <CNode.h>
  14. #include <Widgets/Button.h>
  15. #include <QTabWidget>
  16. #include <QBoxLayout>
  17. #include <QMap>
  18. #include <QDebug>
  19. DataCollectionWidget::DataCollectionWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
  20. {
  21. setTitle("评估数据采集");
  22. m_configExpert = new ConfigExpertDataWidget(this);
  23. m_configMeasure = new ConfigMeasureDataWidget(this);
  24. m_configMeasure->setFixedWidth(256);
  25. m_contentLayout->addWidget(m_configExpert);
  26. m_contentLayout->addWidget(m_configMeasure);
  27. m_configExpert->setHidden(true);
  28. m_configMeasure->setHidden(true);
  29. m_calcBtn = new PushButton("更新数据");
  30. m_topLayout->addStretch();
  31. m_topLayout->addWidget(m_calcBtn);
  32. connect(m_calcBtn, &PushButton::clicked, this, &DataCollectionWidget::slotCalc);
  33. connect(m_tab, &QTabWidget::currentChanged, this, &DataCollectionWidget::slotTabCurrentChanged);
  34. }
  35. void DataCollectionWidget::setType(int type)
  36. {
  37. EvalWidget::setType(type);
  38. setupTabWidget();
  39. }
  40. ///
  41. /// \brief DataCollectionWidget::setupTabWidget
  42. /// 根据评估类型, 评估方案, 评估算法, 加载合适的数据导入界面
  43. void DataCollectionWidget::setupTabWidget()
  44. {
  45. m_tab->clear();
  46. QMap<int, QList<CNodeData>> nodeListMap;
  47. for (int i : indexList()) {
  48. // 获取指标体系数据
  49. QList<CNodeData> nodeList;
  50. bool ret = CNodeDataService().QueryAll(nodeList, m_proj->id, i);
  51. if (ret) {
  52. nodeListMap[i] = nodeList;
  53. } else {
  54. return;
  55. }
  56. // 获取方案规划数据
  57. QList<SchemePlanManager::SchemeProcessInfo> processList;
  58. ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, i);
  59. if (ret == false) {
  60. return;
  61. }
  62. ProjectManager::IndexType t = (ProjectManager::IndexType)i;
  63. QString indexName = ProjectManager::nameOfIndexType(t);
  64. // 效能评估方案中导入评估数据的步骤, 选择物元分析法时使用
  65. SchemePlanManager::SchemeProcessInfo importEffiEvalDataProcess;
  66. for (SchemePlanManager::SchemeProcessInfo process : processList) {
  67. // 综合效能评估 - 灰色聚类法: 效能等级配置页面, 导入评估数据页面
  68. if (process.algorithm == SchemePlanManager::GCE && process.indexType == ProjectManager::EfficiencyIndex) {
  69. GreyClusteringConfigWidget *gc = new GreyClusteringConfigWidget(process.efficiencyGrades);
  70. m_tab->addTab(gc, indexName + " - " + "灰色聚类法效能等级配置");
  71. QVector<GreyClusteringItem> items;
  72. GreyClusteringSampleTable *gs = new GreyClusteringSampleTable(items, 2, 10);
  73. m_tab->addTab(gs, indexName + " - " + "收集效能评估数据");
  74. }
  75. // 综合效能评估 - 物元分析法: 效能等级配置页面, 导入评估数据页面
  76. if (process.algorithm == SchemePlanManager::MEA && process.indexType == ProjectManager::EfficiencyIndex) {
  77. QList<MEConfigItem> items;
  78. CMind *mind = new CMind();
  79. mind->setNodeList(nodeListMap[i]);
  80. MatterElementConfigWidget *mec = new MatterElementConfigWidget(mind, process.efficiencyGrades);
  81. m_tab->addTab(mec, indexName + "-" + "物元分析法效能等级配置");
  82. DataTableWidget *table = new DataTableWidget(importEffiEvalDataProcess, this);
  83. table->mind1()->setNodeList(nodeListMap[i]);
  84. table->setCurrentPage(1);
  85. m_tab->addTab(table, indexName + " - " + "收集效能评估数据");
  86. }
  87. // 导入效能评估的权重分析数据
  88. // 导入其他评估的权重分析数据和评估数据
  89. if (process.dSource >= 0) {
  90. if (process.type == SchemePlanManager::ImportEvalData
  91. && process.indexType == ProjectManager::EfficiencyIndex) {
  92. importEffiEvalDataProcess = process;
  93. continue;
  94. }
  95. DataTableWidget *table = new DataTableWidget(process, this);
  96. table->mind1()->setNodeList(nodeListMap[i]);
  97. if (i == ProjectManager::TechIndex) {
  98. table->mind2()->setNodeList(nodeListMap[ProjectManager::AbilityIndex]);
  99. }
  100. QList<NodeMatrixInfo> list = EvalDataManager::dataSample(process, table->mind1(), table->mind2());
  101. table->setData(list);
  102. table->setCurrentPage(1);
  103. QString processName = SchemePlanManager::processName(process);
  104. m_tab->addTab(table, indexName + " - " + processName);
  105. }
  106. }
  107. }
  108. }
  109. void DataCollectionWidget::slotTabCurrentChanged(int index)
  110. {
  111. DataTableWidget *table = dynamic_cast<DataTableWidget *>(m_tab->widget(index));
  112. if (index >= 0 && table != nullptr) {
  113. bool expert = (table->process().dSource == SchemePlanManager::FromExpert);
  114. if (expert) {
  115. m_configExpert->setProcess(table->process());
  116. }
  117. m_configExpert->setVisible(expert);
  118. bool meaure = (table->process().dSource == SchemePlanManager::FromMeasurement);
  119. if (meaure) {
  120. m_configMeasure->setProcess(table->process());
  121. }
  122. m_configMeasure->setVisible(meaure);
  123. }
  124. if (table == nullptr) {
  125. m_configExpert->setHidden(true);
  126. m_configMeasure->setHidden(true);
  127. }
  128. }
  129. void DataCollectionWidget::slotCalc()
  130. {
  131. DataTableWidget *table = dynamic_cast<DataTableWidget *>(m_tab->currentWidget());
  132. if (table == nullptr) {
  133. return;
  134. }
  135. QStringList nodes = table->hNodes();
  136. QVector<qreal> values = table->values();
  137. qDebug() << __FUNCTION__ << __LINE__ << nodes << endl;
  138. qDebug() << __FUNCTION__ << __LINE__ << values << endl;
  139. if (values.count() != nodes.count() * nodes.count()) {
  140. return;
  141. }
  142. HierarchicalAnalysis *a = new HierarchicalAnalysis(nodes, values);
  143. qDebug() << __FUNCTION__ << __LINE__ << a->getWeights() << endl;
  144. }