Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

201 řádky
6.6 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Learun.Application.TwoDevelopment.LogisticsManagement;
  4. using Learun.Application.TwoDevelopment.PersonnelManagement;
  5. using Learun.Util;
  6. using Nancy;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. namespace Learun.Application.WebApi.Modules
  11. {
  12. /// <summary>
  13. /// 考勤打卡功能
  14. /// </summary>
  15. public class AttendanceApi : BaseApi
  16. {
  17. public AttendanceApi()
  18. : base("/learun/adms/attendance")
  19. {
  20. //判断当前时间是否可以打卡
  21. Get["/IsAttendance"] = IsAttendance;
  22. //上下班打卡
  23. Post["/clockin"] = ClockIn;
  24. //获取考勤打卡记录
  25. Get["/getrecordpagelist"] = GetRecordPageList;
  26. //判断学生当前打卡状态
  27. Get["IsAttendanceStudent"] = IsAttendanceStudent;
  28. //学生打卡
  29. Post["/clockinStudent"] = ClockInStudent;
  30. //打卡记录
  31. Get["/GetTeacherRecord"] = GetTeacherRecord;
  32. //教师上下课打卡:判断当前打卡状态
  33. Get["IsAttendanceTeacher"] = IsAttendanceTeacher;
  34. //教师上下课打卡
  35. Post["/clockinTeacher"] = ClockInTeacher;
  36. //判断教师是否授课
  37. Get["JudgeTeacherIsHasLesson"] = JudgeTeacherIsHasLesson;
  38. }
  39. private ADR_RestrictionIBLL adr_RestrictionBLL = new ADR_RestrictionBLL();
  40. private ADR_RecordIBLL adr_RecordBLL = new ADR_RecordBLL();
  41. private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
  42. public Response GetTeacherRecord(dynamic _)
  43. {
  44. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  45. var res=adr_RecordBLL.GetList(parameter.queryJson);
  46. var jsondata =
  47. new
  48. {
  49. data = res
  50. };
  51. return Success(jsondata);
  52. }
  53. /// <summary>
  54. /// 判断当前时间是否可以打卡
  55. /// </summary>
  56. /// <param name="_"></param>
  57. /// <returns></returns>
  58. public Response IsAttendance(dynamic _)
  59. {
  60. var res = adr_RestrictionBLL.IsAttendance();
  61. var jsondata =
  62. new
  63. {
  64. data = res
  65. };
  66. return Success(jsondata);
  67. }
  68. /// <summary>
  69. /// 学生打卡判断
  70. /// </summary>
  71. /// <param name="_"></param>
  72. /// <returns></returns>
  73. public Response IsAttendanceStudent(dynamic _)
  74. {
  75. var res = adr_RestrictionBLL.IsAttendanceStudent();
  76. var jsondata =
  77. new
  78. {
  79. data = res
  80. };
  81. return Success(jsondata);
  82. }
  83. public class Attendance
  84. {
  85. public decimal ALon { get; set; }
  86. public decimal ALat { get; set; }
  87. public bool AIsOut { get; set; }
  88. public string ARemark { get; set; }
  89. public string ADPhoto { get; set; }
  90. public string ClockPlace { get; set; }
  91. public string LessonSortNo { get; set; }
  92. public string ALTId { get; set; }
  93. public string ALTOEId { get; set; }
  94. }
  95. /// <summary>
  96. /// 上下班打卡
  97. /// </summary>
  98. /// <param name="_"></param>
  99. /// <returns></returns>
  100. public Response ClockIn(dynamic _)
  101. {
  102. Attendance parameter = this.GetReqData<Attendance>();
  103. adr_RestrictionBLL.ClockIn(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark,parameter.ADPhoto,parameter.ClockPlace);
  104. return Success("打卡成功");
  105. }
  106. /// <summary>
  107. /// 学生打卡
  108. /// </summary>
  109. /// <param name="_"></param>
  110. /// <returns></returns>
  111. public Response ClockInStudent(dynamic _)
  112. {
  113. Attendance parameter = this.GetReqData<Attendance>();
  114. adr_RestrictionBLL.ClockInStudent(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace,parameter.LessonSortNo,parameter.ALTId,parameter.ALTOEId);
  115. return Success("打卡成功");
  116. }
  117. /// <summary>
  118. /// 打卡
  119. /// </summary>
  120. /// <param name="_"></param>
  121. /// <returns></returns>
  122. public Response GetRecordPageList(dynamic _)
  123. {
  124. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  125. var data = adr_RecordBLL.GetPageList(parameter.pagination, parameter.queryJson);
  126. var jsonData = new
  127. {
  128. rows = data,
  129. total = parameter.pagination.total,
  130. page = parameter.pagination.page,
  131. records = parameter.pagination.records
  132. };
  133. return Success(jsonData);
  134. }
  135. /// <summary>
  136. /// 教师上下课打卡:判断当前打卡状态
  137. /// </summary>
  138. /// <param name="_"></param>
  139. /// <returns></returns>
  140. public Response IsAttendanceTeacher(dynamic _)
  141. {
  142. var res = adr_RestrictionBLL.IsAttendanceTeacher();
  143. var jsondata =
  144. new
  145. {
  146. data = res
  147. };
  148. return Success(jsondata);
  149. }
  150. /// <summary>
  151. /// 教师上下课打卡
  152. /// </summary>
  153. /// <param name="_"></param>
  154. /// <returns></returns>
  155. public Response ClockInTeacher(dynamic _)
  156. {
  157. Attendance parameter = this.GetReqData<Attendance>();
  158. adr_RestrictionBLL.ClockInTeacher(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.LessonSortNo, parameter.ALTId, parameter.ALTOEId);
  159. return Success("打卡成功");
  160. }
  161. /// <summary>
  162. /// 判断教师是否授课
  163. /// </summary>
  164. /// <param name="_"></param>
  165. /// <returns></returns>
  166. public Response JudgeTeacherIsHasLesson(dynamic _)
  167. {
  168. var jsondata =
  169. new
  170. {
  171. data = false
  172. };
  173. var empInfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(userInfo.account);
  174. if (empInfo == null)
  175. {
  176. return Success(jsondata);
  177. }
  178. if (empInfo.IsHasLesson == true)//授课
  179. {
  180. jsondata = new { data = true };
  181. return Success(jsondata);
  182. }
  183. return Success(jsondata);
  184. }
  185. }
  186. }