Browse Source

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

chensongchao 6 years ago
parent
commit
502b6529a6
4 changed files with 20 additions and 47 deletions
  1. 4 4
      area.cpp
  2. 16 35
      forbid_staff_down_mine.cpp
  3. 0 2
      forbid_staff_down_mine.h
  4. 0 6
      main.cpp

+ 4 - 4
area.cpp

@@ -108,7 +108,7 @@ void area::change_business(uint32_t new_bits)
 
 	uint32_t del=((m_area_type^new_bits)|m_area_type)^m_area_type;
 	uint32_t add=((m_area_type^new_bits)|new_bits)^new_bits;
-
+    log_info("change_area_business:%d,b_type:%d,area_type:%d [del:%d, add:%d]",m_id,new_bits,m_area_type,del,add);
 	if(del==0 && add==0)
 		return;
 
@@ -291,7 +291,7 @@ void area_list::init_monkeycar_area(int id)
             da->m_default_speed = monkeycar_speed;
             da->m_point = init_path(monkeycar_coor,area_id);
             std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
-            ap->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
+            ap->update(over_count_person, over_time_person,scale,map_id,b_type, over_count_vehicle,over_time_vehicle);
 
             ap->m_bound=init_path(path,area_id);
             for(const auto &p : ap->m_bound)
@@ -314,7 +314,7 @@ void area_list::init_monkeycar_area(int id)
 				area_list::instance()->add(area_id,ap);
 
             ap->m_bound=init_path(path,area_id);
-            ap->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
+            ap->update(over_count_person, over_time_person,scale,map_id,b_type, over_count_vehicle,over_time_vehicle);
             for(const auto &p : ap->m_bound)
               log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
             for(const auto &p : da->m_point)
@@ -450,7 +450,7 @@ void area_list::init_from_db(int id/*=-1*/)
 				newobj=true;
             }
 
-            tmp_ptr->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
+            tmp_ptr->update(over_count_person, over_time_person,scale,map_id,b_type, over_count_vehicle,over_time_vehicle);
             tmp_ptr->m_speed=std::move(map_);
             tmp_ptr->m_bound=init_path(path,area_id);
             tmp_ptr->m_is_work_area = is_work_area;

+ 16 - 35
forbid_staff_down_mine.cpp

@@ -1,7 +1,3 @@
-//
-// Created by Administrator on 2019/3/5.
-//
-
 #include "forbid_staff_down_mine.h"
 #include "log.h"
 #include "tool_time.h"
@@ -12,14 +8,10 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
     std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine ";
     sql += " where status = 1 and end_time > now() ";
     if (id != -1)
-    {
         sql += " and id = " + std::to_string(id) + ";";
-    }
     else
-    {
         sql += ";";
-        m_map.clear();
-    }
+
     std::string Error;
     YADB::CDBResultSet DBRes;
     sDBConnPool.Query(sql.c_str(),DBRes,Error);
@@ -29,13 +21,6 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         log_error("增加或修改失败,数据库中找不到: sql", sql.c_str());
         return ;
     }
-    forbid_staff_down_mine::instance()->update_forbid_data(DBRes,true);
-}
-
-//更新数据
-void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes,bool bInsert)
-{
-    std::string Error;
     while ( DBRes.GetNextRecod(Error) )
     {
         int key = 0;
@@ -53,22 +38,24 @@ void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes,bool
         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 != nullptr)
+        //如果存在则查找更新。查找不到则插入
+        if (s)
         {
-            if(!bInsert)
+            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;
-                        log_info("Check Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "
+                    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());
-                        continue;
-                    }
+                    break;
                 }
+                if (f) continue;
             }
         }
         else
@@ -85,16 +72,11 @@ void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes,bool
         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());
+                    ,key,staff_id,state,start_time.c_str(),end_time.c_str());
         s->forbidList.push_back(info);
     }
 }
 
-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);
@@ -103,8 +85,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;

+ 0 - 2
forbid_staff_down_mine.h

@@ -45,8 +45,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 - 6
main.cpp

@@ -71,12 +71,6 @@ struct Init_Setting
         //三率模块
         init_three_rates(DBSetting);
 
-		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();