|
@@ -10,7 +10,10 @@
|
|
|
#include"ant.h"
|
|
|
#include"card.h"
|
|
|
#include"area.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)
|
|
@@ -26,6 +29,8 @@ 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);
|
|
@@ -41,15 +46,15 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
|
|
|
|
|
|
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)
|
|
|
{
|
|
@@ -131,86 +136,63 @@ 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)
|
|
|
+/*
|
|
|
+ * 修改车及卡的数据
|
|
|
+ * 在 ET_INSERT | ET_DELETE id64 = 卡ID =10000001198
|
|
|
+ * ET_UPDATE id64 = 卡ID;员工ID或者车ID=10000001198;101 分号间隔
|
|
|
+ */
|
|
|
+void module_meta_date_changed::deal_call_edit_vehicle_or_staff(const std::string & id64, EDIT_TYPE_ID edit_type_id)
|
|
|
{
|
|
|
- //车信息修改 id64=车ID vehicle_id
|
|
|
+ // 在 ET_INSERT | ET_DELETE id64 = 卡ID =10000001198
|
|
|
+ //ET_UPDATE id64 = 卡ID;员工ID或者车ID=10000001198;101 分号间隔
|
|
|
if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
|
|
|
{
|
|
|
- char sql[1024] = {'\0'};
|
|
|
- sprintf(sql,"select card_id from dat_vehicle_extend where vehicle_id=%d;", (int)id64);
|
|
|
- std::string Error;
|
|
|
- YADB::CDBResultSet DBRes;
|
|
|
- sDBConnPool.Query(sql,DBRes,Error);
|
|
|
- int64_t nCount = DBRes.GetRecordCount( Error );
|
|
|
- if (nCount > 0)
|
|
|
+ int64_t card_id = std::stoll(id64);
|
|
|
+ if (ET_UPDATE == edit_type_id)
|
|
|
{
|
|
|
- int64_t card_id = 0;
|
|
|
- while ( DBRes.GetNextRecod(Error) )
|
|
|
+ std::vector<std::string> vecSegTag;
|
|
|
+ boost::split(vecSegTag, id64,boost::is_any_of(";"));
|
|
|
+ if (vecSegTag.size() == 1) //数据发生错误
|
|
|
{
|
|
|
- std::string szCard_id;
|
|
|
- DBRes.GetField( "card_id",szCard_id, Error );
|
|
|
- card_id = atoll(szCard_id.c_str());
|
|
|
+ log_errno("Web Send Data Error!(%s)",id64.c_str());
|
|
|
+ return;
|
|
|
}
|
|
|
- card_list::instance()->init_vehicle(card_id);
|
|
|
+ auto c = card_list::instance()->get_card_by_cid(std::stoi(vecSegTag[1].c_str()));
|
|
|
+ if (nullptr != c && tool_other::type_id_to_str(c->m_type,c->m_id) != tool_other::to13str(vecSegTag[0]))
|
|
|
+ {
|
|
|
+ //如果修改了卡号,则删除原来的卡的数据
|
|
|
+ remove_card(c);
|
|
|
+ }
|
|
|
+ card_id = std::stoll(vecSegTag[0]);
|
|
|
}
|
|
|
+ card_list::instance()->init_vehicle(card_id);
|
|
|
}
|
|
|
- else if(ET_DELETE == edit_type_id)
|
|
|
+ else
|
|
|
{
|
|
|
- auto c = card_list::instance()->get_card_by_cid(id64);
|
|
|
- remove_card(c);
|
|
|
-
|
|
|
- //auto str = tool_other::to13str(id64);
|
|
|
- //remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
|
|
|
+ std::string card_id = id64;
|
|
|
+ auto str = tool_other::to13str(card_id);
|
|
|
+ remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void module_meta_date_changed::deal_call_edit_staff(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)
|
|
|
{
|
|
|
- //人员信息更改 id64=人员ID staff_id
|
|
|
- if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
|
|
|
+ std::string lsz = id64;
|
|
|
+ std::string card_id64_str = tool_other::to13str(lsz);
|
|
|
+ int type = tool_other::id64_to_type(card_id64_str);
|
|
|
+ if(tool_other::is_person(type) || tool_other::is_vehicle(type))
|
|
|
{
|
|
|
- char sql[1024] = {'\0'};
|
|
|
- sprintf(sql,"select card_id from dat_staff_extend where staff_id=%d;", (int)id64);
|
|
|
- std::string Error;
|
|
|
- YADB::CDBResultSet DBRes;
|
|
|
- sDBConnPool.Query(sql,DBRes,Error);
|
|
|
- int64_t nCount = DBRes.GetRecordCount( Error );
|
|
|
- if (nCount > 0)
|
|
|
+ if (edit_type_id == ET_UPDATE)
|
|
|
{
|
|
|
- int64_t card_id = 0;
|
|
|
- while ( DBRes.GetNextRecod(Error) )
|
|
|
+ auto c = card_list::instance()->get(tool_other::card_id_to_u64(card_id64_str));
|
|
|
+ if (nullptr != c)
|
|
|
{
|
|
|
- std::string szCard_id;
|
|
|
- DBRes.GetField( "card_id",szCard_id, Error );
|
|
|
- card_id = atoll(szCard_id.c_str());
|
|
|
+ char id[100] = {0};
|
|
|
+ sprintf(id,"%s;%d",lsz.c_str(),c->m_cid);
|
|
|
+ lsz = id;
|
|
|
}
|
|
|
- card_list::instance()->init_staffer(card_id);
|
|
|
}
|
|
|
- }
|
|
|
- else if(ET_DELETE == edit_type_id)
|
|
|
- {
|
|
|
- auto c = card_list::instance()->get_card_by_cid(id64);
|
|
|
- remove_card(c);
|
|
|
- //auto str = tool_other::to13str(id64);
|
|
|
-
|
|
|
- //remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void module_meta_date_changed::deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id)
|
|
|
-{
|
|
|
- std::string card_id64_str = tool_other::to13str(static_cast<uint64_t>(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))
|
|
|
- {
|
|
|
- deal_call_edit_vehicle(id64, edit_type_id);
|
|
|
+ deal_call_edit_vehicle_or_staff(lsz,edit_type_id);
|
|
|
}
|
|
|
else
|
|
|
{
|