SchemePlanWidget.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include "SchemePlanWidget.h"
  2. #include "SchemeFlowWidget.h"
  3. #include "ProjectManager.h"
  4. #include <dbService/ClassSet.h>
  5. #include <dbService/SchemeProcessService.h>
  6. #include <CSchemeView.h>
  7. #include <Widgets/Button.h>
  8. #include <QTabWidget>
  9. #include <QLayout>
  10. #include <QDebug>
  11. SchemePlanWidget::SchemePlanWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
  12. {
  13. setTitle("评估方案规划");
  14. setupUI();
  15. }
  16. void SchemePlanWidget::setType(int type)
  17. {
  18. EvalWidget::setType(type);
  19. setupTabWidget();
  20. }
  21. void SchemePlanWidget::setupUI()
  22. {
  23. m_topLayout->addStretch();
  24. m_export = new PushButton("保存", this);
  25. m_export->setEnabled(false);
  26. m_topLayout->addWidget(m_export);
  27. m_topLayout->addSpacing(10);
  28. m_export->setHidden(true);
  29. connect(m_export, &PushButton::clicked, this, &SchemePlanWidget::slotExportClicked);
  30. }
  31. QList<SchemePlanManager::SchemeProcessInfo> SchemePlanWidget::templateSchemes(int projId, int indexType)
  32. {
  33. QList<SchemePlanManager::SchemeProcessType> types;
  34. switch (indexType) {
  35. case ProjectManager::AbilityIndex: {
  36. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  37. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  38. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  39. break;
  40. }
  41. case ProjectManager::TechIndex: {
  42. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  43. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  44. break;
  45. }
  46. case ProjectManager::OptimalIndex: {
  47. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  48. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  49. SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  50. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  51. break;
  52. }
  53. case ProjectManager::EfficiencyIndex: {
  54. types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportWeightData,
  55. SchemePlanManager::OptimizeIndex, SchemePlanManager::CalculateWeight,
  56. SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
  57. SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
  58. break;
  59. }
  60. }
  61. QList<SchemePlanManager::SchemeProcessInfo> schemes;
  62. for (int i = 0; i < types.count(); i++) {
  63. SchemePlanManager::SchemeProcessInfo process;
  64. process.projectId = projId;
  65. process.indexType = indexType;
  66. process.type = types[i];
  67. process.step = i;
  68. process.dSource = SchemePlanManager::processOptionalDataSource(process).first();
  69. process.algorithm = SchemePlanManager::processOptionalAlgorithms(process).first();
  70. schemes.append(process);
  71. }
  72. return schemes;
  73. }
  74. void SchemePlanWidget::setupTabWidget()
  75. {
  76. m_tab->clear();
  77. for (int i : indexList()) {
  78. SchemeFlowWidget *m = new SchemeFlowWidget(this);
  79. connect(m, &SchemeFlowWidget::sigSchemeProcessEdited, this, &SchemePlanWidget::slotSchemeProcessEdited);
  80. QList<SchemePlanManager::SchemeProcessInfo> schemes;
  81. bool ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(schemes, m_proj->id, i);
  82. if (ret && schemes.count() <= 0) {
  83. schemes = templateSchemes(m_proj->id, i);
  84. ret = SchemeProcessService().AddAllSchemeProcess(schemes);
  85. }
  86. if (ret) {
  87. m->loadSchemes(schemes);
  88. }
  89. ProjectManager::IndexType t = (ProjectManager::IndexType)i;
  90. QString s = ProjectManager::nameOfIndexType(t);
  91. m_tab->addTab(m, s);
  92. }
  93. }
  94. void SchemePlanWidget::slotExportClicked()
  95. {
  96. for (int i = 0; i < m_tab->count(); i++) {
  97. SchemeFlowWidget *w = (SchemeFlowWidget *)m_tab->widget(i);
  98. QList<SchemePlanManager::SchemeProcessInfo> schemes = w->schemes();
  99. }
  100. }
  101. void SchemePlanWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process)
  102. {
  103. SchemeProcessService().UpdateSchemeProcess(process);
  104. }