1
0
lixioayao 5 роки тому
батько
коміт
4cc7ffd8b1
7 змінених файлів з 27 додано та 54 видалено
  1. 10 27
      bulletin_broad_show.cpp
  2. 3 9
      card.cpp
  3. 4 0
      card_base.cpp
  4. 4 5
      card_base.h
  5. 0 2
      card_person.cpp
  6. 1 0
      his_location.h
  7. 5 11
      mine_business.cpp

+ 10 - 27
bulletin_broad_show.cpp

@@ -2,16 +2,16 @@
 // Created by songchao.chen on 2019/6/26.
 //
 
-#include "bulletin_broad_show.h"
-#include "mine_business.h"
 #include <config_file.h>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string.hpp>
 #include <fstream>
 #include <unistd.h>
+#include <ctime>
+#include "bulletin_broad_show.h"
+#include "mine_business.h"
 #include <sys/stat.h>
 #include "log.h"
-#include <tool_time.h>
 
 bulletin_broad_show::bulletin_broad_show()
 {
@@ -62,13 +62,8 @@ void bulletin_broad_show::CreateDirectoryEx(const std::string & sPathName )
 
 void bulletin_broad_show::run_bulletin_board()
 {
-    uint32_t t = tool_time::now_to_seconds();
-    if (m_lastshow_bulletin_time == 0)
-    {
-        m_lastshow_bulletin_time = t;
-        return;
-    }
-    if (t > m_lastshow_bulletin_time && t - m_lastshow_bulletin_time > m_bulletin_board_time )
+    time_t t = std::time(nullptr);
+    if (t - m_lastshow_bulletin_time > m_bulletin_board_time )
     {
         //把当前文件写到文件中
         m_lastshow_bulletin_time = t;
@@ -94,25 +89,13 @@ void bulletin_broad_show::run_bulletin_board()
 
 void bulletin_broad_show::set_bulletin_board_path(std::string & path)
 {
-    if (path.length() == 0)
-    {
-        return;
-    }
-    int count = 0;
-    for(int i = path.length() - 1 ; i > 0 ;i--)
+    if (path.empty()) return;
+    for(unsigned i = path.length() - 1 ; i > 0 ;i--)
     {
         if ( path[i] == '/')
-        {
-            count++;
-        }
+            path.pop_back();
         else
-        {
-            break;
-        }
+          break;
     }
     m_bulletin_board_path = path;
-    if (count > 0)
-    {
-        m_bulletin_board_path = path.substr(0,path.length() - count);
-    }
-}
+}

+ 3 - 9
card.cpp

@@ -60,13 +60,9 @@ void card_list::init_staffer(const std::string & lszId64)
             person* tmp_ptr= static_cast<person*>(card_ptr.get());
             person* db_person_ptr= static_cast<person*>(db_person.get());
 
-            tmp_ptr->m_cid = db_person_ptr->m_cid;
-            tmp_ptr->m_type = db_person_ptr->m_type;
-            tmp_ptr->m_deptid = db_person_ptr->m_deptid;
+            card_ptr->set_base_data(db_person_ptr->m_cid,db_person_ptr->m_type,db_person_ptr->m_deptid,db_person_ptr->m_level_id);
             //group_id
             //occ_id
-            tmp_ptr->m_level_id = db_person_ptr->m_level_id;
-    //        tmp_ptr->m_display = db_person_ptr->m_display;
             tmp_ptr->m_workLine = db_person_ptr->m_workLine;
             tmp_ptr->m_stafferName = db_person_ptr->m_stafferName;
             tmp_ptr->m_deptName = db_person_ptr->m_deptName;
@@ -105,17 +101,15 @@ void card_list::init_vehicle(const std::string & lszId64)
 	}
 	else
 	{
-		car* db_car= static_cast<car*>(map.begin()->second.get());
         uint64_t id64 = map.begin()->first;
 		auto card_ptr = card_list::instance()->get(id64);
+		car* db_car= static_cast<car*>(map.begin()->second.get());
 		if(card_ptr)
 		{
 			car* tmp_ptr= static_cast<car*>(card_ptr.get());
-			//tmp_ptr->m_display = static_cast<uint16_t>(db_car->m_display);
-			tmp_ptr->m_deptid = db_car->m_deptid;
+            card_ptr->set_base_data(db_car->m_cid,db_car->m_type,db_car->m_deptid,db_car->m_level_id);
 			tmp_ptr->m_vehicle_category_id = db_car->m_vehicle_category_id;
 			tmp_ptr->m_vehicle_type_id = db_car->m_vehicle_type_id;
-			tmp_ptr->m_level_id = db_car->m_level_id;
             if(db_car->m_display!=tmp_ptr->m_display){
                 request(id64,tmp_ptr->m_id,db_car->m_display);
             }

+ 4 - 0
card_base.cpp

@@ -278,6 +278,10 @@ bool card_location_base::is_vehicle() const
     return tool_other::is_vehicle(m_type);
 }
 
+void card_location_base::set_base_data(uint32_t cid,uint16_t type,uint32_t deptid,int32_t level_id) {
+    m_cid=cid;m_type=type;m_deptid=deptid;m_level_id=level_id;
+    m_his_location_card->set_cid(cid);
+}
 card_location_base::~card_location_base()
 {
 }

+ 4 - 5
card_base.h

@@ -79,15 +79,13 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
 	time_t m_help_last_time=0;
 	int    m_help_bit=0;
 
-	void inc_upmine_flag(int flag)
-	{
-		m_upmine_flag=flag;
-	}
-    int upmine_flag(){return m_upmine_flag.load();}
 
     card_location_base()=default;
     card_location_base(const std::string&type,uint32_t id,uint16_t dis,int16_t t,int32_t,int32_t,uint32_t );
 
+	void inc_upmine_flag(int flag){m_upmine_flag=flag;}
+    int upmine_flag(){return m_upmine_flag.load();}
+
 	virtual void do_business(const std::shared_ptr<site>&site,const point &pt,double acc)=0;
 	virtual void on_timer()=0;
     virtual std::shared_ptr<mine_tool> get_mine_tool()=0;
@@ -115,6 +113,7 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
 
     bool is_person() const;
     bool is_vehicle() const;
+    void set_base_data(uint32_t cid,uint16_t type,uint32_t deptid,int32_t level_id);
 	virtual ~card_location_base();
 
     static std::shared_ptr<card_location_base> make_person(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,

+ 0 - 2
card_person.cpp

@@ -241,9 +241,7 @@ point person::getSmoothPoint(uint64_t& t)
 void person::get_card(bool f)
 {
 	if (!m_mine_tool->m_is_attendance)
-	{
 		return ;
-	}
 	mine_business::inst()->fetch_add(m_display);
 }
 

+ 1 - 0
his_location.h

@@ -23,6 +23,7 @@ struct location_card
     bool 		m_isInsert ;	//是否
     static uint32_t  m_difftime;//进入盲区得时长限制 时长 
     static int  m_distance;//进入盲区后,第一个点与之前得距离  像素距离
+    void set_cid(uint32_t cid){m_objid=cid;}
 	struct mini_data
 	{
 		mini_data(const point &p,uint64_t t)

+ 5 - 11
mine_business.cpp

@@ -140,9 +140,8 @@ struct staffer_num_business
 
 	void fetch_add(bool bDisplay)
     {
-        if(bDisplay) {
+        if(bDisplay) 
             m_staff_num++;
-        }
 		m_staff_num_real++;
     }
 	staffer_num_business()
@@ -150,18 +149,13 @@ struct staffer_num_business
         reset();
 		m_record_staffer_timeval = 0;
 	}
-    uint32_t get_staff_num() const { return m_staff_num;}
-    uint32_t get_staff_real_num() const { return m_staff_num_real;}
-
+    uint32_t get_staff_num() const { return m_staff_num.load();}
 private:
-	void reset(){
-	    m_staff_num=0;
-	    m_staff_num_real=0;
-	}
+	void reset(){m_staff_num=0;m_staff_num_real=0;}
 	// 井下考勤并且要显示的人数
-	std::atomic<uint32_t> m_staff_num;
+	std::atomic<uint32_t> m_staff_num{0};
 	// 井下总人数
-    std::atomic<uint32_t> m_staff_num_real;
+    std::atomic<uint32_t> m_staff_num_real{0};
     // 通知web最后时间
 	std::time_t m_record_staffer_timeval;
 };