Pārlūkot izejas kodu

专家端校验数据完整性;
处理评估结果的无效值;
删除样例数据;
显示评估报告前判断有无数据;

chengxr 1 gadu atpakaļ
vecāks
revīzija
cd6fa28758

+ 19 - 1
ExpertClient/EXDataTableView.cpp

@@ -158,7 +158,6 @@ void EXDataTableView::setupModels()
                         for (int j = 0; j < hHeaders.count(); j++) {
                             CNodeData hNode     = hHeaders[j];
                             QStandardItem *item = new QStandardItem();
-                            item->setText("0");
                             model->setItem(i, j, item);
                         }
                     }
@@ -229,6 +228,23 @@ CMind *EXDataTableView::mind2() const
     return m_mind2;
 }
 
+bool EXDataTableView::checkDataComplete() const
+{
+    for (QList<EXDataItemModel *> modelList : m_models) {
+        for (EXDataItemModel *model : modelList) {
+            for (int r = 0; r < model->rowCount(); ++r) {
+                for (int c = 0; c < model->columnCount(); ++c) {
+                    QStandardItem *item = model->item(r, c);
+                    if (item == nullptr || item->text().length() <= 0) {
+                        return false;
+                    }
+                }
+            }
+        }
+    }
+    return true;
+}
+
 void EXDataTableView::exportData(const QString &path)
 {
     QString filePath = path;
@@ -418,6 +434,8 @@ void EXDataTableView::slotSave()
 
 void EXDataTableView::itemChanged(QStandardItem *item)
 {
+    emit signalItemEdited();
+
     if (m_process.type == SchemePlanManager::ImportWeightData) {
         return;
     }

+ 5 - 0
ExpertClient/EXDataTableView.h

@@ -71,8 +71,13 @@ public:
     CMind *mind1() const;
     CMind *mind2() const;
 
+    bool checkDataComplete() const;
+
     void exportData(const QString &path);
 
+signals:
+    void signalItemEdited();
+
 private:
     void editItemData(const QModelIndex &index, const QString &val);
 

+ 27 - 1
ExpertClient/EXDataView.cpp

@@ -78,12 +78,32 @@ void EXDataView::setupTabWidget()
 
                 QString processName = SchemePlanManager::processName(process);
                 m_tab->addTab(table, indexName + " - " + processName);
+                connect(table, &EXDataTableView::signalItemEdited, this, &EXDataView::slotDataEdited);
             }
         }
     }
 }
 
-void EXDataView::slotTabCurrentChanged(int index) { }
+bool EXDataView::checkDataComplete()
+{
+    for (int i = 0; i < m_tab->count(); ++i) {
+        EXDataTableView *table = (EXDataTableView *)m_tab->widget(i);
+        if (table->checkDataComplete() == false) {
+            return false;
+        }
+    }
+    return true;
+}
+
+void EXDataView::slotTabCurrentChanged(int index)
+{
+    if (index < 0) {
+        return;
+    }
+
+    bool complete = checkDataComplete();
+    emit signalCompleteStateChanged(complete);
+}
 
 void EXDataView::slotExportData()
 {
@@ -104,3 +124,9 @@ void EXDataView::slotExportData()
         table->exportData(filePath);
     }
 }
+
+void EXDataView::slotDataEdited()
+{
+    bool complete = checkDataComplete();
+    emit signalCompleteStateChanged(complete);
+}

+ 6 - 0
ExpertClient/EXDataView.h

@@ -20,14 +20,20 @@ public:
 
     void setType(int type) override;
 
+signals:
+    void signalCompleteStateChanged(bool complete);
+
 private:
     void setupTabWidget();
+    bool checkDataComplete();
 
 public slots:
     void slotTabCurrentChanged(int index);
 
     void slotExportData();
 
+    void slotDataEdited();
+
 signals:
 
 private:

+ 7 - 0
ExpertClient/EXProjectView.cpp

@@ -124,6 +124,7 @@ void EXProjectView::connectSigalsAndSlots()
 {
     connect(m_tree, &TreeWidget::itemClicked, this, &EXProjectView::itemClicked);
     connect(m_export, &PushButton::clicked, m_dataCollection, &EXDataView::slotExportData);
+    connect(m_dataCollection, &EXDataView::signalCompleteStateChanged, this, &EXProjectView::slotCompleteStateChanged);
 }
 
 void EXProjectView::itemClicked(QTreeWidgetItem *item, int column)
@@ -148,3 +149,9 @@ void EXProjectView::itemClicked(QTreeWidgetItem *item, int column)
 
     showEvalWidget(eval, taskIndex);
 }
+
+void EXProjectView::slotCompleteStateChanged(bool complete)
+{
+    m_export->setEnabled(complete);
+    m_export->setToolTip(complete ? "导出评估数据" : "请将该评估类型的数据补充完整后再导出");
+}

+ 1 - 0
ExpertClient/EXProjectView.h

@@ -37,6 +37,7 @@ private:
 
 private slots:
     void itemClicked(QTreeWidgetItem *item, int column);
+    void slotCompleteStateChanged(bool complete);
 
 private:
     ProjectInfo *m_proj = nullptr;

+ 0 - 3
QFD/common/ProjectManager.cpp

@@ -7,9 +7,6 @@
 #include <QMetaEnum>
 #include <QDebug>
 
-int kDemoProjId1 = 113;
-int kDemoProjId2 = 999;
-
 QString ProjectManager::nameOfIndexType(ProjectManager::IndexType t)
 {
     switch (t) {

+ 0 - 3
QFD/common/ProjectManager.h

@@ -3,9 +3,6 @@
 
 #include <QObject>
 
-extern int kDemoProjId1;
-extern int kDemoProjId2;
-
 class ProjectInfo;
 
 class ProjectManager : QObject

+ 0 - 1
QFD/dbService/CNodeDataService.cpp

@@ -152,7 +152,6 @@ bool CNodeDataService::QueryAllValid(QList<CNodeData> &cNodeDataList, int projec
                     "project_id = %1 and eval_type= %2 order by number")
                     .arg(projectId)
                     .arg(evalType);
-    qDebug() << __FUNCTION__ << __LINE__ << selectSql << endl;
 
     QList<CNodeData> tempList;
     if (query.exec(selectSql)) {

+ 0 - 21
QFD/widgets/ConfigMeasureDataWidget.cpp

@@ -26,7 +26,6 @@ void ConfigMeasureDataWidget::setProcess(SchemePlanManager::SchemeProcessInfo pr
 {
     m_process = process;
     reloadData();
-    addTestData();
 }
 
 void ConfigMeasureDataWidget::reloadData()
@@ -174,26 +173,6 @@ void ConfigMeasureDataWidget::refreshList()
     }
 }
 
-void ConfigMeasureDataWidget::addTestData()
-{
-    bool rightPage = (m_process.type == SchemePlanManager::ImportWeightData
-                      && m_process.indexType == ProjectManager::OptimalIndex);
-    bool rightProj = m_process.projectId == kDemoProjId2;
-    if (!rightPage || !rightProj) {
-        return;
-    }
-
-    m_listWidget->clear();
-
-    for (int i = 0; i < 20; i++) {
-        QListWidgetItem *item = new QListWidgetItem;
-
-        item->setText(QString("数据%1").arg(i + 1));
-
-        m_listWidget->addItem(item);
-    }
-}
-
 void ConfigMeasureDataWidget::slotAddDataClicked()
 {
     emit sigAddData();

+ 0 - 2
QFD/widgets/ConfigMeasureDataWidget.h

@@ -45,8 +45,6 @@ private:
 
     void refreshList();
 
-    void addTestData();
-
 private slots:
     void slotAddDataClicked();
     void slotRemoveDataClicked(int index);

+ 0 - 29
QFD/widgets/DataTableWidget.cpp

@@ -206,8 +206,6 @@ void DataTableWidget::setupModels()
     }
 
     setCurrentPage(1);
-
-    addTestMesureData();
 }
 
 void DataTableWidget::setupTabWidget()
@@ -529,33 +527,6 @@ void DataTableWidget::setNodeMatrixData(QList<NodeMatrixInfo *> data, bool isExp
     m_isFillingData = false;
 }
 
-void DataTableWidget::addTestMesureData()
-{
-    bool rightPage = (m_process.type == SchemePlanManager::ImportWeightData
-                      && m_process.indexType == ProjectManager::OptimalIndex);
-    bool rightProj = m_process.projectId == kDemoProjId2;
-    if (!rightPage || !rightProj) {
-        return;
-    }
-
-    double data[120] = { 4.1,  0.04, 0.19, 0.01, 0.36, 0.05, 3.9,  0.08, 0.38, 0.18, 0.19, 0.04, 5.9,  0.07, 0.23,
-                         0.04, 0.36, 0.07, 4.9,  0.23, 1.03, 0.3,  1.4,  0.09, 4,    0.14, 0.57, 0.11, 1.12, 0.05,
-                         6.1,  0.23, 1.19, 0.47, 0.93, 0.07, 8.2,  0.21, 0.88, 0.2,  0.97, 0.1,  6.5,  0.13, 0.8,
-                         0.26, 0.52, 0.09, 7.5,  0.16, 1.28, 0.88, 0.8,  0.12, 6.8,  0.04, 0.17, 0.02, 0.24, 0.11,
-                         7.4,  0.05, 0.33, 0.06, 0.39, 0.1,  5.7,  0.08, 0.6,  0.47, 0.46, 0.08, 2.4,  0.14, 0.23,
-                         0.04, 0.94, 0.02, 2.2,  0.24, 0.35, 0.06, 1.78, 0.02, 1.9,  0.11, 0.3,  0.1,  0.5,  0.04,
-                         1.8,  0.06, 0.28, 0.1,  0.29, 0.03, 15.9, 0.2,  1.05, 0.21, 1.84, 0.12, 18.9, 0.09, 0.82,
-                         0.34, 0.58, 0.36, 18.8, 0.12, 0.8,  0.39, 0.76, 0.26, 16.8, 0.27, 1.74, 1.51, 1.78, 0.32 };
-
-    DataTableItemModel *model = m_models[1].first();
-    for (int i = 0; i < 120; i++) {
-        QString text        = QString("%1").arg(data[i]);
-        QStandardItem *item = new QStandardItem(text);
-        item->setEditable(false);
-        model->setItem(i / 6, i % 6, item);
-    }
-}
-
 void DataTableWidget::updateModel(DataTableItemModel *model, QList<CNodeData> &hHeaders, QList<CNodeData> &vHeaders,
                                   int hStart, int vStart)
 {

+ 0 - 2
QFD/widgets/DataTableWidget.h

@@ -72,8 +72,6 @@ public:
 
     void setNodeMatrixData(QList<NodeMatrixInfo *> data, bool isExpertData);
 
-    void addTestMesureData();
-
 signals:
     void sigMeasureDataEdited(NodeMatrixInfo *info);
 

+ 46 - 40
QFD/widgets/EvalReportWidget.cpp

@@ -14,6 +14,8 @@
 #include <dbService/MindScoreService.h>
 #include <dbService/EffectResultService.h>
 #include <dbService/GradeInfoService.h>
+#include <dbService/UserConfigService.h>
+#include <dbService/NodeMatrixService.h>
 
 #include <QLabel>
 #include <QBoxLayout>
@@ -30,7 +32,6 @@ EvalReportWidget::EvalReportWidget(ProjectInfo *proj, int indexType, QWidget *pa
 
     loadAlgs();
     loadData();
-    loadWeightData();
 }
 
 void EvalReportWidget::exportReport()
@@ -38,6 +39,8 @@ void EvalReportWidget::exportReport()
     qDebug() << "=====>exportReport";
     if (m_proj->id != 113)
         return;
+
+    return;
     if (m_indexType == ProjectManager::OptimalIndex) {  // 方案优选
         QString path = "D:/FireFly/QFD2/bin/dataset/方案优选评估报告.docx";
         QDesktopServices::openUrl(QUrl::fromLocalFile(path));
@@ -192,6 +195,10 @@ void EvalReportWidget::loadData()
     m_mind = new CMind(this);
     m_mind->setNodeList(nodeList);
 
+    if (checkDataComplete() == false) {
+        return;
+    }
+
     if (m_indexType != ProjectManager::TechIndex) {
         showIndexWeight();
     } else {
@@ -207,6 +214,34 @@ void EvalReportWidget::loadData()
     }
 }
 
+bool EvalReportWidget::checkDataComplete()
+{
+    QString indexName = ProjectManager::nameOfIndexType((ProjectManager::IndexType)m_indexType);
+
+    bool ret = NodeMatrixService().hasMeasureData(m_proj->id, indexName);
+
+    if (ret == true) {
+        return true;
+    }
+
+    QList<UserConfig *> cfgList;
+    ret = UserConfigService().QueryUserConfigListInfoByEngineerId(&cfgList, m_proj->id);
+    if (ret == false || cfgList.size() <= 0) {
+        return false;
+    }
+
+    bool expertDataComplete = true;
+    for (UserConfig *cfg : cfgList) {
+        ret = NodeMatrixService().hasExpertData(m_proj->id, indexName, cfg->userId);
+        if (ret == false) {
+            expertDataComplete = false;
+            break;
+        }
+    }
+
+    return expertDataComplete;
+}
+
 void EvalReportWidget::showIndexWeight()
 {
     int levels = m_mind->levels();
@@ -584,11 +619,15 @@ void EvalReportWidget::showEffiResult()
         }
 
         for (int r = 0; r < model->rowCount(); ++r) {
+            QStandardItem *vHeader  = model->verticalHeaderItem(r);
+            QList<double> rowValues = effData[effData.keys()[i]][vHeader->text()];
             for (int c = 0; c < model->columnCount(); ++c) {
-                QStandardItem *vHeader = model->verticalHeaderItem(r);
-                QStandardItem *item    = new QStandardItem();
-                if (effData.keys().size() > i && effData[effData.keys()[i]][vHeader->text()].size() > c) {
-                    QString text = QString("%1").arg(effData[effData.keys()[i]][vHeader->text()][c]);
+                QStandardItem *item = new QStandardItem();
+                if (effData.keys().size() > i && rowValues.size() > c) {
+                    QString text = QString("%1").arg(rowValues[c]);
+                    if (std::isnan(rowValues[c])) {
+                        text = "0";
+                    }
                     item->setText(text);
                 }
 
@@ -609,41 +648,6 @@ void EvalReportWidget::makePlotClear(PlotView *plotView)
     plotView->clearPlottables();
 }
 
-void EvalReportWidget::loadWeightData()
-{
-    bool rightProj = m_proj->id == kDemoProjId2;
-    if (!rightProj) {
-        return;
-    }
-
-    QTableView *table         = (QTableView *)m_indexTab->widget(0);
-    DataTableItemModel *model = (DataTableItemModel *)table->model();
-
-    QList<SchemePlanManager::SchemeProcessInfo> processList;
-    SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, m_indexType);
-
-    for (SchemePlanManager::SchemeProcessInfo process : processList) {
-        if (process.algorithm == SchemePlanManager::PrincipalComponents) {
-            double values[6] = { 0.223841, 0.243793, 0.209692, 0.16775, 0.088213, 0.0701681 };
-            for (int i = 0; i < 6; i++) {
-                QStandardItem *item = new QStandardItem(QString("%1").arg(values[i]));
-                item->setEditable(false);
-                model->setItem(i, 0, item);
-            }
-
-        } else if (process.algorithm == SchemePlanManager::Entropy) {
-            double values[6] = { 0.167234, 0.126622, 0.153871, 0.227901, 0.13719, 0.187182 };
-            for (int i = 0; i < 6; i++) {
-                QStandardItem *item = new QStandardItem(QString("%1").arg(values[i]));
-                item->setEditable(false);
-                model->setItem(i, 0, item);
-            }
-        }
-    }
-
-    showIndexWeightPlot();
-}
-
 void EvalReportWidget::slotSelectIndexPlotType(int)
 {
     showIndexWeightPlot();
@@ -687,6 +691,8 @@ void EvalReportWidget::slotEffiTabIndexChanged(int index)
         QStandardItem *item   = model->item(0, i);
         PlotView::Data data { header->text(), item->text().toDouble() };
         qDebug() << __FUNCTION__ << __LINE__ << data.name << data.value << endl;
+        qDebug() << __FUNCTION__ << __LINE__ << std::isnan(data.value) << endl;
+
         values.append(data);
     }
 

+ 2 - 2
QFD/widgets/EvalReportWidget.h

@@ -34,6 +34,8 @@ private:
 
     void loadData();
 
+    bool checkDataComplete();
+
     void showIndexWeight();
     void showIndexWeightPlot();
 
@@ -51,8 +53,6 @@ private:
 
     void makePlotClear(PlotView *plotView);
 
-    void loadWeightData();
-
 private slots:
     void slotSelectIndexPlotType(int type);
     void slotSelectTechPlotType(int type);

+ 0 - 18
QFD/widgets/GreyClusteringSampleTable.cpp

@@ -631,22 +631,4 @@ void GreyClusteringSampleTable::initClusteringItems()
     }
 
     qDeleteAll(effectIndexInfoList);
-    if (projectid == kDemoProjId1) {
-        QVector<double> left = { 2, 35, 2, 90, 2.5, 35, 70, 2.5, 35, 30, 2.5, 70, 25, 2, 50, 1, 45, 8, 60, 1 };
-
-        QVector<double> right = { 4, 20, 3, 40, 0.5, 55, 90, 1.2, 55, 70, 1.2, 90, 60, 6, 20, 3, 75, 25, 25, 3 };
-
-        int sn = 0;
-        for (auto &item : m_greyClusterings) {
-            if (item.value.isNull()) {
-                continue;
-            }
-
-            if (sn < left.size()) {
-                item.value->oldValue = left.at(sn);
-                item.value->newValue = right.at(sn);
-            }
-            sn++;
-        }
-    }
 }