@@ -16,12 +16,15 @@ namespace Learun.Application.WebApi.Modules | |||||
public class AttendanceApi : BaseApi | public class AttendanceApi : BaseApi | ||||
{ | { | ||||
public AttendanceApi() | public AttendanceApi() | ||||
: base("/learun/adms/attendance") | |||||
: base("/api/ht/attendance") | |||||
{ | { | ||||
//判断当前时间是否可以打卡 | //判断当前时间是否可以打卡 | ||||
//Get["/IsAttendance"] = IsAttendance; | //Get["/IsAttendance"] = IsAttendance; | ||||
//上下班打卡 | //上下班打卡 | ||||
Post["/clockin"] = ClockIn; | Post["/clockin"] = ClockIn; | ||||
Get["/clockstat"] = ClockStat; | |||||
//获取考勤打卡记录 | //获取考勤打卡记录 | ||||
//Get["/getrecordpagelist"] = GetRecordPageList; | //Get["/getrecordpagelist"] = GetRecordPageList; | ||||
//判断学生当前打卡状态 | //判断学生当前打卡状态 | ||||
@@ -44,18 +47,34 @@ namespace Learun.Application.WebApi.Modules | |||||
private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL(); | 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 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> | ||||
/// 判断当前时间是否可以打卡 | /// 判断当前时间是否可以打卡 | ||||
/// </summary> | /// </summary> | ||||
@@ -113,34 +132,27 @@ namespace Learun.Application.WebApi.Modules | |||||
var userinfo = LoginUserInfo.Get(); | var userinfo = LoginUserInfo.Get(); | ||||
//员工账号 | //员工账号 | ||||
string EmpNo = userinfo.account; | 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 | |||||
/// </summary> | /// </summary> | ||||
/// <param name="_"></param> | /// <param name="_"></param> | ||||
/// <returns></returns> | /// <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); | |||||
//} | |||||
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> | ||||
/// 教师上下课打卡:判断当前打卡状态 | /// 教师上下课打卡:判断当前打卡状态 | ||||
@@ -209,7 +209,26 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||||
} | } | ||||
} | } | ||||
#endregion | |||||
#endregion | |||||
public Tuple<int, string, int, string> GetTodayClock(string acc) | |||||
{ | |||||
try | |||||
{ | |||||
return aDR_RecordService.GetTodayClock(acc); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
if (ex is ExceptionEx) | |||||
{ | |||||
throw; | |||||
} | |||||
else | |||||
{ | |||||
throw ExceptionEx.ThrowBusinessException(ex); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,6 +1,7 @@ | |||||
using Learun.Util; | using Learun.Util; | ||||
using System.Data; | using System.Data; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System; | |||||
namespace Learun.Application.TwoDevelopment.LogisticsManagement | namespace Learun.Application.TwoDevelopment.LogisticsManagement | ||||
{ | { | ||||
@@ -68,5 +69,6 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||||
void SaveEntity(string keyValue, ADR_RecordEntity entity); | void SaveEntity(string keyValue, ADR_RecordEntity entity); | ||||
#endregion | #endregion | ||||
Tuple<int, string, int, string> GetTodayClock(string acc); | |||||
} | } | ||||
} | } |
@@ -458,6 +458,42 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement | |||||
} | } | ||||
} | } | ||||
#endregion | #endregion | ||||
public Tuple<int, string, int, string> 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<ADR_RecordEntity>(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<int, string, int, string>(sbstat,sbsj,xbstat,xbsj); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
if (ex is ExceptionEx) | |||||
{ | |||||
throw; | |||||
} | |||||
else | |||||
{ | |||||
throw ExceptionEx.ThrowServiceException(ex); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -280,24 +280,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
//2021.12.30 上下班设置时间段打卡 | //2021.12.30 上下班设置时间段打卡 | ||||
#region 二次打卡 | #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>( | var attendancerecord = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>( | ||||
@@ -309,59 +292,9 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
{ | { | ||||
ADType = "2";//下班 | 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(); | ADR_RecordEntity adrRecordEntity = new ADR_RecordEntity(); | ||||
adrRecordEntity.Create(); | adrRecordEntity.Create(); | ||||
adrRecordEntity.UserName = userinfo.realName; | adrRecordEntity.UserName = userinfo.realName; | ||||
@@ -370,14 +303,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||||
adrRecordEntity.ADTime = datetimenow; | adrRecordEntity.ADTime = datetimenow; | ||||
adrRecordEntity.ClockTime = devicetime; | adrRecordEntity.ClockTime = devicetime; | ||||
adrRecordEntity.ClockStatus = ClockStatus; | adrRecordEntity.ClockStatus = ClockStatus; | ||||
//if (deviceEntity != null && !string.IsNullOrEmpty(deviceEntity.DName)) | |||||
//{ | |||||
// adrRecordEntity.ClockPlace = deviceEntity.DName; | |||||
//} | |||||
//else | |||||
//{ | |||||
// adrRecordEntity.ClockPlace = "未知"; | |||||
//} | |||||
adrRecordEntity.ADYear = strTimeYear; | adrRecordEntity.ADYear = strTimeYear; | ||||
adrRecordEntity.ADMonth = strTimeMonth; | adrRecordEntity.ADMonth = strTimeMonth; | ||||
adrRecordEntity.ADDay = strTimeDay; | adrRecordEntity.ADDay = strTimeDay; | ||||