Commit 93cf0e94 by wyc

考勤上报(把保存时重复考勤的限制,改成了提交时才检查重复)

parent 845144e9
......@@ -1626,13 +1626,13 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
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 attendances = perAttendanceDepts?.Where((w) => unitTypes.Contains(w.UnitType) && accountingUnit.Equals(w.AccountingUnit)).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();
//var data_Numbers = datas.Select(w => w.PersonnelNumber).ToList();
//var attendanceDepts = perAttendanceDepts?.Where(w => 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>();
......@@ -1747,27 +1747,27 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
});
}
foreach (var attendanceDept in attendanceDepts.Where(a => row.PersonnelNumber.Equals(a.PersonnelNumber)))
{
for (int day = 1; day <= 31; day++)
{
string dayPropertyName = $"Day{day:00}";
var attendanceDeptValue = typeof(per_attendance_dept).GetProperty(dayPropertyName)?.GetValue(attendanceDept);
var dataValue = typeof(AttendanceDept).GetProperty(dayPropertyName)?.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() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"{day}号存在考勤记录,所在科室为:{attendanceDept.AccountingUnit},请核实后重新填写"},
});
}
}
}
//foreach (var attendanceDept in attendanceDepts.Where(a => row.PersonnelNumber.Equals(a.PersonnelNumber)))
//{
// for (int day = 1; day <= 31; day++)
// {
// string dayPropertyName = $"Day{day:00}";
// var attendanceDeptValue = typeof(per_attendance_dept).GetProperty(dayPropertyName)?.GetValue(attendanceDept);
// var dataValue = typeof(AttendanceDept).GetProperty(dayPropertyName)?.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() ?? "" },
// { "考勤类型", "" },
// { "错误原因", $"{day}号存在考勤记录,所在科室为:{attendanceDept.AccountingUnit},请核实后重新填写"},
// });
// }
// }
//}
var accounting = cofaccounting.Find(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit);
var attendance = attendances.Find(w => w.PersonnelNumber == row.PersonnelNumber && w.UnitType == unitType.ToString() && w.AccountingUnit == accountingUnit);
......@@ -1969,10 +1969,15 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
string queryAccountingUnit = userInfo.User.Department;
if (!queryUnitTypes.Contains(unitType)) throw new PerformanceException("当前用户角色与“核算组别”不匹配");
var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.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) => queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit)).ToList();
if (!attendances.Any()) return new ApiResponse(ResponseType.OK, "暂无数据,无需提交!");
int[] states = { (int)Attendance.Report.通过, (int)Attendance.Report.提交 };
//查询是否在其他科室的考勤记录
var data_Numbers = attendances.Select(w => w.PersonnelNumber).ToList();
var attendanceDepts = perAttendanceDepts?.Where(w => data_Numbers.Contains(w.PersonnelNumber) && unitType != w.UnitType && queryAccountingUnit != w.AccountingUnit && w.State.Equals(states)).ToList();
var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId);
var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>();
......@@ -1980,7 +1985,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
foreach (var item in attendances.Select((row, ind) => (row, ind)))
{
var row = item.row;
if (string.IsNullOrEmpty(row.PersonnelNumber) || string.IsNullOrEmpty(row.PersonnelNumber))
if (string.IsNullOrEmpty(row.PersonnelNumber))
{
error.Add(new Dictionary<string, string>
{
......@@ -2102,13 +2107,33 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
continue;
}
foreach (var attendanceDept in attendanceDepts.Where(a => row.PersonnelNumber.Equals(a.PersonnelNumber)))
{
for (int day = 1; day <= 31; day++)
{
string dayPropertyName = $"Day{day:00}";
var attendanceDeptValue = typeof(per_attendance_dept).GetProperty(dayPropertyName)?.GetValue(attendanceDept);
var dataValue = typeof(AttendanceDept).GetProperty(dayPropertyName)?.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() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"{day}号已提交考勤记录,所在科室为:{attendanceDept.AccountingUnit},请勿重复提交"},
});
}
}
}
}
if (error.Count > 0)
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
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.通过))
if (attendances.Count > 0 && attendances.Count == attendances.Count(w => w.State == (int)Attendance.Report.通过))
throw new PerformanceException("当前考勤已审核通过,无法提交!");
var submitTime = DateTime.Now;
......
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