Commit b8299bfe by ruyun.zhang

科室考勤上报录入结果统计&下载接口

parent 2a6523ec
...@@ -426,6 +426,7 @@ public IActionResult DownloadStatistics(int allotId) ...@@ -426,6 +426,7 @@ public IActionResult DownloadStatistics(int allotId)
new ExcelDownloadHeads { Alias = "员工号", Name = nameof(AttendanceStatistics.PersonnelNumber) }, new ExcelDownloadHeads { Alias = "员工号", Name = nameof(AttendanceStatistics.PersonnelNumber) },
new ExcelDownloadHeads { Alias = "在科开始时问", Name = nameof(AttendanceStatistics.BeginDate) }, new ExcelDownloadHeads { Alias = "在科开始时问", Name = nameof(AttendanceStatistics.BeginDate) },
new ExcelDownloadHeads { Alias = "在科结束时间", Name = nameof(AttendanceStatistics.EndDate) }, new ExcelDownloadHeads { Alias = "在科结束时间", Name = nameof(AttendanceStatistics.EndDate) },
new ExcelDownloadHeads { Alias = "人员系数", Name = nameof(AttendanceStatistics.PermanentStaff) },
}; };
var type = _attendanceService.GetAttendanceType(allotId); var type = _attendanceService.GetAttendanceType(allotId);
foreach (var item in type.Data) foreach (var item in type.Data)
...@@ -483,6 +484,7 @@ public IActionResult DownloadAuditDetail(int allotId, string unitType, string ac ...@@ -483,6 +484,7 @@ public IActionResult DownloadAuditDetail(int allotId, string unitType, string ac
new ExcelDownloadHeads { Alias = "员工号", Name = nameof(AttendanceStatistics.PersonnelNumber) }, new ExcelDownloadHeads { Alias = "员工号", Name = nameof(AttendanceStatistics.PersonnelNumber) },
new ExcelDownloadHeads { Alias = "在科开始时问", Name = nameof(AttendanceStatistics.BeginDate) }, new ExcelDownloadHeads { Alias = "在科开始时问", Name = nameof(AttendanceStatistics.BeginDate) },
new ExcelDownloadHeads { Alias = "在科结束时间", Name = nameof(AttendanceStatistics.EndDate) }, new ExcelDownloadHeads { Alias = "在科结束时间", Name = nameof(AttendanceStatistics.EndDate) },
new ExcelDownloadHeads { Alias = "人员系数", Name = nameof(AttendanceStatistics.PermanentStaff) },
}; };
var type = _attendanceService.GetAttendanceType(allotId); var type = _attendanceService.GetAttendanceType(allotId);
foreach (var item in type.Data) foreach (var item in type.Data)
...@@ -607,6 +609,20 @@ public ApiResponse<List<AttendanceDeptAuditList>> DeptAuditList(int allotId, str ...@@ -607,6 +609,20 @@ public ApiResponse<List<AttendanceDeptAuditList>> DeptAuditList(int allotId, str
} }
/// <summary> /// <summary>
/// 科室考勤上报录入状态
/// </summary>
/// <param name="allotId">绩效月ID</param>
/// <param name="unitType">核算组别</param>
/// <returns></returns>
[HttpPost]
[Route("dept/state")]
public ApiResponse<AttendanceDeptState> DeptState(int allotId, string unitType)
{
var userid = claim.GetUserId();
return _attendanceService.DeptState(allotId, userid, unitType);
}
/// <summary>
/// 科室考勤上报录入加载 /// 科室考勤上报录入加载
/// </summary> /// </summary>
/// <param name="allotId">绩效月ID</param> /// <param name="allotId">绩效月ID</param>
...@@ -640,6 +656,79 @@ public ApiResponse DeptSave(int allotId, string unitType, [FromBody] List<Attend ...@@ -640,6 +656,79 @@ public ApiResponse DeptSave(int allotId, string unitType, [FromBody] List<Attend
} }
/// <summary> /// <summary>
/// 科室考勤上报录入结果统计
/// </summary>
/// <param name="allotId">绩效月ID</param>
/// <param name="unitType">核算组别</param>
/// <param name="accountingUnit">核算单元</param>
/// <returns></returns>
[HttpPost]
[Route("dept/compute")]
public ApiResponse<List<AttendanceStatistics>> DeptCompute(int allotId, string unitType, string accountingUnit)
{
if (!Enum.TryParse(unitType, out UnitType unitType1))
throw new PerformanceException("核算组别错误");
if (string.IsNullOrEmpty(accountingUnit))
throw new PerformanceException("核算单元错误");
return _attendanceService.DeptCompute(allotId, unitType, accountingUnit);
}
/// <summary>
/// 科室考勤上报录入结果统计下载
/// </summary>
/// <param name="allotId">绩效月ID</param>
/// <param name="unitType">核算组别</param>
/// <param name="accountingUnit">核算单元</param>
/// <returns></returns>
[HttpPost]
[Route("dept/download/compute")]
public IActionResult DownloadDeptCompute(int allotId, string unitType, string accountingUnit)
{
if (!Enum.TryParse(unitType, out UnitType unitType1))
throw new PerformanceException("核算组别错误");
if (string.IsNullOrEmpty(accountingUnit))
throw new PerformanceException("核算单元错误");
List<ExcelDownloadHeads> excelDownloadHeads = new List<ExcelDownloadHeads>()
{
new ExcelDownloadHeads { Alias = "核算组别", Name = nameof(AttendanceStatistics.UnitType) },
new ExcelDownloadHeads { Alias = "核算单元名称", Name = nameof(AttendanceStatistics.AccountingUnit) },
new ExcelDownloadHeads { Alias = "姓名", Name = nameof(AttendanceStatistics.PersonnelName) },
new ExcelDownloadHeads { Alias = "员工号", Name = nameof(AttendanceStatistics.PersonnelNumber) },
new ExcelDownloadHeads { Alias = "在科开始时问", Name = nameof(AttendanceStatistics.BeginDate) },
new ExcelDownloadHeads { Alias = "在科结束时间", Name = nameof(AttendanceStatistics.EndDate) },
new ExcelDownloadHeads { Alias = "人员系数", Name = nameof(AttendanceStatistics.PermanentStaff) },
};
var type = _attendanceService.GetAttendanceType(allotId);
foreach (var item in type.Data)
{
excelDownloadHeads.Add(new ExcelDownloadHeads() { Alias = item.AttendanceName, Name = item.AttendanceName });
}
excelDownloadHeads.Add(new ExcelDownloadHeads() { Alias = "出勤天数", Name = "AttendanceDays" });
var userid = claim.GetUserId();
var res = _attendanceService.DeptCompute(allotId, unitType, accountingUnit);
var result = (res?.Data == null) ? new List<AttendanceStatistics>() : res.Data;
var ser = JsonConvert.SerializeObject(result);
var rows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(ser);
var filepath = _attendanceService.ExcelDownload(rows, "科室上报考勤结果", allotId, excelDownloadHeads);
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
var provider = new FileExtensionContentTypeProvider();
FileInfo fileInfo = new FileInfo(filepath);
var memi = provider.Mappings[".xlsx"];
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
}
/// <summary>
/// 科室考勤上报录入提交 /// 科室考勤上报录入提交
/// </summary> /// </summary>
/// <param name="allotId">绩效月ID</param> /// <param name="allotId">绩效月ID</param>
...@@ -688,6 +777,8 @@ public ApiResponse DeptAudit(int allotId, string unitType, string accountingUnit ...@@ -688,6 +777,8 @@ public ApiResponse DeptAudit(int allotId, string unitType, string accountingUnit
{ {
if (audit == null) if (audit == null)
throw new PerformanceException("审核参数错误"); throw new PerformanceException("审核参数错误");
if (string.IsNullOrEmpty(unitType) || string.IsNullOrEmpty(accountingUnit))
throw new PerformanceException("核算单元及组别信息错误");
var states = new int[] { (int)Attendance.Report.通过, (int)Attendance.Report.驳回, }; var states = new int[] { (int)Attendance.Report.通过, (int)Attendance.Report.驳回, };
if (!states.Contains(audit.State)) if (!states.Contains(audit.State))
......
...@@ -520,6 +520,14 @@ ...@@ -520,6 +520,14 @@
<param name="state"></param> <param name="state"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AttendanceController.DeptState(System.Int32,System.String)">
<summary>
科室考勤上报录入状态
</summary>
<param name="allotId">绩效月ID</param>
<param name="unitType">核算组别</param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AttendanceController.DeptLoad(System.Int32)"> <member name="M:Performance.Api.Controllers.AttendanceController.DeptLoad(System.Int32)">
<summary> <summary>
科室考勤上报录入加载 科室考勤上报录入加载
...@@ -536,6 +544,24 @@ ...@@ -536,6 +544,24 @@
<param name="datas"></param> <param name="datas"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.AttendanceController.DeptCompute(System.Int32,System.String,System.String)">
<summary>
科室考勤上报录入结果统计
</summary>
<param name="allotId">绩效月ID</param>
<param name="unitType">核算组别</param>
<param name="accountingUnit">核算单元</param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AttendanceController.DownloadDeptCompute(System.Int32,System.String,System.String)">
<summary>
科室考勤上报录入结果统计下载
</summary>
<param name="allotId">绩效月ID</param>
<param name="unitType">核算组别</param>
<param name="accountingUnit">核算单元</param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AttendanceController.DeptSubmit(System.Int32,System.String,System.Collections.Generic.List{Performance.DtoModels.Request.AttendanceDept})"> <member name="M:Performance.Api.Controllers.AttendanceController.DeptSubmit(System.Int32,System.String,System.Collections.Generic.List{Performance.DtoModels.Request.AttendanceDept})">
<summary> <summary>
科室考勤上报录入提交 科室考勤上报录入提交
......
...@@ -3188,6 +3188,11 @@ ...@@ -3188,6 +3188,11 @@
调入时间 调入时间
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.Response.AttendanceDeptState.Title">
<summary>
标题名
</summary>
</member>
<member name="P:Performance.DtoModels.Response.AttendanceDeptAuditList.Code"> <member name="P:Performance.DtoModels.Response.AttendanceDeptAuditList.Code">
<summary> <summary>
编码 编码
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
namespace Performance.DtoModels.Response namespace Performance.DtoModels.Response
{ {
public class AttendanceDeptState : AttendanceDeptAuditList
{
/// <summary>
/// 标题名
/// </summary>
public string Title { get; set; }
}
public class AttendanceDeptAuditList public class AttendanceDeptAuditList
{ {
/// <summary> /// <summary>
......
using AutoMapper; using AutoMapper;
using GraphQL; using GraphQL;
using MassTransit; using MassTransit;
using MassTransit.Internals.Extensions; using MassTransit.Internals.Extensions;
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using MySqlX.XDevAPI.Common; using MySqlX.XDevAPI.Common;
using Newtonsoft.Json; using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using OfficeOpenXml; using OfficeOpenXml;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reactive;
using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable; using System.Reflection.PortableExecutable;
using Z.EntityFramework.Plus; using Z.EntityFramework.Plus;
...@@ -1373,6 +1375,55 @@ public ApiResponse<List<AttendanceDeptAuditList>> DeptAuditList(int allotId, str ...@@ -1373,6 +1375,55 @@ public ApiResponse<List<AttendanceDeptAuditList>> DeptAuditList(int allotId, str
return new ApiResponse<List<AttendanceDeptAuditList>>(ResponseType.OK, items); return new ApiResponse<List<AttendanceDeptAuditList>>(ResponseType.OK, items);
} }
public ApiResponse<AttendanceDeptState> DeptState(int allotId, int userid, string unitType)
{
var allot = perforPerallotRepository.GetEntity(w => w.ID == allotId);
if (allot == null)
throw new PerformanceException("当前绩效记录不存在");
var begMonthDate = allot.Month >= 1 && allot.Month <= 12 ? new DateTime(allot.Year, allot.Month, 1) : new DateTime(allot.Year, 12, 1);
var endMonthDate = begMonthDate.AddMonths(1).AddDays(-1);
//当角色对应时过滤
var userInfo = _userRepository.GetUser(userid);
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var queryUnitTypes = UnitTypeUtil.GetMaps(userInfo?.URole.Type ?? 0);
var queryAccountingUnit = userInfo.User.Department;
var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId);
var attendanceDepts = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit))
?? new List<per_attendance_dept>();
var item = new AttendanceDeptState
{
Title = $"{allot.Name ?? $"{allot.Year}{allot.Month}月"} {queryAccountingUnit} {unitType} 考勤上报",
Code = cofaccounting.FirstOrDefault(w => unitType.Equals(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit))?.Code ?? "",
UnitType = unitType,
AccountingUnit = queryAccountingUnit,
Count = attendanceDepts.Count(),
ConfirmCount = attendanceDepts.Count(p => p.State == (int)Attendance.Report.提交),
FinishCount = attendanceDepts.Count(p => p.State == (int)Attendance.Report.通过),
RejectCount = attendanceDepts.Count(p => p.State == (int)Attendance.Report.驳回),
SubmitUser = attendanceDepts.OrderByDescending(o => o.SubmitUser).Select(s => s.SubmitUser).FirstOrDefault(),
SubmitTime = attendanceDepts.OrderByDescending(o => o.SubmitTime).Select(s => s.SubmitTime).FirstOrDefault(),
AuditUser = attendanceDepts.OrderByDescending(o => o.AuditUser).Select(s => s.AuditUser).FirstOrDefault(),
AuditTime = attendanceDepts.OrderByDescending(o => o.AuditTime).Select(s => s.AuditTime).FirstOrDefault(),
Remarks = string.Join(";", attendanceDepts.Select(p => p.Remarks).Where(s => !string.IsNullOrEmpty(s)).Distinct()),
};
item.State = (int)Attendance.Report.未提交;
if (item.RejectCount > 0)
item.State = (int)Attendance.Report.驳回;
else if (item.Count > 0 && item.FinishCount == item.Count)
item.State = (int)Attendance.Report.通过;
else if (item.Count > 0 && item.ConfirmCount == item.Count)
item.State = (int)Attendance.Report.提交;
return new ApiResponse<AttendanceDeptState>(ResponseType.OK, item);
}
/// <summary> /// <summary>
/// 科室考勤上报录入加载 /// 科室考勤上报录入加载
/// </summary> /// </summary>
...@@ -1415,7 +1466,7 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName) ...@@ -1415,7 +1466,7 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName)
new HandsonColumn(nameof(per_attendance_dept.PersonnelName).ToLower()), new HandsonColumn(nameof(per_attendance_dept.PersonnelName).ToLower()),
new HandsonColumn(nameof(per_attendance_dept.PermanentStaff).ToLower(), format: DataFormat.小数), new HandsonColumn(nameof(per_attendance_dept.PermanentStaff).ToLower(), format: DataFormat.小数),
}); });
List<string> allDays = new List<string>();
var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>(); var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>();
for (DateTime i = begMonthDate; i <= endMonthDate; i = i.AddDays(1)) for (DateTime i = begMonthDate; i <= endMonthDate; i = i.AddDays(1))
{ {
...@@ -1424,8 +1475,13 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName) ...@@ -1424,8 +1475,13 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName)
handson.ColHeaders.Add($"{beaDay}({title})"); handson.ColHeaders.Add($"{beaDay}({title})");
var source = types.Select(w => w.AttendanceName).ToArray(); var source = types.Select(w => w.AttendanceName).ToArray();
handson.Columns.Add(new HandsonColumn($"Day{beaDay}".ToLower()) { Type = "autocomplete", Strict = true, Source = source }); handson.Columns.Add(new HandsonColumn($"Day{beaDay}".ToLower()) { Type = "autocomplete", Strict = true, Source = source });
allDays.Add($"Day{beaDay}".ToLower());
} }
Func<object, string> getAattendanceType = (value) =>
{
_ = int.TryParse(value == null ? "" : value.ToString(), out int typeId);
return typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : "";
};
List<Dictionary<string, object>> datas = new List<Dictionary<string, object>>(); List<Dictionary<string, object>> datas = new List<Dictionary<string, object>>();
if (attendances.Any()) if (attendances.Any())
{ {
...@@ -1436,7 +1492,7 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName) ...@@ -1436,7 +1492,7 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName)
foreach (var column in handson.Columns) foreach (var column in handson.Columns)
{ {
dict.TryGetValue(column.Data, out object value); dict.TryGetValue(column.Data, out object value);
row.AddOrUpdate(column.Data, value); row.AddOrUpdate(column.Data, allDays.Contains(column.Data) ? getAattendanceType(value) : value);
} }
datas.Add(row); datas.Add(row);
} }
...@@ -1499,16 +1555,21 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1499,16 +1555,21 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在"); if (userInfo?.User == null) throw new NotImplementedException("当前用户不存在");
if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色"); if (userInfo?.URole == null) throw new NotImplementedException("当前用户暂未分配角色");
var queryUnitTypes = UnitTypeUtil.GetMaps(userInfo?.URole.Type ?? 0); var unitTypes = UnitTypeUtil.GetMaps(userInfo?.URole.Type ?? 0);
string queryAccountingUnit = userInfo.User.Department; string accountingUnit = userInfo.User.Department;
if (!queryUnitTypes.Contains(unitType)) throw new PerformanceException("当前用户角色与“核算组别”不匹配"); if (!unitTypes.Contains(unitType)) throw new PerformanceException("当前用户角色与“核算组别”不匹配");
var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>(); var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>();
var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId); var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId);
var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId); var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit)); var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && unitTypes.Contains(w.UnitType) && accountingUnit.Equals(w.AccountingUnit))
?? new List<per_attendance_dept>();
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("当前考勤已审核通过,无法提交!");
List<per_attendance_dept> newAttendanceDepts = new List<per_attendance_dept>(); List<per_attendance_dept> newAttendanceDepts = new List<per_attendance_dept>();
List<per_attendance_dept> updAttendanceDepts = new List<per_attendance_dept>(); List<per_attendance_dept> updAttendanceDepts = new List<per_attendance_dept>();
...@@ -1627,8 +1688,8 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1627,8 +1688,8 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
} }
var accounting = cofaccounting.FirstOrDefault(p => p.UnitType == unitType && p.AccountingUnit == queryAccountingUnit); 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 == queryAccountingUnit); var attendance = attendances.FirstOrDefault(w => w.PersonnelNumber == row.PersonnelNumber && w.UnitType == unitType.ToString() && w.AccountingUnit == accountingUnit);
if (attendance == null) if (attendance == null)
{ {
attendance = new per_attendance_dept attendance = new per_attendance_dept
...@@ -1637,7 +1698,7 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1637,7 +1698,7 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
AllotId = allotId, AllotId = allotId,
Code = accounting?.Code ?? "", Code = accounting?.Code ?? "",
UnitType = unitType, UnitType = unitType,
AccountingUnit = queryAccountingUnit, AccountingUnit = accountingUnit,
}; };
attendance.PersonnelNumber = row.PersonnelNumber; attendance.PersonnelNumber = row.PersonnelNumber;
attendance.PersonnelName = row.PersonnelName; attendance.PersonnelName = row.PersonnelName;
...@@ -1732,6 +1793,119 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1732,6 +1793,119 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
return new ApiResponse(ResponseType.OK, "保存成功"); return new ApiResponse(ResponseType.OK, "保存成功");
} }
public ApiResponse<List<AttendanceStatistics>> DeptCompute(int allotId, string unitType, string accountingUnit)
{
var allot = perforPerallotRepository.GetEntity(w => w.ID == allotId);
if (allot == null)
throw new PerformanceException("当前绩效记录不存在");
var begMonthDate = allot.Month >= 1 && allot.Month <= 12 ? new DateTime(allot.Year, allot.Month, 1) : new DateTime(allot.Year, 12, 1);
var endMonthDate = begMonthDate.AddMonths(1).AddDays(-1);
var statistics = new List<AttendanceStatistics>();
var deptDetail = DeptDetail(allotId, unitType, accountingUnit);
if (deptDetail?.Data?.Data == null)
return new ApiResponse<List<AttendanceStatistics>>(ResponseType.OK, "", statistics);
var datas = deptDetail.Data.Data;
var types = perfoPperAttendanceTypeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_attendance_type>();
var cofaccounting = cofaccountingRepository.GetEntities(g => g.AllotId == allotId);
//var employees = perforPeremployeeRepository.GetEntities(g => g.AllotId == allotId);
//var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit));
foreach (var item in datas)
{
var days = new[]
{
new { Date = begMonthDate.AddDays(00), OrgTypeName = item.Day01 },
new { Date = begMonthDate.AddDays(01), OrgTypeName = item.Day02 },
new { Date = begMonthDate.AddDays(02), OrgTypeName = item.Day03 },
new { Date = begMonthDate.AddDays(03), OrgTypeName = item.Day04 },
new { Date = begMonthDate.AddDays(04), OrgTypeName = item.Day05 },
new { Date = begMonthDate.AddDays(05), OrgTypeName = item.Day06 },
new { Date = begMonthDate.AddDays(06), OrgTypeName = item.Day07 },
new { Date = begMonthDate.AddDays(07), OrgTypeName = item.Day08 },
new { Date = begMonthDate.AddDays(08), OrgTypeName = item.Day09 },
new { Date = begMonthDate.AddDays(09), OrgTypeName = item.Day10 },
new { Date = begMonthDate.AddDays(10), OrgTypeName = item.Day11 },
new { Date = begMonthDate.AddDays(11), OrgTypeName = item.Day12 },
new { Date = begMonthDate.AddDays(12), OrgTypeName = item.Day13 },
new { Date = begMonthDate.AddDays(13), OrgTypeName = item.Day14 },
new { Date = begMonthDate.AddDays(14), OrgTypeName = item.Day15 },
new { Date = begMonthDate.AddDays(15), OrgTypeName = item.Day16 },
new { Date = begMonthDate.AddDays(16), OrgTypeName = item.Day17 },
new { Date = begMonthDate.AddDays(17), OrgTypeName = item.Day18 },
new { Date = begMonthDate.AddDays(18), OrgTypeName = item.Day19 },
new { Date = begMonthDate.AddDays(19), OrgTypeName = item.Day20 },
new { Date = begMonthDate.AddDays(20), OrgTypeName = item.Day21 },
new { Date = begMonthDate.AddDays(21), OrgTypeName = item.Day22 },
new { Date = begMonthDate.AddDays(22), OrgTypeName = item.Day23 },
new { Date = begMonthDate.AddDays(23), OrgTypeName = item.Day24 },
new { Date = begMonthDate.AddDays(24), OrgTypeName = item.Day25 },
new { Date = begMonthDate.AddDays(25), OrgTypeName = item.Day26 },
new { Date = begMonthDate.AddDays(26), OrgTypeName = item.Day27 },
new { Date = begMonthDate.AddDays(27), OrgTypeName = item.Day28 },
new { Date = begMonthDate.AddDays(28), OrgTypeName = item.Day29 },
new { Date = begMonthDate.AddDays(29), OrgTypeName = item.Day30 },
new { Date = begMonthDate.AddDays(30), OrgTypeName = item.Day31 },
};
var vaildDays = days.Where(w => !string.IsNullOrEmpty(w.OrgTypeName));
if (vaildDays?.Any() == true)
{
var vaildBegDate = vaildDays.Min(w => w.Date);
for (int i = 0; i < vaildDays.Count(); i++)
{
var currDate = vaildDays.ElementAt(i).Date;
var nextDate = (i + 1 < vaildDays.Count()) ? vaildDays.ElementAt(i + 1).Date : vaildDays.Max(w => w.Date);
if (nextDate.Day - currDate.Day > 1 || currDate == vaildDays.Max(w => w.Date))
{
var stat = new AttendanceStatistics
{
AllotID = allotId,
Code = cofaccounting.FirstOrDefault(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit)?.Code ?? "",
UnitType = unitType,
AccountingUnit = accountingUnit,
PersonnelNumber = item.PersonnelNumber,
PersonnelName = item.PersonnelName,
PermanentStaff = item.PermanentStaff,
BeginDate = vaildBegDate,
EndDate = currDate,
Detial = new List<AttendanceStatisticsDetial>()
};
stat.Detial = days.Where(w => w.Date >= vaildBegDate && w.Date <= currDate)
.GroupBy(w => w.OrgTypeName)
.Select(w => new AttendanceStatisticsDetial
{
Title = w.Key,
Value = w.Count(),
Remark = "",//item.IsDeduction == (int)Attendance.Deduction.核减 ? "核减" : "不核减",
}).ToList();
foreach (var tp in types)
{
if (!stat.Detial.Any(w => w.Title == tp.AttendanceName))
{
stat.Detial.Add(new AttendanceStatisticsDetial
{
Title = tp.AttendanceName,
Value = 0,
Remark = tp.IsDeduction == (int)Attendance.Deduction.核减 ? "核减" : "不核减",
});
}
}
statistics.Add(stat);
vaildBegDate = nextDate;
}
}
}
}
return new ApiResponse<List<AttendanceStatistics>>(ResponseType.OK, "", statistics);
}
/// <summary> /// <summary>
/// 科室考勤上报录入提交 /// 科室考勤上报录入提交
/// </summary> /// </summary>
...@@ -1763,6 +1937,13 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u ...@@ -1763,6 +1937,13 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit)) var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && queryUnitTypes.Contains(w.UnitType) && queryAccountingUnit.Equals(w.AccountingUnit))
?? new List<per_attendance_dept>(); ?? new List<per_attendance_dept>();
if (!attendances.Any()) return new ApiResponse(ResponseType.OK, "暂无数据,无需提交!");
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 submitTime = DateTime.Now; var submitTime = DateTime.Now;
foreach (var item in attendances) foreach (var item in attendances)
{ {
...@@ -1777,7 +1958,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u ...@@ -1777,7 +1958,7 @@ public ApiResponse DeptSubmit(int allotId, string unitType, int userid, string u
return new ApiResponse(ResponseType.OK, "提交成功"); return new ApiResponse(ResponseType.OK, "提交成功");
} }
/// <summary> /// <summary>
/// 科室考勤上报录入提交 /// 科室考勤上报录入撤回
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param> /// <param name="unitType"></param>
...@@ -1811,13 +1992,13 @@ public ApiResponse DeptRollback(int allotId, string unitType, int userid, string ...@@ -1811,13 +1992,13 @@ public ApiResponse DeptRollback(int allotId, string unitType, int userid, string
var stateCount = attendances.GroupBy(w => w.State).Select(w => new { w.Key, StateCount = w.Count() }).ToList(); var stateCount = attendances.GroupBy(w => w.State).Select(w => new { w.Key, StateCount = w.Count() }).ToList();
if (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("当前考勤已审核通过,无法撤回!"); throw new PerformanceException("当前考勤已审核通过,无法撤回!");
if (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("当前考勤尚未提交,无需撤回!"); throw new PerformanceException("当前考勤尚未提交,无需撤回!");
if (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("当前考勤尚已驳回,无需撤回!"); throw new PerformanceException("当前考勤尚已驳回,无需撤回!");
var submitTime = DateTime.Now; var submitTime = DateTime.Now;
...@@ -1856,6 +2037,8 @@ public ApiResponse DeptAudit(int allotId, string unitType, string accountingUnit ...@@ -1856,6 +2037,8 @@ public ApiResponse DeptAudit(int allotId, string unitType, string accountingUnit
var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && unitType.Equals(w.UnitType) && accountingUnit.Equals(w.AccountingUnit)) var attendances = _attendanceDeptRepository.GetEntities((w) => w.AllotId == allotId && unitType.Equals(w.UnitType) && accountingUnit.Equals(w.AccountingUnit))
?? new List<per_attendance_dept>(); ?? new List<per_attendance_dept>();
if (attendances.Count() == 0)
throw new PerformanceException("当前考勤暂无数据,无法审核!");
if (attendances.Count() != attendances.Count(w => w.State == (int)Attendance.Report.提交)) if (attendances.Count() != attendances.Count(w => w.State == (int)Attendance.Report.提交))
throw new PerformanceException("当前考勤尚未提交,请勿审核!"); throw new PerformanceException("当前考勤尚未提交,请勿审核!");
...@@ -1911,7 +2094,7 @@ public ApiResponse<AttendanceDeptDetail> DeptDetail(int allotId, string unitType ...@@ -1911,7 +2094,7 @@ public ApiResponse<AttendanceDeptDetail> DeptDetail(int allotId, string unitType
{ {
var title = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(i.DayOfWeek).Replace("星期", ""); var title = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(i.DayOfWeek).Replace("星期", "");
var beaDay = i.Day.ToString().PadLeft(2, '0'); var beaDay = i.Day.ToString().PadLeft(2, '0');
detail.Columns.Add(new TColumn($"Day{beaDay}".ToLower(), $"{beaDay}({title})")); detail.Columns.Add(new TColumn($"Day{beaDay}".ToLower(), $"{beaDay}({title})", width: 60));
} }
if (!attendances.Any()) return new ApiResponse<AttendanceDeptDetail>(ResponseType.OK, "操作成功", detail); if (!attendances.Any()) return new ApiResponse<AttendanceDeptDetail>(ResponseType.OK, "操作成功", detail);
......
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