@@ -1,4 +1,6 @@
using Dapper;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Application.TwoDevelopment.PersonnelManagement;
using Learun.DataBase.Repository;
using Learun.Util;
@@ -250,6 +252,8 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
var queryParam = queryJson.ToJObject();
var datest = DateTime.Now.ToDateString();
var dateet = datest;
if (!queryParam["startTime"].IsEmpty())
{
datest = queryParam["startTime"].ToDate().ToDateString();
@@ -266,6 +270,32 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
{
return totalResult;
}
#region 查询参数
var userNo = string.Empty;
if (!queryParam["UserNo"].IsEmpty())
{
userNo = queryParam["UserNo"].ToString();
}
var userName = string.Empty;
if (!queryParam["UserName"].IsEmpty())
{
userName = queryParam["UserName"].ToString();
}
var deptId = string.Empty;
if (!queryParam["F_DepartmentId"].IsEmpty())
{
deptId = queryParam["F_DepartmentId"].ToString();
}
var clockStatus = string.Empty;
if (!queryParam["ClockStatus"].IsEmpty())
{
clockStatus = queryParam["ClockStatus"].ToString();
}
#endregion
//考勤时间段查询语句
var totalSql = new StringBuilder();
totalSql.Append("select top 100 percent * from ( ");
@@ -276,44 +306,45 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
var date = datest.ToDate().AddDays(i).ToDateString();
//当天查询语句
var strSql = new StringBuilder();
strSql.Append($"select u.F_Encode as UserNo,u.F_RealName as UserName,u.F_DepartmentId as Department,t.ID,t.ADphoto,t.ADType,emp.Photo,emp.CompilationCategory,t.img,t.IsFit,t.ADTime,t.ClockTime,t.ClockStatus,'{date}' as ClockDate ");
strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u ");
strSql.Append(" inner join EmpInfo emp on u.F_EnCode=emp.EmpNo ");
strSql.Append(" left join ADR_Record t on u.F_EnCode=t.UserNo and t.ADYear='" + date.Substring(0, 4) + "' and t.ADMonth='" + date.Substring(5, 2) + "' and t.ADDay='" + date.Substring(8, 2) + "' ");
strSql.Append(" where u.F_Description='教师' AND u.F_DeleteMark = 0 AND u.F_EnabledMark = 1 and u.F_Encode is not null ");
var UserNoPrev = Config.GetValue("ADR_RecordUserNoPrev");
if (!string.IsNullOrEmpty(UserNoPrev))
{
strSql.Append(" and u.F_encode like '" + UserNoPrev + "%' ");
}
strSql.Append($"select u.EmpNo as UserNo,u.EmpName as UserName,u.F_DepartmentId as Department,t.ID,t.ADphoto,t.ADType,u.Photo,u.CompilationCategory,t.img,t.IsFit,t.ADTime,t.ClockTime,t.ClockStatus,'{date}' as ClockDate ");
//strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u ");
strSql.Append(" from EmpInfo u ");
//strSql.Append(" inner join EmpInfo emp on u.F_EnCode=emp.EmpNo ");
strSql.Append(" left join ADR_Record t on u.EmpNo=t.UserNo and t.ADYear='" + date.Substring(0, 4) + "' and t.ADMonth='" + date.Substring(5, 2) + "' and t.ADDay='" + date.Substring(8, 2) + "' where 1=1 ");
//strSql.Append(" where u.F_Description='教师' AND u.F_DeleteMark = 0 AND u.F_EnabledMark = 1 and u.F_Encode is not null ");
//var UserNoPrev = Config.GetValue("ADR_RecordUserNoPrev");
//if (!string.IsNullOrEmpty(UserNoPrev))
//{
// strSql.Append(" and u.F_encode like '" + UserNoPrev + "%' ");
//}
// 虚拟参数
if (!q ueryParam["U serNo"] .IsEmpty())
if (!userNo.IsEmpty())
{
strSql.Append($" AND u.F_EnCode = '{queryParam["UserNo"].ToString() }' ");
strSql.Append($" AND u.EmpNo = '{userNo }' ");
}
if (!q ueryParam["U serName"] .IsEmpty())
if (!userName.IsEmpty())
{
strSql.Append($" AND u.F_RealName Like '%{queryParam["UserName"].ToString() }%' ");
strSql.Append($" AND u.EmpName Like '%{userName }%' ");
}
if (!queryParam["F_DepartmentId"] .IsEmpty())
if (!deptId .IsEmpty())
{
strSql.Append($" AND emp.F_DepartmentId = '{queryParam["F_DepartmentId"].ToString() }' ");
strSql.Append($" AND u.F_DepartmentId = '{deptId }' ");
}
if (!queryParam["ClockStatus"] .IsEmpty())
if (!clockStatus .IsEmpty())
{
//if (queryParam["ClockStatus"].ToString() == "6" || queryParam["ClockStatus"].ToString() == "0")//缺勤、旷工
if (queryParam["ClockStatus"].ToString() == "0")
if (clockStatus == "0")
{
strSql.Append(" AND t.ClockStatus is null ");
}
else if(queryParam["ClockStatus"].ToString() == "6")
else if (clockStatus == "6")
{
}
else
{
strSql.Append($" AND t.ClockStatus = '{queryParam["ClockStatus"].ToString() }' ");
strSql.Append($" AND t.ClockStatus = '{clockStatus }' ");
}
}
totalSql.Append(strSql);
@@ -325,13 +356,13 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
totalSql.Append(" ) as bb where 1=1 order by bb.ClockDate");
//当天记录列表
var data = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>(totalSql.ToString())
.GroupBy(x => new { x.UserNo, x.UserName, x.Department, x.ClockDate,x.CompilationCategory }).Select(x => new
.GroupBy(x => new { x.UserNo, x.UserName, x.Department, x.ClockDate, x.CompilationCategory }).Select(x => new
{
UserNo = x.Key.UserNo,
UserName = x.Key.UserName,
Department = x.Key.Department,
ClockDate = x.Key.ClockDate,
CompilationCategory=x.Key.CompilationCategory,
CompilationCategory = x.Key.CompilationCategory,
Group = x.Select(y => new ADR_RecordEntity()
{
ADType = y.ADType,
@@ -340,7 +371,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
ClockStatus = y.ClockStatus,
Photo = y.Photo,
IsFit = y.IsFit,
Img=y.Img
Img = y.Img
})
}).ToList();
@@ -364,7 +395,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
CompilationCategory=item.CompilationCategory,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 0,
@@ -419,7 +450,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 1,
ADPhoto = adtype2 != null ? adtype2.ADPhoto:"",
ADPhoto = adtype2 != null ? adtype2.ADPhoto : "",
TimePeriod = string.Format("上午上下班({0}-{1})", restrictionEntity.WorkTime, restrictionEntity.NoonCloseTime),
ADStatusWork = adtype1 != null ? adtype1.ClockStatus : "6",
ADStatusClose = adtype8 != null ? adtype8.ClockStatus : "6",
@@ -460,23 +491,23 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
#endregion
}
if (!queryParam["ClockStatus"] .IsEmpty())
if (!clockStatus .IsEmpty())
{
var ClockStatus = queryParam["ClockStatus"].ToString();
if(ClockStatus== "6")
// var ClockStatus = queryParam["ClockStatus"].ToString();
if (clockStatus == "6")
{
totalResult = totalResult.Where(x => x.ADStatusWork == ClockStatus || x.ADStatusClose == C lockStatus).ToList();
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus || x.ADStatusClose == c lockStatus).ToList();
}
if(ClockStatus== "1")
if (clockStatus == "1")
{
totalResult = totalResult.Where(x => x.ADStatusWork == ClockStatus && x.ADStatusClose == C lockStatus).ToList();
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus && x.ADStatusClose == c lockStatus).ToList();
}
//totalResult.Where(x => x.ClockStatus == ClockStatus);
}
var result= totalResult;
if (pagination.sidx== "UserName")
var result = totalResult;
if (pagination.sidx == "UserName")
{
if (pagination.sord=="ASC")
if (pagination.sord == "ASC")
{
result = totalResult.OrderBy(x => x.UserName).ToList();
}
@@ -522,12 +553,292 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
}
}
public IEnumerable<ADR_RecordEntity> GetStatisticDetailList(string queryJson)
{
try
{
var basedbname = BaseRepository().getDbConnection().Database;
var queryParam = queryJson.ToJObject();
var datest = DateTime.Now.ToDateString();
var dateet = datest;
if (!queryParam["startTime"].IsEmpty())
{
datest = queryParam["startTime"].ToDate().ToDateString();
}
if (!queryParam["endTime"].IsEmpty())
{
dateet = queryParam["endTime"].ToDate().ToDateString();
}
//考勤时间段查询结果
var totalResult = new List<ADR_RecordEntity>();
//启用的考勤规则
var restrictionEntity = this.BaseRepository("CollegeMIS").FindEntity<ADR_RestrictionEntity>(m => m.REnable == true);
if (restrictionEntity == null)
{
return totalResult;
}
#region 查询参数
var userNo = string.Empty;
if (!queryParam["UserNo"].IsEmpty())
{
userNo = queryParam["UserNo"].ToString();
}
var userName = string.Empty;
if (!queryParam["UserName"].IsEmpty())
{
userName = queryParam["UserName"].ToString();
}
var deptId = string.Empty;
if (!queryParam["F_DepartmentId"].IsEmpty())
{
deptId = queryParam["F_DepartmentId"].ToString();
}
var clockStatus = string.Empty;
if (!queryParam["ClockStatus"].IsEmpty())
{
clockStatus = queryParam["ClockStatus"].ToString();
}
#endregion
//考勤时间段查询语句
var totalSql = new StringBuilder();
totalSql.Append("select top 100 percent * from ( ");
//考勤时间段查询
for (int i = 0; i < (dateet.ToDate() - datest.ToDate()).Days + 1; i++)
{
//当天日期
var date = datest.ToDate().AddDays(i).ToDateString();
//当天查询语句
var strSql = new StringBuilder();
strSql.Append($"select u.EmpNo as UserNo,u.EmpName as UserName,u.F_DepartmentId as Department,d.F_FullName as DepartmentName,t.ID,t.ADphoto,t.ADType,u.Photo,u.CompilationCategory,t.img,t.IsFit,t.ADTime,t.ClockTime,t.ClockStatus,'{date}' as ClockDate ");
//strSql.Append(" from " + basedbname + ".dbo.LR_Base_User u ");
strSql.Append(" from EmpInfo u ");
strSql.Append(" left join " + basedbname + ".dbo.LR_Base_Department d on u.F_DepartmentId=d.F_DepartmentId ");
//strSql.Append(" inner join EmpInfo emp on u.F_EnCode=emp.EmpNo ");
strSql.Append(" left join ADR_Record t on u.EmpNo=t.UserNo and t.ADYear='" + date.Substring(0, 4) + "' and t.ADMonth='" + date.Substring(5, 2) + "' and t.ADDay='" + date.Substring(8, 2) + "' where 1=1 ");
//strSql.Append(" where u.F_Description='教师' AND u.F_DeleteMark = 0 AND u.F_EnabledMark = 1 and u.F_Encode is not null ");
//var UserNoPrev = Config.GetValue("ADR_RecordUserNoPrev");
//if (!string.IsNullOrEmpty(UserNoPrev))
//{
// strSql.Append(" and u.F_encode like '" + UserNoPrev + "%' ");
//}
// 虚拟参数
if (!userNo.IsEmpty())
{
strSql.Append($" AND u.EmpNo = '{userNo}' ");
}
if (!userName.IsEmpty())
{
strSql.Append($" AND u.EmpName Like '%{userName}%' ");
}
if (!deptId.IsEmpty())
{
strSql.Append($" AND u.F_DepartmentId = '{deptId}' ");
}
if (!clockStatus.IsEmpty())
{
//if (queryParam["ClockStatus"].ToString() == "6" || queryParam["ClockStatus"].ToString() == "0")//缺勤、旷工
if (clockStatus == "0")
{
strSql.Append(" AND t.ClockStatus is null ");
}
else if (clockStatus == "6")
{
}
else
{
strSql.Append($" AND t.ClockStatus = '{clockStatus}' ");
}
}
totalSql.Append(strSql);
if (i < (dateet.ToDate() - datest.ToDate()).Days)
{
totalSql.Append(" union ");
}
}
totalSql.Append(" ) as bb where 1=1 order by bb.ClockDate");
//当天记录列表
var data = this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>(totalSql.ToString())
.GroupBy(x => new { x.UserNo, x.UserName, x.Department, x.DepartmentName, x.ClockDate, x.CompilationCategory }).Select(x => new
{
UserNo = x.Key.UserNo,
UserName = x.Key.UserName,
Department = x.Key.Department,
x.Key.DepartmentName,
ClockDate = x.Key.ClockDate,
CompilationCategory = x.Key.CompilationCategory,
Group = x.Select(y => new ADR_RecordEntity()
{
ADType = y.ADType,
ADPhoto = y.ADPhoto,
ClockTime = y.ClockTime,
ClockStatus = y.ClockStatus,
Photo = y.Photo,
IsFit = y.IsFit,
Img = y.Img
})
}).ToList();
if (restrictionEntity.ClockTime == "二次打卡")
{
#region 二次打卡
foreach (var item in data)
{
//上班时间
var WorkTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.WorkTime).ToDate();
//下班时间
var CloseTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.CloseTime).ToDate();
var WholeMinutes = (CloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//全天应工作分钟数
string photo = item.Group.FirstOrDefault().Photo;
var adtype1 = item.Group.FirstOrDefault(x => x.ADType == "1");//上班
var adtype2 = item.Group.FirstOrDefault(x => x.ADType == "2");//下班
//全天
var whole = new ADR_RecordEntity()
{
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
DepartmentName = item.DepartmentName,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 0,
ADPhoto = adtype2 != null ? adtype2.ADPhoto : "",
TimePeriod = string.Format("上下班({0}-{1})", restrictionEntity.WorkTime, restrictionEntity.CloseTime),
ADStatusWork = adtype1 != null ? adtype1.ClockStatus : "6",
ADStatusClose = adtype2 != null ? adtype2.ClockStatus : "6",
ClockTimeWork = adtype1 != null ? adtype1.ClockTime.ToTimeString() : "-",
ClockTimeClose = adtype2 != null ? adtype2.ClockTime.ToTimeString() : "-",
ChidaoMinutes = adtype1 != null ? adtype1.ClockStatus == "2" ? (adtype1.ClockTime.Value - WorkTimeTemp).TotalMinutes.ToInt() : 0 : 0,
ZaoTuiMinutes = adtype2 != null ? adtype2.ClockStatus == "3" ? (CloseTimeTemp - adtype2.ClockTime.Value).TotalMinutes.ToInt() : 0 : 0,
ChuQinMinutes = adtype1 != null && adtype2 != null ? (adtype2.ClockTime.Value - adtype1.ClockTime.Value).TotalMinutes.ToInt() : 0,
QueQinMinutes = adtype1 != null && adtype2 != null ? 0 : WholeMinutes,
RestMinutes = 0,
Photo = photo,// adtype1 != null && adtype2 != null ? adtype1.Photo: "",
IsFitstr = (adtype1 != null ? adtype1.IsFit.ToString() : "") + "," + (adtype2 != null ? adtype2.IsFit.ToString() : ""),
Img = (adtype1 != null ? adtype1.Img : "") + "," + (adtype2 != null ? adtype2.Img : ""),
};
whole.WorkMinutes = WholeMinutes == whole.QueQinMinutes ? 0 : WholeMinutes - whole.ChidaoMinutes - whole.ZaoTuiMinutes - whole.QueQinMinutes;
totalResult.Add(whole);
}
#endregion
}
else
{
#region 四次打卡
foreach (var item in data)
{
//上班时间
var WorkTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.WorkTime).ToDate();
//下班时间
var CloseTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity.CloseTime).ToDate();
//中午下班时间
var NoonCloseTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity?.NoonCloseTime).ToDate();
//中午上班时间
var NoonWorkTimeTemp = string.Format("{0} {1}", item.ClockDate, restrictionEntity?.NoonWorkTime).ToDate();
var MorningMinutes = (NoonCloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//上午应工作分钟数
var AfternoonMinutes = (CloseTimeTemp - NoonWorkTimeTemp).TotalMinutes.ToInt();//下午应工作分钟数
var adtype1 = item.Group.FirstOrDefault(x => x.ADType == "1");//上班
var adtype8 = item.Group.FirstOrDefault(x => x.ADType == "8");//中午下班
var adtype7 = item.Group.FirstOrDefault(x => x.ADType == "7");//中午上班
var adtype2 = item.Group.FirstOrDefault(x => x.ADType == "2");//下班
//上午
var morning = new ADR_RecordEntity()
{
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 1,
ADPhoto = adtype2 != null ? adtype2.ADPhoto : "",
TimePeriod = string.Format("上午上下班({0}-{1})", restrictionEntity.WorkTime, restrictionEntity.NoonCloseTime),
ADStatusWork = adtype1 != null ? adtype1.ClockStatus : "6",
ADStatusClose = adtype8 != null ? adtype8.ClockStatus : "6",
ClockTimeWork = adtype1 != null ? adtype1.ClockTime.ToTimeString() : "-",
ClockTimeClose = adtype8 != null ? adtype8.ClockTime.ToTimeString() : "-",
ChidaoMinutes = adtype1 != null ? adtype1.ClockStatus == "2" ? (adtype1.ClockTime.Value - WorkTimeTemp).TotalMinutes.ToInt() : 0 : 0,
ZaoTuiMinutes = adtype8 != null ? adtype8.ClockStatus == "3" ? (NoonCloseTimeTemp - adtype8.ClockTime.Value).TotalMinutes.ToInt() : 0 : 0,
ChuQinMinutes = adtype1 != null && adtype8 != null ? (adtype8.ClockTime.Value - adtype1.ClockTime.Value).TotalMinutes.ToInt() : 0,
QueQinMinutes = adtype1 != null && adtype8 != null ? 0 : MorningMinutes,
RestMinutes = 0
};
morning.WorkMinutes = MorningMinutes == morning.QueQinMinutes ? 0 : MorningMinutes - morning.ChidaoMinutes - morning.ZaoTuiMinutes - morning.QueQinMinutes;
totalResult.Add(morning);
//下午
var afternoon = new ADR_RecordEntity()
{
UserNo = item.UserNo,
UserName = item.UserName,
Department = item.Department,
CompilationCategory = item.CompilationCategory,
ClockDate = item.ClockDate,
BanCi = "上下班",
TimePeriodNo = 2,
TimePeriod = string.Format("下午上下班({0}-{1})", restrictionEntity.NoonWorkTime, restrictionEntity.CloseTime),
ADStatusWork = adtype7 != null ? adtype7.ClockStatus : "6",
ADStatusClose = adtype2 != null ? adtype2.ClockStatus : "6",
ClockTimeWork = adtype7 != null ? adtype7.ClockTime.ToTimeString() : "-",
ClockTimeClose = adtype2 != null ? adtype2.ClockTime.ToTimeString() : "-",
ChidaoMinutes = adtype7 != null ? adtype7.ClockStatus == "2" ? (adtype7.ClockTime.Value - NoonWorkTimeTemp).TotalMinutes.ToInt() : 0 : 0,
ZaoTuiMinutes = adtype2 != null ? adtype2.ClockStatus == "3" ? (CloseTimeTemp - adtype2.ClockTime.Value).TotalMinutes.ToInt() : 0 : 0,
ChuQinMinutes = adtype7 != null && adtype2 != null ? (adtype2.ClockTime.Value - adtype7.ClockTime.Value).TotalMinutes.ToInt() : 0,
QueQinMinutes = adtype7 != null && adtype2 != null ? 0 : AfternoonMinutes,
RestMinutes = 0
};
afternoon.WorkMinutes = AfternoonMinutes == afternoon.QueQinMinutes ? 0 : AfternoonMinutes - afternoon.ChidaoMinutes - afternoon.ZaoTuiMinutes - afternoon.QueQinMinutes;
totalResult.Add(afternoon);
}
#endregion
}
if (!clockStatus.IsEmpty())
{
//var ClockStatus = queryParam["ClockStatus"].ToString();
if (clockStatus == "6")
{
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus || x.ADStatusClose == clockStatus).ToList();
}
if (clockStatus == "1")
{
totalResult = totalResult.Where(x => x.ADStatusWork == clockStatus && x.ADStatusClose == clockStatus).ToList();
}
//totalResult.Where(x => x.ClockStatus == ClockStatus);
}
var result = totalResult;
return result;// totalResult.OrderBy(x => x.ClockDate).ThenBy(x => x.UserNo).ThenBy(x => x.TimePeriodNo);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
public string GetStatisticDetailimg(string teachno)
{
var strSql = new StringBuilder();
strSql.Append("SELECT t.img ");
strSql.Append(" FROM ADR_Record t ");
strSql.Append(" WHERE 1=1 and userno='"+ teachno + "' and isfit=1 and img is not null");
strSql.Append(" WHERE 1=1 and userno='" + teachno + "' and isfit=1 and img is not null");
return this.BaseRepository("CollegeMIS").FindObject(strSql.ToString())?.ToString();
}
@@ -575,7 +886,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
}
if (string.IsNullOrWhiteSpace(entity.ADYear)) entity.ADYear = entity.ADTime.Value.Year.ToString();
if (string.IsNullOrWhiteSpace(entity.ADMonth)) entity.ADMonth = entity.ADTime.Value.Month.ToString().PadLeft(2, '0');
if (string.IsNullOrWhiteSpace(entity.ADDay)) entity.ADDay = entity.ADTime.Value.Day.ToString().PadLeft(2,'0');
if (string.IsNullOrWhiteSpace(entity.ADDay)) entity.ADDay = entity.ADTime.Value.Day.ToString().PadLeft(2, '0');
if (!string.IsNullOrEmpty(keyValue))
{
entity.Modify(keyValue);
@@ -590,7 +901,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement
entity.Create();
this.BaseRepository("CollegeMIS").Insert(entity);
}
//同步修改授课考勤打卡
aDR_RestrictionService.ClockInModifyTeachAttendance(entity);
}