NodeMatrixService.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. #include "NodeMatrixService.h"
  2. #include "SqlDBHelper.h"
  3. #include <QDebug>
  4. NodeMatrixService::NodeMatrixService(QObject *parent) { }
  5. bool NodeMatrixService::AddNodeMatrixInfo(const NodeMatrixInfo &nodeMatrixInfo)
  6. {
  7. bool ret = false;
  8. try {
  9. Transaction t(SqlDBHelper::getDatabase());
  10. InsertQuery q = t.insertInto("t_node_matrix_info (expert_name, engineer_id, node, "
  11. "abscissa, ordinate, "
  12. "node_value, expert_id,mind_name,write_date,mark)");
  13. q.values(nodeMatrixInfo.expertName, nodeMatrixInfo.engineerId, nodeMatrixInfo.node, nodeMatrixInfo.abscissa,
  14. nodeMatrixInfo.ordinate, nodeMatrixInfo.nodeValue, nodeMatrixInfo.expertId, nodeMatrixInfo.mindId,
  15. nodeMatrixInfo.writeDate.toString(), nodeMatrixInfo.mark)
  16. .exec();
  17. t.commit();
  18. ret = true;
  19. } catch (const DBException &ex) {
  20. qDebug() << ex.lastError.text();
  21. }
  22. return ret;
  23. }
  24. /*批量节点信息新增*/
  25. bool NodeMatrixService::AddNodeMatrixInfoList(const QList<NodeMatrixInfo *> &jbInfoList)
  26. {
  27. bool ret = false;
  28. try {
  29. Transaction t(SqlDBHelper::getDatabase());
  30. for (int i = 0; i < jbInfoList.length(); i++) {
  31. NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
  32. InsertQuery query = t.insertInto("t_node_matrix_info (expert_name, engineer_id, node, abscissa, "
  33. "ordinate, "
  34. "node_value, expert_id,mind_id,write_date,mark,table_msg)");
  35. query.values(nodeMatrixInfo->expertName, nodeMatrixInfo->engineerId, nodeMatrixInfo->node,
  36. nodeMatrixInfo->abscissa, nodeMatrixInfo->ordinate, nodeMatrixInfo->nodeValue,
  37. nodeMatrixInfo->expertId, nodeMatrixInfo->mindId, nodeMatrixInfo->writeDate.toString(),
  38. nodeMatrixInfo->mark, nodeMatrixInfo->tableMsg)
  39. .exec();
  40. t.commit();
  41. }
  42. ret = true;
  43. } catch (const DBException &ex) {
  44. qDebug() << ex.lastError.text();
  45. }
  46. return ret;
  47. }
  48. /*批量节点信息新增----专家端*/
  49. bool NodeMatrixService::AddNodeMatrixInfoList2(const QList<NodeMatrixInfo *> &jbInfoList)
  50. {
  51. bool ret = false;
  52. try {
  53. Transaction t(SqlDBHelper::getDatabase2());
  54. for (int i = 0; i < jbInfoList.length(); i++) {
  55. NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
  56. InsertQuery query = t.insertInto("t_node_matrix_info (expert_name, engineer_id, node, abscissa, "
  57. "ordinate, "
  58. "node_value, expert_id,mind_id,write_date,mark,table_msg,tab_index)");
  59. query.values(nodeMatrixInfo->expertName, nodeMatrixInfo->engineerId, nodeMatrixInfo->node,
  60. nodeMatrixInfo->abscissa, nodeMatrixInfo->ordinate, nodeMatrixInfo->nodeValue,
  61. nodeMatrixInfo->expertId, nodeMatrixInfo->mindId, nodeMatrixInfo->writeDate.toString(),
  62. nodeMatrixInfo->mark, nodeMatrixInfo->tableMsg, nodeMatrixInfo->tabIndex)
  63. .exec();
  64. t.commit();
  65. }
  66. ret = true;
  67. } catch (const DBException &ex) {
  68. qDebug() << ex.lastError.text();
  69. }
  70. return ret;
  71. }
  72. /*修改节点值*/
  73. bool NodeMatrixService::UpdateNodeMatrixNodeValue(const NodeMatrixInfo &nodeMatrixInfo)
  74. {
  75. bool ret = false;
  76. try {
  77. Transaction t(SqlDBHelper::getDatabase());
  78. t.update("t_node_matrix_info")
  79. .set("NODE_VALUE", nodeMatrixInfo.nodeValue)
  80. .where("ENGINEER_ID = ? and expert_name = and abscissa = ? and "
  81. "ordinate = ? ",
  82. nodeMatrixInfo.engineerId, nodeMatrixInfo.expertName, nodeMatrixInfo.abscissa,
  83. nodeMatrixInfo.ordinate);
  84. t.commit();
  85. ret = true;
  86. } catch (const DBException &ex) {
  87. qDebug() << ex.lastError.text();
  88. }
  89. return ret;
  90. }
  91. bool NodeMatrixService::UpdateNodeMatrixNodeValueList(const QList<NodeMatrixInfo *> jbInfoList)
  92. {
  93. QSqlDatabase db = SqlDBHelper::getDatabase();
  94. QSqlQuery query(db);
  95. bool ret = false;
  96. for (int i = 0; i < jbInfoList.length(); i++) {
  97. NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
  98. QString updateSql = QString("UPDATE t_node_matrix_info SET NODE_VALUE ='%1' WHERE "
  99. "ENGINEER_ID = %2 AND expert_name = '%3'"
  100. " AND abscissa = '%4' AND ordinate = '%5' and table_msg = '%6' "
  101. "and mark = '%7'")
  102. .arg(nodeMatrixInfo->nodeValue)
  103. .arg(nodeMatrixInfo->engineerId)
  104. .arg(nodeMatrixInfo->expertName)
  105. .arg(nodeMatrixInfo->abscissa)
  106. .arg(nodeMatrixInfo->ordinate)
  107. .arg(nodeMatrixInfo->tableMsg)
  108. .arg(nodeMatrixInfo->mark);
  109. // qDebug() << updateSql;
  110. query.exec(updateSql);
  111. ret = true;
  112. }
  113. return ret;
  114. }
  115. bool NodeMatrixService::UpdateNodeMatrixNodeValueList2(const QList<NodeMatrixInfo *> jbInfoList)
  116. {
  117. QSqlDatabase db = SqlDBHelper::getDatabase2();
  118. QSqlQuery query(db);
  119. bool ret = false;
  120. for (int i = 0; i < jbInfoList.length(); i++) {
  121. NodeMatrixInfo *nodeMatrixInfo = jbInfoList.at(i);
  122. QString updateSql = QString("UPDATE t_node_matrix_info SET NODE_VALUE ='%1' WHERE "
  123. "ENGINEER_ID = %2 AND expert_name = '%3'"
  124. " AND abscissa = '%4' AND ordinate = '%5' and table_msg = '%6' "
  125. "and mark = '%7' and tab_index = '%8'")
  126. .arg(nodeMatrixInfo->nodeValue)
  127. .arg(nodeMatrixInfo->engineerId)
  128. .arg(nodeMatrixInfo->expertName)
  129. .arg(nodeMatrixInfo->abscissa)
  130. .arg(nodeMatrixInfo->ordinate)
  131. .arg(nodeMatrixInfo->tableMsg)
  132. .arg(nodeMatrixInfo->mark)
  133. .arg(nodeMatrixInfo->tabIndex);
  134. // qDebug() << updateSql;
  135. query.exec(updateSql);
  136. ret = true;
  137. }
  138. return ret;
  139. }
  140. /*根据专家姓名和工程id获取节点信息*/
  141. bool NodeMatrixService::QueryNodeMatrixListByExpertNameAndEngineerId(QString expertName, int engineerId,
  142. QString tableMsg, QString mark)
  143. {
  144. QSqlDatabase db = SqlDBHelper::getDatabase();
  145. QSqlQuery query(db);
  146. bool ret = false;
  147. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  148. "node_value, expert_id,mind_id,write_date from "
  149. "t_node_matrix_info where expert_name "
  150. "= '%1' and engineer_id ='%2' and table_msg='%3' and mark = '%4'")
  151. .arg(expertName)
  152. .arg(QString::number(engineerId))
  153. .arg(tableMsg)
  154. .arg(mark);
  155. if (query.exec(selectSql)) {
  156. if (query.next()) {
  157. ret = true;
  158. }
  159. } else {
  160. qDebug() << query.lastError();
  161. }
  162. qDebug() << ret;
  163. return ret;
  164. }
  165. /*根据专家姓名和工程id获取节点信息*/
  166. bool NodeMatrixService::QueryNodeMatrixListByExpertIdAndEngineerId(QString expertId, int engineerId, QString tableMsg)
  167. {
  168. QSqlDatabase db = SqlDBHelper::getDatabase();
  169. QSqlQuery query(db);
  170. bool ret = false;
  171. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  172. "node_value, expert_id,mind_id,write_date from "
  173. "t_node_matrix_info where expert_id "
  174. "= '%1' and engineer_id ='%2' and table_msg='%3'")
  175. .arg(expertId)
  176. .arg(QString::number(engineerId))
  177. .arg(tableMsg);
  178. // qDebug() << selectSql;
  179. if (query.exec(selectSql)) {
  180. if (query.next()) {
  181. ret = true;
  182. }
  183. } else {
  184. qDebug() << query.lastError();
  185. }
  186. // qDebug() << ret;
  187. return ret;
  188. }
  189. bool NodeMatrixService::QueryNodeMatrixListByExpertNameAndEngineerId(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
  190. QString expertName, int engineerId)
  191. {
  192. QSqlDatabase db = SqlDBHelper::getDatabase();
  193. QSqlQuery query(db);
  194. bool ret = false;
  195. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  196. "node_value, expert_id,mind_id,write_date from "
  197. "t_node_matrix_info where expert_name "
  198. "= '%1' and engineer_id ='%2'")
  199. .arg(expertName)
  200. .arg(QString::number(engineerId));
  201. if (query.exec(selectSql)) {
  202. while (query.next()) {
  203. if (query.isNull(0) == false) {
  204. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  205. nodeMatrixInfo->id = query.value(0).toInt();
  206. nodeMatrixInfo->expertName = query.value(1).toString();
  207. nodeMatrixInfo->node = query.value(2).toString();
  208. nodeMatrixInfo->engineerId = query.value(3).toInt();
  209. nodeMatrixInfo->abscissa = query.value(4).toString();
  210. nodeMatrixInfo->ordinate = query.value(5).toString();
  211. nodeMatrixInfo->nodeValue = query.value(6).toString();
  212. nodeMatrixInfo->expertId = query.value(7).toInt();
  213. nodeMatrixInfo->mindId = query.value(8).toInt();
  214. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  215. nodeMatrixInfo->mark = query.value(10).toString();
  216. nodeMatrixInfoList->append(nodeMatrixInfo);
  217. }
  218. ret = true;
  219. }
  220. } else {
  221. qDebug() << query.lastError();
  222. }
  223. return ret;
  224. }
  225. bool NodeMatrixService::QueryNodeMatrixListByExpertNameAndEngineerId2(QString expertName, int engineerId,
  226. QString tableMsg, QString mark, int tabIndex)
  227. {
  228. QSqlDatabase db = SqlDBHelper::getDatabase2();
  229. QSqlQuery query(db);
  230. bool ret = false;
  231. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  232. "node_value, expert_id,mind_id,write_date from "
  233. "t_node_matrix_info where expert_name "
  234. "= '%1' and engineer_id ='%2' and table_msg='%3' and mark = '%4' and tab_index = '%5'")
  235. .arg(expertName)
  236. .arg(QString::number(engineerId))
  237. .arg(tableMsg)
  238. .arg(mark)
  239. .arg(tabIndex);
  240. if (query.exec(selectSql)) {
  241. if (query.next()) {
  242. ret = true;
  243. }
  244. } else {
  245. qDebug() << query.lastError();
  246. }
  247. qDebug() << ret;
  248. return ret;
  249. }
  250. bool NodeMatrixService::QueryNodesByExpertNameAndEngineerId2(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
  251. QString expertName, int engineerId, QString tableMsg,
  252. QString mark, int tabIndex)
  253. {
  254. QSqlDatabase db = SqlDBHelper::getDatabase2();
  255. QSqlQuery query(db);
  256. bool ret = false;
  257. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  258. "node_value, expert_id,mind_id,write_date from "
  259. "t_node_matrix_info where expert_name "
  260. "= '%1' and engineer_id ='%2' and table_msg='%3' and mark = '%4' and tab_index = '%5'")
  261. .arg(expertName)
  262. .arg(QString::number(engineerId))
  263. .arg(tableMsg)
  264. .arg(mark)
  265. .arg(tabIndex);
  266. // qDebug() << "----" << selectSql;
  267. if (query.exec(selectSql)) {
  268. while (query.next()) {
  269. if (query.isNull(0) == false) {
  270. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  271. nodeMatrixInfo->id = query.value(0).toInt();
  272. nodeMatrixInfo->expertName = query.value(1).toString();
  273. nodeMatrixInfo->node = query.value(2).toString();
  274. nodeMatrixInfo->engineerId = query.value(3).toInt();
  275. nodeMatrixInfo->abscissa = query.value(4).toString();
  276. nodeMatrixInfo->ordinate = query.value(5).toString();
  277. nodeMatrixInfo->nodeValue = query.value(6).toString();
  278. nodeMatrixInfo->expertId = query.value(7).toInt();
  279. nodeMatrixInfo->mindId = query.value(8).toInt();
  280. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  281. nodeMatrixInfo->mark = query.value(10).toString();
  282. nodeMatrixInfoList->append(nodeMatrixInfo);
  283. }
  284. ret = true;
  285. }
  286. } else {
  287. qDebug() << query.lastError();
  288. }
  289. qDebug() << ret;
  290. return ret;
  291. }
  292. bool NodeMatrixService::QueryNodeValueByUserIdAndEngineerId(int experId, int engineerId)
  293. {
  294. QSqlDatabase db = SqlDBHelper::getDatabase();
  295. QSqlQuery query(db);
  296. bool ret = false;
  297. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  298. "node_value, expert_id,mind_id,write_date from "
  299. "t_node_matrix_info where expert_id "
  300. "= '%1' and engineer_id ='%2'")
  301. .arg(QString::number(experId))
  302. .arg(QString::number(engineerId));
  303. // qDebug() << "selectSql=" << selectSql;
  304. if (query.exec(selectSql)) {
  305. if (query.next()) {
  306. ret = true;
  307. }
  308. } else {
  309. qDebug() << query.lastError();
  310. }
  311. return ret;
  312. }
  313. bool NodeMatrixService::QueryNodeMatrixListByExpertIdAndEngineerId(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
  314. int expertId, int engineerId, QString tableMsg)
  315. {
  316. QSqlDatabase db = SqlDBHelper::getDatabase();
  317. QSqlQuery query(db);
  318. bool ret = false;
  319. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  320. "node_value, expert_id,mind_id,write_date from "
  321. "t_node_matrix_info where expert_id "
  322. "= '%1' and engineer_id ='%2' and table_msg ='%3'")
  323. .arg(QString::number(expertId))
  324. .arg(QString::number(engineerId))
  325. .arg(tableMsg);
  326. // qDebug() << "selectSql=" << selectSql;
  327. if (query.exec(selectSql)) {
  328. while (query.next()) {
  329. if (query.isNull(0) == false) {
  330. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  331. nodeMatrixInfo->id = query.value(0).toInt();
  332. nodeMatrixInfo->expertName = query.value(1).toString();
  333. nodeMatrixInfo->node = query.value(2).toString();
  334. nodeMatrixInfo->engineerId = query.value(3).toInt();
  335. nodeMatrixInfo->abscissa = query.value(4).toString();
  336. nodeMatrixInfo->ordinate = query.value(5).toString();
  337. nodeMatrixInfo->nodeValue = query.value(6).toString();
  338. nodeMatrixInfo->expertId = query.value(7).toInt();
  339. nodeMatrixInfo->mindId = query.value(8).toInt();
  340. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  341. nodeMatrixInfo->mark = query.value(10).toString();
  342. nodeMatrixInfoList->append(nodeMatrixInfo);
  343. }
  344. ret = true;
  345. }
  346. } else {
  347. qDebug() << query.lastError();
  348. }
  349. return ret;
  350. }
  351. bool NodeMatrixService::QueryNodeMatrixListByExpertIdAndEngineerId2(QList<NodeMatrixInfo *> *nodeMatrixInfoList,
  352. int expertId, int engineerId, QString tableMsg)
  353. {
  354. QSqlDatabase db = SqlDBHelper::getDatabase2();
  355. QSqlQuery query(db);
  356. bool ret = false;
  357. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  358. "node_value, expert_id,mind_id,write_date from "
  359. "t_node_matrix_info where expert_id "
  360. "= '%1' and engineer_id ='%2' and table_msg ='%3'")
  361. .arg(QString::number(expertId))
  362. .arg(QString::number(engineerId))
  363. .arg(tableMsg);
  364. // qDebug() << "selectSql=" << selectSql;
  365. if (query.exec(selectSql)) {
  366. while (query.next()) {
  367. if (query.isNull(0) == false) {
  368. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  369. nodeMatrixInfo->id = query.value(0).toInt();
  370. nodeMatrixInfo->expertName = query.value(1).toString();
  371. nodeMatrixInfo->node = query.value(2).toString();
  372. nodeMatrixInfo->engineerId = query.value(3).toInt();
  373. nodeMatrixInfo->abscissa = query.value(4).toString();
  374. nodeMatrixInfo->ordinate = query.value(5).toString();
  375. nodeMatrixInfo->nodeValue = query.value(6).toString();
  376. nodeMatrixInfo->expertId = query.value(7).toInt();
  377. nodeMatrixInfo->mindId = query.value(8).toInt();
  378. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  379. nodeMatrixInfo->mark = query.value(10).toString();
  380. nodeMatrixInfoList->append(nodeMatrixInfo);
  381. }
  382. ret = true;
  383. }
  384. } else {
  385. qDebug() << query.lastError();
  386. }
  387. return ret;
  388. }
  389. /*根据专家姓名查询对应的节点信息*/
  390. bool NodeMatrixService::QueryNodeMatrixListByExpertName(QList<NodeMatrixInfo *> *nodeMatrixInfoList, QString expertName)
  391. {
  392. QSqlDatabase db = SqlDBHelper::getDatabase();
  393. QSqlQuery query(db);
  394. bool ret = false;
  395. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  396. "node_value, expert_id,mind_name,write_date from "
  397. "t_node_matrix_info where expert_name = '%1'")
  398. .arg(expertName);
  399. if (query.exec(selectSql)) {
  400. while (query.next()) {
  401. if (query.isNull(0) == false) {
  402. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  403. nodeMatrixInfo->id = query.value(0).toInt();
  404. nodeMatrixInfo->expertName = query.value(1).toString();
  405. nodeMatrixInfo->node = query.value(2).toString();
  406. nodeMatrixInfo->engineerId = query.value(3).toInt();
  407. nodeMatrixInfo->abscissa = query.value(4).toString();
  408. nodeMatrixInfo->ordinate = query.value(5).toString();
  409. nodeMatrixInfo->nodeValue = query.value(6).toString();
  410. nodeMatrixInfo->expertId = query.value(7).toInt();
  411. nodeMatrixInfo->mindId = query.value(8).toInt();
  412. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  413. nodeMatrixInfo->mark = query.value(10).toString();
  414. nodeMatrixInfoList->append(nodeMatrixInfo);
  415. }
  416. ret = true;
  417. }
  418. } else {
  419. qDebug() << query.lastError();
  420. }
  421. return ret;
  422. }
  423. /*根据专家姓名编号对应的节点信息*/
  424. bool NodeMatrixService::QueryNodeMatrixListByExpertId(QList<NodeMatrixInfo *> *nodeMatrixInfoList, int expertId)
  425. {
  426. QSqlDatabase db = SqlDBHelper::getDatabase();
  427. QSqlQuery query(db);
  428. bool ret = false;
  429. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  430. "node_value, expert_id,mind_name,write_date from "
  431. "t_node_matrix_info where expert_id = '%1'")
  432. .arg(expertId);
  433. if (query.exec(selectSql)) {
  434. while (query.next()) {
  435. if (query.isNull(0) == false) {
  436. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  437. nodeMatrixInfo->id = query.value(0).toInt();
  438. nodeMatrixInfo->expertName = query.value(1).toString();
  439. nodeMatrixInfo->node = query.value(2).toString();
  440. nodeMatrixInfo->engineerId = query.value(3).toInt();
  441. nodeMatrixInfo->abscissa = query.value(4).toString();
  442. nodeMatrixInfo->ordinate = query.value(5).toString();
  443. nodeMatrixInfo->nodeValue = query.value(6).toString();
  444. nodeMatrixInfo->expertId = query.value(7).toInt();
  445. nodeMatrixInfo->mindId = query.value(8).toInt();
  446. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  447. nodeMatrixInfo->mark = query.value(10).toString();
  448. nodeMatrixInfoList->append(nodeMatrixInfo);
  449. }
  450. ret = true;
  451. }
  452. } else {
  453. qDebug() << query.lastError();
  454. }
  455. return ret;
  456. }
  457. /*根据工程编号查询对应的节点信息*/
  458. bool NodeMatrixService::QueryNodeMatrixListByEngineerId(QList<NodeMatrixInfo *> *nodeMatrixInfoList, int engineerId)
  459. {
  460. QSqlDatabase db = SqlDBHelper::getDatabase();
  461. QSqlQuery query(db);
  462. bool ret = false;
  463. QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
  464. "node_value, expert_id ,mind_name,write_date from "
  465. "t_node_matrix_info where engineer_id = '%1'")
  466. .arg(engineerId);
  467. if (query.exec(selectSql)) {
  468. while (query.next()) {
  469. if (query.isNull(0) == false) {
  470. NodeMatrixInfo *nodeMatrixInfo = new NodeMatrixInfo();
  471. nodeMatrixInfo->id = query.value(0).toInt();
  472. nodeMatrixInfo->expertName = query.value(1).toString();
  473. nodeMatrixInfo->node = query.value(2).toString();
  474. nodeMatrixInfo->engineerId = query.value(3).toInt();
  475. nodeMatrixInfo->abscissa = query.value(4).toString();
  476. nodeMatrixInfo->ordinate = query.value(5).toString();
  477. nodeMatrixInfo->nodeValue = query.value(6).toString();
  478. nodeMatrixInfo->expertId = query.value(7).toInt();
  479. nodeMatrixInfo->mindId = query.value(8).toInt();
  480. nodeMatrixInfo->writeDate = query.value(9).toDateTime();
  481. nodeMatrixInfo->mark = query.value(10).toString();
  482. nodeMatrixInfoList->append(nodeMatrixInfo);
  483. }
  484. ret = true;
  485. }
  486. } else {
  487. qDebug() << query.lastError();
  488. }
  489. return ret;
  490. }
  491. /*根据工程编号删除对应的节点信息*/
  492. bool NodeMatrixService::DeleteNodeMatrixListByEngineerId(int engineerId)
  493. {
  494. bool ret = false;
  495. try {
  496. Transaction t(SqlDBHelper::getDatabase());
  497. t.deleteFrom("t_node_matrix_info").where("engineer_id = ?", engineerId);
  498. t.commit();
  499. ret = true;
  500. } catch (const DBException &ex) {
  501. qDebug() << ex.lastError.text();
  502. }
  503. return ret;
  504. }
  505. /*根据专家名称删除对应的节点信息*/
  506. bool NodeMatrixService::DeleteNodeMatrixListByExpertName(QString expertName)
  507. {
  508. bool ret = false;
  509. try {
  510. Transaction t(SqlDBHelper::getDatabase());
  511. t.deleteFrom("t_node_matrix_info").where("expert_name = ?", expertName);
  512. t.commit();
  513. ret = true;
  514. } catch (const DBException &ex) {
  515. qDebug() << ex.lastError.text();
  516. }
  517. return ret;
  518. }
  519. /*根据专家编号删除对应的节点信息*/
  520. bool NodeMatrixService::DeleteNodeMatrixListByExpertId(int expertId)
  521. {
  522. bool ret = false;
  523. try {
  524. Transaction t(SqlDBHelper::getDatabase());
  525. t.deleteFrom("t_node_matrix_info").where("expert_id = ?", expertId);
  526. t.commit();
  527. ret = true;
  528. } catch (const DBException &ex) {
  529. qDebug() << ex.lastError.text();
  530. }
  531. return ret;
  532. }