|
- using Learun.Application.Base.SystemModule;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using Learun.Application.TwoDevelopment.LogisticsManagement;
- using Learun.Application.TwoDevelopment.PersonnelManagement;
- using Learun.Util;
- using Nancy;
- using System;
- using System.Collections.Generic;
- using System.IO;
-
- namespace Learun.Application.WebApi.Modules
- {
- /// <summary>
- /// 考勤打卡功能
- /// </summary>
- public class AttendanceApi : BaseApi
- {
- public AttendanceApi()
- : base("/api/ht/attendance")
- {
- //判断当前时间是否可以打卡
- //Get["/IsAttendance"] = IsAttendance;
- //上下班打卡
- Post["/clockin"] = ClockIn;
-
-
- Get["/clockstat"] = ClockStat;
- //获取考勤打卡记录
- //Get["/getrecordpagelist"] = GetRecordPageList;
- //判断学生当前打卡状态
- //Get["IsAttendanceStudent"] = IsAttendanceStudent;
- //学生打卡
- //Post["/clockinStudent"] = ClockInStudent;
- //打卡记录
- //Get["/GetTeacherRecord"] = GetTeacherRecord;
-
- //教师上下课打卡:判断当前打卡状态
- //Get["IsAttendanceTeacher"] = IsAttendanceTeacher;
- //教师上下课打卡
- //Post["/clockinTeacher"] = ClockInTeacher;
-
- //判断教师是否授课
- //Get["JudgeTeacherIsHasLesson"] = JudgeTeacherIsHasLesson;
- }
- private ADR_RestrictionIBLL adr_RestrictionBLL = new ADR_RestrictionBLL();
- private ADR_RecordIBLL adr_RecordBLL = new ADR_RecordBLL();
- private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
-
-
- public Response GetTeacherRecord(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var res = adr_RecordBLL.GetList(parameter.queryJson);
- var jsondata =
- new
- {
- data = res
- };
- return Success(jsondata);
- }
- public Response ClockStat(dynamic _)
- {
- //Attendance parameter = this.GetReqData<Attendance>();
- var userinfo = LoginUserInfo.Get();
- //员工账号
- string EmpNo = userinfo.account;
- var res = adr_RecordBLL.GetTodayClock(EmpNo);
- var jsondata =
- new
- {
- start = res.Item1,
- startTime = res.Item2,
- end = res.Item3,
- endTime = res.Item4
- };
- return Success(jsondata);
- }
- /// <summary>
- /// 判断当前时间是否可以打卡
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- //public Response IsAttendance(dynamic _)
- //{
- // var res = adr_RestrictionBLL.IsAttendance();
- // var jsondata =
- // new
- // {
- // data = res
- // };
- // return Success(jsondata);
- //}
- /// <summary>
- /// 学生打卡判断
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- //public Response IsAttendanceStudent(dynamic _)
- //{
- // var res = adr_RestrictionBLL.IsAttendanceStudent();
- // var jsondata =
- // new
- // {
- // data = res
- // };
- // return Success(jsondata);
- //}
-
- public class Attendance
- {
- public decimal ALon { get; set; }
- public decimal ALat { get; set; }
- public bool AIsOut { get; set; }
- public string ARemark { get; set; }
- public string ADPhoto { get; set; }
- public string ClockPlace { get; set; }
- public string LessonSortNo { get; set; }
- public string ALTId { get; set; }
- public string ALTOEId { get; set; }
- public string Img { get; set; }
- }
-
- /// <summary>
- /// 上下班打卡
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response ClockIn(dynamic _)
- {
-
- Attendance parameter = this.GetReqData<Attendance>();
- var userinfo = LoginUserInfo.Get();
- //员工账号
- string EmpNo = userinfo.account;
- //string result = "0";
-
- //根据用户编号获取用户头像
- //var einfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(EmpNo);
- //if (einfo == null)
- //{
- // return Fail("用户数据错误!");
- //}
- //string userimg = einfo.Photo;
- //string imgid = parameter.Img;
-
- //if (result == "1")
- //{
- adr_RestrictionBLL.ClockIn(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.Img);
-
- return Success("打卡成功");
- //}
- //else
- //{
- // return Fail("打卡失败!");
- //}
-
-
- }
- /// <summary>
- /// 学生打卡
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- //public Response ClockInStudent(dynamic _)
- //{
- // Attendance parameter = this.GetReqData<Attendance>();
-
- // adr_RestrictionBLL.ClockInStudent(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.LessonSortNo, parameter.ALTId, parameter.ALTOEId);
-
- // return Success("打卡成功");
- //}
- /// <summary>
- /// 打卡
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetRecordPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = adr_RecordBLL.GetPageList(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 教师上下课打卡:判断当前打卡状态
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- //public Response IsAttendanceTeacher(dynamic _)
- //{
- // var res = adr_RestrictionBLL.IsAttendanceTeacher();
- // var jsondata =
- // new
- // {
- // data = res
- // };
- // return Success(jsondata);
- //}
- /// <summary>
- /// 教师上下课打卡
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- //public Response ClockInTeacher(dynamic _)
- //{
- // Attendance parameter = this.GetReqData<Attendance>();
-
- // var userinfo = LoginUserInfo.Get();
- // //员工账号
- // string EmpNo = userinfo.account;
-
- // //根据用户编号获取用户头像
- // var einfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(EmpNo);
- // if (einfo == null)
- // {
- // return Fail("用户数据错误!");
- // }
- // string userimg = einfo.Photo;
- // string imgid = parameter.Img;
-
- // var url = Config.GetValue("FaceCheckApi");
-
- // string result = Util.HttpMethods.HttpGet($"{url}{userimg}/{imgid}");
- // if (result == "1")
- // {
- // adr_RestrictionBLL.ClockInTeacher(parameter.ALon, parameter.ALat, parameter.AIsOut, parameter.ARemark, parameter.ADPhoto, parameter.ClockPlace, parameter.LessonSortNo, parameter.ALTId, parameter.ALTOEId, parameter.Img);
-
- // return Success("打卡成功");
- // }
- // else
- // {
- // return Fail("打卡照片异常,请重新拍照!");
- // }
-
-
- //}
-
- /// <summary>
- /// 判断教师是否授课
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- //public Response JudgeTeacherIsHasLesson(dynamic _)
- //{
- // var jsondata =
- // new
- // {
- // data = false
- // };
- // var empInfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(userInfo.account);
- // if (empInfo == null)
- // {
- // return Success(jsondata);
- // }
- // if (empInfo.IsHasLesson == true)//授课
- // {
- // jsondata = new { data = true };
- // return Success(jsondata);
- // }
- // return Success(jsondata);
- //}
- }
- }
|