|
|
@@ -1,9 +1,12 @@ |
|
|
|
using Dapper; |
|
|
|
using Learun.Application.TwoDevelopment.EducationalAdministration; |
|
|
|
using Learun.Application.TwoDevelopment.LogisticsManagement; |
|
|
|
using Learun.DataBase.Repository; |
|
|
|
using Learun.Util; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Data; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
|
|
|
|
namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
@@ -205,5 +208,652 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 打卡 |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
public bool ClockIn(decimal ALon, decimal ALat, bool AIsOut, string ARemark, string ADPhoto, string ClockPlace, string img) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
// var attendancerulEntity = this.BaseRepository("CollegeMIS").FindEntity<ADR_RestrictionEntity>(m => m.REnable == true); |
|
|
|
var userinfo = LoginUserInfo.Get(); |
|
|
|
//员工账号 |
|
|
|
string EmpNo = userinfo.account; |
|
|
|
var empInfo = this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicEntity>(x => x.StuCode == EmpNo); |
|
|
|
if (empInfo == null) |
|
|
|
{ |
|
|
|
throw new Exception("未找到该同学"); |
|
|
|
} |
|
|
|
|
|
|
|
//考勤状态 |
|
|
|
string ADType = "1"; |
|
|
|
//考勤结果 |
|
|
|
string ClockStatus = "1"; |
|
|
|
//当前服务器日期 |
|
|
|
var datenow = DateTime.Now.ToString("yyyy-MM-dd"); |
|
|
|
|
|
|
|
var datetimenow = DateTime.Now; |
|
|
|
|
|
|
|
//当前时间年月日时分秒 |
|
|
|
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); |
|
|
|
|
|
|
|
#region |
|
|
|
//上班时间 |
|
|
|
//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); |
|
|
|
|
|
|
|
////中午下班时间 |
|
|
|
//DateTime offworkDateTimelunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.NoonCloseTime); |
|
|
|
////中午上班时间 |
|
|
|
//DateTime workDateTimelunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.NoonWorkTime); |
|
|
|
////中午下班考勤时间段 |
|
|
|
//DateTime offworkstartlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutStartTime2); |
|
|
|
//DateTime offworkendlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignOutEndTime2); |
|
|
|
////中午上班考勤时间段 |
|
|
|
//DateTime workstartlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInStartTime2); |
|
|
|
//DateTime workendlunch = Convert.ToDateTime(datenow + " " + attendancerulEntity.SignInEndTime2); |
|
|
|
|
|
|
|
|
|
|
|
//var leaveTime = attendancerulEntity.LeaveOverTime ?? 0; |
|
|
|
//var overTime = attendancerulEntity.LateOvertime ?? 0; |
|
|
|
#endregion |
|
|
|
|
|
|
|
//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<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)//如果存在上班考勤记录 |
|
|
|
{ |
|
|
|
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; |
|
|
|
adrRecordEntity.UserNo = EmpNo; |
|
|
|
adrRecordEntity.ADType = ADType; |
|
|
|
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; |
|
|
|
adrRecordEntity.ALon = ALon; |
|
|
|
adrRecordEntity.ALat = ALat; |
|
|
|
//adrRecordEntity.AIsOut = AIsOut; |
|
|
|
//adrRecordEntity.ARemark = ARemark; |
|
|
|
adrRecordEntity.ADPhoto = ADPhoto; |
|
|
|
adrRecordEntity.ClockPlace = ClockPlace; |
|
|
|
//adrRecordEntity.Img = img; |
|
|
|
//adrRecordEntity.IsFit = true; |
|
|
|
////记录日志 |
|
|
|
//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 = "0"; |
|
|
|
//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','自动化服务')"); |
|
|
|
//去重 |
|
|
|
//获取当日考勤记录 |
|
|
|
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(); |
|
|
|
//签到去重 |
|
|
|
if (adrRecordEntity.ADType == "1" && attendancerecordlist.Count(m => m.ADType == "1") > 0)//签过到了 |
|
|
|
{ |
|
|
|
//每日保留第一次签到记录 |
|
|
|
return true; |
|
|
|
} |
|
|
|
//签退去重 |
|
|
|
if (adrRecordEntity.ADType == "2" && attendancerecordlist.Count(m => m.ADType == "2") > 0)//签过退了 |
|
|
|
{ |
|
|
|
//更新签退时间,签退状态 |
|
|
|
var firstoffworkentity = attendancerecordlist.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; |
|
|
|
} |
|
|
|
//考勤记录 |
|
|
|
this.BaseRepository("CollegeMIS").ExecuteBySql("insert into ADR_Record(ID, UserNo, ADType, ADTime, ClockTime, ClockStatus, ClockPlace, ADYear, ADMonth, ADDay, ADPhoto,ALon,ALat) values('" + adrRecordEntity.ID + "','" + adrRecordEntity.UserNo + "','" + adrRecordEntity.ADType + "','" + adrRecordEntity.ADTime + "','" + adrRecordEntity.ClockTime + "','" + adrRecordEntity.ClockStatus + "','" + adrRecordEntity.ClockPlace + "','" + adrRecordEntity.ADYear + "','" + adrRecordEntity.ADMonth + "','" + adrRecordEntity.ADDay + "','" + adrRecordEntity.ADPhoto + "'," + adrRecordEntity.ALon + "," + adrRecordEntity.ALat + ")"); |
|
|
|
//同步修改授课考勤打卡 |
|
|
|
//ClockInModifyTeachAttendance(adrRecordEntity); |
|
|
|
return true; |
|
|
|
//} |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 四次打卡 |
|
|
|
//else//四次打卡 |
|
|
|
//{ |
|
|
|
|
|
|
|
// //首先判断是否在中午考勤时间段 |
|
|
|
// //如果在中午下班考勤时间段 |
|
|
|
// if (offworkstartlunch <= devicetime && devicetime <= offworkendlunch) |
|
|
|
// { |
|
|
|
// //早退判断 |
|
|
|
// if (devicetime < offworkDateTimelunch) |
|
|
|
// { |
|
|
|
// //早退 |
|
|
|
// //允许早退判断 |
|
|
|
// if (attendancerulEntity.LeaveOverTime.HasValue && attendancerulEntity.LeaveOverTime != 0) |
|
|
|
// { |
|
|
|
// //中午下班最早签退时间 |
|
|
|
// DateTime offworkDateTimeFree = offworkDateTimelunch.AddMinutes(-Convert.ToDouble(attendancerulEntity.LeaveOverTime)); |
|
|
|
// if (devicetime > offworkDateTimeFree) |
|
|
|
// { |
|
|
|
// //正常 |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //早退 |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //早退 |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "3";//早退 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //正常 |
|
|
|
// ADType = "8";//中午下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// //写入考勤数据 |
|
|
|
// ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); |
|
|
|
// adrRecordEntity.Create(); |
|
|
|
// adrRecordEntity.UserNo = EmpNo; |
|
|
|
// adrRecordEntity.ADType = ADType; |
|
|
|
// 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; |
|
|
|
// adrRecordEntity.ALon = ALon; |
|
|
|
// adrRecordEntity.ALat = ALat; |
|
|
|
// adrRecordEntity.AIsOut = AIsOut; |
|
|
|
// adrRecordEntity.ARemark = ARemark; |
|
|
|
// adrRecordEntity.ADPhoto = ADPhoto; |
|
|
|
// adrRecordEntity.ClockPlace = ClockPlace; |
|
|
|
// adrRecordEntity.Img = img; |
|
|
|
// adrRecordEntity.IsFit = true; |
|
|
|
// ////记录日志 |
|
|
|
// //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 = "0"; |
|
|
|
// //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','自动化服务')"); |
|
|
|
|
|
|
|
// //考勤记录 |
|
|
|
// //去重 |
|
|
|
// 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(); |
|
|
|
// if (attendancerecordlist.Count(m => m.ADType == "8") > 0)//存在中午下班记录更新记录 |
|
|
|
// { |
|
|
|
// var firstoffworkentity = attendancerecordlist.FirstOrDefault(m => m.ADType == "8"); |
|
|
|
// firstoffworkentity.ADTime = datetimenow; |
|
|
|
// firstoffworkentity.ClockTime = devicetime; |
|
|
|
// firstoffworkentity.ClockStatus = ClockStatus; |
|
|
|
|
|
|
|
// this.BaseRepository("CollegeMIS").ExecuteBySql("update ADR_Record set ADTime='" + firstoffworkentity.ADTime + "',ClockTime='" + firstoffworkentity.ClockTime + "',ClockStatus='" + firstoffworkentity.ClockStatus + "',ADPhoto='" + firstoffworkentity.ADPhoto + "' where ID='" + firstoffworkentity.ID + "'"); |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// 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 + "')"); |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// //如果在中午上班考勤时间段 |
|
|
|
// else if (workstartlunch <= devicetime && devicetime <= workendlunch) |
|
|
|
// { |
|
|
|
// //迟到判断 |
|
|
|
// if (devicetime > workDateTimelunch) |
|
|
|
// { |
|
|
|
// //迟到 |
|
|
|
// //允许迟到判断 |
|
|
|
// 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";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
// //正常 |
|
|
|
// ADType = "7";//中午下班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// //写入考勤数据 |
|
|
|
// ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); |
|
|
|
// adrRecordEntity.Create(); |
|
|
|
// adrRecordEntity.UserNo = EmpNo; |
|
|
|
// adrRecordEntity.ADType = ADType; |
|
|
|
// 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; |
|
|
|
// 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 attendancerecordlist = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>("select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'").ToList(); |
|
|
|
// if (attendancerecordlist.Count(m => m.ADType == "7") == 0) |
|
|
|
// { |
|
|
|
// 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 + "')"); |
|
|
|
// } |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// else//不在中午考勤时间段判断迟到早退 |
|
|
|
// { |
|
|
|
|
|
|
|
// if (devicetime <= signInEndTime) |
|
|
|
// { |
|
|
|
// ADType = "1";//上班 |
|
|
|
// ClockStatus = "1";//正常 |
|
|
|
// } |
|
|
|
// else if (devicetime >= signOutStartTime) |
|
|
|
// { |
|
|
|
// 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 (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";//迟到 |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); |
|
|
|
// adrRecordEntity.Create(); |
|
|
|
// adrRecordEntity.UserNo = EmpNo; |
|
|
|
// adrRecordEntity.ADType = ADType; |
|
|
|
// 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; |
|
|
|
// 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 attendancerecordlist = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>("select * from ADR_Record where ADYear='" + strTimeYear + "' and ADMonth='" + strTimeMonth + "' and ADDay='" + strTimeDay + "' and UserNo='" + EmpNo + "'").ToList(); |
|
|
|
// //签到去重 |
|
|
|
// if (adrRecordEntity.ADType == "1" && attendancerecordlist.Count(m => m.ADType == "1") > 0)//签过到了 |
|
|
|
// { |
|
|
|
// //每日保留第一次签到记录 |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// //中午签到去重 |
|
|
|
// if (adrRecordEntity.ADType == "7" && attendancerecordlist.Count(m => m.ADType == "7") > 0)//中午签过到了 |
|
|
|
// { |
|
|
|
// //每日保留第一次中午签到记录 |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// //中午签退去重 |
|
|
|
// if (adrRecordEntity.ADType == "8" && attendancerecordlist.Count(m => m.ADType == "8") > 0)//中午签过退了 |
|
|
|
// { |
|
|
|
// //更新签退时间,签退状态 |
|
|
|
// var firstoffworkentity = attendancerecordlist.FirstOrDefault(m => m.ADType == "8"); |
|
|
|
// firstoffworkentity.ADTime = datetimenow; |
|
|
|
// firstoffworkentity.ClockTime = devicetime; |
|
|
|
// firstoffworkentity.ClockStatus = ClockStatus; |
|
|
|
// //firstoffworkentity.ADPhoto = str; |
|
|
|
// this.BaseRepository("CollegeMIS").ExecuteBySql("update ADR_Record set ADTime='" + firstoffworkentity.ADTime + "',ClockTime='" + firstoffworkentity.ClockTime + "',ClockStatus='" + firstoffworkentity.ClockStatus + "',ADPhoto='" + firstoffworkentity.ADPhoto + "' where ID='" + firstoffworkentity.ID + "'"); |
|
|
|
// return true; |
|
|
|
// } |
|
|
|
// //签退去重 |
|
|
|
// if (adrRecordEntity.ADType == "2" && attendancerecordlist.Count(m => m.ADType == "2") > 0)//签过退了 |
|
|
|
// { |
|
|
|
// //更新签退时间,签退状态 |
|
|
|
// var firstoffworkentity = attendancerecordlist.FirstOrDefault(m => m.ADType == "2"); |
|
|
|
// firstoffworkentity.ADTime = datetimenow; |
|
|
|
// firstoffworkentity.ClockTime = devicetime; |
|
|
|
// firstoffworkentity.ClockStatus = ClockStatus; |
|
|
|
// //firstoffworkentity.ADPhoto = str; |
|
|
|
// 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; |
|
|
|
// } |
|
|
|
// //考勤记录 |
|
|
|
// 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; |
|
|
|
// } |
|
|
|
|
|
|
|
//} |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
//return true; |
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
if (ex is ExceptionEx) |
|
|
|
{ |
|
|
|
throw; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
throw ExceptionEx.ThrowServiceException(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |