hblastregrecorddao.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "hblastregrecorddao.h"
  2. HBlastRegRecordDao::HBlastRegRecordDao(QSqlDatabase db) : database(db) {}
  3. bool HBlastRegRecordDao::addHBlastRegRecord(const HBlastRegRecord& record) {
  4. QSqlQuery query;
  5. query.prepare("INSERT INTO h_blast_reg_record (uuid, equip_sn, equip_version, reg_deto_count, error_deto_count, after_test_bus_v, after_test_bus_i, bus_leakage_current_i, net_charged_v, net_charged_i, before_blasting_v, before_blasting_i, record_uuid, created_at, updated_at, deleted_at, create_by, update_by) "
  6. "VALUES (:uuid, :equip_sn, :equip_version, :reg_deto_count, :error_deto_count, :after_test_bus_v, :after_test_bus_i, :bus_leakage_current_i, :net_charged_v, :net_charged_i, :before_blasting_v, :before_blasting_i, :record_uuid, :created_at, :updated_at, :deleted_at, :create_by, :update_by)");
  7. query.bindValue(":uuid", record.getUuid());
  8. query.bindValue(":equip_sn", record.getEquipSn());
  9. query.bindValue(":equip_version", record.getEquipVersion());
  10. query.bindValue(":reg_deto_count", record.getRegDetoCount());
  11. query.bindValue(":error_deto_count", record.getErrorDetoCount());
  12. query.bindValue(":after_test_bus_v", record.getAfterTestBusV());
  13. query.bindValue(":after_test_bus_i", record.getAfterTestBusI());
  14. query.bindValue(":bus_leakage_current_i", record.getBusLeakageCurrentI());
  15. query.bindValue(":net_charged_v", record.getNetChargedV());
  16. query.bindValue(":net_charged_i", record.getNetChargedI());
  17. query.bindValue(":before_blasting_v", record.getBeforeBlastingV());
  18. query.bindValue(":before_blasting_i", record.getBeforeBlastingI());
  19. query.bindValue(":record_uuid", record.getRecordUuid());
  20. query.bindValue(":created_at", record.getCreatedAt());
  21. query.bindValue(":updated_at", record.getUpdatedAt());
  22. query.bindValue(":deleted_at", record.getDeletedAt());
  23. query.bindValue(":create_by", record.getCreateBy());
  24. query.bindValue(":update_by", record.getUpdateBy());
  25. if (query.exec()) {
  26. return true;
  27. } else {
  28. qDebug() << "Insert failed:" << query.lastError().text();
  29. return false;
  30. }
  31. }
  32. bool HBlastRegRecordDao::updateHBlastRegRecord(const HBlastRegRecord& record) {
  33. QSqlQuery query;
  34. query.prepare("UPDATE h_blast_reg_record SET uuid = :uuid, equip_sn = :equip_sn, equip_version = :equip_version, reg_deto_count = :reg_deto_count, error_deto_count = :error_deto_count, after_test_bus_v = :after_test_bus_v, after_test_bus_i = :after_test_bus_i, bus_leakage_current_i = :bus_leakage_current_i, net_charged_v = :net_charged_v, net_charged_i = :net_charged_i, before_blasting_v = :before_blasting_v, before_blasting_i = :before_blasting_i, record_uuid = :record_uuid, created_at = :created_at, updated_at = :updated_at, deleted_at = :deleted_at, create_by = :create_by, update_by = :update_by "
  35. "WHERE id = :id");
  36. query.bindValue(":id", record.getId());
  37. query.bindValue(":uuid", record.getUuid());
  38. query.bindValue(":equip_sn", record.getEquipSn());
  39. query.bindValue(":equip_version", record.getEquipVersion());
  40. query.bindValue(":reg_deto_count", record.getRegDetoCount());
  41. query.bindValue(":error_deto_count", record.getErrorDetoCount());
  42. query.bindValue(":after_test_bus_v", record.getAfterTestBusV());
  43. query.bindValue(":after_test_bus_i", record.getAfterTestBusI());
  44. query.bindValue(":bus_leakage_current_i", record.getBusLeakageCurrentI());
  45. query.bindValue(":net_charged_v", record.getNetChargedV());
  46. query.bindValue(":net_charged_i", record.getNetChargedI());
  47. query.bindValue(":before_blasting_v", record.getBeforeBlastingV());
  48. query.bindValue(":before_blasting_i", record.getBeforeBlastingI());
  49. query.bindValue(":record_uuid", record.getRecordUuid());
  50. query.bindValue(":created_at", record.getCreatedAt());
  51. query.bindValue(":updated_at", record.getUpdatedAt());
  52. query.bindValue(":deleted_at", record.getDeletedAt());
  53. query.bindValue(":create_by", record.getCreateBy());
  54. query.bindValue(":update_by", record.getUpdateBy());
  55. if (query.exec()) {
  56. return true;
  57. } else {
  58. qDebug() << "Update failed:" << query.lastError().text();
  59. return false;
  60. }
  61. }
  62. bool HBlastRegRecordDao::deleteHBlastRegRecord(qint64 id) {
  63. QSqlQuery query;
  64. query.prepare("DELETE FROM h_blast_reg_record WHERE id = :id");
  65. query.bindValue(":id", id);
  66. if (query.exec()) {
  67. return true;
  68. } else {
  69. qDebug() << "Delete failed:" << query.lastError().text();
  70. return false;
  71. }
  72. }
  73. // HBlastRegRecord HBlastRegRecordDao::getHBlastRegRecordById(qint64 id) {
  74. // HBlastRegRecord record;
  75. // QSqlQuery query;
  76. // query.prepare("SELECT * FROM h_blast_reg_record WHERE id = :id");
  77. // query.bindValue(":id", id);
  78. // if (query.exec() && query.next()) {
  79. // record.setId(query.value("id").toLongLong());
  80. // record.setUuid(query.value("uuid").toString());
  81. // record.setEquipSn(query.value("equip_sn").toString());
  82. // record.setEquipVersion(query.value("equip_version").toString());
  83. // record.setRegDetoCount(query.value("reg_deto_count").toInt());
  84. // record.setErrorDetoCount(query.value("error_deto_count").toInt());
  85. // record.setAfterTestBusV(query.value("after_test_bus_v").toString());
  86. // record.setAfterTestBusI(query.value("after_test_bus_i").toString());
  87. // record.setBusLeakageCurrentI(query.value("bus_leakage_current_i").toString());
  88. // record.setNetChargedV(query.value("net_charged_v").toString());
  89. // record.setNetChargedI(query.value("net_charged_i").toString());
  90. // record.setBeforeBlastingV(query.value("before_blasting_v").toString());
  91. // record.setBeforeBlastingI(query.value("before_blasting_i").toString());
  92. // record.setRecordUuid(query.value("record_uuid").toString());
  93. // record.setCreatedAt(query.value("created_at").toDateTime());
  94. // record.setUpdatedAt(query.value("updated_at").toDateTime());
  95. // record.setDeletedAt(query.value("deleted_at").toDateTime());
  96. // record.setCreateBy(query.value("create_by").toLongLong());
  97. // record.setUpdateBy(query.value("update_by").toLongLong());
  98. // }
  99. // return record;
  100. // }