From 3930277f9d27fc908f3e05e4553d368b5c1f40f2 Mon Sep 17 00:00:00 2001 From: dyy <807692433@qq.com> Date: Fri, 10 May 2024 10:44:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E6=95=99?= =?UTF-8?q?=E5=B8=88=E8=80=83=E5=8B=A4=E6=89=93=E5=8D=A1=EF=BC=9A=E6=8E=88?= =?UTF-8?q?=E8=AF=BE=E6=95=99=E5=B8=88=E5=8F=AF=E5=AE=9E=E7=8E=B0=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=89=93=E5=8D=A1=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ADR_Restriction/ADR_RestrictionService.cs | 107 +++++++++++++++--- 1 file changed, 93 insertions(+), 14 deletions(-) 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 87cc912f7..c2ef0d53a 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 @@ -184,6 +184,11 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement var userinfo = LoginUserInfo.Get(); //员工账号 string EmpNo = userinfo.account; + EmpInfoEntity empInfo = this.BaseRepository("CollegeMIS").FindEntity(x => x.EmpNo == EmpNo); + if (empInfo == null) + { + return true; + } //考勤状态 string ADType = "0"; @@ -207,6 +212,68 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement //设备事件时间(在这里,=当前时间) DateTime devicetime = Convert.ToDateTime(strTime); + //判断教师是坐班还是授课:授课的话可一直正常打卡,不受考勤规则的限制;第一次为上班,第二次为下班,第三次之后更新下班; + if (empInfo.CompilationCategory == "2") //授课 + { + ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); + adrRecordEntity.Create(); + adrRecordEntity.UserName = userinfo.realName; + adrRecordEntity.UserNo = EmpNo; + adrRecordEntity.ADType = ADType; + adrRecordEntity.ADTime = datetimenow; + adrRecordEntity.ClockTime = devicetime; + adrRecordEntity.ClockStatus = ClockStatus; + adrRecordEntity.ADYear = strTimeYear; + adrRecordEntity.ADMonth = strTimeMonth; + adrRecordEntity.ADDay = strTimeDay; + adrRecordEntity.ALon = ALon; + adrRecordEntity.ALat = ALat; + adrRecordEntity.AIsOut = AIsOut; + adrRecordEntity.ARemark = ARemark; + adrRecordEntity.ADPhoto = ADPhoto; + adrRecordEntity.ClockPlace = ClockPlace; + adrRecordEntity.Img = img; + adrRecordEntity.IsFit = true; + //判断是上班还是下班 + var attendancerecord = this.BaseRepository("CollegeMIS").FindList( + "select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'").ToList(); + if (attendancerecord.Where(x => x.ADType == "1").Any()) + { + adrRecordEntity.ADType = "2"; + if (attendancerecord.Where(x => x.ADType == "2").Any()) + { + //更新签退时间,签退状态 + var firstoffworkentity = attendancerecord.FirstOrDefault(m => m.ADType == "2"); + firstoffworkentity.ADTime = datetimenow; + firstoffworkentity.ClockTime = devicetime; + firstoffworkentity.ClockStatus = ClockStatus; + firstoffworkentity.ARemark = ARemark; + firstoffworkentity.ClockPlace = ClockPlace; + firstoffworkentity.Img = img; + firstoffworkentity.ADPhoto = ADPhoto; + firstoffworkentity.AIsOut = AIsOut; + this.BaseRepository("CollegeMIS").ExecuteBySql("update ADR_Record set ADTime='" + firstoffworkentity.ADTime + "',ClockTime='" + firstoffworkentity.ClockTime + "',ClockStatus='" + firstoffworkentity.ClockStatus + "',ADPhoto='" + firstoffworkentity.ADPhoto + "' where ID='" + firstoffworkentity.ID + "'"); + //同步修改授课考勤打卡 + ClockInModifyTeachAttendance(adrRecordEntity); + return true; + } + } + else + { + //写入上班记录 + adrRecordEntity.ADType = "1"; + } + //考勤记录 + this.BaseRepository("CollegeMIS").ExecuteBySql("insert into ADR_Record(ID, UserNo, ADType, ADTime, ClockTime, ClockStatus, ClockPlace,Img, ADYear, ADMonth, ADDay, ADPhoto,ALon,ALat,AIsOut,IsFit,ARemark) values(" + + "'" + adrRecordEntity.ID + "','" + adrRecordEntity.UserNo + "','" + adrRecordEntity.ADType + "','" + adrRecordEntity.ADTime + "'," + + "'" + adrRecordEntity.ClockTime + "','" + adrRecordEntity.ClockStatus + "','" + adrRecordEntity.ClockPlace + "','" + adrRecordEntity.Img + "','" + adrRecordEntity.ADYear + "'," + + "'" + adrRecordEntity.ADMonth + "','" + adrRecordEntity.ADDay + "','" + adrRecordEntity.ADPhoto + "'," + adrRecordEntity.ALon + "," + adrRecordEntity.ALat + ",'" + adrRecordEntity.AIsOut + "','" + adrRecordEntity.IsFit + "','" + adrRecordEntity.ARemark + "')"); + //同步修改授课考勤打卡 + ClockInModifyTeachAttendance(adrRecordEntity); + return true; + } + //上班时间 DateTime workDateTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.WorkTime); //上班考勤时间段 @@ -253,7 +320,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement ADType = "2";//下班 ClockStatus = "1";//正常 } - else if (devicetime < signOutStartTime && devicetime > signInEndTime)//小于下班时间 + else if (devicetime < signOutStartTime && devicetime > signInEndTime)//小于下班时间 { //首先判断是上班还是下班 //该用户当日有签到记录视为下班签退 @@ -266,7 +333,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement { ADType = "2";//下班 - if(devicetime< workDateTimelunch) + if (devicetime < workDateTimelunch) { DateTime offworkDateTimeFree1 = offworkstartlunch.AddMinutes(-leaveTime); if (devicetime < offworkDateTimeFree1) @@ -281,7 +348,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement } else { - if(devicetime>=(signOutStartTime.AddMinutes(-leaveTime))) + if (devicetime >= (signOutStartTime.AddMinutes(-leaveTime))) { ClockStatus = "1"; } @@ -316,17 +383,17 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement } else//判断为上班迟到 { - if (devicetime< offworkstartlunch.AddMinutes(-leaveTime)) + if (devicetime < offworkstartlunch.AddMinutes(-leaveTime)) { ADType = "1"; ClockStatus = "2"; } - else if(devicetime>= offworkstartlunch.AddMinutes(-leaveTime) && devicetime<= offworkendlunch) + else if (devicetime >= offworkstartlunch.AddMinutes(-leaveTime) && devicetime <= offworkendlunch) { ADType = "2"; ClockStatus = "1"; } - else if(devicetime>= workstartlunch && devicetime<=workendlunch.AddMinutes(overTime)) + else if (devicetime >= workstartlunch && devicetime <= workendlunch.AddMinutes(overTime)) { ADType = "1"; ClockStatus = "1"; @@ -1163,14 +1230,15 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement return adrresult; } //代课老师全天可以考勤 - if (empinfo.IsHasLesson == true) - { - attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity(m => m.REnable == true && m.AType == 2); - } - else - { - attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity(m => m.REnable == true && m.AType == 1); - } + //if (empinfo.IsHasLesson == true) + //{ + // attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity(m => m.REnable == true && m.AType == 2); + //} + //else + //{ + // attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity(m => m.REnable == true && m.AType == 1); + //} + attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity(m => m.REnable == true); //考勤规则为空时 if (attendancerulEntity == null) { @@ -1236,6 +1304,17 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement "select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'").ToList(); + //判断教师是坐班还是授课:授课的话可一直正常打卡,不受考勤规则的限制; + if (empinfo.CompilationCategory == "2")//授课 + { + adrresult.AttendanceType = 1; + adrresult.AttendanceTypeString = "正常打卡"; + var userWorkTime = attendancerecordList.Where(m => m.ADType == "1").OrderByDescending(m => m.ADTime).FirstOrDefault()?.ADTime.Value; + var userCloseTime = attendancerecordList.Where(m => m.ADType == "2").OrderByDescending(m => m.ADTime).FirstOrDefault()?.ADTime.Value; + adrresult.UserWorkTime = userWorkTime != null ? userWorkTime.ToString() : ""; + adrresult.UserCloseTime = userCloseTime != null ? userCloseTime.ToString() : ""; + return adrresult; + } if (attendancerulEntity.ClockTime == "二次打卡") {