Bläddra i källkod

'效能评估接口'

zsf 1 år sedan
förälder
incheckning
4ef237210b

+ 36 - 0
QFD/dbService/ClassSet.h

@@ -378,6 +378,7 @@ class GradeInfo
 public:
     int id = -1;         //主键id
     int projectId;       //工程id
+    int type;            //类型0物元分析法1灰色聚类法
     QString gradeName;   //等级名称
     QString gradeValue;  //等级值
 };
@@ -396,4 +397,39 @@ public:
     QString gradeIndexValue;  //等级指标值
 };
 
+/**
+ * @projectName   QFD2
+ * @author        mimang
+ * @date          2023-09-15
+ * @desc          效能指标信息
+ */
+class EffectIndexInfo
+{
+public:
+    int id = -1;               //主键id
+    int projectId;             //工程id
+    QString effectIndexName;   //效能指标名称
+    QString effectIndexValue;  //效能指标值
+    QString effectIndexUnit;   //单位
+    QString extendLeft;        //延拓左
+    QString extendRight;       //延拓右
+};
+
+/**
+ * @projectName   QFD2
+ * @author        mimang
+ * @date          2023-09-15
+ * @desc          效能结果信息
+ */
+class EffectResult
+{
+public:
+    int id = -1;           //主键id
+    int projectId;         //工程id
+    QString effectOld;     //效能指标名称
+    QString effectNew;     //效能指标值
+    QString effectResult;  //结果
+    QString createTime;    //创建时间
+};
+
 #endif  // CLASSSET_H

+ 73 - 0
QFD/dbService/EffectIndexInfoService.cpp

@@ -0,0 +1,73 @@
+#include "EffectIndexInfoService.h"
+#include "SqlDBHelper.h"
+#include <QDebug>
+
+EffectIndexInfoService::EffectIndexInfoService(QObject *parent) { }
+
+int EffectIndexInfoService::AddEffectIndexInfo(const EffectIndexInfo &effectIndexInfo)
+{
+    int ret = -1;
+    try {
+        Transaction t(SqlDBHelper::getDatabase());
+        InsertQuery query = t.insertInto("t_effect_index_info(`project_id`, `effect_index_name`, `effect_index_value`, "
+                                         "`effect_index_unit`, `extend_left`, `extend_right`)");
+        NonQueryResult result = query.values(effectIndexInfo.projectId, effectIndexInfo.effectIndexName,
+                                             effectIndexInfo.effectIndexValue, effectIndexInfo.effectIndexUnit,
+                                             effectIndexInfo.extendLeft, effectIndexInfo.extendRight)
+                                        .exec();
+        t.commit();
+        ret = result.lastInsertId().toInt();
+    } catch (const DBException &ex) {
+        qDebug() << ex.lastError.text();
+    }
+    return ret;
+}
+
+bool EffectIndexInfoService::QueryEffectIndexInfoByProjectId(EffectIndexInfo *effectIndexInfo, int projectId)
+{
+    QSqlDatabase db = SqlDBHelper::getDatabase();
+    QSqlQuery query(db);
+    bool ret = false;
+    QString selectSql =
+            QString("SELECT id, "
+                    "project_id,effect_index_name,effect_index_value,effect_index_unit,extend_left,extend_right FROM "
+                    "t_effect_index_info WHERE project_id = %1")
+                    .arg(projectId);
+    if (query.exec(selectSql)) {
+        if (query.next()) {
+            if (query.isNull(0) == false) {
+                effectIndexInfo->id               = query.value(0).toInt();
+                effectIndexInfo->projectId        = query.value(1).toInt();
+                effectIndexInfo->effectIndexName  = query.value(2).toString();
+                effectIndexInfo->effectIndexValue = query.value(3).toString();
+                effectIndexInfo->effectIndexUnit  = query.value(4).toString();
+                effectIndexInfo->extendLeft       = query.value(5).toString();
+                effectIndexInfo->extendRight      = query.value(6).toString();
+            }
+            ret = true;
+        }
+    } else {
+        qDebug() << query.lastError();
+    }
+    return ret;
+}
+
+bool EffectIndexInfoService::UpdateEffectIndexInfo(const EffectIndexInfo &effectIndexInfo)
+{
+    bool ret = false;
+    try {
+        Transaction t(SqlDBHelper::getDatabase());
+        t.update("t_effect_index_info")
+                .set("effect_index_name", effectIndexInfo.effectIndexName)
+                .set("effect_index_value", effectIndexInfo.effectIndexValue)
+                .set("effect_index_unit", effectIndexInfo.effectIndexUnit)
+                .set("extend_left", effectIndexInfo.extendLeft)
+                .set("extend_right", effectIndexInfo.extendRight)
+                .where("id = ?", effectIndexInfo.id);
+        t.commit();
+        ret = true;
+    } catch (const DBException &ex) {
+        qDebug() << ex.lastError.text();
+    }
+    return ret;
+}

+ 14 - 0
QFD/dbService/EffectIndexInfoService.h

@@ -0,0 +1,14 @@
+#ifndef EFFECTINDEXINFOSERVICE_H
+#define EFFECTINDEXINFOSERVICE_H
+#include "ClassSet.h"
+
+class EffectIndexInfoService
+{
+public:
+    EffectIndexInfoService(QObject *parent = nullptr);
+    int AddEffectIndexInfo(const EffectIndexInfo &effectIndexInfo);
+    bool UpdateEffectIndexInfo(const EffectIndexInfo &effectIndexInfo);
+    bool QueryEffectIndexInfoByProjectId(EffectIndexInfo *effectIndexInfo, int projectId);
+};
+
+#endif  // EFFECTINDEXINFOSERVICE_H

+ 51 - 0
QFD/dbService/EffectResultService.cpp

@@ -0,0 +1,51 @@
+#include "EffectResultService.h"
+#include "SqlDBHelper.h"
+#include <QDebug>
+EffectResultService::EffectResultService(QObject *parent) { }
+
+int EffectResultService::AddEffectResult(const EffectResult &effectResult)
+{
+    int ret = -1;
+    try {
+        Transaction t(SqlDBHelper::getDatabase());
+        InsertQuery query = t.insertInto("t_effect_result(`project_id`, `effect_old`, `effect_new`, "
+                                         "`effect_result`, `create_time`)");
+        NonQueryResult result =
+                query.values(effectResult.projectId, effectResult.effectOld, effectResult.effectNew,
+                             effectResult.effectResult, QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"))
+                        .exec();
+        t.commit();
+        ret = result.lastInsertId().toInt();
+    } catch (const DBException &ex) {
+        qDebug() << ex.lastError.text();
+    }
+    return ret;
+}
+
+bool EffectResultService::QueryAllEffectResultByProjectId(QList<EffectResult *> *effectResult, int projectId)
+{
+
+    QSqlDatabase db = SqlDBHelper::getDatabase();
+    QSqlQuery query(db);
+    bool ret          = false;
+    QString selectSql = QString("SELECT id, project_id, effect_old,effect_new,effect_result,create_time FROM "
+                                "t_effect_result where project_id = %1 order by create_time desc")
+                                .arg(projectId);
+    if (query.exec(selectSql)) {
+        while (query.next()) {
+            if (query.isNull(0) == false) {
+                EffectResult *projectInfo = new EffectResult();
+                projectInfo->id           = query.value(0).toInt();
+                projectInfo->effectOld    = query.value(1).toString();
+                projectInfo->effectNew    = query.value(2).toString();
+                projectInfo->effectResult = query.value(3).toString();
+                projectInfo->createTime   = query.value(4).toString();
+                effectResult->append(projectInfo);
+            }
+            ret = true;
+        }
+    } else {
+        qDebug() << query.lastError();
+    }
+    return ret;
+}

+ 13 - 0
QFD/dbService/EffectResultService.h

@@ -0,0 +1,13 @@
+#ifndef EFFECTRESULTSERVICE_H
+#define EFFECTRESULTSERVICE_H
+#include "ClassSet.h"
+
+class EffectResultService
+{
+public:
+    EffectResultService(QObject *parent = nullptr);
+    int AddEffectResult(const EffectResult &effectResult);
+    bool QueryAllEffectResultByProjectId(QList<EffectResult *> *effectResult, int projectId);
+};
+
+#endif  // EFFECTRESULTSERVICE_H

+ 8 - 5
QFD/dbService/GradeInfoService.cpp

@@ -8,8 +8,9 @@ int GradeInfoService::AddGradeInfo(const GradeInfo &gradeInfo)
     int ret = -1;
     try {
         Transaction t(SqlDBHelper::getDatabase());
-        InsertQuery query     = t.insertInto("t_grade_info(`project_id`, `grade_name`, `grade_value`)");
-        NonQueryResult result = query.values(gradeInfo.projectId, gradeInfo.gradeName, gradeInfo.gradeValue).exec();
+        InsertQuery query = t.insertInto("t_grade_info(`project_id`, `grade_name`, `grade_value`, `type`)");
+        NonQueryResult result =
+                query.values(gradeInfo.projectId, gradeInfo.gradeName, gradeInfo.gradeValue, gradeInfo.type).exec();
         t.commit();
         ret = result.lastInsertId().toInt();
     } catch (const DBException &ex) {
@@ -35,14 +36,15 @@ bool GradeInfoService::UpdateGradeInfo(const GradeInfo &gradeInfo)
     return ret;
 }
 
-bool GradeInfoService::QueryGradeByProjectId(GradeInfo *gradeInfo, int projectId)
+bool GradeInfoService::QueryGradeByProjectIdAndType(GradeInfo *gradeInfo, int projectId, int type)
 {
     QSqlDatabase db = SqlDBHelper::getDatabase();
     QSqlQuery query(db);
     bool ret          = false;
     QString selectSql = QString("SELECT id, project_id,grade_name,grade_value FROM "
-                                "t_grade_info WHERE project_id = %1")
-                                .arg(projectId);
+                                "t_grade_info WHERE project_id = %1 and type = %2")
+                                .arg(projectId)
+                                .arg(type);
     if (query.exec(selectSql)) {
         if (query.next()) {
             if (query.isNull(0) == false) {
@@ -50,6 +52,7 @@ bool GradeInfoService::QueryGradeByProjectId(GradeInfo *gradeInfo, int projectId
                 gradeInfo->projectId  = query.value(1).toInt();
                 gradeInfo->gradeName  = query.value(2).toString();
                 gradeInfo->gradeValue = query.value(3).toString();
+                gradeInfo->type       = query.value(4).toInt();
             }
             ret = true;
         }

+ 1 - 1
QFD/dbService/GradeInfoService.h

@@ -8,7 +8,7 @@ public:
     GradeInfoService(QObject *parent = nullptr);
     int AddGradeInfo(const GradeInfo &gradeInfo);
     bool UpdateGradeInfo(const GradeInfo &gradeInfo);
-    bool QueryGradeByProjectId(GradeInfo *gradeInfo, int projectId);
+    bool QueryGradeByProjectIdAndType(GradeInfo *gradeInfo, int projectId, int type);
 };
 
 #endif  // GRADEINFOSERVICE_H

+ 4 - 0
QFD/dbService/dbService.pri

@@ -4,6 +4,8 @@ HEADERS += \
     $$PWD/ClassSet.h \
     $$PWD/DBServiceSet.h \
     $$PWD/DemandWeightService.h \
+    $$PWD/EffectIndexInfoService.h \
+    $$PWD/EffectResultService.h \
     $$PWD/EngineerService.h \
     $$PWD/GradeIndexInfoService.h \
     $$PWD/GradeInfoService.h \
@@ -25,6 +27,8 @@ SOURCES += \
     $$PWD/ClassSet.cpp \
     $$PWD/DBServiceSet.cpp \
     $$PWD/DemandWeightService.cpp \
+    $$PWD/EffectIndexInfoService.cpp \
+    $$PWD/EffectResultService.cpp \
     $$PWD/EngineerService.cpp \
     $$PWD/GradeIndexInfoService.cpp \
     $$PWD/GradeInfoService.cpp \