76 lines
2.8 KiB
C++
76 lines
2.8 KiB
C++
#ifndef ATTENDANCE_SYSTEM_SCHEDULE_HPP
|
|
#define ATTENDANCE_SYSTEM_SCHEDULE_HPP
|
|
|
|
#include <string>
|
|
#include <ctime>
|
|
|
|
namespace AttendanceSystem {
|
|
|
|
// 班次类型枚举
|
|
enum class ShiftType {
|
|
DAY_SHIFT, // 白班
|
|
NIGHT_SHIFT, // 夜班
|
|
ROTATING_SHIFT // 轮班
|
|
};
|
|
|
|
class ScheduleRule {
|
|
public:
|
|
ScheduleRule();
|
|
ScheduleRule(const std::string& id, const std::string& shiftName,
|
|
int startHour, int startMinute, int endHour, int endMinute,
|
|
int breakDuration, int overtimeThreshold, ShiftType type = ShiftType::DAY_SHIFT);
|
|
|
|
// Getter方法
|
|
std::string getRuleId() const { return ruleId_; }
|
|
std::string getShiftName() const { return shiftName_; }
|
|
int getStartHour() const { return startHour_; }
|
|
int getStartMinute() const { return startMinute_; }
|
|
int getEndHour() const { return endHour_; }
|
|
int getEndMinute() const { return endMinute_; }
|
|
int getBreakDuration() const { return breakDuration_; } // 分钟
|
|
int getOvertimeThreshold() const { return overtimeThreshold_; } // 分钟
|
|
ShiftType getShiftType() const { return shiftType_; }
|
|
int getVersion() const { return version_; }
|
|
time_t getCreateTime() const { return createTime_; }
|
|
|
|
// Setter方法
|
|
void setRuleId(const std::string& id) { ruleId_ = id; }
|
|
void setShiftName(const std::string& name) { shiftName_ = name; }
|
|
void setStartTime(int hour, int minute) { startHour_ = hour; startMinute_ = minute; }
|
|
void setEndTime(int hour, int minute) { endHour_ = hour; endMinute_ = minute; }
|
|
void setBreakDuration(int minutes) { breakDuration_ = minutes; }
|
|
void setOvertimeThreshold(int minutes) { overtimeThreshold_ = minutes; }
|
|
void setShiftType(ShiftType type) { shiftType_ = type; }
|
|
|
|
// 版本控制:创建新版本
|
|
ScheduleRule createNewVersion() const;
|
|
|
|
// 验证规则是否有效
|
|
bool isValid() const;
|
|
|
|
// 计算工作时间(分钟)
|
|
int calculateWorkDuration() const;
|
|
|
|
// 判断是否在加班时间内
|
|
bool isOvertime(int actualEndHour, int actualEndMinute) const;
|
|
|
|
// 显示排班信息
|
|
void display() const;
|
|
|
|
private:
|
|
std::string ruleId_; // 规则ID
|
|
std::string shiftName_; // 班次名称
|
|
int startHour_; // 上班时间-小时
|
|
int startMinute_; // 上班时间-分钟
|
|
int endHour_; // 下班时间-小时
|
|
int endMinute_; // 下班时间-分钟
|
|
int breakDuration_; // 休息时长(分钟)
|
|
int overtimeThreshold_; // 加班阈值(分钟)
|
|
ShiftType shiftType_; // 班次类型
|
|
int version_; // 版本号
|
|
time_t createTime_; // 创建时间
|
|
};
|
|
|
|
} // namespace AttendanceSystem
|
|
|
|
#endif // ATTENDANCE_SYSTEM_SCHEDULE_HPP
|