您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

270 行
8.9 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("/api/ht/attendance")
  19. {
  20. //判断当前时间是否可以打卡
  21. //Get["/IsAttendance"] = IsAttendance;
  22. //上下班打卡
  23. Post["/clockin"] = ClockIn;
  24. Get["/clockstat"] = ClockStat;
  25. //获取考勤打卡记录
  26. //Get["/getrecordpagelist"] = GetRecordPageList;
  27. //判断学生当前打卡状态
  28. //Get["IsAttendanceStudent"] = IsAttendanceStudent;
  29. //学生打卡
  30. //Post["/clockinStudent"] = ClockInStudent;
  31. //打卡记录
  32. //Get["/GetTeacherRecord"] = GetTeacherRecord;
  33. //教师上下课打卡:判断当前打卡状态
  34. //Get["IsAttendanceTeacher"] = IsAttendanceTeacher;
  35. //教师上下课打卡
  36. //Post["/clockinTeacher"] = ClockInTeacher;
  37. //判断教师是否授课
  38. //Get["JudgeTeacherIsHasLesson"] = JudgeTeacherIsHasLesson;
  39. }
  40. private ADR_RestrictionIBLL adr_RestrictionBLL = new ADR_RestrictionBLL();
  41. private ADR_RecordIBLL adr_RecordBLL = new ADR_RecordBLL();
  42. private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
  43. public Response GetTeacherRecord(dynamic _)
  44. {
  45. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  46. var res = adr_RecordBLL.GetList(parameter.queryJson);
  47. var jsondata =
  48. new
  49. {
  50. data = res
  51. };
  52. return Success(jsondata);
  53. }
  54. public Response ClockStat(dynamic _)
  55. {
  56. //Attendance parameter = this.GetReqData<Attendance>();
  57. var userinfo = LoginUserInfo.Get();
  58. //员工账号
  59. string EmpNo = userinfo.account;
  60. var res = adr_RecordBLL.GetTodayClock(EmpNo);
  61. var jsondata =
  62. new
  63. {
  64. start = res.Item1,
  65. startTime = res.Item2,
  66. end = res.Item3,
  67. endTime = res.Item4
  68. };
  69. return Success(jsondata);
  70. }
  71. /// <summary>
  72. /// 判断当前时间是否可以打卡
  73. /// </summary>
  74. /// <param name="_"></param>
  75. /// <returns></returns>
  76. //public Response IsAttendance(dynamic _)
  77. //{
  78. // var res = adr_RestrictionBLL.IsAttendance();
  79. // var jsondata =
  80. // new
  81. // {
  82. // data = res
  83. // };
  84. // return Success(jsondata);
  85. //}
  86. /// <summary>
  87. /// 学生打卡判断
  88. /// </summary>
  89. /// <param name="_"></param>
  90. /// <returns></returns>
  91. //public Response IsAttendanceStudent(dynamic _)
  92. //{
  93. // var res = adr_RestrictionBLL.IsAttendanceStudent();
  94. // var jsondata =
  95. // new
  96. // {
  97. // data = res
  98. // };
  99. // return Success(jsondata);
  100. //}
  101. public class Attendance
  102. {
  103. public decimal ALon { get; set; }
  104. public decimal ALat { get; set; }
  105. public bool AIsOut { get; set; }
  106. public string ARemark { get; set; }
  107. public string ADPhoto { get; set; }
  108. public string ClockPlace { get; set; }
  109. public string LessonSortNo { get; set; }
  110. public string ALTId { get; set; }
  111. public string ALTOEId { get; set; }
  112. public string Img { get; set; }
  113. }
  114. /// <summary>
  115. /// 上下班打卡
  116. /// </summary>
  117. /// <param name="_"></param>
  118. /// <returns></returns>
  119. public Response ClockIn(dynamic _)
  120. {
  121. Attendance parameter = this.GetReqData<Attendance>();
  122. var userinfo = LoginUserInfo.Get();
  123. //员工账号
  124. string EmpNo = userinfo.account;
  125. //string result = "0";
  126. //根据用户编号获取用户头像
  127. //var einfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(EmpNo);
  128. //if (einfo == null)
  129. //{
  130. // return Fail("用户数据错误!");
  131. //}
  132. //string userimg = einfo.Photo;
  133. //string imgid = parameter.Img;
  134. //if (result == "1")
  135. //{
  136. adr_RestrictionBLL.ClockIn(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.Img);
  137. return Success("打卡成功");
  138. //}
  139. //else
  140. //{
  141. // return Fail("打卡失败!");
  142. //}
  143. }
  144. /// <summary>
  145. /// 学生打卡
  146. /// </summary>
  147. /// <param name="_"></param>
  148. /// <returns></returns>
  149. //public Response ClockInStudent(dynamic _)
  150. //{
  151. // Attendance parameter = this.GetReqData<Attendance>();
  152. // adr_RestrictionBLL.ClockInStudent(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.LessonSortNo, parameter.ALTId, parameter.ALTOEId);
  153. // return Success("打卡成功");
  154. //}
  155. /// <summary>
  156. /// 打卡
  157. /// </summary>
  158. /// <param name="_"></param>
  159. /// <returns></returns>
  160. public Response GetRecordPageList(dynamic _)
  161. {
  162. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  163. var data = adr_RecordBLL.GetPageList(parameter.pagination, parameter.queryJson);
  164. var jsonData = new
  165. {
  166. rows = data,
  167. total = parameter.pagination.total,
  168. page = parameter.pagination.page,
  169. records = parameter.pagination.records
  170. };
  171. return Success(jsonData);
  172. }
  173. /// <summary>
  174. /// 教师上下课打卡:判断当前打卡状态
  175. /// </summary>
  176. /// <param name="_"></param>
  177. /// <returns></returns>
  178. //public Response IsAttendanceTeacher(dynamic _)
  179. //{
  180. // var res = adr_RestrictionBLL.IsAttendanceTeacher();
  181. // var jsondata =
  182. // new
  183. // {
  184. // data = res
  185. // };
  186. // return Success(jsondata);
  187. //}
  188. /// <summary>
  189. /// 教师上下课打卡
  190. /// </summary>
  191. /// <param name="_"></param>
  192. /// <returns></returns>
  193. //public Response ClockInTeacher(dynamic _)
  194. //{
  195. // Attendance parameter = this.GetReqData<Attendance>();
  196. // var userinfo = LoginUserInfo.Get();
  197. // //员工账号
  198. // string EmpNo = userinfo.account;
  199. // //根据用户编号获取用户头像
  200. // var einfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(EmpNo);
  201. // if (einfo == null)
  202. // {
  203. // return Fail("用户数据错误!");
  204. // }
  205. // string userimg = einfo.Photo;
  206. // string imgid = parameter.Img;
  207. // var url = Config.GetValue("FaceCheckApi");
  208. // string result = Util.HttpMethods.HttpGet($"{url}{userimg}/{imgid}");
  209. // if (result == "1")
  210. // {
  211. // adr_RestrictionBLL.ClockInTeacher(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.LessonSortNo, parameter.ALTId, parameter.ALTOEId, parameter.Img);
  212. // return Success("打卡成功");
  213. // }
  214. // else
  215. // {
  216. // return Fail("打卡照片异常,请重新拍照!");
  217. // }
  218. //}
  219. /// <summary>
  220. /// 判断教师是否授课
  221. /// </summary>
  222. /// <param name="_"></param>
  223. /// <returns></returns>
  224. //public Response JudgeTeacherIsHasLesson(dynamic _)
  225. //{
  226. // var jsondata =
  227. // new
  228. // {
  229. // data = false
  230. // };
  231. // var empInfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(userInfo.account);
  232. // if (empInfo == null)
  233. // {
  234. // return Success(jsondata);
  235. // }
  236. // if (empInfo.IsHasLesson == true)//授课
  237. // {
  238. // jsondata = new { data = true };
  239. // return Success(jsondata);
  240. // }
  241. // return Success(jsondata);
  242. //}
  243. }
  244. }