CheckInDataView.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. namespace OASystem.Domain.ViewModels.QiYeWeChat;
  2. /// <summary>
  3. /// 打卡记录数据
  4. /// </summary>
  5. public class CheckInDataView : ResponseBase
  6. {
  7. public List<CheckInDataInfo> checkindata { get; set; }
  8. }
  9. public class CheckInDataInfo
  10. {
  11. /// <summary>
  12. /// 用户id
  13. /// </summary>
  14. public string userid { get; set; }
  15. /// <summary>
  16. /// 打卡规则名称
  17. /// </summary>
  18. public string groupname { get; set; }
  19. /// <summary>
  20. /// 打卡类型。字符串,目前有:上班打卡,下班打卡,外出打卡
  21. /// </summary>
  22. public string checkin_type { get; set; }
  23. /// <summary>
  24. /// 异常类型,字符串,包括:时间异常,地点异常,未打卡,wifi异常,非常用设备。如果有多个异常,以分号间隔
  25. /// </summary>
  26. public string exception_type { get; set; }
  27. /// <summary>
  28. /// 打卡时间。Unix时间戳
  29. /// </summary>
  30. public long checkin_time { get; set; }
  31. /// <summary>
  32. /// 打卡时间。Unix时间戳
  33. /// </summary>
  34. public DateTime checkin_time_dt
  35. {
  36. get
  37. {
  38. return new DateTime(checkin_time * 10000000 + 621355968000000000L).ToLocalTime();
  39. }
  40. }
  41. /// <summary>
  42. /// 打卡地点title
  43. /// </summary>
  44. public string location_title { get; set; }
  45. /// <summary>
  46. /// 打卡地点详情
  47. /// </summary>
  48. public string location_detail { get; set; }
  49. /// <summary>
  50. /// 打卡wifi名称
  51. /// </summary>
  52. public string wifiname { get; set; }
  53. /// <summary>
  54. /// 打卡备注
  55. /// </summary>
  56. public string notes { get; set; }
  57. /// <summary>
  58. /// 打卡的MAC地址/bssid
  59. /// </summary>
  60. public string wifimac { get; set; }
  61. /// <summary>
  62. /// 打卡的附件media_id,可使用media/get获取附件
  63. /// </summary>
  64. public List<string> mediaids { get; set; }
  65. /// <summary>
  66. /// 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
  67. /// </summary>
  68. public long lat { get; set; }
  69. /// <summary>
  70. /// 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
  71. /// </summary>
  72. public long lng { get; set; }
  73. /// <summary>
  74. /// 打卡设备id
  75. /// </summary>
  76. public string deviceid { get; set; }
  77. /// <summary>
  78. /// 标准打卡时间,指此次打卡时间对应的标准上班时间或标准下班时间
  79. /// </summary>
  80. public long sch_checkin_time { get; set; }
  81. /// <summary>
  82. /// 打卡时间。Unix时间戳
  83. /// </summary>
  84. public DateTime sch_checkin_time_dt
  85. {
  86. get
  87. {
  88. return new DateTime(sch_checkin_time * 10000000 + 621355968000000000L).ToLocalTime();
  89. }
  90. }
  91. /// <summary>
  92. /// 规则id,表示打卡记录所属规则的id
  93. /// </summary>
  94. public int groupid { get; set; }
  95. /// <summary>
  96. /// 班次id,表示打卡记录所属规则中,所属班次的id
  97. /// </summary>
  98. public int schedule_id { get; set; }
  99. /// <summary>
  100. /// 时段id,表示打卡记录所属规则中,某一班次中的某一时段的id,如上下班时间为9:00-12:00、13:00-18:00的班次中,9:00-12:00为其中一组时段
  101. /// </summary>
  102. public int timeline_id { get; set; }
  103. // ==================== 扩展属性(用于业务判断) ====================
  104. /// <summary>
  105. /// 是否为未打卡异常
  106. /// </summary>
  107. public bool IsMissPunch => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("未打卡");
  108. /// <summary>
  109. /// 是否为上班打卡
  110. /// </summary>
  111. public bool IsMorningCheckIn => checkin_type == "上班打卡";
  112. /// <summary>
  113. /// 是否为下班打卡
  114. /// </summary>
  115. public bool IsEveningCheckIn => checkin_type == "下班打卡";
  116. /// <summary>
  117. /// 是否为外出打卡
  118. /// </summary>
  119. public bool IsOutCheckIn => checkin_type == "外出打卡";
  120. /// <summary>
  121. /// 是否为正常打卡(无异常)
  122. /// </summary>
  123. public bool IsNormalCheckIn => string.IsNullOrEmpty(exception_type) || exception_type == "正常";
  124. /// <summary>
  125. /// 是否为时间异常
  126. /// </summary>
  127. public bool IsTimeException => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("时间异常");
  128. /// <summary>
  129. /// 是否为地点异常
  130. /// </summary>
  131. public bool IsLocationException => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("地点异常");
  132. /// <summary>
  133. /// 是否为WiFi异常
  134. /// </summary>
  135. public bool IsWifiException => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("wifi异常");
  136. /// <summary>
  137. /// 是否为非常用设备
  138. /// </summary>
  139. public bool IsUnusualDevice => !string.IsNullOrEmpty(exception_type) && exception_type.Contains("非常用设备");
  140. /// <summary>
  141. /// 获取异常类型描述
  142. /// </summary>
  143. public string GetExceptionDescription()
  144. {
  145. if (string.IsNullOrEmpty(exception_type))
  146. return "正常";
  147. return exception_type;
  148. }
  149. /// <summary>
  150. /// 获取打卡类型描述
  151. /// </summary>
  152. public string GetCheckInTypeDescription()
  153. {
  154. return checkin_type switch
  155. {
  156. "上班打卡" => "上班打卡",
  157. "下班打卡" => "下班打卡",
  158. "外出打卡" => "外出打卡",
  159. _ => checkin_type
  160. };
  161. }
  162. /// <summary>
  163. /// 获取打卡时间(HH:mm格式)
  164. /// </summary>
  165. public string GetCheckInTimeString()
  166. {
  167. return checkin_time_dt.ToString("HH:mm:ss");
  168. }
  169. /// <summary>
  170. /// 获取标准打卡时间(HH:mm格式)
  171. /// </summary>
  172. public string GetStandardCheckInTimeString()
  173. {
  174. return sch_checkin_time_dt.ToString("HH:mm:ss");
  175. }
  176. /// <summary>
  177. /// 判断是否为上午打卡(9:00 - 12:00)
  178. /// </summary>
  179. public bool IsMorningTimeSlot()
  180. {
  181. var timeOfDay = checkin_time_dt.TimeOfDay;
  182. var morningStart = TimeSpan.FromHours(8);
  183. var morningEnd = TimeSpan.FromHours(12);
  184. return timeOfDay >= morningStart && timeOfDay <= morningEnd;
  185. }
  186. /// <summary>
  187. /// 判断是否为下午打卡(13:30 - 18:00)
  188. /// </summary>
  189. public bool IsAfternoonTimeSlot()
  190. {
  191. var timeOfDay = checkin_time_dt.TimeOfDay;
  192. var afternoonStart = TimeSpan.FromHours(13).Add(TimeSpan.FromMinutes(30));
  193. var afternoonEnd = TimeSpan.FromHours(18).Add(TimeSpan.FromMinutes(30));
  194. return timeOfDay >= afternoonStart && timeOfDay <= afternoonEnd;
  195. }
  196. }