001/include/checkin.hpp

82 lines
2.6 KiB
C++

#ifndef ATTENDANCE_SYSTEM_CHECKIN_HPP
#define ATTENDANCE_SYSTEM_CHECKIN_HPP
#include <string>
#include <ctime>
#include <vector>
namespace AttendanceSystem {
// 打卡方式枚举
enum class CheckInMethod {
FACE_RECOGNITION, // 人脸识别
GPS_LOCATION, // GPS定位
CARD_SWIPE // 工牌刷卡
};
// 位置信息结构
struct Location {
double latitude; // 纬度
double longitude; // 经度
Location() : latitude(0.0), longitude(0.0) {}
Location(double lat, double lng) : latitude(lat), longitude(lng) {}
bool isValid() const {
return latitude >= -90.0 && latitude <= 90.0 &&
longitude >= -180.0 && longitude <= 180.0;
}
};
class CheckInRecord {
public:
CheckInRecord();
CheckInRecord(const std::string& recordId, const std::string& employeeId,
CheckInMethod method, time_t timestamp, const Location& location);
// Getter方法
std::string getRecordId() const { return recordId_; }
std::string getEmployeeId() const { return employeeId_; }
CheckInMethod getMethod() const { return method_; }
time_t getTimestamp() const { return timestamp_; }
Location getLocation() const { return location_; }
std::vector<unsigned char> getFaceFeature() const { return faceFeature_; }
// Setter方法
void setRecordId(const std::string& id) { recordId_ = id; }
void setEmployeeId(const std::string& empId) { employeeId_ = empId; }
void setMethod(CheckInMethod method) { method_ = method; }
void setTimestamp(time_t ts) { timestamp_ = ts; }
void setLocation(const Location& loc) { location_ = loc; }
void setFaceFeature(const std::vector<unsigned char>& feature) { faceFeature_ = feature; }
// 验证记录是否有效
bool isValid() const;
// 获取打卡方式字符串
std::string getMethodString() const;
// 获取格式化时间字符串
std::string getFormattedTime() const;
// 显示打卡记录
void display() const;
// 判断是否迟到(相对于指定时间)
bool isLate(int expectedHour, int expectedMinute) const;
// 判断是否早退(相对于指定时间)
bool isEarlyLeave(int expectedHour, int expectedMinute) const;
private:
std::string recordId_; // 记录ID
std::string employeeId_; // 员工ID
CheckInMethod method_; // 打卡方式
time_t timestamp_; // 时间戳
Location location_; // 位置信息
std::vector<unsigned char> faceFeature_; // 人脸特征数据(二进制)
};
} // namespace AttendanceSystem
#endif // ATTENDANCE_SYSTEM_CHECKIN_HPP