Commit 6be8cabb by wyc

审核医院其他绩效时,使用异步/加载上月调整/考勤上报添加排序

parent cbeef790
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
...@@ -422,10 +423,10 @@ public ApiResponse CommitResult([FromBody] AprAmountAuditRequest request) ...@@ -422,10 +423,10 @@ public ApiResponse CommitResult([FromBody] AprAmountAuditRequest request)
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("apr/audit")] [Route("apr/audit")]
public ApiResponse AuditResult([FromBody] AprAmountAuditRequest request) public async Task<ApiResponse> AuditResult([FromBody] AprAmountAuditRequest request)
{ {
var userid = claim.GetUserId(); var userid = claim.GetUserId();
return employeeService.ConfirmAudit(userid, request); return await employeeService.ConfirmAudit(userid, request);
} }
/// <summary> /// <summary>
......
...@@ -6308,6 +6308,11 @@ ...@@ -6308,6 +6308,11 @@
状态(未提交 = 1,提交 =2,通过 = 3,驳回 = 4) 状态(未提交 = 1,提交 =2,通过 = 3,驳回 = 4)
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.Entity.per_attendance_dept.Sort">
<summary>
科室(考勤上报)排序
</summary>
</member>
<member name="P:Performance.EntityModels.Entity.per_attendance_dept.SubmitUser"> <member name="P:Performance.EntityModels.Entity.per_attendance_dept.SubmitUser">
<summary> <summary>
提交用户 提交用户
......
...@@ -57,7 +57,10 @@ public class per_attendance_dept ...@@ -57,7 +57,10 @@ public class per_attendance_dept
/// 状态(未提交 = 1,提交 =2,通过 = 3,驳回 = 4) /// 状态(未提交 = 1,提交 =2,通过 = 3,驳回 = 4)
/// </summary> /// </summary>
public int State { get; set; } public int State { get; set; }
/// <summary>
/// 科室(考勤上报)排序
/// </summary>
public int Sort { get; set; }
/// <summary> /// <summary>
/// 提交用户 /// 提交用户
/// </summary> /// </summary>
......
...@@ -727,9 +727,6 @@ public ApiResponse AttendanceTypeBatch(int allotId, int hospitalId, SaveCollectD ...@@ -727,9 +727,6 @@ public ApiResponse AttendanceTypeBatch(int allotId, int hospitalId, SaveCollectD
return new ApiResponse(ResponseType.OK, ""); return new ApiResponse(ResponseType.OK, "");
} }
/// <summary> /// <summary>
/// 加载默认考勤类型 /// 加载默认考勤类型
/// </summary> /// </summary>
...@@ -1662,15 +1659,17 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName) ...@@ -1662,15 +1659,17 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName)
if (allot == null) if (allot == null)
throw new PerformanceException("当前绩效记录不存在"); 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 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 endMonthDate = begMonthDate.AddMonths(1).AddDays(-1);
//当角色对应时过滤 //当角色对应时过滤
var userInfo = _userRepository.GetUser(userid); var userInfo = _userRepository.GetUser(userid);
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 queryUnitTypes = UnitTypeUtil.GetMaps(userInfo.URole.Type ?? 0);
var queryAccountingUnit = userInfo.User.Department; var queryAccountingUnit = userInfo.User.Department;
Expression<Func<per_attendance_dept, bool>> deptExpression = (w) => w.AllotId == allotId; Expression<Func<per_attendance_dept, bool>> deptExpression = (w) => w.AllotId == allotId;
...@@ -1708,6 +1707,7 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName) ...@@ -1708,6 +1707,7 @@ public ApiResponse DeptLoad(int allotId, int userid, string userName)
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())
{ {
attendances = attendances.OrderBy(w => w.Sort).ToList();
foreach (var item in attendances) foreach (var item in attendances)
{ {
Dictionary<string, object> row = new Dictionary<string, object>(); Dictionary<string, object> row = new Dictionary<string, object>();
...@@ -1940,7 +1940,8 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1940,7 +1940,8 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
AccountingUnit = accountingUnit, AccountingUnit = accountingUnit,
PersonnelNumber = row.PersonnelNumber, PersonnelNumber = row.PersonnelNumber,
PersonnelName = row.PersonnelName, PersonnelName = row.PersonnelName,
PermanentStaff = row.PermanentStaff ?? emp?.PermanentStaff PermanentStaff = row.PermanentStaff ?? emp?.PermanentStaff,
Sort = item.ind
}; };
for (int day = 1; day <= 31; day++) for (int day = 1; day <= 31; day++)
{ {
...@@ -1955,7 +1956,7 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit ...@@ -1955,7 +1956,7 @@ public ApiResponse DeptSave(int allotId, List<AttendanceDept> datas, string unit
attendance.PersonnelNumber = row.PersonnelNumber; attendance.PersonnelNumber = row.PersonnelNumber;
attendance.PersonnelName = row.PersonnelName; attendance.PersonnelName = row.PersonnelName;
attendance.PermanentStaff = row.PermanentStaff ?? emp?.PermanentStaff; attendance.PermanentStaff = row.PermanentStaff ?? emp?.PermanentStaff;
attendance.Sort = item.ind;
for (int day = 1; day <= 31; day++) for (int day = 1; day <= 31; day++)
{ {
string dayPropertyName = $"Day{day:00}"; string dayPropertyName = $"Day{day:00}";
...@@ -2563,7 +2564,7 @@ public ApiResponse<AttendanceDeptDetail> DeptDetail(int allotId, string unitType ...@@ -2563,7 +2564,7 @@ public ApiResponse<AttendanceDeptDetail> DeptDetail(int allotId, string unitType
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>();
Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : ""; Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : "";
foreach (var row in attendances) foreach (var row in attendances.OrderBy(w => w.Sort).ToList())
{ {
var accounting = cofaccounting.FirstOrDefault(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit); var accounting = cofaccounting.FirstOrDefault(p => p.UnitType == unitType && p.AccountingUnit == accountingUnit);
var attendance = new AttendanceDeptMore var attendance = new AttendanceDeptMore
...@@ -2646,7 +2647,7 @@ public ApiResponse<List<AttendanceDeptReport>> DeptReport(int allotId, string un ...@@ -2646,7 +2647,7 @@ public ApiResponse<List<AttendanceDeptReport>> DeptReport(int allotId, string un
deptExpression = deptExpression.And(w => w.PersonnelNumber.Contains(searchTxet) || w.PersonnelName.Contains(searchTxet)); deptExpression = deptExpression.And(w => w.PersonnelNumber.Contains(searchTxet) || w.PersonnelName.Contains(searchTxet));
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 attendances = _attendanceDeptRepository.GetEntities(deptExpression) ?? new List<per_attendance_dept>(); var attendances = _attendanceDeptRepository.GetEntities(deptExpression).OrderBy(w => w.Sort).ToList() ?? new List<per_attendance_dept>();
var names = typeof(per_attendance_dept_report).GetProperties().Select(w => w.Name); var names = typeof(per_attendance_dept_report).GetProperties().Select(w => w.Name);
var rows = _service.QueryAttendanceDeptReport(allotId, unitType, accountingUnit, searchTxet); var rows = _service.QueryAttendanceDeptReport(allotId, unitType, accountingUnit, searchTxet);
Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : ""; Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : "";
...@@ -2785,7 +2786,7 @@ public ApiResponse<List<AttendanceDeptReport>> DeptComputeReport(int allotId, st ...@@ -2785,7 +2786,7 @@ public ApiResponse<List<AttendanceDeptReport>> DeptComputeReport(int allotId, st
deptExpression = deptExpression.And(w => w.PersonnelNumber.Contains(searchTxet) || w.PersonnelName.Contains(searchTxet)); deptExpression = deptExpression.And(w => w.PersonnelNumber.Contains(searchTxet) || w.PersonnelName.Contains(searchTxet));
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 attendances = _attendanceDeptRepository.GetEntities(deptExpression) ?? new List<per_attendance_dept>(); var attendances = _attendanceDeptRepository.GetEntities(deptExpression).OrderBy(w => w.Sort).ToList() ?? new List<per_attendance_dept>();
var names = typeof(per_attendance_dept_report).GetProperties().Select(w => w.Name); var names = typeof(per_attendance_dept_report).GetProperties().Select(w => w.Name);
var rows = _service.QueryAttendanceDeptReportCompute(allotId, unitType, accountingUnit, searchTxet); var rows = _service.QueryAttendanceDeptReportCompute(allotId, unitType, accountingUnit, searchTxet);
Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : ""; Func<int?, string> getAattendanceType = (typeId) => typeId > 0 ? types.FirstOrDefault(w => w.Id == typeId)?.AttendanceName ?? "考勤类型缺失" : "";
......
using GraphQL; using GraphQL;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.Request; using Performance.DtoModels.Request;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -364,49 +365,88 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId) ...@@ -364,49 +365,88 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
var successfulType = _pperAttendanceTypeRepository.AddRange(perAttendanceTypeList.ToArray()); var successfulType = _pperAttendanceTypeRepository.AddRange(perAttendanceTypeList.ToArray());
if (successfulType) if (successfulType)
{ {
var prevPerEmployee = _perforPeremployeeRepository.GetEntities(g => g.AllotId == prevAllotId && g.IsVerify == 1); var attDepts = _perforPerAttendanceDeptRepository.GetEntities();
if (!prevPerEmployee.Any()) return; if (!attDepts.Exists(w => w.AllotId == allot.ID))
// 当月的考勤上报
var attDepts = _perforPerAttendanceDeptRepository.GetEntities(w => w.AllotId == allot.ID).ToList();
if (!attDepts.Any())
{ {
//查询默认考勤类型 var typeDefault = _pperAttendanceTypeRepository.GetEntity(g => g.AllotId == allot.ID && g.IsDefault == (int)Attendance.Default.默认)?.Id;
var typeDefault = _pperAttendanceTypeRepository.GetEntity(g => g.AllotId == allot.ID && g.IsDefault == (int)Attendance.Default.默认)?.Id ?? null;
var cofaccounting = _cofaccountingRepository.GetEntities(g => g.AllotId == prevAllotId);
int currentMonth = DateTime.DaysInMonth(allot.Year, allot.Month); int currentMonth = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAttDepts = prevPerEmployee.Select(t =>
var updateAttDepts = new List<per_attendance_dept>();
var previousAttDepts = attDepts.Where(w => w.AllotId == prevAllotId).ToList();
foreach (var item in previousAttDepts)
{ {
var code = cofaccounting var updateAttDept = new per_attendance_dept
.Where(p => p.UnitType == t.UnitType && p.AccountingUnit == t.AccountingUnit)
.Select(p => p.Code)
.FirstOrDefault() ?? "";
var newDept = new per_attendance_dept
{ {
HospitalId = t.HospitalId, HospitalId = item.HospitalId,
AllotId = allot.ID, AllotId = allot.ID,
PersonnelName = t.DoctorName, PersonnelNumber = item.PersonnelNumber,
PersonnelNumber = t.PersonnelNumber, PersonnelName = item.PersonnelName,
PermanentStaff = t.PermanentStaff ?? 0, PermanentStaff = item.PermanentStaff,
Code = code, Code = item.Code,
UnitType = t.UnitType, UnitType = item.UnitType,
AccountingUnit = t.AccountingUnit, AccountingUnit = item.AccountingUnit,
State = (int)Attendance.Report.未提交 State = (int)Attendance.Report.未提交,
Sort = item.Sort
}; };
for (int day = 1; day <= currentMonth; day++)
for (int i = 1; i <= currentMonth; i++)
{ {
typeof(per_attendance_dept).GetProperty($"Day{i:d2}")?.SetValue(newDept, typeDefault); var property = typeof(per_attendance_dept).GetProperty($"Day{day:d2}");
if (property != null)
{
property.SetValue(updateAttDept, typeDefault);
}
} }
updateAttDepts.Add(updateAttDept);
return newDept; }
}).ToList(); _perforPerAttendanceDeptRepository.AddRange(updateAttDepts.ToArray());
_perforPerAttendanceDeptRepository.AddRange(newAttDepts.ToArray());
} }
} }
#region (旧)考勤上报加载上月
//if (successfulType)
//{
// var prevPerEmployee = _perforPeremployeeRepository.GetEntities(g => g.AllotId == prevAllotId && g.IsVerify == 1);
// if (!prevPerEmployee.Any()) return;
// // 当月的考勤上报
// var attDepts = _perforPerAttendanceDeptRepository.GetEntities(w => w.AllotId == allot.ID).ToList();
// if (!attDepts.Any())
// {
// //查询默认考勤类型
// var typeDefault = _pperAttendanceTypeRepository.GetEntity(g => g.AllotId == allot.ID && g.IsDefault == (int)Attendance.Default.默认)?.Id ?? null;
// var cofaccounting = _cofaccountingRepository.GetEntities(g => g.AllotId == prevAllotId);
// int currentMonth = DateTime.DaysInMonth(allot.Year, allot.Month);
// var newAttDepts = prevPerEmployee.Select(t =>
// {
// var code = cofaccounting
// .Where(p => p.UnitType == t.UnitType && p.AccountingUnit == t.AccountingUnit)
// .Select(p => p.Code)
// .FirstOrDefault() ?? "";
// var newDept = new per_attendance_dept
// {
// HospitalId = t.HospitalId,
// AllotId = allot.ID,
// PersonnelName = t.DoctorName,
// PersonnelNumber = t.PersonnelNumber,
// PermanentStaff = t.PermanentStaff ?? 0,
// Code = code,
// UnitType = t.UnitType,
// AccountingUnit = t.AccountingUnit,
// State = (int)Attendance.Report.未提交
// };
// for (int i = 1; i <= currentMonth; i++)
// {
// typeof(per_attendance_dept).GetProperty($"Day{i:d2}")?.SetValue(newDept, typeDefault);
// }
// return newDept;
// }).ToList();
// _perforPerAttendanceDeptRepository.AddRange(newAttDepts.ToArray());
// }
//}
#endregion
} }
/// <summary> /// <summary>
/// 加载上月绩效考核 /// 加载上月绩效考核
...@@ -415,7 +455,7 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId) ...@@ -415,7 +455,7 @@ public void Copy_AttendanceType(per_allot allot, int prevAllotId)
/// <param name="prevAllotId"></param> /// <param name="prevAllotId"></param>
public void Copy_AssessType(per_allot allot, int prevAllotId) public void Copy_AssessType(per_allot allot, int prevAllotId)
{ {
_logger.LogInformation($"copy assessType"); _logger.LogInformation("copy assessType");
var operatingTime = DateTime.Now; var operatingTime = DateTime.Now;
#region 考核类型加载上月 #region 考核类型加载上月
//查询本月和上月的类型 //查询本月和上月的类型
......
...@@ -31,7 +31,7 @@ public DapperService(IOptions<AppConnection> options, ILogger<DapperService> log ...@@ -31,7 +31,7 @@ public DapperService(IOptions<AppConnection> options, ILogger<DapperService> log
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
public void FreezeAllotSync(int allotId) public void FreezeAllotSync(int allotId)
{ {
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
{ {
...@@ -43,6 +43,26 @@ public void FreezeAllotSync(int allotId) ...@@ -43,6 +43,26 @@ public void FreezeAllotSync(int allotId)
} }
}); });
} }
/// <summary>
/// 审核医院其他绩效时,使用异步
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
public async Task FreezeAllotSyncAsync(int allotId)
{
await Task.Run(async () =>
{
using (var connection = new MySqlConnection(_options.Value.PerformanceConnectionString))
{
if (connection.State != ConnectionState.Open)
await connection.OpenAsync();
string sql = $@"call proc_freeze_allot({allotId})";
await connection.ExecuteAsync(sql, commandTimeout: 60 * 60);
}
});
}
/// <summary> /// <summary>
/// 数据静态存储 /// 数据静态存储
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Performance.Services namespace Performance.Services
...@@ -451,7 +452,9 @@ public bool Audit(int allotId) ...@@ -451,7 +452,9 @@ public bool Audit(int allotId)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <param name="isAudit"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="PerformanceException"></exception>
public List<OhterAmountAuditResponse> GetAprList(int allotId, int userId, int isAudit) public List<OhterAmountAuditResponse> GetAprList(int allotId, int userId, int isAudit)
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userId); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
...@@ -493,7 +496,7 @@ public List<OhterAmountAuditResponse> GetAprList(int allotId, int userId, int is ...@@ -493,7 +496,7 @@ public List<OhterAmountAuditResponse> GetAprList(int allotId, int userId, int is
}; };
}); });
if (result != null && result.Any()) if (result.Any())
result = result.OrderByDescending(o => o.CreateDate).ToList(); result = result.OrderByDescending(o => o.CreateDate).ToList();
return result.ToList(); return result.ToList();
...@@ -637,7 +640,7 @@ public bool CommitApr(int allotId, string department, int status, DateTime date) ...@@ -637,7 +640,7 @@ public bool CommitApr(int allotId, string department, int status, DateTime date)
/// <param name="userid"></param> /// <param name="userid"></param>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public ApiResponse ConfirmAudit(int userid, AprAmountAuditRequest request) public async Task<ApiResponse> ConfirmAudit(int userid, AprAmountAuditRequest request)
{ {
List<Dictionary<string, string>> error = new List<Dictionary<string, string>>(); List<Dictionary<string, string>> error = new List<Dictionary<string, string>>();
...@@ -659,7 +662,7 @@ public ApiResponse ConfirmAudit(int userid, AprAmountAuditRequest request) ...@@ -659,7 +662,7 @@ public ApiResponse ConfirmAudit(int userid, AprAmountAuditRequest request)
.Where(w => w != null); .Where(w => w != null);
error.AddRange(err); error.AddRange(err);
if (error.Count > 0) if (error.Any())
return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error); return new ApiResponse(ResponseType.WarningTable, "验证不通过,当前操作已拒绝", error);
var allApramounts = request.IsPass == 1 var allApramounts = request.IsPass == 1
...@@ -679,7 +682,7 @@ public ApiResponse ConfirmAudit(int userid, AprAmountAuditRequest request) ...@@ -679,7 +682,7 @@ public ApiResponse ConfirmAudit(int userid, AprAmountAuditRequest request)
} }
} }
} }
_service.FreezeAllotSync(request.AllotId); await _service.FreezeAllotSyncAsync(request.AllotId);
return new ApiResponse(ResponseType.OK, ""); return new ApiResponse(ResponseType.OK, "");
} }
......
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