Commit 804116dd by wyc

考勤上报保存或者提交审核时,判断其他科室是否有冲突的考勤

parent 1b6f6799
......@@ -1569,13 +1569,16 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId);
var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && unitTypes.Contains(w.UnitType) && accountingUnit.Equals(w.AccountingUnit))
?? new List<per_attendance_dept>();
var perAttendanceDepts = _attendanceDeptRepository.GetEntities(w => w.AllotId == allotId) ?? new List<per_attendance_dept>();
var attendances = perAttendanceDepts?.Where((w) => w.AllotId == allotId && unitTypes.Contains(w.UnitType) && accountingUnit.Equals(w.AccountingUnit)).ToList();
var stateCount = attendances.GroupBy(w => w.State).Select(w => new { w.Key, StateCount = w.Count() }).ToList();
if (attendances.Count() > 0 && attendances.Count() == attendances.Count(w => w.State == (int)Attendance.Report.通过))
throw new PerformanceException("当前考勤已审核通过,无法提交!");
//查询是否在其他科室的考勤记录
var data_Numbers = datas.Select(w => w.PersonnelNumber).ToList();
var attendanceDepts = perAttendanceDepts?.Where(w => w.AllotId == allotId && data_Numbers.Contains(w.PersonnelNumber) && unitType != w.UnitType && accountingUnit != w.AccountingUnit).ToList();
List<per_attendance_dept> newAttendanceDepts = new List<per_attendance_dept>();
List<per_attendance_dept> updAttendanceDepts = new List<per_attendance_dept>();
List<int> validAttendanceId = new List<int>();
......@@ -1692,6 +1695,29 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
}
}
foreach (var attendanceDept in attendanceDepts)
{
if (row.PersonnelNumber.Equals(attendanceDept.PersonnelNumber))
{
for (int i = 1; i <= 31; i++)
{
var attendanceDeptValue = (object)typeof(per_attendance_dept).GetProperty("Day" + i.ToString("D2"))?.GetValue(attendanceDept);
var dataValue = (object)typeof(AttendanceDept).GetProperty("Day" + i.ToString("D2"))?.GetValue(row);
if (!string.IsNullOrEmpty(attendanceDeptValue?.ToString()) && !string.IsNullOrEmpty(dataValue?.ToString()))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", attendanceDept.PersonnelNumber ?? "" },
{ "姓名", attendanceDept.PersonnelName ?? "" },
{ "人员系数", attendanceDept.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"{i.ToString("D2")}号存在考勤记录,所在科室为:{attendanceDept.AccountingUnit},请核实后重新填写"},
});
}
}
}
}
var accounting = cofaccounting.FirstOrDefault(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit);
var attendance = attendances.FirstOrDefault(w => w.PersonnelNumber == row.PersonnelNumber && w.UnitType == unitType.ToString() && w.AccountingUnit == accountingUnit);
......@@ -1783,6 +1809,7 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
validAttendanceId.Add(attendance.Id);
}
}
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment