|
@@ -16,12 +16,6 @@
|
|
|
#include "card.h"
|
|
|
#include "area.h"
|
|
|
#include "event.h"
|
|
|
-#include <fstream>
|
|
|
-#include <unistd.h>
|
|
|
-#include <sys/stat.h>
|
|
|
-
|
|
|
-#include <boost/algorithm/string/split.hpp>
|
|
|
-#include <boost/algorithm/string.hpp>
|
|
|
|
|
|
#include <rapidjson/writer.h>
|
|
|
#include <rapidjson/stringbuffer.h>
|
|
@@ -144,13 +138,10 @@ struct staffer_num_business
|
|
|
{
|
|
|
void record_staffer_num();
|
|
|
|
|
|
- void fetch_add(bool bDisplay,bool bAttendance = true)
|
|
|
+ void fetch_add(bool bDisplay)
|
|
|
{
|
|
|
- if(bDisplay && bAttendance) {
|
|
|
+ if(bDisplay) {
|
|
|
m_staff_num++;
|
|
|
- }
|
|
|
- if (bDisplay){
|
|
|
- m_staff_show_num++;
|
|
|
}
|
|
|
m_staff_num_real++;
|
|
|
}
|
|
@@ -160,21 +151,17 @@ struct staffer_num_business
|
|
|
m_record_staffer_timeval = 0;
|
|
|
}
|
|
|
uint32_t get_staff_num() const { return m_staff_num;}
|
|
|
- uint32_t get_staff_show_num() const { return m_staff_show_num;}
|
|
|
uint32_t get_staff_real_num() const { return m_staff_num_real;}
|
|
|
|
|
|
private:
|
|
|
void reset(){
|
|
|
m_staff_num=0;
|
|
|
m_staff_num_real=0;
|
|
|
- m_staff_show_num = 0;
|
|
|
}
|
|
|
// 井下考勤并且要显示的人数
|
|
|
std::atomic<uint32_t> m_staff_num;
|
|
|
// 井下总人数
|
|
|
std::atomic<uint32_t> m_staff_num_real;
|
|
|
- // 井下显示人数
|
|
|
- std::atomic<uint32_t> m_staff_show_num;
|
|
|
// 通知web最后时间
|
|
|
std::time_t m_record_staffer_timeval;
|
|
|
};
|
|
@@ -279,16 +266,13 @@ mine_business* mine_business::inst()
|
|
|
}
|
|
|
void mine_business::run_business()
|
|
|
{
|
|
|
- //公告牌显示井下人数
|
|
|
- show_bulletin_board();
|
|
|
-
|
|
|
record_staffer_num();
|
|
|
handle_reverse_alarm();
|
|
|
handle_rear_end();
|
|
|
}
|
|
|
-void mine_business::fetch_add(bool bDisplay,bool bAttendance/* = true*/)
|
|
|
+void mine_business::fetch_add(bool bDisplay)
|
|
|
{
|
|
|
- m_staffer_num_ptr->fetch_add(bDisplay,bAttendance);
|
|
|
+ m_staffer_num_ptr->fetch_add(bDisplay);
|
|
|
}
|
|
|
|
|
|
void mine_business::record_staffer_num()
|
|
@@ -326,61 +310,9 @@ void mine_business::clear_vehicle()
|
|
|
m_rear_ended_ptr->clear();
|
|
|
}
|
|
|
|
|
|
-void mine_business::CreateDirectoryEx(const std::string & sPathName )
|
|
|
-{
|
|
|
- std::vector<std::string> vecSegTag;
|
|
|
- boost::split(vecSegTag, sPathName, boost::is_any_of("/"));
|
|
|
- if (vecSegTag.size() == 1) //数据发生错误
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- std::string curPath = "";
|
|
|
- for (int i = 0 ; i < (int)vecSegTag.size() ; i++)
|
|
|
- {
|
|
|
- curPath += vecSegTag[i];
|
|
|
- if(vecSegTag[i].length() > 1 && vecSegTag[i][0] != '.' )
|
|
|
- {
|
|
|
- int a = access(curPath.c_str(), F_OK);
|
|
|
- if(a == -1)
|
|
|
- {
|
|
|
- mkdir(curPath.c_str(),0755);
|
|
|
- }
|
|
|
- }
|
|
|
- curPath += "/";
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//公告牌显示--当前井下人数: 100 人
|
|
|
-void mine_business::show_bulletin_board()
|
|
|
+uint32_t mine_business::get_mine_display_staff_num()
|
|
|
{
|
|
|
- std::time_t t = time(NULL);
|
|
|
- if (m_lastshow_bulletin_time == 0)
|
|
|
- {
|
|
|
- m_lastshow_bulletin_time = t;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (t > m_lastshow_bulletin_time && t - m_lastshow_bulletin_time > CYaSetting::g_bulletin_board_time )
|
|
|
- {
|
|
|
- //把当前文件写到文件中
|
|
|
- m_lastshow_bulletin_time = t;
|
|
|
- uint32_t num = m_staffer_num_ptr->get_staff_show_num();
|
|
|
- std::string path = CYaSetting::g_bulletin_board_path;
|
|
|
- static bool g_bCreatePath = false;
|
|
|
- if (!g_bCreatePath)
|
|
|
- {
|
|
|
- CreateDirectoryEx(path); //创建目录
|
|
|
- g_bCreatePath = true;
|
|
|
- }
|
|
|
- path += "/" + CYaSetting::g_bulletin_board_file_name;
|
|
|
- std::ofstream f1(path.c_str());//打开文件用于写,若文件不存在就创建它
|
|
|
- if(!f1.is_open()) {
|
|
|
- return;//打开文件失败则结束运行
|
|
|
- }
|
|
|
- std::string szText = "井下当前总人数: " + std::to_string(num) + "人";
|
|
|
- f1<< szText << std::endl;
|
|
|
- f1.close(); //关闭文件
|
|
|
- log_info("show_bulletin_board : %s" ,szText.c_str());
|
|
|
- }
|
|
|
+ return m_staffer_num_ptr->get_staff_num();
|
|
|
}
|
|
|
///////staffer_num_business
|
|
|
/**********************************
|