DataImpl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /************************************************************************/
  2. /* Copyright (C), 2016-2020, [IT], 保留所有权利;
  3. /* 模 块 名:;
  4. /* 描 述:当前项目数据库操作实现;
  5. /*
  6. /* 版 本:[V];
  7. /* 作 者:[IT];
  8. /* 日 期:[11/13/2016];
  9. /*
  10. /*
  11. /* 注 意:;
  12. /*
  13. /* 修改记录:[IT];
  14. /* 修改日期:;
  15. /* 修改版本:;
  16. /* 修改内容:;
  17. /************************************************************************/
  18. #ifndef __DATA_IMPL__
  19. #define __DATA_IMPL__
  20. #pragma once
  21. #include <vector>
  22. #include "TableInfo.h"
  23. class CDataImpl
  24. {
  25. public:
  26. CDataImpl(void);
  27. virtual ~CDataImpl(void);
  28. // 私有变量;
  29. private:
  30. sqlite3 *m_psqlite3;
  31. // 用户函数;
  32. public:
  33. BOOL Open();
  34. void Close();
  35. // begin;
  36. int TransactionBegin()
  37. {
  38. char* psqlite_error = NULL;
  39. INT nRet = sqlite3_exec(m_psqlite3, "begin;", 0, 0, &psqlite_error);
  40. if ( nRet != SQLITE_OK)
  41. {
  42. if ( psqlite_error )
  43. {
  44. sqlite3_free(psqlite_error);
  45. psqlite_error = NULL;
  46. }
  47. return nRet;
  48. }
  49. return SQLITE_OK;
  50. }
  51. // commit;
  52. int TransactionCommit()
  53. {
  54. char* psqlite_error = NULL;
  55. INT nRet = sqlite3_exec(m_psqlite3, "commit;", 0, 0, &psqlite_error);
  56. if ( nRet != SQLITE_OK)
  57. {
  58. if ( psqlite_error )
  59. {
  60. sqlite3_free(psqlite_error);
  61. psqlite_error = NULL;
  62. }
  63. return nRet;
  64. }
  65. return SQLITE_OK;
  66. }
  67. // 执行语句;
  68. BOOL ExecteSQL(IN LPCSTR lpSQL);
  69. // 查询表是否存在;
  70. BOOL QueryTable(std::string table);
  71. // 根据订单号查询订单信息;//返回查询数量;
  72. INT QueryMidInfo(std::string order, STMid &data);
  73. INT QueryKeyInfo(std::string sn, STKeys &data);
  74. INT QueryUnReportKeyInfo(std::vector<STKeys> &vtdata);
  75. INT QueryLogInfo(std::string sn, STLog &data);
  76. INT QueryUnReportLogInfo(std::vector<STLog> &vtdata);
  77. // 查询订单抄写成功数量,成功上报数量,抄写总数;
  78. INT QueryBidInfo(std::string order, BidInfo &binfo);
  79. // 插入mid信息;
  80. INT InsertMidInfo(STMid &data);
  81. // 插入sn key信息;
  82. INT InsertKeyInfo(STKeys &data);
  83. // 插入log;
  84. INT InsertLogInfo(STLog &data);
  85. // 批量插入keys;
  86. INT BatchInsertKeyInfo(std::vector<STKeys> &vtdata);
  87. // 更新MID表;
  88. BOOL UpdateMidInfo(STMid &data);
  89. // 更新下载状态;(成功时,更新完成时间)
  90. BOOL UpdateDownloadStatus(std::string order, int status, std::string des = "" /*失败描述*/);
  91. // 更新抄写状态;
  92. BOOL UpdateKeyCopyStatus(std::string sn);
  93. // 更新上报状态;
  94. BOOL UpdateKeyReportStatus(std::string sn);
  95. BOOL BatchUpdateKeyReportStatus(std::vector<STKeys> &vtKeys);
  96. // 更新日志上报状态;
  97. BOOL UpdateLogReportStatus(std::string sn, std::string type);
  98. // 删除订单所有数据;
  99. BOOL RemoveBidData(std::string order);
  100. };
  101. #endif