Browse Source

数据分析

chengxr 1 year ago
parent
commit
b45bfc56fe

+ 1 - 0
.gitignore

@@ -37,3 +37,4 @@ Makefile*
 !bin/libmysql.dll
 QtNodes/src/ConnectionPainter.cpp
 bin/QtNodesd.exp
+bin/exportData.ini

+ 1 - 0
ExpertClient/EXDataTableView.cpp

@@ -73,6 +73,7 @@ void EXDataTableView::initWidget()
     m_previous = new PushButton("上一级指标", this);
     m_next     = new PushButton("下一级指标", this);
     m_save     = new PushButton("保存", this);
+    m_save->setHidden(true);
 }
 
 void EXDataTableView::initLayout()

+ 1 - 0
ExpertClient/EXProjectView.cpp

@@ -98,6 +98,7 @@ void EXProjectView::initWidgets()
 
     m_export = new PushButton("导出", this);
     m_user   = new PushButton("user");
+    m_user->setHidden(true);
 }
 
 void EXProjectView::initLayout()

+ 4 - 0
ExpertClient/main.cpp

@@ -38,6 +38,10 @@ int main(int argc, char *argv[])
     a.setApplicationName("ExpertClient");
     a.setApplicationDisplayName("伪装防护评估系统软件");
 
+    QFont font;
+    font.setPointSize(14);
+    a.setFont(font);
+
     Q_INIT_RESOURCE(qfluentwidgets);
 
     QTranslator *translator = new QTranslator();

+ 6 - 0
QFD/CCanvas/CMind.cpp

@@ -300,3 +300,9 @@ void CMind::getSeqNodes(QList<QList<SeqNode>> &seqNodes) const
         }
     }
 }
+
+const CNode *CMind::nodeObject() const
+{
+    CNode *node = nullptr;
+    return node;
+}

+ 2 - 0
QFD/CCanvas/CMind.h

@@ -75,6 +75,8 @@ public:
 
     void getSeqNodes(QList<QList<SeqNode>> &seqNodes) const;  // 序列所有节点
 
+    const CNode *nodeObject() const;
+
 signals:
     void sigRemoveNode(int id);
 

+ 1 - 1
QFD/CCanvas/CNode.cpp

@@ -12,7 +12,7 @@ const CNode *CNode::rNode() const
     if (pNode() == nullptr) {
         return this;
     }
-    return pNode();
+    return pNode()->rNode();
 }
 
 QList<CNode *> CNode::cNodes() const

+ 2 - 0
QFD/QFD.pro

@@ -74,6 +74,7 @@ SOURCES += \
     algorithm/SetPairAnalysis.cpp \
     algorithm/ZScore.cpp \
     algorithm/test_main.cpp \
+    common/DataEvaluator.cpp \
     common/EvalDataManager.cpp \
     common/ExpertManager.cpp \
     common/MindEvaluation.cpp \
@@ -145,6 +146,7 @@ HEADERS += \
     algorithm/PCA.h \
     algorithm/SetPairAnalysis.h \
     algorithm/ZScore.h \
+    common/DataEvaluator.h \
     common/EvalDataManager.h \
     common/ExpertManager.h \
     common/MindEvaluation.h \

+ 5 - 0
QFD/algorithm/PCA.h

@@ -7,6 +7,11 @@
 class PCA
 {
 public:
+    /**
+     * @brief PCA
+     * @param source : 输入矩阵,一行代表一个样本, 每列对应一个指标
+     * @param thd
+     */
     PCA(const QVector<QVector<double>> &source, double thd = 0.85);
 
     void compute();

+ 117 - 0
QFD/common/DataEvaluator.cpp

@@ -0,0 +1,117 @@
+#include "DataEvaluator.h"
+
+#include <ProjectManager.h>
+#include <SchemePlanManager.h>
+#include <CMind.h>
+
+#include <dbService/ClassSet.h>
+#include <dbService/NodeMatrixService.h>
+#include <dbService/CNodeDataService.h>
+
+#include <QMap>
+
+DataEvaluator::DataEvaluator(QObject *parent) : QObject(parent) { }
+
+void DataEvaluator::setProcess(SchemePlanManager::SchemeProcessInfo process)
+{
+    m_process = process;
+}
+
+SchemePlanManager::SchemeProcessInfo DataEvaluator::process() const
+{
+    return m_process;
+}
+
+void DataEvaluator::setGatherType(DataEvaluator::GatherType type)
+{
+    m_gatherType = type;
+}
+
+DataEvaluator::GatherType DataEvaluator::gatherType() const
+{
+    return m_gatherType;
+}
+
+bool DataEvaluator::evaluate()
+{
+    if (m_process.type == SchemePlanManager::ImportWeightData) {
+        if (m_process.dSource == SchemePlanManager::FromExpert) {
+            return evaluateWeightFromExpert();
+        } else if (m_process.dSource == SchemePlanManager::FromMeasurement) {
+            return evaluateWeightFromMeasure();
+        }
+    } else if (m_process.type == SchemePlanManager::ImportEvalData) {
+        if (m_process.indexType == ProjectManager::TechIndex) {
+            if (m_process.dSource == SchemePlanManager::FromExpert) {
+                return evaluateTechFromExpert();
+            } else if (m_process.dSource == SchemePlanManager::FromMeasurement) {
+                return evaluateTechFromMeasure();
+            }
+        } else if (m_process.indexType == ProjectManager::OptimalIndex) {
+            return evaluateScheme();
+        } else if (m_process.indexType == ProjectManager::EfficiencyIndex) {
+            return evaluateEfficiencyMEA();
+        }
+    }
+
+    return false;
+}
+
+bool DataEvaluator::evaluateWeightFromExpert()
+{
+    return false;
+}
+
+bool DataEvaluator::evaluateWeightFromMeasure()
+{
+    /// 获取权重分析数据
+    QString indexName = ProjectManager::nameOfIndexType((ProjectManager::IndexType)m_process.indexType);
+    QList<NodeMatrixInfo *> dataList;
+    bool ret = NodeMatrixService().QueryMeaureDataByProjectAndIndex(&dataList, indexName, m_process.projectId);
+    if (ret == false) {
+        return false;
+    }
+
+    /// 使用 uuid 将数据分组
+    QStringList m_uuidList;
+    QMap<QString, QList<NodeMatrixInfo *>> m_nodeData;
+    for (NodeMatrixInfo *info : dataList) {
+        if (m_uuidList.contains(info->strUuid) == false) {
+            m_uuidList.append(info->strUuid);
+            QList<NodeMatrixInfo *> list;
+            m_nodeData[info->strUuid] = list;
+        }
+        m_nodeData[info->strUuid].append(info);
+    }
+
+    /// 获取指标体系
+
+    /// 根据指标体系层级, 构造算法需要的数据
+
+    return false;
+}
+
+bool DataEvaluator::evaluateTechFromExpert()
+{
+    return false;
+}
+
+bool DataEvaluator::evaluateTechFromMeasure()
+{
+    return false;
+}
+
+bool DataEvaluator::evaluateScheme()
+{
+    return false;
+}
+
+bool DataEvaluator::evaluateEfficiencyMEA()
+{
+    return false;
+}
+
+bool DataEvaluator::evaluateEfficiencyGCE()
+{
+    return false;
+}

+ 48 - 0
QFD/common/DataEvaluator.h

@@ -0,0 +1,48 @@
+#ifndef DATAEVALUATOR_H
+#define DATAEVALUATOR_H
+
+#include <QObject>
+
+#include "SchemePlanManager.h"
+
+class DataEvaluator : public QObject
+{
+    Q_OBJECT
+public:
+    enum GatherType
+    {
+        Result,  // 结果集结
+        Matrix   // 矩阵集结
+    };
+
+    explicit DataEvaluator(QObject *parent = nullptr);
+
+    void setProcess(SchemePlanManager::SchemeProcessInfo process);
+
+    SchemePlanManager::SchemeProcessInfo process() const;
+
+    void setGatherType(GatherType type);
+
+    GatherType gatherType() const;
+
+    bool evaluate();
+
+private:
+    bool evaluateWeightFromExpert();   // 权重分析,专家数据
+    bool evaluateWeightFromMeasure();  // 权重分析,实测数据
+
+    bool evaluateTechFromExpert();   // 技术重要度评估,专家数据
+    bool evaluateTechFromMeasure();  // 技术重要评估,实测数据
+
+    bool evaluateScheme();  // 方案优选评估
+
+    bool evaluateEfficiencyMEA();  // 效能评估, 物元分析法
+    bool evaluateEfficiencyGCE();  // 效能评估, 灰色聚类法
+
+private:
+    SchemePlanManager::SchemeProcessInfo m_process;
+
+    GatherType m_gatherType = Result;
+};
+
+#endif  // DATAEVALUATOR_H

+ 1 - 1
QFD/dbService/CNodeDataService.cpp

@@ -114,7 +114,7 @@ bool CNodeDataService::QueryAll(QList<CNodeData> &cNodeDataList, int projectId,
     QString selectSql =
             QString("SELECT id,project_id, eval_type,number,p_number,name,remark,dimension,type,is_effective FROM "
                     "t_node_data WHERE "
-                    "project_id = %1 and eval_type= %2")
+                    "project_id = %1 and eval_type= %2 order by number")
                     .arg(projectId)
                     .arg(evalType);
     if (query.exec(selectSql)) {

+ 1 - 1
QFD/main.cpp

@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
     font.setPointSize(14);
     a.setFont(font);
 
-    cTest();
+    //    cTest();
 
     int ret = a.exec();
     delete w;

+ 14 - 1
QFD/widgets/DataCollectionWidget.cpp

@@ -9,6 +9,7 @@
 #include "EvalDataManager.h"
 #include "algorithm/HierarchicalAnalysis.h"
 #include "MindEvaluation.h"
+#include "DataEvaluator.h"
 
 #include "GreyClusteringConfigWidget.h"  // 灰色聚类配置
 #include "GreyClusteringSampleTable.h"   // 灰色聚类评估
@@ -65,6 +66,8 @@ DataCollectionWidget::DataCollectionWidget(ProjectInfo *proj, QWidget *parent) :
 
     m_addSchemeWidget = new CreateSchemeWidget(this);
 
+    m_evaluator = new DataEvaluator(this);
+
     connect(m_calcBtn, &PushButton::clicked, this, &DataCollectionWidget::slotCalc);
 
     connect(m_tab, &QTabWidget::currentChanged, this, &DataCollectionWidget::slotTabCurrentChanged);
@@ -211,6 +214,16 @@ void DataCollectionWidget::slotCalc()
 {
     DataTableWidget *table = dynamic_cast<DataTableWidget *>(m_tab->currentWidget());
     if (table != nullptr) {
+        // 打印当前页面概要: 指标体系类型,方案步骤(数据种类), 数据来源(专家/实测)
+        QString indexName   = ProjectManager::nameOfIndexType((ProjectManager::IndexType)table->process().indexType);
+        QString processName = SchemePlanManager::processName(table->process());
+        QString dataSource  = SchemePlanManager::stringFromDataSource(table->process().dSource);
+        qDebug() << __FUNCTION__ << __LINE__ << indexName << processName << dataSource << endl;
+
+        m_evaluator->setProcess(table->process());
+        m_evaluator->setGatherType((DataEvaluator::GatherType)m_comboBox->currentIndex());
+        m_evaluator->evaluate();
+
         QTableView *tableView     = (QTableView *)table->tabWidget()->currentWidget();
         DataTableItemModel *model = (DataTableItemModel *)tableView->model();
 
@@ -481,7 +494,7 @@ void DataCollectionWidget::slotAddMeasureData()
             info->strUuid        = uuid;
 
             info->abscissa  = n.name;
-            info->nodeValue = "1";
+            info->nodeValue = "0";
             dataList.append(info);
         }
     }

+ 3 - 0
QFD/widgets/DataCollectionWidget.h

@@ -9,6 +9,7 @@ class ConfigSchemeDataWidget;
 class CreateSchemeWidget;
 
 class NodeMatrixInfo;
+class DataEvaluator;
 
 class UserConfig;
 class QFUser;
@@ -65,6 +66,8 @@ private:
     PushButton *m_calcBtn = nullptr;
 
     CreateSchemeWidget *m_addSchemeWidget = nullptr;
+
+    DataEvaluator *m_evaluator = nullptr;
 };
 
 #endif  // DATACOLLECTIONWIDGET_H

+ 1 - 1
QFD/widgets/ExpertInfoWidget.cpp

@@ -92,7 +92,7 @@ void ExpertInfoWidget::initWindow()
 {
     setWindowFlags(Qt::Window);
     setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
-    setFixedWidth(400);
+    setFixedWidth(420);
 
     //    setModal(true);
     //    setWindowFlags(Qt::Dialog);