补充字典中科室不存在,但医院其他绩效有人员信息

parent 5867b3c6
...@@ -711,22 +711,24 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty ...@@ -711,22 +711,24 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
/// <returns></returns> /// <returns></returns>
public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowManage, bool isEmpDic = false) public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowManage, bool isEmpDic = false)
{ {
var fullAmounts = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Status == 3);
var employees = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
// 获取一次次绩效结果 // 获取一次次绩效结果
var list = GetAllotPerformance(allotId, hospitalId, isShowManage); var response = GetAllotPerformance(allotId, hospitalId, isShowManage);
// 获取二次绩效结果 // 获取二次绩效结果
var seconds = GetSecondPerformance(allotId); var seconds = GetSecondPerformance(allotId, employees, fullAmounts);
if (seconds != null) if (seconds != null)
list?.AddRange(seconds); response?.AddRange(seconds);
// 补充医院其他绩效 // 补充医院其他绩效
var result = AddAprAmount(allotId, list); if (fullAmounts != null && fullAmounts.Any())
response = AddAprAmount(allotId, response, fullAmounts);
// 预留比例 // 预留比例
if (result != null) if (response != null)
{ {
var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政后勤.ToString(), "行政工勤" }; var types = new string[] { UnitType.行政高层.ToString(), UnitType.行政中层.ToString(), UnitType.行政后勤.ToString(), "行政工勤" };
var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId); foreach (var item in response)
foreach (var item in result)
{ {
// 二次分配默认 调节系数100% // 二次分配默认 调节系数100%
var adjust = item.Source == "二次绩效" ? 1 : (item.Adjust ?? 1); var adjust = item.Source == "二次绩效" ? 1 : (item.Adjust ?? 1);
...@@ -749,21 +751,21 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM ...@@ -749,21 +751,21 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
item.ShouldGiveFee = Math.Round(real + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero); item.ShouldGiveFee = Math.Round(real + (item.OthePerfor ?? 0) + (item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero);
item.ReservedRatio = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0; item.ReservedRatio = employees?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
item.ReservedRatioFee = Math.Round(real * (item.ReservedRatio ?? 0), 2, MidpointRounding.AwayFromZero); item.ReservedRatioFee = Math.Round(real * (item.ReservedRatio ?? 0), 2, MidpointRounding.AwayFromZero);
item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 2, MidpointRounding.AwayFromZero); item.RealGiveFee = Math.Round(item.ShouldGiveFee - (item.ReservedRatioFee ?? 0) ?? 0, 2, MidpointRounding.AwayFromZero);
// 姓名始终按人员字典显示 // 姓名始终按人员字典显示
item.EmployeeName = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.DoctorName ?? ""; item.EmployeeName = employees?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.DoctorName ?? "";
// 人员信息使用人员字典中数据 // 人员信息使用人员字典中数据
if (isEmpDic) if (isEmpDic)
{ {
item.AccountingUnit = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.AccountingUnit ?? ""; item.AccountingUnit = employees?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.AccountingUnit ?? "";
item.UnitType = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.UnitType ?? ""; item.UnitType = employees?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.UnitType ?? "";
} }
} }
} }
response.RemoveAll(w => w.PerforSumFee == 0 && w.PerforManagementFee == 0 && w.ShouldGiveFee == 0 && w.OthePerfor == 0 && w.RealGiveFee == 0);
return result?.OrderByDescending(t => t.AccountingUnit).ToList(); return response?.OrderByDescending(t => t.AccountingUnit).ToList();
} }
/// <summary> /// <summary>
...@@ -837,39 +839,63 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i ...@@ -837,39 +839,63 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
private List<ComputeResponse> GetSecondPerformance(int allotId) private List<ComputeResponse> GetSecondPerformance(int allotId, List<per_employee> employees, List<view_per_apr_amount> fullAmounts)
{ {
List<ComputeResponse> responses = new List<ComputeResponse>();
var again = _perforAgcomputeRepository.GetEntities(t => t.AllotId == allotId); var again = _perforAgcomputeRepository.GetEntities(t => t.AllotId == allotId);
if (again != null && again.Any()) if (again == null || !again.Any())
{ {
var disAgains = again.Select(w => new return responses;
}
var disAgains = again
.Select(w => new { w.AllotId, w.SecondId, w.UnitType, w.Department, w.WorkPost, w.JobNumber, w.PersonName, w.PerforSumFee, w.OthePerfor, w.NightWorkPerfor, w.RealGiveFee })
.Distinct();
responses = disAgains
.GroupBy(t => new { t.UnitType, t.Department, t.WorkPost, t.JobNumber, t.PersonName })
.Select(t =>
{ {
w.AllotId, var comp = new ComputeResponse("二次绩效", t.Key.Department, t.Key.PersonName, t.Key.JobNumber, t.Key.WorkPost);
w.SecondId, comp.UnitType = t.Key.UnitType;
w.UnitType, comp.PerforSumFee = t.Sum(g => g.PerforSumFee);
w.Department, comp.NightWorkPerfor = t.Sum(g => g.NightWorkPerfor);
w.WorkPost, return comp;
w.JobNumber, })?.ToList();
w.PersonName,
w.PerforSumFee, if (fullAmounts == null || !fullAmounts.Any())
w.OthePerfor, {
w.NightWorkPerfor, return responses;
w.RealGiveFee }
}).Distinct();
var group = disAgains // 补充字典中该科室不存在,但有其它绩效的人员信息
.GroupBy(t => new { t.UnitType, t.Department, t.WorkPost, t.JobNumber, t.PersonName }) foreach (var second in disAgains.Select(w => new { w.UnitType, w.Department }).Distinct())
.Select(t => {
var amounts = fullAmounts.Where(w => w.UnitType == second.UnitType && w.AccountingUnit == second.Department);
var jobNumbers = fullAmounts
.Where(w => w.UnitType == second.UnitType && w.AccountingUnit == second.Department)
.Select(t => t.PersonnelNumber)
.Distinct();
foreach (var jobNumber in jobNumbers)
{
if (!responses.Any(w => w.UnitType == second.UnitType && w.AccountingUnit == second.Department && w.JobNumber == jobNumber))
{ {
var comp = new ComputeResponse("二次绩效", t.Key.Department, t.Key.PersonName, t.Key.JobNumber, t.Key.WorkPost); per_employee employee = employees?.FirstOrDefault(t => t.UnitType == second.UnitType && t.AccountingUnit == second.Department && t.PersonnelNumber == jobNumber);
comp.UnitType = t.Key.UnitType; if (employee != null && employee.UnitType == second.UnitType)
comp.PerforSumFee = t.Sum(g => g.PerforSumFee); {
comp.NightWorkPerfor = t.Sum(g => g.NightWorkPerfor); var bc = new ComputeResponse("二次绩效", second.Department, employee.DoctorName, jobNumber, employee.JobTitle);
return comp; bc.UnitType = employee.UnitType;
}); responses.Add(bc);
return group?.ToList(); }
}
}
} }
return null;
return responses;
} }
/// <summary> /// <summary>
...@@ -877,21 +903,17 @@ private List<ComputeResponse> GetSecondPerformance(int allotId) ...@@ -877,21 +903,17 @@ private List<ComputeResponse> GetSecondPerformance(int allotId)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="computes"></param> /// <param name="computes"></param>
public List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> computes) public List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> computes, List<view_per_apr_amount> fullAmounts)
{ {
if (computes == null || !computes.Any()) if (computes == null || !computes.Any())
return computes; return computes;
var list = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Status == 3);
if (list == null || !list.Any())
return computes;
List<string> uses = new List<string>(); List<string> uses = new List<string>();
foreach (var item in computes.Where(w => !string.IsNullOrEmpty(w.JobNumber)).GroupBy(w => new { w.AccountingUnit, w.JobNumber })) foreach (var item in computes.Where(w => !string.IsNullOrEmpty(w.JobNumber)).GroupBy(w => new { w.AccountingUnit, w.JobNumber }))
{ {
// 补充过一次就不在补充了 // 补充过一次就不在补充了
var emp = computes.Where(w => w.AccountingUnit == item.Key.AccountingUnit && w.JobNumber == item.Key.JobNumber).OrderByDescending(w => w.Source).FirstOrDefault(); var emp = computes.Where(w => w.AccountingUnit == item.Key.AccountingUnit && w.JobNumber == item.Key.JobNumber).OrderByDescending(w => w.Source).FirstOrDefault();
var apramount = list.Where(t => t.AccountingUnit == emp.AccountingUnit && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim()); var apramount = fullAmounts?.Where(t => t.AccountingUnit == emp.AccountingUnit && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim());
// 如果医院其他绩效 已经被使用,则不再多次带出,防止单个人多次出现造成金额叠加 // 如果医院其他绩效 已经被使用,则不再多次带出,防止单个人多次出现造成金额叠加
var tag = $"{(emp.AccountingUnit ?? "")}-{(emp.JobNumber ?? "")}"; var tag = $"{(emp.AccountingUnit ?? "")}-{(emp.JobNumber ?? "")}";
if (apramount != null && !uses.Contains(tag)) if (apramount != null && !uses.Contains(tag))
...@@ -899,16 +921,6 @@ public List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> com ...@@ -899,16 +921,6 @@ public List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> com
emp.OthePerfor = apramount?.Sum(w => w.Amount) ?? 0; emp.OthePerfor = apramount?.Sum(w => w.Amount) ?? 0;
uses.Add(tag); uses.Add(tag);
} }
//foreach (var emp in computes)
//{
// if (!emp.OthePerfor.HasValue || emp.OthePerfor == 0)
// {
// var apramount = list.Where(t => t.AccountingUnit == emp.AccountingUnit
// && !string.IsNullOrEmpty(t.PersonnelNumber) && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim());
// emp.OthePerfor = apramount?.Sum(w => w.Amount) ?? 0;
// }
//}
} }
return computes; return computes;
......
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