module_meta_date_changed.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #include "module_meta_date_changed.h"
  2. #include"module_attendance_person.h"
  3. #include"module_attendance_vehicle.h"
  4. #include"ant.h"
  5. void module_meta_date_changed::deal_call_edit_vehicle(int64_t id64, EDIT_TYPE_ID edit_type_id)
  6. {
  7. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  8. {
  9. card_list::instance()->init_vehicle(id64);
  10. }
  11. else if(ET_DELETE == edit_type_id)
  12. {
  13. auto str = tool_other::to13str(id64);
  14. remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
  15. }
  16. }
  17. void module_meta_date_changed::deal_call_edit_staff(int64_t id64, EDIT_TYPE_ID edit_type_id)
  18. {
  19. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  20. {
  21. card_list::instance()->init_staffer(id64);
  22. }
  23. else if(ET_DELETE == edit_type_id)
  24. {
  25. auto str = tool_other::to13str(id64);
  26. remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
  27. }
  28. }
  29. void module_meta_date_changed::deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id)
  30. {
  31. std::string card_id64_str = tool_other::to13str(static_cast<uint64_t>(id64));
  32. int type = tool_other::id64_to_type(card_id64_str);
  33. if(tool_other::is_person(type))
  34. {
  35. deal_call_edit_staff(id64, edit_type_id);
  36. }
  37. else if(tool_other::is_vehicle(type))
  38. {
  39. deal_call_edit_vehicle(id64, edit_type_id);
  40. }
  41. else
  42. {
  43. log_error("基础数据 删除卡type不对:type=%d", type);
  44. }
  45. }
  46. void module_meta_date_changed::deal_call_edit_area(int id, EDIT_TYPE_ID edit_type_id)
  47. {
  48. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  49. {
  50. if(is_monkeycar_area(id))
  51. {
  52. area_list::instance()->init_monkeycar_area(id);
  53. }
  54. else
  55. {
  56. area_list::instance()->init_from_db(id);
  57. }
  58. }
  59. else if(ET_DELETE == edit_type_id)
  60. {
  61. auto area_ptr = area_list::instance()->get(id);
  62. if(!area_ptr)
  63. {
  64. log_info("区域已经删除:areaid=%d", id);
  65. return;
  66. }
  67. //删除告警
  68. delete_area_event(area_ptr);
  69. area_list::instance()->remove(id);
  70. }
  71. }
  72. void module_meta_date_changed::deal_call_edit_reader(int id, EDIT_TYPE_ID edit_type_id)
  73. {
  74. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  75. {
  76. sit_list::instance()->init_site(id);
  77. }
  78. else if(ET_DELETE == edit_type_id)
  79. {
  80. //删除告警
  81. sit_list::instance()->remove(id);
  82. }
  83. }
  84. void module_meta_date_changed::deal_call_edit_antenna(int id,EDIT_TYPE_ID edit_type_id)
  85. {
  86. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  87. {
  88. sit_list::instance()->read_sit_list(id);
  89. }
  90. else if(ET_DELETE == edit_type_id)
  91. {
  92. delete_antenna(id);
  93. }
  94. }
  95. void module_meta_date_changed::deal_call_edit_path(int id, EDIT_TYPE_ID edit_type_id)
  96. {
  97. if(ET_INSERT == edit_type_id)
  98. {
  99. log_error("path不支持增加操作");
  100. std_debug("path不支持增加操作");
  101. }
  102. else if(ET_UPDATE == edit_type_id)
  103. {
  104. sit_list::instance()->read_ant_path(id);
  105. }
  106. else if(ET_DELETE == edit_type_id)
  107. {
  108. auto sit_ptr = sit_list::instance()->get(id);
  109. if(sit_ptr)
  110. {
  111. sit_ptr->clear_path();
  112. }
  113. log_info("path删除成功,分站id=%d", id);
  114. std_debug("path删除成功,分站id=%d", id);
  115. }
  116. }
  117. void module_meta_date_changed::deal_call_edit_map(int id, EDIT_TYPE_ID edit_type_id)
  118. {
  119. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  120. {
  121. if(!is_cur_map(id))
  122. {
  123. log_info("修改的不是当前使用的地图,要修改地图id=%d,当前使用地图id=%d", id, cur_map_id());
  124. return;
  125. }
  126. update_map_info(id);
  127. }
  128. else if(ET_DELETE == edit_type_id)
  129. {
  130. if(is_cur_map(id))
  131. {
  132. log_error("删除了当前使用的地图");
  133. return;
  134. }
  135. }
  136. }
  137. void module_meta_date_changed::deal_call_edit_light(int id, EDIT_TYPE_ID edit_type_id)
  138. {
  139. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  140. {
  141. }
  142. else if(ET_DELETE == edit_type_id)
  143. {
  144. }
  145. }
  146. void module_meta_date_changed::deal_call_edit_lights_group(int id, EDIT_TYPE_ID edit_type_id)
  147. {
  148. if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
  149. {
  150. }
  151. else if(ET_DELETE == edit_type_id)
  152. {
  153. }
  154. }
  155. void module_meta_date_changed::init_setting()
  156. {
  157. //pRes = getMysqlRes("select setting_id, name, type, value from dat_setting;");
  158. }
  159. void module_meta_date_changed::remove_card(uint32_t id, int32_t type)
  160. {
  161. uint64_t card_id = card_list::to_id64(type, id);
  162. auto card_ptr = card_list::instance()->get(card_id);
  163. if(!card_ptr)
  164. {
  165. log_error("基础数据, 在全局列表中删除卡,全局列表中已经不存在此卡, id=%d, type=%d", id, type);
  166. return;
  167. }
  168. auto area_hover_ptr = card_ptr->get_area_hover();
  169. if(area_hover_ptr && 0!=area_hover_ptr->id() && 0!=area_hover_ptr->mapid())
  170. {
  171. module_area::on_leave(card_ptr->m_id, area_hover_ptr, card_ptr->m_type);
  172. }
  173. if(card_ptr->is_person())
  174. {
  175. module_attendance_person::up_mine(card_ptr, nullptr);
  176. }
  177. else
  178. {
  179. module_attendance_vehicle::save_attendance(card_ptr, nullptr);
  180. module_meta_date_changed::clear_card(card_ptr);
  181. }
  182. // 避免状态重置
  183. card_list::instance()->remove(card_id);
  184. log_info("基础数据, 在全局列表中删除卡成功, id=%d, type=%d", id, type);
  185. }