Jelajahi Sumber

load his card for staff

lihz 7 tahun lalu
induk
melakukan
6b103bba74
4 mengubah file dengan 84 tambahan dan 6 penghapusan
  1. 3 1
      SyncTime/SyncManager.cpp
  2. 77 3
      YAServerDlg.cpp
  3. 2 1
      YAServerDlg.h
  4. 2 1
      log_def.h

+ 3 - 1
SyncTime/SyncManager.cpp

@@ -172,10 +172,12 @@ bool HostServer::SyncManager::updateSync(unsigned long long rootIdCode, int idx,
 			if(aa < 0){
 				aa += TIME_MAX;
 			}
+			int bb = (receiveTime > TIME_MAX) ? 1 : 0;
+			int cc = (sendTime > TIME_MAX) ? 1 : 0;
 
 			sprintf_s(filename, "%s\\%d.log", logDir.c_str(), localIdCode>>8);
 			ofstream outfile(filename, ofstream::app);  
-			sprintf_s(temp, "sn:%d, %I64d, %I64d\r", SyncNum, timeDelay, aa); 
+			sprintf_s(temp, "sn:%d, up:%d, %I64d, %I64d, %I64d, %I64d, r_cross:%d, s_cross:%d\r", SyncNum, msg.UpperIdCode() >> 8, receiveTime, sendTime, timeDelay, aa, bb, cc); 
 			outfile << temp;
 		}
 

+ 77 - 3
YAServerDlg.cpp

@@ -9748,7 +9748,8 @@ void CYAServerDlg::init_base_data()
 void CYAServerDlg::load_his_data()
 {
 	//load_his_reader(); // 分站状态
-	load_his_card_postion(); // 标识卡所在位置
+	load_his_card_postion_vehicle(); // 标识卡所在位置
+	load_his_card_postion_staff();
 	//load_his_card_state();
 	deal_hist_card_postion();
 	load_his_driving_face_card_postion();//掘进面卡所在位置
@@ -9789,7 +9790,7 @@ void CYAServerDlg::load_his_area()
 	show_log(strlog);
 }
 
-void CYAServerDlg::load_his_card_postion()
+void CYAServerDlg::load_his_card_postion_vehicle()
 {
 	CMysqlConn* pConn = NULL;
 	CDBConnGuard pDbGuard(pConn);
@@ -9858,7 +9859,80 @@ void CYAServerDlg::load_his_card_postion()
 	}
 	mysql_free_result(pRes);
 	CString strlog;
-	strlog.Format(_T("%s%d%s"), _T(LOG_LOAD_HIS_POSTION), nRow, _T(LOG_RECORD_COUNT));
+	strlog.Format(_T("%s%d%s"), _T(LOG_LOAD_HIS_POSTION_VEHICLE), nRow, _T(LOG_RECORD_COUNT));
+	show_log(strlog);
+}
+
+void CYAServerDlg::load_his_card_postion_staff()
+{
+	CMysqlConn* pConn = NULL;
+	CDBConnGuard pDbGuard(pConn);
+
+	if(pConn == NULL){
+		return;
+	}
+
+	MYSQL_RES* pRes;
+	MYSQL_ROW pRow;
+	int err = 0;
+	char buf[LENGTH_SQL] = {0};
+	sprintf_s(buf, "select l.card_id, l.cur_time, l.x, l.y, l.z, l.map_id, l.area_id, l.state, \
+				   case when l.cur_time >= date_sub(now(), interval 2 minute) then l.speed else 0 end as speed, \
+				   l.mileage, la.enter_time, att.start_time, \
+				   case when isnull(att.end_time) then 2 else 1 end as down_state \
+				   from rt_location l, rt_location_area la, rt_att_staff att, dat_card c \
+				   where l.card_id = c.card_id and l.card_id = la.card_id and l.card_id = att.card_id \
+				   and c.state=0;");
+
+	pRes = pConn->Execute(buf, err);
+
+	if (err)
+	{
+		return;
+	}
+
+	int nRow = 0;
+	std::string rec_time, enter_time, start_time;
+	while(pRow = mysql_fetch_row(pRes)){
+		CardMap::iterator it = mp_card_list_all.find(pRow[0]);
+		if(it != mp_card_list_all.end()){
+			rec_time = pRow[1];
+			API_StringToTime(rec_time, it->second->rec_time);
+
+			it->second->x = atof(pRow[2]);
+			it->second->y = atof(pRow[3]);
+			it->second->z = atof(pRow[4]);
+
+			it->second->map_id = atoi(pRow[5]);	
+			it->second->area_id = atoi(pRow[6]);					
+			it->second->state = atoi(pRow[7]);
+			it->second->set_speed(atof(pRow[8]));
+			it->second->mileage = atof(pRow[9]);
+
+			enter_time = pRow[10];
+			CFunctions::string2systemtime(enter_time,it->second->enter_area_time);
+			start_time = pRow[11];
+			API_StringToTime(start_time, it->second->down_time);
+
+			it->second->pos_state = atoi(pRow[12]);
+			it->second->pos_state_old = it->second->pos_state;
+
+			it->second->last_x = it->second->x;
+			it->second->last_y = it->second->y;
+			it->second->last_z = it->second->z;
+
+			::GetLocalTime(&it->second->deal_time);
+
+			it->second->is_hist = true;
+			it->second->isdealed = true;
+			it->second->isoutput = true;
+			it->second->issent = false;
+			nRow++;
+		}
+	}
+	mysql_free_result(pRes);
+	CString strlog;
+	strlog.Format(_T("%s%d%s"), _T(LOG_LOAD_HIS_POSTION_STAFF), nRow, _T(LOG_RECORD_COUNT));
 	show_log(strlog);
 }
 

+ 2 - 1
YAServerDlg.h

@@ -292,7 +292,8 @@ public:
 	void load_his_data();
 	void load_his_area(); // 所在区域
 	void load_his_reader(); // 分站状态
-	void load_his_card_postion(); // 所在位置
+	void load_his_card_postion_vehicle(); // 所在位置
+	void load_his_card_postion_staff();
 	void load_his_driving_face_card_postion(); // 所在位置
 	void load_his_driving_face_card_state(); // 载入掘进面卡状态
 	void load_his_card_state(); // 加载卡状态

+ 2 - 1
log_def.h

@@ -28,7 +28,8 @@
 #define LOG_INIT_LIGHTS_GROUP		"初始化红绿灯组信息"
 #define LOG_INIT_PATROL "初始化巡检路线信息"
 #define LOG_LOAD_HIS_AREA "载入区域历史数据"
-#define LOG_LOAD_HIS_POSTION "载入位置历史数据"
+#define LOG_LOAD_HIS_POSTION_VEHICLE "载入车辆位置历史数据"
+#define LOG_LOAD_HIS_POSTION_STAFF "载入人员位置历史数据"
 #define LOG_LOAD_HIS_STATE "载入状态历史数据"
 #define LOG_LOAD_HIS_READER "载入分站历史数据"
 #define LOG_RECORD_COUNT "条记录"