jsonBuilder.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /**
  2. * @brief
  3. json构造器类
  4. * @version
  5. V 1.0.0
  6. * @author
  7. 王益俊
  8. * @date
  9. 创建时间: 2018-08-17\n
  10. * @note
  11. 2018-08-17 创建类。\n
  12. * @warning
  13. * @bug
  14. */
  15. #ifndef _JSONBUILDER_H_
  16. #define _JSONBUILDER_H_
  17. #include <map>
  18. #include <rapidjson/document.h>
  19. #include "jsonCommon.h"
  20. #include "ws_common.h"
  21. namespace YA
  22. {
  23. class jsonBuilder
  24. {
  25. private:
  26. /**
  27. * @brief
  28. 加上版本信息函数。
  29. * @param [out] rapidjson::Value& root 根jason对象\n
  30. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  31. * @return 无\n
  32. * @note
  33. * @warning
  34. * @bug
  35. */
  36. void __AddVersion( rapidjson::Value& root, rapidjson::Document::AllocatorType& Allocator );
  37. /**
  38. * @brief
  39. 设置命令信息函数。
  40. * @param [in] const char* szCmd 命令\n
  41. * @param [out] rapidjson::Value& root 根jason对象\n
  42. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  43. * @return 无\n
  44. * @note
  45. * @warning
  46. * @bug
  47. */
  48. void __SetCmd( const char* szCmd, rapidjson::Value& root, rapidjson::Document::AllocatorType& Allocator );
  49. /**
  50. * @brief
  51. 构造卡明细函数。
  52. * @param [in] const _CARD_POS_& CardPos 卡位置\n
  53. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  54. * @param [out] rapidjson::Value& DetailItem 生成的单个人卡明细\n
  55. * @return 构造是否成功\n
  56. * @note
  57. * @warning
  58. * @bug
  59. */
  60. bool __BuildDetail( const _CARD_POS_& CardPos, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& DetailItem );
  61. /**
  62. * @brief
  63. 构造部门列表json对象函数。
  64. * @param [in] const std::map<int, _STAT_DEPT_ITEM_>& dept_map 部门统计列表\n
  65. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  66. * @param [out] rapidjson::Value& Dept 生成的部门json对象\n
  67. * @return 构造是否成功\n
  68. * @note
  69. * @warning
  70. * @bug
  71. */
  72. bool __BuildDept( const std::map<int, _STAT_DEPT_ITEM_>& dept_map, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& Dept );
  73. /**
  74. * @brief
  75. 构造部门项json对象函数。
  76. * @param [in] const _STAT_DEPT_ITEM_& st_dept_item 部门项\n
  77. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  78. * @param [out] rapidjson::Value& DeptItem 生成的部门项json对象\n
  79. * @return 无\n
  80. * @note
  81. * @warning
  82. * @bug
  83. */
  84. void __BuildDeptItem( const _STAT_DEPT_ITEM_& st_dept_item, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& DeptItem );
  85. /**
  86. * @brief
  87. 构造基础卡项json对象函数。
  88. * @param [in] const _BASE_CARD_& Card 基础卡对象\n
  89. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  90. * @param [out] rapidjson::Value& CardItem 生成的卡json对象\n
  91. * @return 无\n
  92. * @note
  93. * @warning
  94. * @bug
  95. */
  96. void __BuildBaseCardItem( const _BASE_CARD_& Card, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value& CardItem );
  97. /**
  98. * @brief
  99. 生成Dept Map函数。
  100. * @param [in] const _CARD_POS_& CardPos 卡定位数据\n
  101. * @param [out] std::map<int, _STAT_DEPT_ITEM_>& DeptMap 生成的Dept Map\n
  102. * @return 无\n
  103. * @note
  104. * @warning
  105. * @bug
  106. */
  107. void __CreateDeptMap( const _CARD_POS_& CardPos, std::map<int, _STAT_DEPT_ITEM_>& DeptMap );
  108. /**
  109. * @brief
  110. 生成_STAT_DEPT_ITEM_结构体函数。
  111. * @param [in] const _CARD_POS_& CardPos 卡定位数据\n
  112. * @param [out] _STAT_DEPT_ITEM_& DeptItem 生成的DeptItem\n
  113. * @return 无\n
  114. * @note
  115. * @warning
  116. * @bug
  117. */
  118. void __CreateDeptItem( const _CARD_POS_& CardPos, _STAT_DEPT_ITEM_& DeptItem );
  119. /**
  120. * @brief
  121. 构造id sum map对象函数。
  122. * @param [in] const std::map<int,int>& id_sum_map id sum 列表\n
  123. * @param [in] const char* szName 名称\n
  124. * @param [out] rapidjson::Document::AllocatorType& Allocator 分配器\n
  125. * @param [out] rapidjson::Value& Dept 生成的部门json对象\n
  126. * @return 无\n
  127. * @note
  128. * @warning
  129. * @bug
  130. */
  131. void __BuildIDSumMap( const std::map<int,int>& id_sum_map, const char* szName, rapidjson::Document::AllocatorType & Allocator, rapidjson::Value & Parent );
  132. /**
  133. * @brief
  134. 格式化生成卡号函数。
  135. * @param [in] const _BASE_CARD_& CardPos 卡位置\n
  136. * @return 格式化生成的卡号\n
  137. * @note
  138. * @warning
  139. * @bug
  140. */
  141. std::string __FmtCardID( const _BASE_CARD_& CardPos );
  142. public:
  143. jsonBuilder();
  144. virtual ~jsonBuilder();
  145. /**
  146. * @brief
  147. 生成登录jason函数。
  148. * @param [in] const _JS_LOGIN_& Login 登录参数\n
  149. * @return 如果成功返回生成的json字符串,否则返回空字符串\n
  150. * @note
  151. * @warning
  152. * @bug
  153. */
  154. std::string BuildLogin( const _JS_LOGIN_& Login );
  155. /**
  156. * @brief
  157. 生成卡位置jason函数。
  158. * @param [in] const std::map<int, _CARD_POS_>& CardPosList 卡位置列表\n
  159. * @return 如果成功返回生成的json字符串,否则返回空字符串\n
  160. * @note
  161. * @warning
  162. * @bug
  163. */
  164. std::string BuildCardPos( const std::map<uint64_t, _CARD_POS_>& CardPosList );
  165. std::string build_ios_card_pos(const _CARD_POS_& card);
  166. /**
  167. * @brief
  168. 生成车辆进入特殊区域jason函数。
  169. * @param [in] const _BASE_CARD_& Card 卡结构体\n
  170. * @return 如果成功返回生成的json字符串,否则返回空字符串\n
  171. * @note
  172. * @warning
  173. * @bug
  174. */
  175. std::string BuildSpecialAreaProcess( const _BASE_CARD_& stCard );
  176. /**
  177. * @brief
  178. 解析呼叫结构体函数。
  179. * @param [in] const _JS_LOGIN_& Login 登录参数\n
  180. * @return 如果成功返回生成的jason字符串,否则返回空字符串\n
  181. * @note
  182. * @warning
  183. * @bug
  184. */
  185. bool ParseCall_Card_Req( const std::string& JasonText, _JS_CALL_CARD_REQ_& CallCardReq, std::string& Error );
  186. };
  187. }
  188. #endif /* _JSONBUILDER_H_ */