|
|
@@ -83,7 +83,7 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement |
|
|
|
dp.Add("ADStatus", queryParam["ADStatus"].ToString(), DbType.String); |
|
|
|
strSql.Append(" AND t.ClockStatus = @ADStatus "); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.BaseRepository("CollegeMIS").FindList<ADR_RecordEntity>(strSql.ToString(), dp, pagination); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
@@ -289,69 +289,114 @@ namespace Learun.Application.TwoDevelopment.LogisticsManagement |
|
|
|
ClockStatus = y.ClockStatus |
|
|
|
}) |
|
|
|
}); |
|
|
|
//启用的考勤规则 |
|
|
|
var restrictionEntity = this.BaseRepository("CollegeMIS").FindEntity<ADR_RestrictionEntity>(m => m.REnable == true); |
|
|
|
var WorkTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.WorkTime).ToDate(); |
|
|
|
var NoonCloseTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.NoonCloseTime).ToDate(); |
|
|
|
var NoonWorkTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.NoonWorkTime).ToDate(); |
|
|
|
var CloseTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.CloseTime).ToDate(); |
|
|
|
var MorningMinutes = (NoonCloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//上午应工作分钟数 |
|
|
|
var AfternoonMinutes = (CloseTimeTemp - NoonWorkTimeTemp).TotalMinutes.ToInt();//下午应工作分钟数 |
|
|
|
|
|
|
|
//结果列表 |
|
|
|
var result = new List<ADR_RecordEntity>(); |
|
|
|
foreach (var item in data) |
|
|
|
{ |
|
|
|
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() |
|
|
|
//启用的考勤规则 |
|
|
|
var restrictionEntity = this.BaseRepository("CollegeMIS").FindEntity<ADR_RestrictionEntity>(m => m.REnable == true); |
|
|
|
if (restrictionEntity != null) |
|
|
|
{ |
|
|
|
//上班时间 |
|
|
|
var WorkTimeTemp = string.Format("{0} {1}", date, restrictionEntity.WorkTime).ToDate(); |
|
|
|
//下班时间 |
|
|
|
var CloseTimeTemp = string.Format("{0} {1}", date, restrictionEntity.CloseTime).ToDate(); |
|
|
|
if (restrictionEntity.ClockTime == "二次打卡") |
|
|
|
{ |
|
|
|
UserNo = item.UserNo, |
|
|
|
UserName = item.UserName, |
|
|
|
Department = item.Department, |
|
|
|
ClockDate = date, |
|
|
|
BanCi = "上下班", |
|
|
|
TimePeriodNo = 1, |
|
|
|
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; |
|
|
|
result.Add(morning); |
|
|
|
//下午 |
|
|
|
var afternoon = new ADR_RecordEntity() |
|
|
|
#region 二次打卡 |
|
|
|
var WholeMinutes = (CloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//全天应工作分钟数 |
|
|
|
|
|
|
|
foreach (var item in data) |
|
|
|
{ |
|
|
|
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, |
|
|
|
ClockDate = date, |
|
|
|
BanCi = "上下班", |
|
|
|
TimePeriodNo = 0, |
|
|
|
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 |
|
|
|
}; |
|
|
|
whole.WorkMinutes = WholeMinutes == whole.QueQinMinutes ? 0 : WholeMinutes - whole.ChidaoMinutes - whole.ZaoTuiMinutes - whole.QueQinMinutes; |
|
|
|
result.Add(whole); |
|
|
|
} |
|
|
|
#endregion |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
UserNo = item.UserNo, |
|
|
|
UserName = item.UserName, |
|
|
|
Department = item.Department, |
|
|
|
ClockDate = date, |
|
|
|
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; |
|
|
|
result.Add(afternoon); |
|
|
|
} |
|
|
|
#region 四次打卡 |
|
|
|
//中午下班时间 |
|
|
|
var NoonCloseTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.NoonCloseTime).ToDate(); |
|
|
|
//中午上班时间 |
|
|
|
var NoonWorkTimeTemp = string.Format("{0} {1}", date, restrictionEntity?.NoonWorkTime).ToDate(); |
|
|
|
var MorningMinutes = (NoonCloseTimeTemp - WorkTimeTemp).TotalMinutes.ToInt();//上午应工作分钟数 |
|
|
|
var AfternoonMinutes = (CloseTimeTemp - NoonWorkTimeTemp).TotalMinutes.ToInt();//下午应工作分钟数 |
|
|
|
|
|
|
|
foreach (var item in data) |
|
|
|
{ |
|
|
|
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, |
|
|
|
ClockDate = date, |
|
|
|
BanCi = "上下班", |
|
|
|
TimePeriodNo = 1, |
|
|
|
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; |
|
|
|
result.Add(morning); |
|
|
|
//下午 |
|
|
|
var afternoon = new ADR_RecordEntity() |
|
|
|
{ |
|
|
|
UserNo = item.UserNo, |
|
|
|
UserName = item.UserName, |
|
|
|
Department = item.Department, |
|
|
|
ClockDate = date, |
|
|
|
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; |
|
|
|
result.Add(afternoon); |
|
|
|
} |
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
return result.OrderBy(x => x.UserNo).ThenBy(x => x.UserName).ThenBy(x => x.TimePeriodNo); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|