EquipDataPointRelatedManager.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /**************************************************************************************************
  2. 版本所有(C), 2021-2022, 北京普达迪泰
  3. ***************************************************************************************************
  4. 文 件 名:EquipDataPointRelatedManager.cpp
  5. 版 本 号: 1.00初版
  6. 作 者: HYF
  7. 生成日期:2021-12-20
  8. 最近修改:
  9. 功能描述: 点关联信息
  10. 函数列表:
  11. 修改历史:
  12. 1.日 期 : 2021-12-20
  13. 作 者 : HYF
  14. 修改内容 : 创建文件
  15. **************************************************************************************************/
  16. #include "pch.h"
  17. #include "EquipDataPointRelatedManager.h"
  18. #include "CppSQLite3.h"
  19. #include "DBFactory.h"
  20. #include "EquipDataPointRelated.h"
  21. EquipDataPointRelatedManager::EquipDataPointRelatedManager()
  22. {
  23. }
  24. EquipDataPointRelatedManager::~EquipDataPointRelatedManager()
  25. {
  26. }
  27. /**************************************************************************************************
  28. 函 数 名 :QueryAll
  29. 功能描述 :查询
  30. 输出参数 :略
  31. 返 回 值 :CppSQLite3Query
  32. **************************************************************************************************/
  33. CppSQLite3Query EquipDataPointRelatedManager::Query()
  34. {
  35. try
  36. {
  37. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  38. return pDB->execQuery(_T("SELECT * FROM equip_data_point_related;"));
  39. }
  40. catch (CppSQLite3Exception& e)
  41. {
  42. LOG::E(e.errorMessage());
  43. }
  44. }
  45. CppSQLite3Query EquipDataPointRelatedManager::Query(DWORD iTaskId)
  46. {
  47. try
  48. {
  49. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  50. char szCmd[256];
  51. sprintf_s(szCmd, "SELECT * FROM equip_data_point_related WHERE task_id=%d;", iTaskId);
  52. return pDB->execQuery(szCmd);
  53. }
  54. catch (CppSQLite3Exception& e)
  55. {
  56. LOG::E(e.errorMessage());
  57. }
  58. }
  59. CppSQLite3Query EquipDataPointRelatedManager::Query(DWORD iTaskId, LPCTSTR szEquipCode)
  60. {
  61. try
  62. {
  63. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  64. char szCmd[256];
  65. sprintf_s(szCmd, "SELECT * FROM equip_data_point_related WHERE task_id=%d AND equip_code='%s';", iTaskId, szEquipCode);
  66. return pDB->execQuery(szCmd);
  67. }
  68. catch (CppSQLite3Exception& e)
  69. {
  70. LOG::E(e.errorMessage());
  71. }
  72. }
  73. /**************************************************************************************************
  74. 函 数 名 :Query
  75. 功能描述 :基于设备编码查询
  76. 输出参数 :无
  77. 返 回 值 :CppSQLite3Query
  78. **************************************************************************************************/
  79. CppSQLite3Query EquipDataPointRelatedManager::Query(DWORD iTaskId, LPCTSTR szEquipCode, DWORD iItemId, DWORD iSubItemId)
  80. {
  81. try
  82. {
  83. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  84. char szCmd[256];
  85. sprintf_s(szCmd,
  86. "SELECT * FROM equip_data_point_related WHERE task_id=%d AND equip_code='%s' AND item_id=%d AND subitem_id=%d;",
  87. iTaskId,
  88. szEquipCode,
  89. iItemId,
  90. iSubItemId);
  91. return pDB->execQuery(szCmd);
  92. }
  93. catch (CppSQLite3Exception& e)
  94. {
  95. LOG::E(e.errorMessage());
  96. }
  97. }
  98. /**************************************************************************************************
  99. 函 数 名 :Add
  100. 功能描述 :增加
  101. 输入参数 :略
  102. 输出参数 :略
  103. 返 回 值 :TRUE 成功;FALSE 失败
  104. **************************************************************************************************/
  105. BOOL EquipDataPointRelatedManager::Add(const EquipDataPointRelated& data)
  106. {
  107. DWORD iTaskId = data.GetTaskId();
  108. CString szEquipCode = data.GetEquipCode();
  109. DWORD iItemId = data.GetItemId();
  110. DWORD iItemType = data.GetItemType();
  111. DWORD iSubItemId = data.GetSubItemId();
  112. DWORD iPointSubItemId = data.GetPointSubItemId();
  113. DOUBLE fDX = data.GetDX();
  114. DOUBLE fDY = data.GetDY();
  115. DOUBLE fDZ = data.GetDZ();
  116. DOUBLE fTotal = data.GetTotal();
  117. DOUBLE fOffset = data.GetOffset();
  118. DOUBLE fOnPlane = data.GetOnPlane();
  119. DOUBLE fOutPlane = data.GetOutPlane();
  120. try
  121. {
  122. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  123. CppSQLite3Buffer bufSQL;
  124. bufSQL.format("INSERT INTO equip_data_point_related "
  125. " ( "
  126. " task_id, "
  127. " equip_code, "
  128. " item_id, "
  129. " item_type, "
  130. " subitem_id, "
  131. " point_subitem_id, "
  132. " dx, "
  133. " dy, "
  134. " dz, "
  135. " total, "
  136. " offset, "
  137. " on_plane, "
  138. " out_plane "
  139. " ) "
  140. " VALUES (%d, %Q, %d, %d, %d, %d, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f, %.3f); ",
  141. iTaskId,
  142. szEquipCode,
  143. iItemId,
  144. iItemType,
  145. iSubItemId,
  146. iPointSubItemId,
  147. fDX,
  148. fDY,
  149. fDZ,
  150. fTotal,
  151. fOffset,
  152. fOnPlane,
  153. fOutPlane
  154. );
  155. pDB->execDML("begin transaction;");
  156. pDB->execDML(bufSQL);
  157. pDB->execDML("commit transaction;");
  158. bufSQL.clear();
  159. }
  160. catch (CppSQLite3Exception& e)
  161. {
  162. LOG::E(e.errorMessage());
  163. return FALSE;
  164. }
  165. return TRUE;
  166. }
  167. /**************************************************************************************************
  168. 函 数 名 :Delete
  169. 功能描述 :删除
  170. 输入参数 :略
  171. 输出参数 :略
  172. 返 回 值 :TRUE 成功;FALSE 失败
  173. **************************************************************************************************/
  174. BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId)
  175. {
  176. try
  177. {
  178. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  179. CppSQLite3Buffer bufSQL;
  180. bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d;", iTaskId);
  181. pDB->execDML("begin transaction;");
  182. pDB->execDML(bufSQL);
  183. pDB->execDML("commit transaction;");
  184. bufSQL.clear();
  185. }
  186. catch (CppSQLite3Exception& e)
  187. {
  188. LOG::E(e.errorMessage());
  189. return FALSE;
  190. }
  191. return TRUE;
  192. }
  193. BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId, LPCTSTR szEquipCode)
  194. {
  195. try
  196. {
  197. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  198. CppSQLite3Buffer bufSQL;
  199. bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d AND equip_code=%Q;", iTaskId, szEquipCode);
  200. pDB->execDML("begin transaction;");
  201. pDB->execDML(bufSQL);
  202. pDB->execDML("commit transaction;");
  203. bufSQL.clear();
  204. }
  205. catch (CppSQLite3Exception& e)
  206. {
  207. LOG::E(e.errorMessage());
  208. return FALSE;
  209. }
  210. return TRUE;
  211. }
  212. BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId, LPCTSTR szEquipCode, DWORD iItemId)
  213. {
  214. try
  215. {
  216. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  217. CppSQLite3Buffer bufSQL;
  218. bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d AND equip_code=%Q AND item_id=%d;", iTaskId, szEquipCode, iItemId);
  219. pDB->execDML("begin transaction;");
  220. pDB->execDML(bufSQL);
  221. pDB->execDML("commit transaction;");
  222. bufSQL.clear();
  223. }
  224. catch (CppSQLite3Exception& e)
  225. {
  226. LOG::E(e.errorMessage());
  227. return FALSE;
  228. }
  229. return TRUE;
  230. }
  231. BOOL EquipDataPointRelatedManager::Delete(DWORD iTaskId, LPCTSTR szEquipCode, DWORD iItemId, DWORD iSubitemId)
  232. {
  233. try
  234. {
  235. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  236. CppSQLite3Buffer bufSQL;
  237. bufSQL.format("DELETE FROM equip_data_point_related WHERE task_id=%d AND equip_code=%Q AND item_id=%d AND subitem_id=%d;", iTaskId, szEquipCode, iItemId, iSubitemId);
  238. pDB->execDML("begin transaction;");
  239. pDB->execDML(bufSQL);
  240. pDB->execDML("commit transaction;");
  241. bufSQL.clear();
  242. }
  243. catch (CppSQLite3Exception& e)
  244. {
  245. LOG::E(e.errorMessage());
  246. return FALSE;
  247. }
  248. return TRUE;
  249. }
  250. /**************************************************************************************************
  251. 函 数 名 :ClearAll
  252. 功能描述 :清除所有数据
  253. 输入参数 :略
  254. 输出参数 :略
  255. 返 回 值 :TRUE 成功;FALSE 失败
  256. **************************************************************************************************/
  257. BOOL EquipDataPointRelatedManager::ClearAll()
  258. {
  259. try
  260. {
  261. CppSQLite3DB* pDB = DBFactory::GetSQLite();
  262. CppSQLite3Buffer bufSQL;
  263. bufSQL.format("DELETE FROM equip_data_point_related;");//删除语句
  264. pDB->execDML("begin transaction;");
  265. pDB->execDML(bufSQL);
  266. pDB->execDML("commit transaction;");
  267. bufSQL.clear();
  268. }
  269. catch (CppSQLite3Exception& e)
  270. {
  271. LOG::E(e.errorMessage());
  272. return FALSE;
  273. }
  274. return TRUE;
  275. }