DataCollectionWidget.cpp 5.7 KB

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