|
|
@@ -213,17 +213,19 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
//当前服务器日期 |
|
|
|
var datenow = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
|
|
|
|
var datetimenow = DateTime.Now; |
|
|
|
|
|
|
|
//当前时间年月日时分秒 |
|
|
|
string strTimeYear = (DateTime.Now.Year).ToString(); |
|
|
|
string strTimeMonth = (DateTime.Now.Month).ToString("d2"); |
|
|
|
string strTimeDay = (DateTime.Now.Day).ToString("d2"); |
|
|
|
string strTimeHour = (DateTime.Now.Hour).ToString("d2"); |
|
|
|
string strTimeMinute = (DateTime.Now.Minute).ToString("d2"); |
|
|
|
string strTimeSecond = (DateTime.Now.Second).ToString("d2"); |
|
|
|
string strTimeYear = (datetimenow.Year).ToString(); |
|
|
|
string strTimeMonth = (datetimenow.Month).ToString("d2"); |
|
|
|
string strTimeDay = (datetimenow.Day).ToString("d2"); |
|
|
|
string strTimeHour = (datetimenow.Hour).ToString("d2"); |
|
|
|
string strTimeMinute = (datetimenow.Minute).ToString("d2"); |
|
|
|
string strTimeSecond = (datetimenow.Second).ToString("d2"); |
|
|
|
string strTime = strTimeYear + "-" + strTimeMonth + "-" + strTimeDay + " " + strTimeHour + ":" + |
|
|
|
strTimeMinute + ":" + strTimeSecond; |
|
|
|
|
|
|
|
//设备事件时间 |
|
|
|
//设备事件时间(在这里,=当前时间) |
|
|
|
DateTime devicetime = Convert.ToDateTime(strTime); |
|
|
|
//掉线补传数据时间判断 |
|
|
|
//设备时间小于当前时间,判断为补传历史时间数据 |
|
|
@@ -233,77 +235,75 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
//} |
|
|
|
//上班时间 |
|
|
|
DateTime workDateTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.WorkTime); |
|
|
|
//上班考勤时间段 |
|
|
|
DateTime signInStartTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInStartTime); |
|
|
|
DateTime signInEndTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInEndTime); |
|
|
|
|
|
|
|
//下班时间 |
|
|
|
DateTime offworkDateTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.CloseTime); |
|
|
|
//下班考勤时间段 |
|
|
|
DateTime signOutStartTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutStartTime); |
|
|
|
DateTime signOutEndTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutEndTime); |
|
|
|
|
|
|
|
var datetimenow = DateTime.Now; |
|
|
|
//2021.12.30 上下班设置时间段打卡 |
|
|
|
#region 二次打卡 |
|
|
|
//判断打卡次数 |
|
|
|
if (attendancerulEntity.ClockTime == "二次打卡") |
|
|
|
{ |
|
|
|
//迟到判断 |
|
|
|
if (devicetime <= workDateTime)//正常 |
|
|
|
//上下班正常打卡 |
|
|
|
if (devicetime >= signInStartTime && devicetime <= signInEndTime) |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//迟到 |
|
|
|
else if (devicetime >= signOutStartTime && devicetime <= signOutEndTime) |
|
|
|
{ |
|
|
|
//签到与签退判断 |
|
|
|
if (devicetime >= offworkDateTime)//如果签到时间大于下班时间则为签退状态 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//小于下班时间 |
|
|
|
{ |
|
|
|
//首先判断是上班还是下班 |
|
|
|
//该用户当日有签到记录视为下班签退 |
|
|
|
var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>( |
|
|
|
"select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + |
|
|
|
strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + |
|
|
|
"' and ADType='1'").ToList(); |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else if (devicetime <= signOutStartTime)//小于下班时间 |
|
|
|
{ |
|
|
|
//首先判断是上班还是下班 |
|
|
|
//该用户当日有签到记录视为下班签退 |
|
|
|
var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>( |
|
|
|
"select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + |
|
|
|
strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + |
|
|
|
"' and ADType='1'").ToList(); |
|
|
|
|
|
|
|
if (attendancerecord.Count() > 0)//如果存在上班考勤记录 |
|
|
|
if (attendancerecord.Count() > 0)//如果存在上班考勤记录 |
|
|
|
{ |
|
|
|
//判断为下班早退 |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0)//如果允许早退,获取范围 |
|
|
|
{ |
|
|
|
//判断为下班早退 |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0)//如果允许早退,获取范围 |
|
|
|
//最早签退时间 |
|
|
|
DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
{ |
|
|
|
//最早签退时间 |
|
|
|
DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//超出早退范围视为早退 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//不允许早退直接视为早退 |
|
|
|
else//超出早退范围视为早退 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
} |
|
|
|
else//判断为上班迟到 |
|
|
|
else//不允许早退直接视为早退 |
|
|
|
{ |
|
|
|
if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0)//如果允许迟到,获取范围 |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
} |
|
|
|
else//判断为上班迟到 |
|
|
|
{ |
|
|
|
if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0)//如果允许迟到,获取范围 |
|
|
|
{ |
|
|
|
//最晚签到时间 |
|
|
|
DateTime workDateTimeFree = workDateTime.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
{ |
|
|
|
//最晚签到时间 |
|
|
|
DateTime workDateTimeFree = workDateTime.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@@ -311,9 +311,91 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#region old 上下班无打卡时间段 |
|
|
|
|
|
|
|
//if (devicetime <= workDateTime)//正常 |
|
|
|
//{ |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
//} |
|
|
|
//else//迟到 |
|
|
|
//{ |
|
|
|
// //签到与签退判断 |
|
|
|
// if (devicetime >= offworkDateTime)//如果签到时间大于下班时间则为签退状态 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else//小于下班时间 |
|
|
|
// { |
|
|
|
// //首先判断是上班还是下班 |
|
|
|
// //该用户当日有签到记录视为下班签退 |
|
|
|
// var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>( |
|
|
|
// "select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + |
|
|
|
// strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + |
|
|
|
// "' and ADType='1'").ToList(); |
|
|
|
|
|
|
|
// if (attendancerecord.Count() > 0)//如果存在上班考勤记录 |
|
|
|
// { |
|
|
|
// //判断为下班早退 |
|
|
|
// if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0)//如果允许早退,获取范围 |
|
|
|
// { |
|
|
|
// //最早签退时间 |
|
|
|
// DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
// if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else//超出早退范围视为早退 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else//不允许早退直接视为早退 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else//判断为上班迟到 |
|
|
|
// { |
|
|
|
// if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0)//如果允许迟到,获取范围 |
|
|
|
// { |
|
|
|
// //最晚签到时间 |
|
|
|
// DateTime workDateTimeFree = workDateTime.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
// if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "2";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "2";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); |
|
|
|
adrRecordEntity.Create(); |
|
|
|
adrRecordEntity.UserName = userinfo.realName; |
|
|
@@ -571,162 +653,297 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
} |
|
|
|
else//不在中午考勤时间段判断迟到早退 |
|
|
|
{ |
|
|
|
//迟到判断 |
|
|
|
if (devicetime <= workDateTime)//正常 |
|
|
|
//上下班正常打卡 |
|
|
|
if (devicetime >= signInStartTime && devicetime <= signInEndTime) |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//迟到 |
|
|
|
else if (devicetime >= signOutStartTime && devicetime <= signOutEndTime) |
|
|
|
{ |
|
|
|
//签到与签退判断 |
|
|
|
if (devicetime >= offworkDateTime)//如果签到时间大于下班时间则为签退状态 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
//迟到状态 |
|
|
|
else |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//该用户当日有签到记录视为下班签退 |
|
|
|
var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>("select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'"); |
|
|
|
//首先判断上午考勤还是下午考勤 |
|
|
|
//如果小于中午下班时间 |
|
|
|
if (devicetime < offworkDateTimelunch) |
|
|
|
{ |
|
|
|
//首先判断是否中午时间段 |
|
|
|
if (devicetime > offworkDateTimelunch && devicetime < workDateTimelunch) |
|
|
|
//迟到 |
|
|
|
//无上班记录视为迟到 |
|
|
|
if (attendancerecord.Count(m => m.ADType == "1") == 0) |
|
|
|
{ |
|
|
|
//无效打卡 |
|
|
|
////记录日志 |
|
|
|
//ADR_DeviceLogEntity adrDeviceLogEntity = new ADR_DeviceLogEntity(); |
|
|
|
//adrDeviceLogEntity.Create(); |
|
|
|
//if (deviceEntity != null && !string.IsNullOrEmpty(deviceEntity.Id)) |
|
|
|
//{ |
|
|
|
// adrDeviceLogEntity.DeviceId = deviceEntity.Id; |
|
|
|
// stringAlarm += ",设备IP:" + deviceEntity.IpAddress + "不在考勤时间范围内,打卡无效"; |
|
|
|
//} |
|
|
|
|
|
|
|
//adrDeviceLogEntity.LogData = stringAlarm; |
|
|
|
//adrDeviceLogEntity.LogType = "1"; |
|
|
|
//connmis.Execute("insert into ADR_DeviceLog(LogId,DeviceId, LogType, LogData, F_CreateDate, F_CreateUserId, F_CreateUserName) values(" + |
|
|
|
// "'" + adrDeviceLogEntity.LogId + "','" + adrDeviceLogEntity.DeviceId + "','" + adrDeviceLogEntity.LogType + "'," + |
|
|
|
// "'" + adrDeviceLogEntity.LogData + "','" + adrDeviceLogEntity.F_CreateDate + "','system','自动化服务')"); |
|
|
|
return true; |
|
|
|
//上班迟到 |
|
|
|
//获取迟到范围 |
|
|
|
if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
{ |
|
|
|
DateTime workDateTimeFree = workDateTime.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
//早退 |
|
|
|
//有签到记录视为早退 |
|
|
|
else |
|
|
|
{ |
|
|
|
//该用户当日有签到记录视为下班签退 |
|
|
|
var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>("select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'"); |
|
|
|
//首先判断上午考勤还是下午考勤 |
|
|
|
//如果小于中午下班时间 |
|
|
|
if (devicetime < offworkDateTimelunch) |
|
|
|
//获取早退范围 |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
{ |
|
|
|
//迟到 |
|
|
|
//无上班记录视为迟到 |
|
|
|
if (attendancerecord.Count(m => m.ADType == "1") == 0) |
|
|
|
//最早签退时间 |
|
|
|
DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
{ |
|
|
|
//上班迟到 |
|
|
|
//获取迟到范围 |
|
|
|
if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
{ |
|
|
|
DateTime workDateTimeFree = workDateTime.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "1";//上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
ADType = "8";//中午下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
//早退 |
|
|
|
//有签到记录视为早退 |
|
|
|
else |
|
|
|
else//超出早退范围视为早退 |
|
|
|
{ |
|
|
|
//获取早退范围 |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
{ |
|
|
|
//最早签退时间 |
|
|
|
DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "8";//中午下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//超出早退范围视为早退 |
|
|
|
{ |
|
|
|
ADType = "8";//中午下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "8";//中午下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
ADType = "8";//中午下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "8";//中午下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else if (devicetime > workDateTimelunch)//如果大于中午上班时间,且上级if判断小于下班时间 |
|
|
|
//判断为下午上班打卡迟到或早退 |
|
|
|
{ |
|
|
|
//如果存在中午签到记录 |
|
|
|
//判断为下班早退 |
|
|
|
if (attendancerecord.Count(m => m.ADType == "7") > 0) |
|
|
|
{ |
|
|
|
//早退判断 |
|
|
|
//获取早退范围 |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
{ |
|
|
|
DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//超出早退范围视为早退 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
else if (devicetime > workDateTimelunch)//如果大于中午上班时间,且上级if判断小于下班时间 |
|
|
|
//判断为下午上班打卡迟到或早退 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//获取迟到范围 |
|
|
|
if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
{ |
|
|
|
//如果存在中午签到记录 |
|
|
|
//判断为下班早退 |
|
|
|
if (attendancerecord.Count(m => m.ADType == "7") > 0) |
|
|
|
//最晚签到时间 |
|
|
|
DateTime workDateTimeFree = workDateTimelunch.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
{ |
|
|
|
//早退判断 |
|
|
|
//获取早退范围 |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
{ |
|
|
|
DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else//超出早退范围视为早退 |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "2";//下班 |
|
|
|
ClockStatus = "3";//早退 |
|
|
|
} |
|
|
|
ADType = "7";//中午上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//获取迟到范围 |
|
|
|
if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
{ |
|
|
|
//最晚签到时间 |
|
|
|
DateTime workDateTimeFree = workDateTimelunch.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
{ |
|
|
|
ADType = "7";//中午上班 |
|
|
|
ClockStatus = "1";//正常 |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "7";//中午上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "7";//中午上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
ADType = "7";//中午上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
ADType = "7";//中午上班 |
|
|
|
ClockStatus = "2";//迟到 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region old |
|
|
|
////迟到判断 |
|
|
|
//if (devicetime <= workDateTime)//正常 |
|
|
|
//{ |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
//} |
|
|
|
//else//迟到 |
|
|
|
//{ |
|
|
|
// //签到与签退判断 |
|
|
|
// if (devicetime >= offworkDateTime)//如果签到时间大于下班时间则为签退状态 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// //迟到状态 |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //首先判断是否中午时间段 |
|
|
|
// if (devicetime > offworkDateTimelunch && devicetime < workDateTimelunch) |
|
|
|
// { |
|
|
|
// //无效打卡 |
|
|
|
// ////记录日志 |
|
|
|
// //ADR_DeviceLogEntity adrDeviceLogEntity = new ADR_DeviceLogEntity(); |
|
|
|
// //adrDeviceLogEntity.Create(); |
|
|
|
// //if (deviceEntity != null && !string.IsNullOrEmpty(deviceEntity.Id)) |
|
|
|
// //{ |
|
|
|
// // adrDeviceLogEntity.DeviceId = deviceEntity.Id; |
|
|
|
// // stringAlarm += ",设备IP:" + deviceEntity.IpAddress + "不在考勤时间范围内,打卡无效"; |
|
|
|
// //} |
|
|
|
|
|
|
|
// //adrDeviceLogEntity.LogData = stringAlarm; |
|
|
|
// //adrDeviceLogEntity.LogType = "1"; |
|
|
|
// //connmis.Execute("insert into ADR_DeviceLog(LogId,DeviceId, LogType, LogData, F_CreateDate, F_CreateUserId, F_CreateUserName) values(" + |
|
|
|
// // "'" + adrDeviceLogEntity.LogId + "','" + adrDeviceLogEntity.DeviceId + "','" + adrDeviceLogEntity.LogType + "'," + |
|
|
|
// // "'" + adrDeviceLogEntity.LogData + "','" + adrDeviceLogEntity.F_CreateDate + "','system','自动化服务')"); |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //该用户当日有签到记录视为下班签退 |
|
|
|
// var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>("select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'"); |
|
|
|
// //首先判断上午考勤还是下午考勤 |
|
|
|
// //如果小于中午下班时间 |
|
|
|
// if (devicetime < offworkDateTimelunch) |
|
|
|
// { |
|
|
|
// //迟到 |
|
|
|
// //无上班记录视为迟到 |
|
|
|
// if (attendancerecord.Count(m => m.ADType == "1") == 0) |
|
|
|
// { |
|
|
|
// //上班迟到 |
|
|
|
// //获取迟到范围 |
|
|
|
// if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
// { |
|
|
|
// DateTime workDateTimeFree = workDateTime.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
// if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "2";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "2";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// //早退 |
|
|
|
// //有签到记录视为早退 |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //获取早退范围 |
|
|
|
// if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
// { |
|
|
|
// //最早签退时间 |
|
|
|
// DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
// if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
// { |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else//超出早退范围视为早退 |
|
|
|
// { |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
// } |
|
|
|
// else if (devicetime > workDateTimelunch)//如果大于中午上班时间,且上级if判断小于下班时间 |
|
|
|
// //判断为下午上班打卡迟到或早退 |
|
|
|
// { |
|
|
|
// //如果存在中午签到记录 |
|
|
|
// //判断为下班早退 |
|
|
|
// if (attendancerecord.Count(m => m.ADType == "7") > 0) |
|
|
|
// { |
|
|
|
// //早退判断 |
|
|
|
// //获取早退范围 |
|
|
|
// if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
// { |
|
|
|
// DateTime offworkDateTimeFree = offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
// if (devicetime >= offworkDateTimeFree)//在允许早退范围内记为正常 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else//超出早退范围视为早退 |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "2";//下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //获取迟到范围 |
|
|
|
// if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
// { |
|
|
|
// //最晚签到时间 |
|
|
|
// DateTime workDateTimeFree = workDateTimelunch.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
// if (devicetime <= workDateTimeFree)//在允许迟到范围内记为正常 |
|
|
|
// { |
|
|
|
// ADType = "7";//中午上班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "7";//中午上班 |
|
|
|
// ClockStatus = "2";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// ADType = "7";//中午上班 |
|
|
|
// ClockStatus = "2";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
//} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); |
|
|
|
adrRecordEntity.Create(); |
|
|
|
adrRecordEntity.UserNo = EmpNo; |
|
|
@@ -830,6 +1047,137 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 判断当前时间是否可以打卡 |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
public bool IsAttendance() |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
//当前服务器日期 |
|
|
|
var datenow = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
|
|
|
|
var datetimenow = DateTime.Now; |
|
|
|
var EmpNo = LoginUserInfo.Get().account; |
|
|
|
|
|
|
|
//首先获取考勤规则 |
|
|
|
var attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity<ADR_RestrictionEntity>(m => m.REnable == true); |
|
|
|
//上班时间 |
|
|
|
DateTime workDateTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.WorkTime); |
|
|
|
//上班考勤时间段 |
|
|
|
DateTime signInStartTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInStartTime); |
|
|
|
DateTime signInEndTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInEndTime); |
|
|
|
|
|
|
|
//下班时间 |
|
|
|
DateTime offworkDateTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.CloseTime); |
|
|
|
//下班考勤时间段 |
|
|
|
DateTime signOutStartTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutStartTime); |
|
|
|
DateTime signOutEndTime = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutEndTime); |
|
|
|
|
|
|
|
//小于上班考勤开始时间或大于下班考勤结束时间,不允许打卡 |
|
|
|
if (datetimenow < signInStartTime || datetimenow > signOutEndTime) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
string strTimeYear = (datetimenow.Year).ToString(); |
|
|
|
string strTimeMonth = (datetimenow.Month).ToString("d2"); |
|
|
|
string strTimeDay = (datetimenow.Day).ToString("d2"); |
|
|
|
//该用户当日签到记录 |
|
|
|
var attendancerecordList = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>( |
|
|
|
"select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + |
|
|
|
strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'").ToList(); |
|
|
|
|
|
|
|
//下班最早签退时间 |
|
|
|
DateTime offworkDateTimeFree = signOutStartTime; |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0 |
|
|
|
) //如果允许早退,获取范围 |
|
|
|
{ |
|
|
|
offworkDateTimeFree = |
|
|
|
offworkDateTime.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
} |
|
|
|
if (attendancerulEntity.ClockTime == "二次打卡") |
|
|
|
{ |
|
|
|
//上班 |
|
|
|
if (datetimenow > signInStartTime && datetimenow < offworkDateTimeFree && attendancerecordList.Count(x => x.ADType == "1") > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//下班 |
|
|
|
else if (datetimenow > offworkDateTimeFree && datetimenow < signOutEndTime && attendancerecordList.Count(x => x.ADType == "2") > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
else//四次打卡 |
|
|
|
{ |
|
|
|
//中午下班时间 |
|
|
|
DateTime offworkDateTimelunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.NoonCloseTime); |
|
|
|
//中午下班考勤时间段 |
|
|
|
DateTime offworkstartlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutStartTime2); |
|
|
|
DateTime offworkendlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutEndTime2); |
|
|
|
|
|
|
|
//中午上班时间 |
|
|
|
DateTime workDateTimelunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.NoonWorkTime); |
|
|
|
//中午上班考勤时间段 |
|
|
|
DateTime workstartlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInStartTime2); |
|
|
|
DateTime workendlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInEndTime2); |
|
|
|
|
|
|
|
//中午最早签退时间,默认中午下班开始时间。 |
|
|
|
DateTime offworkDateTimelunchFree = offworkstartlunch; |
|
|
|
if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) //如果允许早退,获取范围 |
|
|
|
{ |
|
|
|
offworkDateTimelunchFree = |
|
|
|
offworkDateTimelunch.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
} |
|
|
|
////中午最晚签到时间 |
|
|
|
//DateTime workDateTimelunchFree = workendlunch; |
|
|
|
////获取迟到范围 |
|
|
|
//if (attendancerulEntity.LateOvertime.HasValue && attendancerulEntity.LateOvertime != 0) |
|
|
|
//{ |
|
|
|
// workDateTimelunchFree = workDateTimelunch.AddMinutes(Convert.ToDouble(attendancerulEntity.LateOvertime)); |
|
|
|
//} |
|
|
|
|
|
|
|
//上班 大于上班开始时间 ,小于中午最早签退时间 |
|
|
|
if (datetimenow > signInStartTime && datetimenow < offworkDateTimelunchFree && attendancerecordList.Count(x => x.ADType == "1") > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//中午下班 大于中午最早签退时间,小于 中午下班结束时间 |
|
|
|
else if (datetimenow > offworkDateTimelunchFree && datetimenow < offworkendlunch && attendancerecordList.Count(x => x.ADType == "8") > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//中午上班 大于中午上班开始时间,小于下班最早签退时间 |
|
|
|
else if (datetimenow > workstartlunch && datetimenow < offworkDateTimeFree && |
|
|
|
attendancerecordList.Count(x => x.ADType == "7") > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//下班 大于下班最早签退时间,小于 下班结束时间 |
|
|
|
else if (datetimenow > offworkDateTimeFree && datetimenow < signOutEndTime && attendancerecordList.Count(x => x.ADType == "2") > 0) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
if (ex is ExceptionEx) |
|
|
|
{ |
|
|
|
throw; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw ExceptionEx.ThrowServiceException(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
public ADR_RestrictionEntity GetADR_RestrictionEntityEnabled() |
|
|
|