|
@@ -13,14 +13,16 @@
|
|
|
//路径变换
|
|
|
struct location_card
|
|
|
{
|
|
|
- location_card(uint32_t id,uint64_t type)
|
|
|
+ location_card(uint32_t id,uint64_t type,uint32_t objid)
|
|
|
:m_cardid(id)
|
|
|
- ,m_type(type)
|
|
|
+ ,m_type(type)
|
|
|
+ ,m_objid(objid)
|
|
|
{
|
|
|
init();
|
|
|
}
|
|
|
uint32_t m_cardid;//卡id
|
|
|
uint16_t m_type;//卡类型
|
|
|
+ uint32_t m_objid;
|
|
|
double m_arg;//运动方向角度值
|
|
|
int m_areaid;//区域
|
|
|
int m_mapid;//地图
|
|
@@ -175,8 +177,9 @@ struct location_card
|
|
|
{
|
|
|
std::string tabName=getTabName();
|
|
|
char nsql[512]={0};
|
|
|
- const char * sql = "replace into %s (card_id,begin_time,map_id,area_id,begin_pt,direction)values(%03d%010d,'%s',%d,%d,'%.2f,%.2f',%f);";
|
|
|
- snprintf(nsql,512,sql,tabName.c_str(),m_type,m_cardid,tool_time::to_str_ex(m_timestamp).c_str(),m_mapid,m_areaid,m_p.x,m_p.y,m_arg);
|
|
|
+ const char * sql = "replace into his_location (obj_id,card_type_id,ident,begin_time,map_id,area_id,begin_pt,direction)"
|
|
|
+ "values(%d,%d,%d,'%s',%d,%d,'%.2f,%.2f',%f);";
|
|
|
+ snprintf(nsql,512,sql,m_objid,m_type,m_cardid,tool_time::to_str(m_timestamp/1000).c_str(),m_mapid,m_areaid,m_p.x,m_p.y,m_arg);
|
|
|
log_info("his_location[%d]:%s",m_cardid,nsql);
|
|
|
sDBConnPool.PushAsync(nsql);
|
|
|
}
|
|
@@ -184,12 +187,13 @@ struct location_card
|
|
|
{
|
|
|
std::string tabName=getTabName();
|
|
|
char nsql[512]={0};
|
|
|
- const char * sql = "update %s set last_time='%s',speed=%.2f where card_id=%03d%010d and begin_time='%s';";
|
|
|
+ const char * sql = "update his_location set last_time='%s',speed=%.2f where obj_id=%d and begin_time='%s';";
|
|
|
double dist = m_p.dist(p);
|
|
|
double t = timestamp - m_timestamp;
|
|
|
double avge_speed= dist/t*1000;
|
|
|
if(std::isnan(avge_speed)|| std::isinf(avge_speed))avge_speed=0;
|
|
|
- snprintf(nsql,512,sql,tabName.c_str(),tool_time::to_str_ex(timestamp).c_str(),avge_speed,m_type,m_cardid,tool_time::to_str_ex(m_timestamp).c_str());
|
|
|
+
|
|
|
+ snprintf(nsql,512,sql,tool_time::to_str(timestamp/1000).c_str(),avge_speed,m_objid,tool_time::to_str(m_timestamp/1000).c_str());
|
|
|
log_info("his_location[%d]:%s",m_cardid,nsql);
|
|
|
sDBConnPool.PushAsync(nsql);
|
|
|
}
|
|
@@ -198,8 +202,8 @@ struct location_card
|
|
|
};
|
|
|
struct location_staff:location_card
|
|
|
{
|
|
|
- location_staff(uint32_t id,uint16_t type)
|
|
|
- :location_card(id,type)
|
|
|
+ location_staff(uint32_t id,uint64_t type,uint32_t objid)
|
|
|
+ :location_card(id,type,objid)
|
|
|
{}
|
|
|
virtual std::string getTabName(){return std::string{"his_location_staff_"};}
|
|
|
//人员如果运行方向发生变化的话,需要求的拐点。如果有拐点,入拐点。时间大与120s则不做处理。没有拐点,则不求
|
|
@@ -266,8 +270,8 @@ struct location_staff:location_card
|
|
|
};
|
|
|
struct location_vehicle:location_card
|
|
|
{
|
|
|
- location_vehicle(uint32_t id,uint16_t type)
|
|
|
- :location_card(id,type)
|
|
|
+ location_vehicle(uint32_t id,uint64_t type,uint32_t objid)
|
|
|
+ :location_card(id,type,objid)
|
|
|
{}
|
|
|
virtual std::string getTabName(){return std::string{"his_location_vehicle_"};}
|
|
|
//车辆是有推送拐点的,所以不需要求拐点。如果运行方向发生变化的话,直接更新数据库即可,使用上一个点的时间。同时生成这一次的历史。
|