namespace OASystem.Domain.ViewModels.QiYeWeChat; /// /// 打卡记录数据 /// public class CheckInDataView : ResponseBase { public List checkindata { get; set; } } public class CheckInDataInfo { /// /// 用户id /// public string userid { get; set; } /// /// 打卡规则名称 /// public string groupname { get; set; } /// /// 打卡类型。字符串,目前有:上班打卡,下班打卡,外出打卡 /// public string checkin_type { get; set; } /// /// 异常类型,字符串,包括:时间异常,地点异常,未打卡,wifi异常,非常用设备。如果有多个异常,以分号间隔 /// public string exception_type { get; set; } /// /// 打卡时间。Unix时间戳 /// public long checkin_time { get; set; } /// /// 打卡时间。Unix时间戳 /// public DateTime checkin_time_dt { get { return new DateTime(checkin_time * 10000000 + 621355968000000000L).ToLocalTime(); } } /// /// 打卡地点title /// public string location_title { get; set; } /// /// 打卡地点详情 /// public string location_detail { get; set; } /// /// 打卡wifi名称 /// public string wifiname { get; set; } /// /// 打卡备注 /// public string notes { get; set; } /// /// 打卡的MAC地址/bssid /// public string wifimac { get; set; } /// /// 打卡的附件media_id,可使用media/get获取附件 /// public List mediaids { get; set; } /// /// 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准 /// public long lat { get; set; } /// /// 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准 /// public long lng { get; set; } /// /// 打卡设备id /// public string deviceid { get; set; } /// /// 标准打卡时间,指此次打卡时间对应的标准上班时间或标准下班时间 /// public long sch_checkin_time { get; set; } /// /// 打卡时间。Unix时间戳 /// public DateTime sch_checkin_time_dt { get { return new DateTime(sch_checkin_time * 10000000 + 621355968000000000L).ToLocalTime(); } } /// /// 规则id,表示打卡记录所属规则的id /// public int groupid { get; set; } /// /// 班次id,表示打卡记录所属规则中,所属班次的id /// public int schedule_id { get; set; } /// /// 时段id,表示打卡记录所属规则中,某一班次中的某一时段的id,如上下班时间为9:00-12:00、13:00-18:00的班次中,9:00-12:00为其中一组时段 /// public int timeline_id { get; set; } // ==================== 扩展属性(用于业务判断) ==================== /// /// 是否为未打卡异常 /// public bool IsMissPunch => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("未打卡"); /// /// 是否为上班打卡 /// public bool IsMorningCheckIn => checkin_type == "上班打卡"; /// /// 是否为下班打卡 /// public bool IsEveningCheckIn => checkin_type == "下班打卡"; /// /// 是否为外出打卡 /// public bool IsOutCheckIn => checkin_type == "外出打卡"; /// /// 是否为正常打卡(无异常) /// public bool IsNormalCheckIn => string.IsNullOrEmpty(exception_type) || exception_type == "正常"; /// /// 是否为时间异常 /// public bool IsTimeException => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("时间异常"); /// /// 是否为地点异常 /// public bool IsLocationException => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("地点异常"); /// /// 是否为WiFi异常 /// public bool IsWifiException => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("wifi异常"); /// /// 是否为非常用设备 /// public bool IsUnusualDevice => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("非常用设备"); /// /// 获取异常类型描述 /// public string GetExceptionDescription() { if (string.IsNullOrEmpty(exception_type)) return "正常"; return exception_type; } /// /// 获取打卡类型描述 /// public string GetCheckInTypeDescription() { return checkin_type switch { "上班打卡" => "上班打卡", "下班打卡" => "下班打卡", "外出打卡" => "外出打卡", _ => checkin_type }; } /// /// 获取打卡时间(HH:mm格式) /// public string GetCheckInTimeString() { return checkin_time_dt.ToString("HH:mm:ss"); } /// /// 获取标准打卡时间(HH:mm格式) /// public string GetStandardCheckInTimeString() { return sch_checkin_time_dt.ToString("HH:mm:ss"); } /// /// 判断是否为上午打卡(9:00 - 12:00) /// public bool IsMorningTimeSlot() { var timeOfDay = checkin_time_dt.TimeOfDay; var morningStart = TimeSpan.FromHours(8); var morningEnd = TimeSpan.FromHours(12); return timeOfDay >= morningStart && timeOfDay <= morningEnd; } /// /// 判断是否为下午打卡(13:30 - 18:00) /// public bool IsAfternoonTimeSlot() { var timeOfDay = checkin_time_dt.TimeOfDay; var afternoonStart = TimeSpan.FromHours(13).Add(TimeSpan.FromMinutes(30)); var afternoonEnd = TimeSpan.FromHours(18).Add(TimeSpan.FromMinutes(30)); return timeOfDay >= afternoonStart && timeOfDay <= afternoonEnd; } }