123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- #include "NodeMatrixService.h"
- #include "SqlDBHelper.h"
- #include <QDebug>
- NodeMatrixService::NodeMatrixService(QObject *parent) { }
- bool NodeMatrixService::AddNodeMatrixInfo(const NodeMatrixInfo &nodeMatrixInfo)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- InsertQuery q = t.insertInto("t_node_matrix_info (expert_name, engineer_id, node, "
- "abscissa, ordinate, "
- "node_value, expert_id,mind_name,write_date,mark,str_uuid)");
- q.values(nodeMatrixInfo.expertName, nodeMatrixInfo.engineerId, nodeMatrixInfo.node, nodeMatrixInfo.abscissa,
- nodeMatrixInfo.ordinate, nodeMatrixInfo.nodeValue, nodeMatrixInfo.expertId, nodeMatrixInfo.mindId,
- nodeMatrixInfo.writeDate.toString(), nodeMatrixInfo.mark, nodeMatrixInfo.strUuid)
- .exec();
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- /*批量节点信息新增*/
- bool NodeMatrixService::AddNodeMatrixInfoList(const QList<NodeMatrixInfo *> &jbInfoList)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- for (int i = 0; i < jbInfoList.length(); i++) {
- NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
- InsertQuery query = t.insertInto("t_node_matrix_info (expert_name, engineer_id, node, abscissa, "
- "ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,table_msg,str_uuid)");
- query.values(nodeMatrixInfo->expertName, nodeMatrixInfo->engineerId, nodeMatrixInfo->node,
- nodeMatrixInfo->abscissa, nodeMatrixInfo->ordinate, nodeMatrixInfo->nodeValue,
- nodeMatrixInfo->expertId, nodeMatrixInfo->mindId, nodeMatrixInfo->writeDate.toString(),
- nodeMatrixInfo->mark, nodeMatrixInfo->tableMsg, nodeMatrixInfo->strUuid)
- .exec();
- t.commit();
- }
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- /*批量节点信息新增----专家端*/
- bool NodeMatrixService::AddNodeMatrixInfoList2(const QList<NodeMatrixInfo *> &jbInfoList)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase2());
- for (int i = 0; i < jbInfoList.length(); i++) {
- NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
- InsertQuery query = t.insertInto("t_node_matrix_info (expert_name, engineer_id, node, abscissa, "
- "ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,table_msg,tab_index)");
- query.values(nodeMatrixInfo->expertName, nodeMatrixInfo->engineerId, nodeMatrixInfo->node,
- nodeMatrixInfo->abscissa, nodeMatrixInfo->ordinate, nodeMatrixInfo->nodeValue,
- nodeMatrixInfo->expertId, nodeMatrixInfo->mindId, nodeMatrixInfo->writeDate.toString(),
- nodeMatrixInfo->mark, nodeMatrixInfo->tableMsg, nodeMatrixInfo->tabIndex)
- .exec();
- t.commit();
- }
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- /*修改节点值*/
- bool NodeMatrixService::UpdateNodeMatrixNodeValue(const NodeMatrixInfo &nodeMatrixInfo)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- t.update("t_node_matrix_info")
- .set("NODE_VALUE", nodeMatrixInfo.nodeValue)
- .where("ENGINEER_ID = ? and expert_name = and abscissa = ? and "
- "ordinate = ? ",
- nodeMatrixInfo.engineerId, nodeMatrixInfo.expertName, nodeMatrixInfo.abscissa,
- nodeMatrixInfo.ordinate);
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- bool NodeMatrixService::UpdateNodeMatrixNodeValueList(const QList<NodeMatrixInfo *> jbInfoList)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- for (int i = 0; i < jbInfoList.length(); i++) {
- NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
- QString updateSql = QString("UPDATE t_node_matrix_info SET NODE_VALUE ='%1' WHERE "
- "ENGINEER_ID = %2 AND expert_name = '%3'"
- " AND abscissa = '%4' AND ordinate = '%5' and table_msg = '%6' "
- "and mark = '%7' and str_uuid = '%8'")
- .arg(nodeMatrixInfo->nodeValue)
- .arg(nodeMatrixInfo->engineerId)
- .arg(nodeMatrixInfo->expertName)
- .arg(nodeMatrixInfo->abscissa)
- .arg(nodeMatrixInfo->ordinate)
- .arg(nodeMatrixInfo->tableMsg)
- .arg(nodeMatrixInfo->mark)
- .arg(nodeMatrixInfo->strUuid);
- // qDebug() << updateSql;
- query.exec(updateSql);
- ret = true;
- }
- return ret;
- }
- bool NodeMatrixService::UpdateNodeMatrixNodeValueList2(const QList<NodeMatrixInfo *> jbInfoList)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase2();
- QSqlQuery query(db);
- bool ret = false;
- for (int i = 0; i < jbInfoList.length(); i++) {
- NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
- QString updateSql = QString("UPDATE t_node_matrix_info SET NODE_VALUE ='%1' WHERE "
- "ENGINEER_ID = %2 AND expert_name = '%3'"
- " AND abscissa = '%4' AND ordinate = '%5' and table_msg = '%6' "
- "and mark = '%7' and tab_index = '%8'")
- .arg(nodeMatrixInfo->nodeValue)
- .arg(nodeMatrixInfo->engineerId)
- .arg(nodeMatrixInfo->expertName)
- .arg(nodeMatrixInfo->abscissa)
- .arg(nodeMatrixInfo->ordinate)
- .arg(nodeMatrixInfo->tableMsg)
- .arg(nodeMatrixInfo->mark)
- .arg(nodeMatrixInfo->tabIndex);
- // qDebug() << updateSql;
- query.exec(updateSql);
- ret = true;
- }
- return ret;
- }
- /*根据专家姓名和工程id获取节点信息*/
- bool NodeMatrixService::QueryNodeMatrixListByExpertNameAndEngineerId(QString expertName, int engineerId,
- QString tableMsg, QString mark)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date from "
- "t_node_matrix_info where expert_name "
- "= '%1' and engineer_id ='%2' and table_msg='%3' and mark = '%4'")
- .arg(expertName)
- .arg(QString::number(engineerId))
- .arg(tableMsg)
- .arg(mark);
- if (query.exec(selectSql)) {
- if (query.next()) {
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- qDebug() << ret;
- return ret;
- }
- /*根据专家姓名和工程id获取节点信息*/
- bool NodeMatrixService::QueryNodeMatrixListByExpertIdAndEngineerId(QString expertId, int engineerId, QString tableMsg)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date from "
- "t_node_matrix_info where expert_id "
- "= '%1' and engineer_id ='%2' and table_msg='%3'")
- .arg(expertId)
- .arg(QString::number(engineerId))
- .arg(tableMsg);
- // qDebug() << selectSql;
- if (query.exec(selectSql)) {
- if (query.next()) {
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- // qDebug() << ret;
- return ret;
- }
- bool NodeMatrixService::QueryNodeMatrixListByExpertNameAndEngineerId(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
- QString expertName, int engineerId)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,str_uuid from "
- "t_node_matrix_info where expert_name "
- "= '%1' and engineer_id ='%2'")
- .arg(expertName)
- .arg(QString::number(engineerId));
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->engineerId = query.value(2).toInt();
- nodeMatrixInfo->node = query.value(3).toString();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- bool NodeMatrixService::QueryNodeMatrixListByExpertNameAndEngineerId2(QString expertName, int engineerId,
- QString tableMsg, QString mark, int tabIndex)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase2();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date from "
- "t_node_matrix_info where expert_name "
- "= '%1' and engineer_id ='%2' and table_msg='%3' and mark = '%4' and tab_index = '%5'")
- .arg(expertName)
- .arg(QString::number(engineerId))
- .arg(tableMsg)
- .arg(mark)
- .arg(tabIndex);
- if (query.exec(selectSql)) {
- if (query.next()) {
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- qDebug() << ret;
- return ret;
- }
- bool NodeMatrixService::QueryNodesByExpertNameAndEngineerId2(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
- QString expertName, int engineerId, QString tableMsg,
- QString mark, int tabIndex)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase2();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,str_uuid from "
- "t_node_matrix_info where expert_name "
- "= '%1' and engineer_id ='%2' and table_msg='%3' and mark = '%4' and tab_index = '%5'")
- .arg(expertName)
- .arg(QString::number(engineerId))
- .arg(tableMsg)
- .arg(mark)
- .arg(tabIndex);
- // qDebug() << "----" << selectSql;
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->node = query.value(2).toString();
- nodeMatrixInfo->engineerId = query.value(3).toInt();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- qDebug() << ret;
- return ret;
- }
- bool NodeMatrixService::QueryNodeValueByUserIdAndEngineerId(int experId, int engineerId)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date from "
- "t_node_matrix_info where expert_id "
- "= '%1' and engineer_id ='%2'")
- .arg(QString::number(experId))
- .arg(QString::number(engineerId));
- // qDebug() << "selectSql=" << selectSql;
- if (query.exec(selectSql)) {
- if (query.next()) {
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- bool NodeMatrixService::QueryNodeMatrixListByExpertIdAndEngineerId(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
- int expertId, int engineerId, QString tableMsg)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,str_uuid from "
- "t_node_matrix_info where expert_id "
- "= '%1' and engineer_id ='%2' and table_msg ='%3'")
- .arg(QString::number(expertId))
- .arg(QString::number(engineerId))
- .arg(tableMsg);
- // qDebug() << "selectSql=" << selectSql;
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->engineerId = query.value(2).toInt();
- nodeMatrixInfo->node = query.value(3).toString();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- }
- ret = true;
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- bool NodeMatrixService::QueryNodeMatrixListByExpertIdAndEngineerId2(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
- int expertId, int engineerId, QString tableMsg)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase2();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,str_uuid from "
- "t_node_matrix_info where expert_id "
- "= '%1' and engineer_id ='%2' and table_msg ='%3'")
- .arg(QString::number(expertId))
- .arg(QString::number(engineerId))
- .arg(tableMsg);
- // qDebug() << "selectSql=" << selectSql;
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->engineerId = query.value(2).toInt();
- nodeMatrixInfo->node = query.value(3).toString();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- /*根据专家姓名查询对应的节点信息*/
- bool NodeMatrixService::QueryNodeMatrixListByExpertName(QList<NodeMatrixInfo *> *nodeMatrixInfoList, QString expertName)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, node,engineer_id, abscissa, ordinate, "
- "node_value, expert_id,mind_name,write_date,mark ,str_uuid from "
- "t_node_matrix_info where expert_name = '%1'")
- .arg(expertName);
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->node = query.value(2).toString();
- nodeMatrixInfo->engineerId = query.value(3).toInt();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- /*根据专家姓名编号对应的节点信息*/
- bool NodeMatrixService::QueryNodeMatrixListByExpertId(QList<NodeMatrixInfo *> *nodeMatrixInfoList, int expertId)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, node,engineer_id, abscissa, ordinate, "
- "node_value, expert_id,mind_name,write_date,mark,str_uuid from "
- "t_node_matrix_info where expert_id = '%1'")
- .arg(expertId);
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->node = query.value(2).toString();
- nodeMatrixInfo->engineerId = query.value(3).toInt();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- /*根据工程编号查询对应的节点信息*/
- bool NodeMatrixService::QueryNodeMatrixListByEngineerId(QList<NodeMatrixInfo *> *nodeMatrixInfoList, int engineerId)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, node, engineer_id, abscissa, ordinate, "
- "node_value, expert_id ,mind_name,write_date,mark,str_uuid from "
- "t_node_matrix_info where engineer_id = '%1'")
- .arg(engineerId);
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->node = query.value(2).toString();
- nodeMatrixInfo->engineerId = query.value(3).toInt();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toInt();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfoList->append(nodeMatrixInfo);
- }
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- /*根据工程编号删除对应的节点信息*/
- bool NodeMatrixService::DeleteNodeMatrixListByEngineerId(int engineerId)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- t.deleteFrom("t_node_matrix_info").where("engineer_id = ?", engineerId);
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- /*根据专家名称删除对应的节点信息*/
- bool NodeMatrixService::DeleteNodeMatrixListByExpertName(QString expertName)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- t.deleteFrom("t_node_matrix_info").where("expert_name = ?", expertName);
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- /*根据专家编号删除对应的节点信息*/
- bool NodeMatrixService::DeleteNodeMatrixListByExpertId(int expertId)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- t.deleteFrom("t_node_matrix_info").where("expert_id = ?", expertId);
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- bool NodeMatrixService::QueryMeaureDataByProjectAndIndex(QList<NodeMatrixInfo *> *dataList, QString index, int projId)
- {
- return QueryDataByProjectAndIndex(dataList, index, projId, 1);
- }
- bool NodeMatrixService::QueryExpertDataByProjectAndIndex(QList<NodeMatrixInfo *> *dataList, QString index, int projId)
- {
- return QueryDataByProjectAndIndex(dataList, index, projId, 0);
- }
- bool NodeMatrixService::QueryDataByProjectAndIndex(QList<NodeMatrixInfo *> *dataList, QString index, int projId,
- int dataSource)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,str_uuid,table_msg from "
- "t_node_matrix_info where mind_id = '%1' and engineer_id ='%2' and table_msg ='%3'")
- .arg(dataSource)
- .arg(QString::number(projId))
- .arg(index);
- // qDebug() << "selectSql=" << selectSql;
- if (query.exec(selectSql)) {
- while (query.next()) {
- if (query.isNull(0) == false) {
- NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
- nodeMatrixInfo->id = query.value(0).toInt();
- nodeMatrixInfo->expertName = query.value(1).toString();
- nodeMatrixInfo->engineerId = query.value(2).toInt();
- nodeMatrixInfo->node = query.value(3).toString();
- nodeMatrixInfo->abscissa = query.value(4).toString();
- nodeMatrixInfo->ordinate = query.value(5).toString();
- nodeMatrixInfo->nodeValue = query.value(6).toString();
- nodeMatrixInfo->expertId = query.value(7).toString();
- nodeMatrixInfo->mindId = query.value(8).toInt();
- nodeMatrixInfo->writeDate = query.value(9).toDateTime();
- nodeMatrixInfo->mark = query.value(10).toString();
- nodeMatrixInfo->strUuid = query.value(11).toString();
- nodeMatrixInfo->tableMsg = query.value(12).toString();
- dataList->append(nodeMatrixInfo);
- }
- }
- ret = true;
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- bool NodeMatrixService::UpdateMeasureData(const NodeMatrixInfo &info)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- if (info.ordinate.length() > 0) {
- t.update("t_node_matrix_info")
- .set("node_value", info.nodeValue)
- .where("mind_id = 1 and engineer_id = ? and table_msg = ? and str_uuid = ? and abscissa = ? and "
- "ordinate = ?",
- info.engineerId, info.tableMsg, info.strUuid, info.abscissa, info.ordinate);
- } else {
- t.update("t_node_matrix_info")
- .set("node_value", info.nodeValue)
- .where("engineer_id = ? and table_msg = ? and str_uuid = ? and abscissa = ?", info.engineerId,
- info.tableMsg, info.strUuid, info.abscissa);
- }
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- bool NodeMatrixService::deleteMeasureData(int projId, QString index, QString uuid)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- t.deleteFrom("t_node_matrix_info")
- .where("engineer_id = ? and table_msg = ? and str_uuid = ?", projId, index, uuid);
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- bool NodeMatrixService::deleteExpertData(int projId, int expertId)
- {
- bool ret = false;
- try {
- Transaction t(SqlDBHelper::getDatabase());
- t.deleteFrom("t_node_matrix_info").where("engineer_id = ? and expert_id = ?", projId, expertId);
- t.commit();
- ret = true;
- } catch (const DBException &ex) {
- qDebug() << ex.lastError.text();
- }
- return ret;
- }
- bool NodeMatrixService::hasMeasureData(int projId, QString index)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,str_uuid,table_msg from "
- "t_node_matrix_info where mind_id = 1 and engineer_id ='%1' and table_msg ='%2'")
- .arg(QString::number(projId))
- .arg(index);
- // qDebug() << "selectSql=" << selectSql;
- if (query.exec(selectSql)) {
- if (query.next()) {
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
- bool NodeMatrixService::hasExpertData(int projId, QString index, int expertId)
- {
- QSqlDatabase db = SqlDBHelper::getDatabase();
- QSqlQuery query(db);
- bool ret = false;
- QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
- "node_value, expert_id,mind_id,write_date,mark,str_uuid,table_msg from "
- "t_node_matrix_info where expert_id = '%1' and engineer_id ='%2' and table_msg ='%3'")
- .arg(QString::number(expertId))
- .arg(QString::number(projId))
- .arg(index);
- // qDebug() << "selectSql=" << selectSql;
- if (query.exec(selectSql)) {
- if (query.next()) {
- ret = true;
- }
- } else {
- qDebug() << query.lastError();
- }
- return ret;
- }
|