Browse Source

Merge branch 'master' of http://local.beijingyongan.com:3000/linux-dev/ya-serv

...
zzj 6 years ago
parent
commit
64aff59878

+ 1 - 0
area.cpp

@@ -108,6 +108,7 @@ void area::change_business(uint32_t new_bits)
 
 	uint32_t del=((m_biz_type^new_bits)|m_biz_type)^m_biz_type;
 	uint32_t add=((m_biz_type^new_bits)|new_bits)^new_bits;
+    log_info("change_area_business:area_id:%d,b_type:%d,area_type:%d [del:%d, add:%d]",m_id,new_bits,m_biz_type,del,add);
 
 	if(del==0 && add==0)
 		return;

+ 2 - 5
card_base.cpp

@@ -89,13 +89,10 @@ void card_location_base::upt_card_pos(YA::_CARD_POS_&cp, point &pt)
     point _p;
     if(pt.empty())
     {
-        _p=*this;
-        pt=_p;
+         _p=*this;pt=_p;
     }
     else
-	{
-       	 _p=pt;
-	}
+         _p=pt;
 	cp.x = tool_other::round(_p.x,3);
 	cp.y = tool_other::round(_p.y,3);
 	//cp.z = pt.z;

+ 33 - 40
forbid_staff_down_mine.cpp

@@ -1,24 +1,15 @@
-//
-// Created by Administrator on 2019/3/5.
-//
-
 #include "forbid_staff_down_mine.h"
 #include "log.h"
 #include "tool_time.h"
-#include "db_api/CDBResultSet.h"
 #include "db_api/CDBSingletonDefine.h"
 
 void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
 {
-    std::string sql = "select id,staff_id,start_time,end_time,status from rt_person_forbid_down_mine where status = 1";
+    std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine where status = 1 and end_time > now() ";
     if (id != -1)
-    {
         sql += " and id = " + std::to_string(id) + ";";
-    }
     else
-    {
-        m_map.clear();
-    }
+        sql += ";";
     std::string Error;
     YADB::CDBResultSet DBRes;
     sDBConnPool.Query(sql.c_str(),DBRes,Error);
@@ -28,59 +19,62 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         log_error("增加或修改失败,数据库中找不到: sql", sql.c_str());
         return ;
     }
-
     while ( DBRes.GetNextRecod(Error) )
     {
         int key = 0;
         DBRes.GetField("id", key, Error);
-        unsigned int s_id = 0;
-        DBRes.GetField("staff_id", s_id, Error);
+        unsigned int staff_id = 0;
+        DBRes.GetField("staff_id", staff_id, Error);
         std::string start_time;
         DBRes.GetField("start_time", start_time, Error);
         std::string end_time;
         DBRes.GetField("end_time", end_time, Error);
         int state;
         DBRes.GetField("status", state, Error);
-
-        std::shared_ptr<SForbidStaffList> s = nullptr;
-        if (id != -1)
+        std::string create_time;
+        DBRes.GetField("oper_time", create_time, Error);
+        std::string update_time;
+        DBRes.GetField("lastupdate", update_time, Error);
+        std::shared_ptr<SForbidStaffList> s = forbid_staff_down_mine::instance()->get(staff_id);
+        //如果存在则查找更新。查找不到则插入
+        if (s)
         {
-            s = forbid_staff_down_mine::instance()->get(s_id);
-            if (s != nullptr)
+            bool f=false;
+            for (SForbidStaffInfo &info : s->forbidList)
             {
-                for (SForbidStaffInfo &info : s->forbidList)
+                //找到记录则更新,停止.找不到,则继续往下走
+                if (info.db_id == key)
                 {
-                    if (info.db_id == key) //已有记录,修改完成
-                    {
-                        info.start_time = tool_time::to_time(start_time);
-                        info.end_time = tool_time::to_time(end_time);
-                        info.state = state;
-                        return;
-                    }
+                    f=true;
+                    info.start_time = tool_time::to_time(start_time);
+                    info.end_time = tool_time::to_time(end_time);
+                    info.state = state;
+                    log_info("Check Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "
+                                ,key,staff_id,state,start_time.c_str(),end_time.c_str());
+                    break;
                 }
             }
+            if(f)continue;
         }
-        if (s == nullptr)
+        else
         {
             s = std::make_shared<SForbidStaffList>();
+            forbid_staff_down_mine::instance()->add(staff_id,s);
         }
-        s->staff_id = s_id;
+        s->staff_id = staff_id;
         SForbidStaffInfo info ;
-        info.staff_id = s_id;
+        info.staff_id = staff_id;
         info.db_id = key;
         info.start_time = tool_time::to_time(start_time);
         info.end_time = tool_time::to_time(end_time);
         info.state = state;
+
+        log_info("Init Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "
+                    ,key,staff_id,state,start_time.c_str(),end_time.c_str());
         s->forbidList.push_back(info);
-        forbid_staff_down_mine::instance()->add(s_id,s);
     }
 }
 
-void forbid_staff_down_mine::del_forbid_staff(int staff_id)
-{
-    forbid_staff_down_mine::instance()->remove(staff_id);
-}
-
 void forbid_staff_down_mine::del_forbid_data(int id,int staff_id)
 {
     auto s = forbid_staff_down_mine::instance()->get(staff_id);
@@ -89,8 +83,7 @@ void forbid_staff_down_mine::del_forbid_data(int id,int staff_id)
         log_info(" remove Forbid Staff:%d Down mine.DBID=%d",s->staff_id,id);
         for(auto it = s->forbidList.begin(); it != s->forbidList.end() ; ++it)
         {
-            SForbidStaffInfo & info = *it;
-            if (info.db_id == id)
+            if ((*it).db_id == id)
             {
                 s->forbidList.erase(it);
                 break;
@@ -106,7 +99,7 @@ void forbid_staff_down_mine::del_forbid_data(int id,int staff_id)
 //是否禁止状态
 bool forbid_staff_down_mine::IsForbid(int staff_id,time_t cur_time)
 {
-    auto flist = m_map;
+    auto flist = forbid_staff_down_mine::instance()->m_map;
     auto it = flist.find(staff_id);
     if (it != flist.end())
     {
@@ -119,4 +112,4 @@ bool forbid_staff_down_mine::IsForbid(int staff_id,time_t cur_time)
         }
     }
     return false;
-}
+}

+ 0 - 2
forbid_staff_down_mine.h

@@ -42,8 +42,6 @@ public:
     void init_forbid_staff(int id = -1);
     // 根据数据库中的自增长id
     void del_forbid_data(int id,int staff_id);
-    // 根据员工ID
-    void del_forbid_staff(int staff_id);
 
     //是否禁止状态
     bool IsForbid(int staff_id,time_t cur_time);

+ 0 - 7
main.cpp

@@ -69,13 +69,6 @@ struct Init_Setting
             std_info("连接webServer[%s] 失败,采集服务器无法启动!",url.c_str());
             exit(0);
         }
-
-		if(0)
-		{
-			std::vector<char> b(1024*1024);
-			usleep(1000*1000);
-		}
-
 		CYaSetting::Init_sys_setting();
         sit_list::instance()->load_from_db();
         card_list::instance()->init_card_from_db();

+ 2 - 2
module_service/area_business_person_dwell_checker.cpp

@@ -36,9 +36,9 @@ void area_business_person_dwell_checker::on_hover(const std::shared_ptr<area_hov
     if(!c->is_person()||a->m_enter_time==0||a->m_area->m_limit_person_min==0)
       return;
 
-	double limit_val = a->m_area->m_limit_person_min*60;
+	int limit_val = a->m_area->m_limit_person_min*60;
+	int cur_val = ( tool_time::now_to_seconds() - a->m_enter_time / 1000);
 
-	double cur_val = ( tool_time::now_to_seconds() - a->m_enter_time / 1000);
 	EVENT_TYPE evType = a->m_area->is_mine() ? EVENT_TYPE::ET_CARD_OVER_TIME_PERSON : EVENT_TYPE::ET_CARD_AREA_OVER_TIME_PERSON;
 	if (limit_val < cur_val)
     {