Commit 0e7acd0c by ruyun.zhang

提交验证,下载修改为统一样式

parent 43e9ea87
......@@ -812,29 +812,19 @@ public ApiResponse<AttendanceDeptDetail> DeptDetail(int allotId, string unitType
/// <param name="unitType">核算组别</param>
/// <param name="accountingUnit">核算单元</param>
/// <param name="searchTxet">工号/姓名</param>
/// <param name="fileName"></param>
/// <returns></returns>
[HttpPost]
[Route("dept/detail/download")]
public IActionResult DeptDetailDownload(int allotId, string unitType, string accountingUnit, string searchTxet, string? fileName)
public IActionResult DeptDetailDownload(int allotId, string unitType, string accountingUnit, string searchTxet)
{
fileName = string.IsNullOrWhiteSpace(fileName) ? "考勤上报审核结果" : Path.GetFileNameWithoutExtension(fileName);
var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files");
if (!Directory.Exists(dpath)) Directory.CreateDirectory(dpath);
string filepath = Path.Combine(dpath, $"{fileName}{DateTime.Now:yyyyMMdd}.xlsx");
if (!Enum.TryParse(unitType, out UnitType unitType1))
throw new PerformanceException("核算组别错误");
var res = _attendanceService.DeptDetail(allotId, unitType, accountingUnit, searchTxet);
var config = new ExcelDownloadRequest() { Name = "考勤上报审核结果" };
if (res.State == ResponseType.OK)
{
var items = JsonHelper.Deserialize<List<Dictionary<string, object>>>(JsonHelper.Serialize(res.Data.Data));
config.Rows = items;
var columns = res.Data.Columns.Select(w => new EColumn(w.Title, w.Field));
config.Columns = columns;
}
var heads = res.Data.Columns.Select(w => new ExcelDownloadHeads { Alias = w.Title, Name = w.Field }).ToList();
var rows = JsonHelper.Deserialize<List<Dictionary<string, object>>>(JsonHelper.Serialize(res.Data.Data));
UtilExtensions.Export(filepath, config);
var filepath = _attendanceService.ExcelDownload(rows, "科室考勤上报结果详情", allotId, heads);
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......
......@@ -1941,11 +1941,143 @@ 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 attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit)) ?? new List<per_attendance_dept>();
if (!attendances.Any()) return new ApiResponse(ResponseType.OK, "暂无数据,无需提交!");
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>();
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
foreach (var item in attendances.Select((row, ind) => (row, ind)))
{
var row = item.row;
if (string.IsNullOrEmpty(row.PersonnelNumber) || string.IsNullOrEmpty(row.PersonnelNumber))
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", row.PersonnelNumber ?? "" },
{ "姓名", row.PersonnelName ?? "" },
{ "人员系数", row.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"“员工号/姓名”尚未填写" },
});
continue;
}
if (attendances.Count(w => w.PersonnelNumber.Trim().Equals(row.PersonnelNumber.Trim(), StringComparison.OrdinalIgnoreCase)) > 1)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", row.PersonnelNumber ?? "" },
{ "姓名", row.PersonnelName ?? "" },
{ "人员系数", row.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"“员工号”多次填写请删除其他保留一条" },
});
continue;
}
var emp = employees.FirstOrDefault(w => w.PersonnelNumber == row.PersonnelNumber);
if (emp == null || emp.DoctorName != row.PersonnelName)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", row.PersonnelNumber ?? "" },
{ "姓名", row.PersonnelName ?? "" },
{ "人员系数", row.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"“员工号/姓名”无法与“人员字典”对应" },
});
continue;
}
if (row.PermanentStaff == null)
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", row.PersonnelNumber ?? "" },
{ "姓名", row.PersonnelName ?? "" },
{ "人员系数", row.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"“人员系数”尚未填写" },
});
continue;
}
Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : "";
var dicDays = new[]
{
new { Date = begMonthDate.AddDays(00), TypeName = getAattendanceType(row.Day01), TypeId = row.Day01 },
new { Date = begMonthDate.AddDays(01), TypeName = getAattendanceType(row.Day02), TypeId = row.Day02 },
new { Date = begMonthDate.AddDays(02), TypeName = getAattendanceType(row.Day03), TypeId = row.Day03 },
new { Date = begMonthDate.AddDays(03), TypeName = getAattendanceType(row.Day04), TypeId = row.Day04 },
new { Date = begMonthDate.AddDays(04), TypeName = getAattendanceType(row.Day05), TypeId = row.Day05 },
new { Date = begMonthDate.AddDays(05), TypeName = getAattendanceType(row.Day06), TypeId = row.Day06 },
new { Date = begMonthDate.AddDays(06), TypeName = getAattendanceType(row.Day07), TypeId = row.Day07 },
new { Date = begMonthDate.AddDays(07), TypeName = getAattendanceType(row.Day08), TypeId = row.Day08 },
new { Date = begMonthDate.AddDays(08), TypeName = getAattendanceType(row.Day09), TypeId = row.Day09 },
new { Date = begMonthDate.AddDays(09), TypeName = getAattendanceType(row.Day10), TypeId = row.Day10 },
new { Date = begMonthDate.AddDays(10), TypeName = getAattendanceType(row.Day11), TypeId = row.Day11 },
new { Date = begMonthDate.AddDays(11), TypeName = getAattendanceType(row.Day12), TypeId = row.Day12 },
new { Date = begMonthDate.AddDays(12), TypeName = getAattendanceType(row.Day13), TypeId = row.Day13 },
new { Date = begMonthDate.AddDays(13), TypeName = getAattendanceType(row.Day14), TypeId = row.Day14 },
new { Date = begMonthDate.AddDays(14), TypeName = getAattendanceType(row.Day15), TypeId = row.Day15 },
new { Date = begMonthDate.AddDays(15), TypeName = getAattendanceType(row.Day16), TypeId = row.Day16 },
new { Date = begMonthDate.AddDays(16), TypeName = getAattendanceType(row.Day17), TypeId = row.Day17 },
new { Date = begMonthDate.AddDays(17), TypeName = getAattendanceType(row.Day18), TypeId = row.Day18 },
new { Date = begMonthDate.AddDays(18), TypeName = getAattendanceType(row.Day19), TypeId = row.Day19 },
new { Date = begMonthDate.AddDays(19), TypeName = getAattendanceType(row.Day20), TypeId = row.Day20 },
new { Date = begMonthDate.AddDays(20), TypeName = getAattendanceType(row.Day21), TypeId = row.Day21 },
new { Date = begMonthDate.AddDays(21), TypeName = getAattendanceType(row.Day22), TypeId = row.Day22 },
new { Date = begMonthDate.AddDays(22), TypeName = getAattendanceType(row.Day23), TypeId = row.Day23 },
new { Date = begMonthDate.AddDays(23), TypeName = getAattendanceType(row.Day24), TypeId = row.Day24 },
new { Date = begMonthDate.AddDays(24), TypeName = getAattendanceType(row.Day25), TypeId = row.Day25 },
new { Date = begMonthDate.AddDays(25), TypeName = getAattendanceType(row.Day26), TypeId = row.Day26 },
new { Date = begMonthDate.AddDays(26), TypeName = getAattendanceType(row.Day27), TypeId = row.Day27 },
new { Date = begMonthDate.AddDays(27), TypeName = getAattendanceType(row.Day28), TypeId = row.Day28 },
new { Date = begMonthDate.AddDays(28), TypeName = getAattendanceType(row.Day29), TypeId = row.Day29 },
new { Date = begMonthDate.AddDays(29), TypeName = getAattendanceType(row.Day30), TypeId = row.Day30 },
new { Date = begMonthDate.AddDays(30), TypeName = getAattendanceType(row.Day31), TypeId = row.Day31 },
};
var days = dicDays.Where(w => w.Date.Date >= begMonthDate && w.Date.Date <= endMonthDate);
foreach (var d in days)
{
if (!string.IsNullOrEmpty(d.TypeName) && !d.TypeId.HasValue)
{
var title = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(d.Date.DayOfWeek).Replace("星期", "");
var beaDay = d.Date.Day.ToString().PadLeft(2, '0');
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", row.PersonnelNumber ?? "" },
{ "姓名", row.PersonnelName ?? "" },
{ "人员系数", row.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", d.TypeName },
{ "错误原因", $"“{beaDay}({title})”考勤类型“{d.TypeName}”不存在"},
});
}
}
if (days.Count(w => string.IsNullOrEmpty(w.TypeName)) == days.Count())
{
error.Add(new Dictionary<string, string>
{
{ "行号", $"第{item.ind + 1}行" },
{ "工号", row.PersonnelNumber ?? "" },
{ "姓名", row.PersonnelName ?? "" },
{ "人员系数", row.PermanentStaff?.ToString() ?? "" },
{ "考勤类型", "" },
{ "错误原因", $"当前人员没有任何考勤记录请删除" },
});
continue;
}
}
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.通过))
......
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