Browse Source

修改算法列表;
数据采集页面重构, 根据方案规划流程加载数据表;

chengxr 1 year ago
parent
commit
d2eeb276e0

+ 1 - 1
QFD/common/SchemePlanManager.cpp

@@ -39,7 +39,7 @@ QString SchemePlanManager::stringFromAlgorithm(SchemePlanManager::Algorithm alg)
     case GCE:
         return "灰色聚类评估法";
     case WeightedSum:
-        return "加权求和法";
+        return "加权求和法";
     }
 }
 

+ 15 - 9
QFD/view/AlgorithmManageView.cpp

@@ -10,13 +10,14 @@ AlgorithmManageView::AlgorithmManageView(QWidget *parent) : QWidget(parent)
     initWidgets();
     initLayouts();
 
-    m_algList.append("主成分分析法");
-    m_algList.append("熵值法");
-    m_algList.append("层次分析法");
-    m_algList.append("层次加权法");
-    m_algList.append("集对分析法");
-    m_algList.append("物元分析法");
-    m_algList.append("灰色聚类评估法");
+    m_algList = { SchemePlanManager::PrincipalComponents,
+                  SchemePlanManager::Entropy,
+                  SchemePlanManager::AHP,
+                  SchemePlanManager::HWM,
+                  SchemePlanManager::SPA,
+                  SchemePlanManager::MEA,
+                  SchemePlanManager::GCE,
+                  SchemePlanManager::WeightedSum };
 
     showAlgs();
 }
@@ -43,7 +44,8 @@ void AlgorithmManageView::initWidgets()
 
 void AlgorithmManageView::initLayouts()
 {
-    m_layout    = new QVBoxLayout(this);
+    m_layout = new QVBoxLayout(this);
+    m_layout->setMargin(20);
     m_topLayout = new QHBoxLayout();
     m_layout->addLayout(m_topLayout);
     m_layout->addWidget(m_listWidget);
@@ -71,7 +73,11 @@ void AlgorithmManageView::showAlgs()
         idx->setFixedWidth(20);
         hBox->addWidget(idx);
         hBox->addSpacing(10);
-        QLabel *name = new QLabel(m_algList[i]);
+
+        SchemePlanManager::Algorithm alg = m_algList[i];
+        QString algStr                   = SchemePlanManager::stringFromAlgorithm(alg);
+
+        QLabel *name = new QLabel(algStr);
         hBox->addWidget(name);
         hBox->addStretch();
     }

+ 4 - 1
QFD/view/AlgorithmManageView.h

@@ -3,6 +3,8 @@
 
 #include <QWidget>
 
+#include "SchemePlanManager.h"
+
 class QVBoxLayout;
 class QLabel;
 class QHBoxLayout;
@@ -28,7 +30,8 @@ private:
     QLabel *m_titleLabel     = nullptr;
     QHBoxLayout *m_topLayout = nullptr;
 
-    QStringList m_algList;
+    QList<SchemePlanManager::Algorithm> m_algList;
+
     QListWidget *m_listWidget = nullptr;
 };
 

+ 42 - 4
QFD/widgets/DataCollectionWidget.cpp

@@ -3,8 +3,17 @@
 #include "DataTableWidget.h"
 #include "ConfigExpertWidget.h"
 
+#include "dbService/SchemeProcessService.h"
+#include "dbService/ClassSet.h"
+#include "dbService/CNodeDataService.h"
+
+#include <CNode.h>
+
 #include <QTabWidget>
 #include <QBoxLayout>
+#include <QMap>
+
+#include <QDebug>
 
 DataCollectionWidget::DataCollectionWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
 {
@@ -22,10 +31,39 @@ void DataCollectionWidget::setType(int type)
 void DataCollectionWidget::setupTabWidget()
 {
     m_tab->clear();
+
+    QMap<int, QList<CNodeData>> nodeListMap;
     for (int i : indexList()) {
-        DataTableWidget *m          = new DataTableWidget(proj(), i, this);
-        ProjectManager::IndexType t = (ProjectManager::IndexType)i;
-        QString s                   = ProjectManager::nameOfIndexType(t);
-        m_tab->addTab(m, s);
+        // 获取指标体系数据
+        QList<CNodeData> nodeList;
+        bool ret = CNodeDataService().QueryAll(nodeList, m_proj->id, i);
+        if (ret) {
+            nodeListMap[i] = nodeList;
+        } else {
+            return;
+        }
+
+        // 获取方案规划数据
+        QList<SchemePlanManager::SchemeProcessInfo> processList;
+        ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, i);
+        if (ret == false) {
+            return;
+        }
+
+        for (SchemePlanManager::SchemeProcessInfo process : processList) {
+            if (process.dSource >= 0) {
+                DataTableWidget *m = new DataTableWidget(process, this);
+                m->mind1()->setNodeList(nodeListMap[i]);
+                if (i == ProjectManager::TechIndex) {
+                    m->mind2()->setNodeList(nodeListMap[ProjectManager::AbilityIndex]);
+                }
+                m->setCurrentPage(1);
+
+                ProjectManager::IndexType t = (ProjectManager::IndexType)i;
+                QString indexName           = ProjectManager::nameOfIndexType(t);
+                QString processName         = SchemePlanManager::processName(process);
+                m_tab->addTab(m, indexName + " - " + processName);
+            }
+        }
     }
 }

+ 20 - 24
QFD/widgets/DataTableWidget.cpp

@@ -18,16 +18,19 @@
 
 #include <QDebug>
 
-DataTableWidget::DataTableWidget(ProjectInfo *proj, int indexType, QWidget *parent)
-    : QWidget(parent), m_proj(proj), m_indexType(indexType)
+DataTableWidget::DataTableWidget(SchemePlanManager::SchemeProcessInfo process, QWidget *parent)
+    : QWidget(parent), m_process(process)
 {
     m_mind1 = new CMind(this);
     m_mind2 = new CMind(this);
     initWidget();
     initLayout();
     connectSignalsAndSlots();
-    setupMind();
-    setCurrentPage(1);
+}
+
+SchemePlanManager::SchemeProcessInfo DataTableWidget::process() const
+{
+    return m_process;
 }
 
 void DataTableWidget::initWidget()
@@ -61,23 +64,6 @@ void DataTableWidget::connectSignalsAndSlots()
     connect(m_dataTab, &QTabWidget::currentChanged, this, &DataTableWidget::slotTabCurrentChanged);
 }
 
-void DataTableWidget::setupMind()
-{
-    QList<CNodeData> list;
-    bool ret = CNodeDataService().QueryAll(list, m_proj->id, m_indexType);
-    if (ret) {
-        m_mind1->setNodeList(list);
-    }
-
-    if (m_indexType == ProjectManager::TechIndex) {
-        QList<CNodeData> list;
-        bool ret = CNodeDataService().QueryAll(list, m_proj->id, ProjectManager::AbilityIndex);
-        if (ret) {
-            m_mind2->setNodeList(list);
-        }
-    }
-}
-
 void DataTableWidget::setupTabWidget()
 {
     /// 创建 tableView 并添加进 tabWidget
@@ -87,7 +73,7 @@ void DataTableWidget::setupTabWidget()
     m_dataTab->clear();
     for (CNodeData n : m_mind1->nodesInLevel(m_currentPage)) {
         QTableView *t = new QTableView(m_dataTab);
-        t->setAlternatingRowColors(m_indexType == ProjectManager::TechIndex);
+        t->setAlternatingRowColors(m_mind2->nodeList().count() > 0);
         t->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
         t->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}");
         t->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}");
@@ -141,7 +127,7 @@ void DataTableWidget::updateCurrentTable()
     }
 
     QList<CNodeData> vList = hList;
-    if (m_indexType == ProjectManager::TechIndex) {
+    if (m_mind2->nodeList().count() > 0) {
         vList = m_mind2->nodesInFinalLevel();
     }
 
@@ -156,7 +142,7 @@ void DataTableWidget::updateCurrentTable()
         for (int j = 0; j < hList.count(); j++) {
             QStandardItem *item = new QStandardItem();
             item->setEditable(false);
-            if (m_indexType != ProjectManager::TechIndex) {
+            if (m_mind2->nodeList().count() <= 0) {
                 if (i == j) {
                     item->setText("1");  // 对角线
                 }
@@ -172,6 +158,16 @@ void DataTableWidget::updateCurrentTable()
     }
 }
 
+CMind *DataTableWidget::mind1() const
+{
+    return m_mind1;
+}
+
+CMind *DataTableWidget::mind2() const
+{
+    return m_mind2;
+}
+
 void DataTableWidget::slotPrevious()
 {
     setCurrentPage(m_currentPage - 1);

+ 9 - 5
QFD/widgets/DataTableWidget.h

@@ -3,6 +3,8 @@
 
 #include <QWidget>
 
+#include "SchemePlanManager.h"
+
 class CMind;
 class ProjectInfo;
 class PushButton;
@@ -21,7 +23,9 @@ class DataTableWidget : public QWidget
 {
     Q_OBJECT
 public:
-    explicit DataTableWidget(ProjectInfo *proj, int indexType, QWidget *parent = nullptr);
+    explicit DataTableWidget(SchemePlanManager::SchemeProcessInfo process, QWidget *parent = nullptr);
+
+    SchemePlanManager::SchemeProcessInfo process() const;
 
     void initWidget();
 
@@ -29,8 +33,6 @@ public:
 
     void connectSignalsAndSlots();
 
-    void setupMind();
-
     void setupTabWidget();
 
     int currentPage() const;
@@ -39,6 +41,9 @@ public:
 
     void updateCurrentTable();
 
+    CMind *mind1() const;
+    CMind *mind2() const;
+
 signals:
 
 public slots:
@@ -47,8 +52,7 @@ public slots:
     void slotTabCurrentChanged(int c);
 
 private:
-    ProjectInfo *m_proj = nullptr;
-    int m_indexType;
+    SchemePlanManager::SchemeProcessInfo m_process;
 
     int m_currentPage = 0;