Browse Source

加载权重分析数据;
加载需求评估的评估数据;

chengxr 1 year ago
parent
commit
0ae9603b01

+ 2 - 0
QFD/QFD.pro

@@ -74,6 +74,7 @@ SOURCES += \
     algorithm/SetPairAnalysis.cpp \
     algorithm/ZScore.cpp \
     algorithm/test_main.cpp \
+    common/EvalDataManager.cpp \
     common/ExpertManager.cpp \
     common/ProjectManager.cpp \
     common/QFDAlert.cpp \
@@ -142,6 +143,7 @@ HEADERS += \
     algorithm/PCA.h \
     algorithm/SetPairAnalysis.h \
     algorithm/ZScore.h \
+    common/EvalDataManager.h \
     common/ExpertManager.h \
     common/ProjectManager.h \
     common/QFDAlert.h \

+ 93 - 0
QFD/common/EvalDataManager.cpp

@@ -0,0 +1,93 @@
+#include "EvalDataManager.h"
+
+#include "ProjectManager.h"
+
+EvalDataManager::EvalDataManager(QObject *parent) : QObject(parent) { }
+
+QList<NodeMatrixInfo> EvalDataManager::dataSample(SchemePlanManager::SchemeProcessInfo process, CMind *mind1,
+                                                  CMind *mind2)
+{
+    QList<NodeMatrixInfo> list;
+
+    if (mind1->levels() < 2) {
+        return list;
+    }
+
+    unsigned seed = 1;
+    srand(seed);
+
+    // 权重数据
+    if (process.type == SchemePlanManager::ImportWeightData) {
+        // 来自专家数据, 子指标间的权重比
+        if (process.dSource == SchemePlanManager::FromExpert) {
+
+            for (int lev = 1; lev < mind1->levels(); lev++) {
+                QList<CNodeData> nodes = mind1->nodesInLevel(lev);
+                for (CNodeData node : nodes) {
+                    QList<CNodeData> subNodes = mind1->subNodes(node);
+
+                    for (int i = 0; i < subNodes.count(); i++) {
+                        CNodeData vNode = subNodes[i];
+                        for (int j = i; j < subNodes.count(); j++) {
+
+                            CNodeData hNode = subNodes[j];
+
+                            NodeMatrixInfo data;
+                            data.engineerId = node.projectId;
+                            data.mark       = QString("%1").arg(lev);
+                            data.abscissa   = QString("%1").arg(hNode.id);
+                            data.ordinate   = QString("%1").arg(vNode.id);
+
+                            if (i == j) {
+                                data.nodeValue = "1";
+                                list.append(data);
+                                continue;
+                            }
+
+                            int r          = rand() % 8 + 2;
+                            data.nodeValue = QString("%1").arg(r);
+                            list.append(data);
+
+                            NodeMatrixInfo data1;
+                            data1.engineerId = node.projectId;
+                            data1.mark       = QString("%1").arg(lev);
+                            data1.abscissa   = QString("%1").arg(vNode.id);
+                            data1.ordinate   = QString("%1").arg(hNode.id);
+                            data1.nodeValue  = QString("1/%1").arg(r);
+                            list.append(data1);
+                        }
+                    }
+                }
+            }
+
+        } else if (process.dSource == SchemePlanManager::FromMeasurement) {
+            for (int i = 0; i < mind1->nodeList().count(); i++) {
+                CNodeData node = mind1->nodeList()[i];
+                NodeMatrixInfo data;
+                data.engineerId = node.projectId;
+                data.abscissa   = QString("%1").arg(node.id);
+                int r           = rand() % 8 + 2;
+                data.nodeValue  = QString("%1").arg(r);
+                list.append(data);
+            }
+        }
+    } else if (process.type == SchemePlanManager::ImportEvalData) {
+        if (process.indexType == ProjectManager::TechIndex) {
+            for (int i = 0; i < mind1->nodeList().count(); i++) {
+                CNodeData hNode = mind1->nodeList()[i];
+                for (int j = 0; j < mind2->nodeList().count(); j++) {
+                    CNodeData vNode = mind2->nodeList()[j];
+                    NodeMatrixInfo data;
+                    data.engineerId = hNode.projectId;
+                    data.abscissa   = QString("%1").arg(hNode.id);
+                    data.ordinate   = QString("%1").arg(vNode.id);
+                    int r           = rand() % 8 + 2;
+                    data.nodeValue  = QString("%1").arg(r);
+                    list.append(data);
+                }
+            }
+        }
+    }
+
+    return list;
+}

+ 26 - 0
QFD/common/EvalDataManager.h

@@ -0,0 +1,26 @@
+#ifndef EVALDATAMANAGER_H
+#define EVALDATAMANAGER_H
+
+#include <QObject>
+
+#include <CMind.h>
+#include <SchemePlanManager.h>
+#include <dbService/ClassSet.h>
+
+struct NodeEvalData
+{
+};
+
+class EvalDataManager : public QObject
+{
+    Q_OBJECT
+public:
+    explicit EvalDataManager(QObject *parent = nullptr);
+
+    static QList<NodeMatrixInfo> dataSample(SchemePlanManager::SchemeProcessInfo process, CMind *mind1,
+                                            CMind *mind2 = nullptr);
+
+signals:
+};
+
+#endif  // EVALDATAMANAGER_H

+ 1 - 1
QFD/dbService/ClassSet.h

@@ -46,7 +46,7 @@ public:
     QString expertName;   //专家名称
     QString expertId;     //专家id
     int engineerId;       //工程id
-    int mindId;           //脑图名称
+    int mindId;           //脑图名称, 区分数据来源
     QString node;         //节点
     QString abscissa;     //横坐标
     QString ordinate;     //纵坐标

+ 4 - 0
QFD/widgets/DataCollectionWidget.cpp

@@ -4,6 +4,8 @@
 #include "ConfigExpertDataWidget.h"
 #include "ConfigMeasureDataWidget.h"
 
+#include "EvalDataManager.h"
+
 #include "GreyClusteringConfigWidget.h"  // 灰色聚类配置
 #include "GreyClusteringSampleTable.h"   // 灰色聚类评估
 #include "MatterElementConfigWidget.h"   // 物元分析配置
@@ -110,6 +112,8 @@ void DataCollectionWidget::setupTabWidget()
                 if (i == ProjectManager::TechIndex) {
                     table->mind2()->setNodeList(nodeListMap[ProjectManager::AbilityIndex]);
                 }
+                QList<NodeMatrixInfo> list = EvalDataManager::dataSample(process, table->mind1(), table->mind2());
+                table->setData(list);
                 table->setCurrentPage(1);
 
                 QString processName = SchemePlanManager::processName(process);

+ 77 - 19
QFD/widgets/DataTableWidget.cpp

@@ -177,14 +177,14 @@ void DataTableWidget::updateCurrentTable()
         table->setRowHeight(i, 35);
     }
 
-    /// 填充单元格
+    /// 填充量纲和指标类型
     for (int i = 0; i < vList.count(); i++) {
-        CNodeData node   = vList[i];
+        CNodeData vNode  = vList[i];
         QStandardItem *d = new QStandardItem();
         d->setEditable(false);
         d->setData(Qt::AlignCenter, Qt::TextAlignmentRole);  // 单元格文字居中
         if (dimensionIndex >= 0) {
-            d->setText(node.dimension);
+            d->setText(vNode.dimension);
             model->setItem(i, dimensionIndex, d);
         }
 
@@ -192,24 +192,77 @@ void DataTableWidget::updateCurrentTable()
             model->setItem(i, typeIndex, d);
             table->setItemDelegateForColumn(typeIndex, m_comboDelegate);
         }
-
-        //        for (int j = 0; j < hList.count(); j++) {
-        //            QStandardItem *item = new QStandardItem();
-        //            item->setEditable(false);
-        //            if (m_mind2->nodeList().count() <= 0) {
-        //                if (i == j) {
-        //                    item->setText("1");  // 对角线
-        //                }
-        //                if (i >= j) {
-        //                    item->setBackground(QBrush(QColor("lightgray")));  // 左下方
-        //                }
-        //            }
-        //            item->setData(Qt::AlignCenter, Qt::TextAlignmentRole);  // 单元格文字居中
-        //            model->setItem(i, j, item);
-        //        }
-
         table->setRowHeight(i, 35);
     }
+
+    /// 填充单元格
+    if (m_process.type == SchemePlanManager::ImportWeightData) {
+        if (m_process.dSource == SchemePlanManager::FromExpert) {
+            for (int i = 0; i < vList.count(); i++) {
+                CNodeData vNode = vList[i];
+                for (int j = 0; j < hList.count(); j++) {
+                    CNodeData hNode = hList[j];
+
+                    QStandardItem *item = new QStandardItem();
+                    item->setData(Qt::AlignCenter, Qt::TextAlignmentRole);  // 单元格文字居中
+                    item->setBackground(QBrush(QColor("white")));
+                    item->setEditable(false);
+
+                    for (NodeMatrixInfo info : m_data) {
+                        if (info.abscissa.toInt() == hNode.id && info.ordinate.toInt() == vNode.id) {
+                            item->setText(info.nodeValue);
+                            model->setItem(i, j, item);
+                            break;
+                        }
+                    }
+                }
+
+                table->setRowHeight(i, 35);
+            }
+        } else if (m_process.dSource == SchemePlanManager::FromMeasurement) {
+            int row = model->rowCount();
+            for (int j = 0; j < hList.count(); j++) {
+                CNodeData hNode = hList[j];
+
+                QStandardItem *item = new QStandardItem();
+                item->setData(Qt::AlignCenter, Qt::TextAlignmentRole);  // 单元格文字居中
+                item->setBackground(QBrush(QColor("white")));
+                item->setEditable(false);
+
+                for (NodeMatrixInfo info : m_data) {
+                    if (info.abscissa.toInt() == hNode.id) {
+                        item->setText(info.nodeValue);
+                        model->setItem(row, j, item);
+                        break;
+                    }
+                }
+            }
+        }
+    } else if (m_process.type == SchemePlanManager::ImportEvalData) {
+        if (m_process.indexType == ProjectManager::TechIndex) {
+            for (int i = 0; i < vList.count(); i++) {
+                CNodeData vNode = vList[i];
+                for (int j = 0; j < hList.count(); j++) {
+                    CNodeData hNode = hList[j];
+
+                    QStandardItem *item = new QStandardItem();
+                    item->setData(Qt::AlignCenter, Qt::TextAlignmentRole);  // 单元格文字居中
+                    item->setBackground(QBrush(QColor("white")));
+                    item->setEditable(false);
+
+                    for (NodeMatrixInfo info : m_data) {
+                        if (info.abscissa.toInt() == hNode.id && info.ordinate.toInt() == vNode.id) {
+                            item->setText(info.nodeValue);
+                            model->setItem(i, j, item);
+                            break;
+                        }
+                    }
+                }
+
+                table->setRowHeight(i, 35);
+            }
+        }
+    }
 }
 
 CMind *DataTableWidget::mind1() const
@@ -222,6 +275,11 @@ CMind *DataTableWidget::mind2() const
     return m_mind2;
 }
 
+void DataTableWidget::setData(QList<NodeMatrixInfo> data)
+{
+    m_data = data;
+}
+
 void DataTableWidget::slotPrevious()
 {
     setCurrentPage(m_currentPage - 1);

+ 10 - 0
QFD/widgets/DataTableWidget.h

@@ -5,6 +5,8 @@
 
 #include "SchemePlanManager.h"
 
+#include <dbService/ClassSet.h>
+
 class DataTableComboDelegate;
 
 class CMind;
@@ -20,6 +22,10 @@ class QHBoxLayout;
 /**
  * @brief The DataTableWidget class
  * 数据表, 整体上是包含多个 QTableView 的 QTabWidget
+ * 显示以下数据:
+ * 能力重要度评估, 技术措施重要度, 方案优选评估: 权重分析数据和评估数据
+ * 综合效能评估: 权重分析数据
+ * 综合效能评估-物元分析法: 评估数据
  */
 class DataTableWidget : public QWidget
 {
@@ -46,6 +52,8 @@ public:
     CMind *mind1() const;
     CMind *mind2() const;
 
+    void setData(QList<NodeMatrixInfo> data);
+
 signals:
 
 public slots:
@@ -73,6 +81,8 @@ private:
     bool m_isSettingTable = false;
 
     DataTableComboDelegate *m_comboDelegate = nullptr;
+
+    QList<NodeMatrixInfo> m_data;
 };
 
 #endif  // DATATABLEWIDGET_H