|
@@ -130,15 +130,21 @@ struct card_sensor_mgr
|
|
|
struct staffer_num_business
|
|
|
{
|
|
|
void record_staffer_num();
|
|
|
- void fetch_add(){m_staff_num++;}
|
|
|
+ void fetch_add(bool f)
|
|
|
+ {
|
|
|
+ if(f)
|
|
|
+ m_staff_num++;
|
|
|
+ m_staff_num_real++;
|
|
|
+
|
|
|
+ }
|
|
|
staffer_num_business()
|
|
|
{
|
|
|
- m_staff_num = 0;
|
|
|
+ reset();
|
|
|
m_record_staffer_timeval = 0;
|
|
|
}
|
|
|
private:
|
|
|
- void reset(){m_staff_num=0;}
|
|
|
- std::atomic<uint32_t> m_staff_num;
|
|
|
+ void reset(){m_staff_num=0;m_staff_num_real=0;}
|
|
|
+ std::atomic<uint32_t> m_staff_num,m_staff_num_real;
|
|
|
std::time_t m_record_staffer_timeval;
|
|
|
};
|
|
|
|
|
@@ -243,9 +249,9 @@ void mine_business::run_business()
|
|
|
handle_reverse_alarm();
|
|
|
handle_rear_end();
|
|
|
}
|
|
|
-void mine_business::fetch_add()
|
|
|
+void mine_business::fetch_add(bool f)
|
|
|
{
|
|
|
- m_staffer_num_ptr->fetch_add();
|
|
|
+ m_staffer_num_ptr->fetch_add(f);
|
|
|
}
|
|
|
void mine_business::record_staffer_num()
|
|
|
{
|
|
@@ -287,31 +293,38 @@ void mine_business::clear_vehicle()
|
|
|
*********************************/
|
|
|
void staffer_num_business::record_staffer_num()
|
|
|
{
|
|
|
- static uint32_t min_num=0,max_num=0;
|
|
|
+ static uint32_t min_num=0,max_num=0,min_num_real=0,max_num_real=0;
|
|
|
std::time_t t = time(NULL);
|
|
|
char ti[64] = { 0 };
|
|
|
strftime(ti,sizeof(ti),"%Y/%m/%d %H:%M:%S",localtime(&t));
|
|
|
std::string sti(ti);
|
|
|
int minute = atoi(sti.substr(sti.find_first_of(':')+1,2).c_str());
|
|
|
+ uint32_t a=m_staff_num.load();
|
|
|
+ uint32_t ar=m_staff_num_real.load();
|
|
|
if(m_record_staffer_timeval==0)
|
|
|
{
|
|
|
- min_num=max_num=m_staff_num;
|
|
|
+ min_num=max_num=a;
|
|
|
+ min_num_real=max_num_real=ar;
|
|
|
m_record_staffer_timeval = t;
|
|
|
}
|
|
|
if(t-m_record_staffer_timeval>=120 && minute%2 == 0)
|
|
|
{
|
|
|
std::stringstream ss;
|
|
|
- ss<< "INSERT INTO his_staff_number(max_num,min_num,ave_num) VALUES("<<max_num<<','<<min_num<<','<<std::lround((max_num+min_num)/2)<<");";
|
|
|
- logn_info(2,"staff_number:%s",ss.str().c_str());
|
|
|
+ ss<< "INSERT INTO his_staff_number(max_num,min_num,ave_num,max_num_real,min_num_real,ave_num_real) VALUES("
|
|
|
+ <<max_num<<','<<min_num<<','<<std::lround((max_num+min_num)/2)<<','
|
|
|
+ <<max_num_real<<','<<min_num_real<<','<<std::lround((max_num_real+min_num_real)/2)<<");";
|
|
|
db_tool::PushAsync(ss.str().c_str());
|
|
|
|
|
|
- min_num=max_num=m_staff_num;
|
|
|
+ min_num=max_num=a;
|
|
|
+ min_num_real=max_num_real=ar;
|
|
|
m_record_staffer_timeval = t;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (min_num>m_staff_num) min_num = m_staff_num;
|
|
|
- if (max_num < m_staff_num) max_num = m_staff_num;
|
|
|
+ if (min_num>a)min_num = a;
|
|
|
+ if (max_num<a)max_num = a;
|
|
|
+ if (min_num_real>ar)min_num_real = ar;
|
|
|
+ if (max_num_real<ar)max_num_real = ar;
|
|
|
}
|
|
|
reset();
|
|
|
return;
|