From f9c6e772b299648bd6611f691adb45392b69fc31 Mon Sep 17 00:00:00 2001 From: dao Date: Thu, 2 Jan 2025 17:54:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/AttendanceApi.cs | 110 ++++++++++-------- .../ADR_Record/ADR_RecordBLL.cs | 21 +++- .../ADR_Record/ADR_RecordIBLL.cs | 2 + .../ADR_Record/ADR_RecordService.cs | 38 +++++- .../ADR_Restriction/ADR_RestrictionService.cs | 82 +------------ 5 files changed, 124 insertions(+), 129 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AttendanceApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AttendanceApi.cs index fd53a0457..72fb7c15d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AttendanceApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AttendanceApi.cs @@ -16,12 +16,15 @@ namespace Learun.Application.WebApi.Modules public class AttendanceApi : BaseApi { public AttendanceApi() - : base("/learun/adms/attendance") + : base("/api/ht/attendance") { //判断当前时间是否可以打卡 //Get["/IsAttendance"] = IsAttendance; //上下班打卡 Post["/clockin"] = ClockIn; + + + Get["/clockstat"] = ClockStat; //获取考勤打卡记录 //Get["/getrecordpagelist"] = GetRecordPageList; //判断学生当前打卡状态 @@ -44,18 +47,34 @@ namespace Learun.Application.WebApi.Modules private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL(); - //public Response GetTeacherRecord(dynamic _) - //{ - // ReqPageParam parameter = this.GetReqData(); - // var res = adr_RecordBLL.GetList(parameter.queryJson); - // var jsondata = - // new - // { - // data = res - // }; - // return Success(jsondata); - //} - + public Response GetTeacherRecord(dynamic _) + { + ReqPageParam parameter = this.GetReqData(); + var res = adr_RecordBLL.GetList(parameter.queryJson); + var jsondata = + new + { + data = res + }; + return Success(jsondata); + } + public Response ClockStat(dynamic _) + { + //Attendance parameter = this.GetReqData(); + 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); + } /// /// 判断当前时间是否可以打卡 /// @@ -113,34 +132,27 @@ namespace Learun.Application.WebApi.Modules var userinfo = LoginUserInfo.Get(); //员工账号 string EmpNo = userinfo.account; - string result = "0"; - //if (parameter.AIsOut) + //string result = "0"; + + //根据用户编号获取用户头像 + //var einfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(EmpNo); + //if (einfo == null) //{ - // result = "1"; + // return Fail("用户数据错误!"); //} - //else - //{ - //根据用户编号获取用户头像 - var einfo = empInfoIBLL.GetEmpInfoEntityByEmpNo(EmpNo); - if (einfo == null) - { - return Fail("用户数据错误!"); - } - string userimg = einfo.Photo; - string imgid = parameter.Img; + //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("打卡失败!"); //} - 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("打卡照片异常,请重新拍照!"); - } } @@ -162,19 +174,19 @@ namespace Learun.Application.WebApi.Modules /// /// /// - //public Response GetRecordPageList(dynamic _) - //{ - // ReqPageParam parameter = this.GetReqData(); - // 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); - //} + public Response GetRecordPageList(dynamic _) + { + ReqPageParam parameter = this.GetReqData(); + 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); + } /// /// 教师上下课打卡:判断当前打卡状态 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs index 1adb9b0fa..ad215bcd7 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordBLL.cs @@ -209,7 +209,26 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } - #endregion + + #endregion + public Tuple GetTodayClock(string acc) + { + try + { + return aDR_RecordService.GetTodayClock(acc); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs index 5de4924f4..9aeb76f61 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordIBLL.cs @@ -1,6 +1,7 @@ using Learun.Util; using System.Data; using System.Collections.Generic; +using System; namespace Learun.Application.TwoDevelopment.LogisticsManagement { @@ -68,5 +69,6 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement void SaveEntity(string keyValue, ADR_RecordEntity entity); #endregion + Tuple GetTodayClock(string acc); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs index 1e47e1701..a82b6d1d8 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/LogisticsManagement/ADR_Record/ADR_RecordService.cs @@ -458,6 +458,42 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement } } #endregion - + public Tuple GetTodayClock(string acc) + { + try + { + var strSql = new StringBuilder(); + strSql.Append("select t.* "); + strSql.Append(" from ADR_Record t "); + strSql.Append(" where ADYear="+DateTime.Today.Year+ " and ADMonth="+DateTime.Today.Month+ " and ADDay="+DateTime.Today.Day+" "); + // 虚拟参数 + var dp = new DynamicParameters(new { }); + if (!acc.IsEmpty()) + { + dp.Add("UserNo", acc, DbType.String); + strSql.Append(" AND t.UserNo = @UserNo "); + } + var data = this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp).ToList(); + + var sbdata = data.FirstOrDefault(x => x.ADType == "1"); + var xbdata= data.FirstOrDefault(x=>x.ADType == "2"); + var sbstat = sbdata==null ? 0 : 1; + var sbsj = sbdata == null ? null: sbdata.ClockTime.Value.ToTimeString(); + var xbstat = xbdata == null ? 0 : 1; + var xbsj = xbdata == null ? null : xbdata.ClockTime.Value.ToTimeString(); + return new Tuple(sbstat,sbsj,xbstat,xbsj); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ADR_Restriction/ADR_RestrictionService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ADR_Restriction/ADR_RestrictionService.cs index 6ccd42b1f..eca825685 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ADR_Restriction/ADR_RestrictionService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ADR_Restriction/ADR_RestrictionService.cs @@ -280,24 +280,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement //2021.12.30 上下班设置时间段打卡 #region 二次打卡 - //判断打卡次数 - //if (attendancerulEntity.ClockTime == "二次打卡") - //{ - //上下班正常打卡 - //if (devicetime >= signInStartTime && devicetime <= signInEndTime) - //if (devicetime <= signInEndTime) - //{ - //ADType = "1";//上班 - //ClockStatus = "1";//正常 - //} - //else if (devicetime >= signOutStartTime && devicetime <= signOutEndTime) - //else if (devicetime >= signOutStartTime) - //{ - // ADType = "2";//下班 - // ClockStatus = "1";//正常 - //} - //else if (devicetime < signOutStartTime && devicetime > signInEndTime)//小于下班时间 - //{ + //首先判断是上班还是下班 //该用户当日有签到记录视为下班签退 var attendancerecord = this.BaseRepository("CollegeMIS").FindList( @@ -309,59 +292,9 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement { ADType = "2";//下班 - //if (devicetime < workDateTimelunch) - //{ - // DateTime offworkDateTimeFree1 = offworkstartlunch.AddMinutes(-leaveTime); - // if (devicetime < offworkDateTimeFree1) - // { - // ClockStatus = "3"; - // } - // else - // { - // ClockStatus = "1"; - // } - - //} - //else - //{ - // if (devicetime >= (signOutStartTime.AddMinutes(-leaveTime))) - // { - // ClockStatus = "1"; - // } - // else - // { - // ClockStatus = "3"; - // } - //} - + } - //else//判断为上班迟到 - //{ - // if (devicetime < offworkstartlunch.AddMinutes(-leaveTime)) - // { - // ADType = "1"; - // ClockStatus = "2"; - // } - // else if (devicetime >= offworkstartlunch.AddMinutes(-leaveTime) && devicetime <= offworkendlunch) - // { - // ADType = "2"; - // ClockStatus = "1"; - // } - // else if (devicetime >= workstartlunch && devicetime <= workendlunch.AddMinutes(overTime)) - // { - // ADType = "1"; - // ClockStatus = "1"; - // } - // else - // { - // ADType = "1"; - // ClockStatus = "2"; - // } - - //} - //} - - + ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); adrRecordEntity.Create(); adrRecordEntity.UserName = userinfo.realName; @@ -370,14 +303,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement adrRecordEntity.ADTime = datetimenow; adrRecordEntity.ClockTime = devicetime; adrRecordEntity.ClockStatus = ClockStatus; - //if (deviceEntity != null && !string.IsNullOrEmpty(deviceEntity.DName)) - //{ - // adrRecordEntity.ClockPlace = deviceEntity.DName; - //} - //else - //{ - // adrRecordEntity.ClockPlace = "未知"; - //} + adrRecordEntity.ADYear = strTimeYear; adrRecordEntity.ADMonth = strTimeMonth; adrRecordEntity.ADDay = strTimeDay;