|
@@ -10,7 +10,11 @@
|
|
|
#include"ant.h"
|
|
|
#include"card.h"
|
|
|
#include"area.h"
|
|
|
-
|
|
|
+#include "forbid_staff_down_mine.h"
|
|
|
+#include <boost/format.hpp>
|
|
|
+#include <boost/tokenizer.hpp>
|
|
|
+#include <boost/algorithm/string/split.hpp>
|
|
|
+#include <boost/algorithm/string.hpp>
|
|
|
|
|
|
///基础数据
|
|
|
void module_meta_date_changed::accept(sio::message::ptr const& data)
|
|
@@ -25,11 +29,13 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
|
|
|
|
|
|
int64_t id=-1;
|
|
|
tool_map::try_get_value(id, JSON_KEY_ID, data);
|
|
|
+ std::string szParam = "0";
|
|
|
+ tool_map::try_get_value(szParam,JSON_KEY_ID,data);
|
|
|
|
|
|
std::string op_type="";
|
|
|
tool_map::try_get_value(op_type, JSON_KEY_OP_TYPE, data);
|
|
|
|
|
|
- if(-1 != id && !op_type.empty())
|
|
|
+ if((-1 != id || szParam != "0") && !op_type.empty())
|
|
|
{
|
|
|
EDIT_TYPE_ID edit_type_id;
|
|
|
if(!try_get_edit_type_id(op_type, edit_type_id))
|
|
@@ -37,20 +43,20 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
|
|
|
log_error("web发来的数据: 基础数据op_type字段错误:op_type=%s", op_type.c_str());
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- log_info("基础数据 receive meta_data_changed: %s, id=%d, op_type=%d", name.c_str(), id, edit_type_id);
|
|
|
+ log_info("基础数据 receive meta_data_changed: %s, id=%d-%s, op_type=%d"
|
|
|
+ , name.c_str(), id,szParam.c_str() , edit_type_id);
|
|
|
|
|
|
if(JSON_KEY_NAME_VEHICLE == name || JSON_KEY_NAME_VEHICLE_EXTEND == name)
|
|
|
{
|
|
|
- deal_call_edit_vehicle(id, edit_type_id);
|
|
|
+ deal_call_edit_vehicle_or_staff(szParam, edit_type_id);
|
|
|
}
|
|
|
else if(JSON_KEY_NAME_STAFF == name || JSON_KEY_NAME_STAFF_EXTEND == name)
|
|
|
{
|
|
|
- deal_call_edit_staff(id, edit_type_id);
|
|
|
+ deal_call_edit_vehicle_or_staff(szParam, edit_type_id);
|
|
|
}
|
|
|
else if(JSON_KEY_NAME_CARD == name)
|
|
|
{
|
|
|
- deal_call_edit_card(id, edit_type_id);
|
|
|
+ deal_call_edit_card(szParam, edit_type_id);
|
|
|
}
|
|
|
else if(JSON_KEY_NAME_AREA == name)
|
|
|
{
|
|
@@ -80,6 +86,10 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
|
|
|
{
|
|
|
deal_call_edit_lights_group(id,edit_type_id);///待实现
|
|
|
}
|
|
|
+ else if (JSON_KEY_NAME_FORBID_PERSON_DOWN_MINE == name)
|
|
|
+ {
|
|
|
+ deal_call_edit_forbid_person_down_mine(id,edit_type_id);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
log_error("web发来的数据: 基础数据name字段错误:name=%s", name.c_str());
|
|
@@ -132,48 +142,61 @@ void module_meta_date_changed::clear_card(std::shared_ptr<card_location_base> ca
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-void module_meta_date_changed::deal_call_edit_vehicle(int64_t id64, EDIT_TYPE_ID edit_type_id)
|
|
|
+/*
|
|
|
+ * 修改车及卡的数据
|
|
|
+ * id64 = ;员工ID或者车ID;卡ID=101;0010000001198 分号间隔
|
|
|
+ */
|
|
|
+void module_meta_date_changed::deal_call_edit_vehicle_or_staff(const std::string & id64, EDIT_TYPE_ID edit_type_id)
|
|
|
{
|
|
|
- if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
|
|
|
- {
|
|
|
- card_list::instance()->init_vehicle(id64);
|
|
|
- }
|
|
|
- else if(ET_DELETE == edit_type_id)
|
|
|
+ std::vector<std::string> vecSegTag;
|
|
|
+ boost::split(vecSegTag, id64, boost::is_any_of(";"));
|
|
|
+ if (vecSegTag.size() == 1) //数据发生错误
|
|
|
{
|
|
|
- auto str = tool_other::to13str(id64);
|
|
|
-
|
|
|
- remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
|
|
|
+ log_errno("Web Send Data Error!(%s)", id64.c_str());
|
|
|
+ return;
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-void module_meta_date_changed::deal_call_edit_staff(int64_t id64, EDIT_TYPE_ID edit_type_id)
|
|
|
-{
|
|
|
+ std::string lsz_card_id = vecSegTag[1];
|
|
|
+ int cid = std::stoi(vecSegTag[0].c_str());
|
|
|
if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
|
|
|
{
|
|
|
- card_list::instance()->init_staffer(id64);
|
|
|
+ if (ET_UPDATE == edit_type_id)
|
|
|
+ {
|
|
|
+ auto c = card_list::instance()->get_card_by_cid(cid);
|
|
|
+ if (nullptr != c && tool_other::type_id_to_str(c->m_type,c->m_id) != lsz_card_id)
|
|
|
+ {
|
|
|
+ //如果修改了卡号,则删除原来的卡的数据
|
|
|
+ remove_card(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int c_type = tool_other::id64_to_type(lsz_card_id);
|
|
|
+ if (tool_other::is_vehicle(c_type))
|
|
|
+ {
|
|
|
+ card_list::instance()->init_vehicle(lsz_card_id);
|
|
|
+ }
|
|
|
+ else if (tool_other::is_person(c_type))
|
|
|
+ {
|
|
|
+ card_list::instance()->init_staffer(lsz_card_id);
|
|
|
+ }
|
|
|
}
|
|
|
- else if(ET_DELETE == edit_type_id)
|
|
|
+ else
|
|
|
{
|
|
|
- auto str = tool_other::to13str(id64);
|
|
|
-
|
|
|
- remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
|
|
|
+ remove_card(tool_other::id64_to_id(lsz_card_id), tool_other::id64_to_type(lsz_card_id));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void module_meta_date_changed::deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id)
|
|
|
+void module_meta_date_changed::deal_call_edit_card(std::string & id64, EDIT_TYPE_ID edit_type_id)
|
|
|
{
|
|
|
- std::string card_id64_str = tool_other::to13str(static_cast<uint64_t>(id64));
|
|
|
+ std::string card_id64_str = tool_other::to13str(id64);
|
|
|
int type = tool_other::id64_to_type(card_id64_str);
|
|
|
-
|
|
|
- if(tool_other::is_person(type))
|
|
|
- {
|
|
|
- deal_call_edit_staff(id64, edit_type_id);
|
|
|
- }
|
|
|
- else if(tool_other::is_vehicle(type))
|
|
|
+ if(tool_other::is_person(type) || tool_other::is_vehicle(type))
|
|
|
{
|
|
|
- deal_call_edit_vehicle(id64, edit_type_id);
|
|
|
+ auto c = card_list::instance()->get(tool_other::card_id_to_u64(card_id64_str));
|
|
|
+ if (nullptr == c) {
|
|
|
+ log_info("web edit card:%s Not bind staff or vehicle. editType:%d", card_id64_str.c_str(), edit_type_id);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ std::string lsz = std::to_string(c->m_cid) + ";" + card_id64_str;
|
|
|
+ deal_call_edit_vehicle_or_staff(lsz,edit_type_id);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -300,21 +323,40 @@ void module_meta_date_changed::deal_call_edit_lights_group(int id, EDIT_TYPE_ID
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 禁止指定人员下井 id = (rt_person_forbid_down_mine)数据库中自增长ID
|
|
|
+void module_meta_date_changed::deal_call_edit_forbid_person_down_mine(int id,EDIT_TYPE_ID edit_type_id)
|
|
|
+{
|
|
|
+ if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
|
|
|
+ {
|
|
|
+ forbid_staff_down_mine::instance()->init_forbid_staff(id);
|
|
|
+ }
|
|
|
+ else if(ET_DELETE == edit_type_id)
|
|
|
+ {
|
|
|
+ forbid_staff_down_mine::instance()->del_forbid_data(id);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void module_meta_date_changed::init_setting()
|
|
|
{
|
|
|
//pRes = getMysqlRes("select setting_id, name, type, value from dat_setting;");
|
|
|
}
|
|
|
|
|
|
-void module_meta_date_changed::remove_card(uint32_t id, int32_t type)
|
|
|
-{
|
|
|
+void module_meta_date_changed::remove_card(uint32_t id, int32_t type) {
|
|
|
uint64_t card_id = tool_other::type_id_to_u64(type, id);
|
|
|
auto card_ptr = card_list::instance()->get(card_id);
|
|
|
- if(!card_ptr)
|
|
|
- {
|
|
|
+ if (!card_ptr) {
|
|
|
log_error("基础数据, 在全局列表中删除卡,全局列表中已经不存在此卡, id=%d, type=%d", id, type);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ remove_card(card_ptr);
|
|
|
+}
|
|
|
+void module_meta_date_changed::remove_card(std::shared_ptr<card_location_base> card_ptr)
|
|
|
+{
|
|
|
+ if (!card_ptr)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ log_info("基础数据, 在全局列表中删除卡成功, id=%d, type=%d",card_ptr->m_type, card_ptr->m_id);
|
|
|
// auto area_hover_ptr = card_ptr->get_area_hover();
|
|
|
// if(area_hover_ptr && 0!=area_hover_ptr->id() && 0!=area_hover_ptr->mapid())
|
|
|
// {
|
|
@@ -331,11 +373,10 @@ void module_meta_date_changed::remove_card(uint32_t id, int32_t type)
|
|
|
|
|
|
// module_meta_date_changed::clear_card(card_ptr);
|
|
|
// }
|
|
|
-
|
|
|
module_meta_date_changed::clear_card(card_ptr);
|
|
|
// 避免状态重置
|
|
|
+ uint64_t card_id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
|
|
|
card_list::instance()->remove(card_id);
|
|
|
- log_info("基础数据, 在全局列表中删除卡成功, id=%d, type=%d", id, type);
|
|
|
}
|
|
|
|
|
|
bool module_meta_date_changed::try_get_edit_type_id(const std::string& op_type, EDIT_TYPE_ID& out_edit_type_id)
|