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

parent 5867b3c6
......@@ -711,22 +711,24 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
/// <returns></returns>
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)
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 empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
foreach (var item in result)
foreach (var item in response)
{
// 二次分配默认 调节系数100%
var adjust = item.Source == "二次绩效" ? 1 : (item.Adjust ?? 1);
......@@ -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.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.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)
{
item.AccountingUnit = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.AccountingUnit ?? "";
item.UnitType = empDic?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.UnitType ?? "";
item.AccountingUnit = employees?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.AccountingUnit ?? "";
item.UnitType = employees?.FirstOrDefault(w => w.PersonnelNumber == item.JobNumber)?.UnitType ?? "";
}
}
}
return result?.OrderByDescending(t => t.AccountingUnit).ToList();
response.RemoveAll(w => w.PerforSumFee == 0 && w.PerforManagementFee == 0 && w.ShouldGiveFee == 0 && w.OthePerfor == 0 && w.RealGiveFee == 0);
return response?.OrderByDescending(t => t.AccountingUnit).ToList();
}
/// <summary>
......@@ -837,26 +839,21 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i
/// </summary>
/// <param name="allotId"></param>
/// <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);
if (again != null && again.Any())
{
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();
var group = disAgains
if (again == null || !again.Any())
{
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 =>
{
......@@ -865,11 +862,40 @@ private List<ComputeResponse> GetSecondPerformance(int allotId)
comp.PerforSumFee = t.Sum(g => g.PerforSumFee);
comp.NightWorkPerfor = t.Sum(g => g.NightWorkPerfor);
return comp;
});
return group?.ToList();
})?.ToList();
if (fullAmounts == null || !fullAmounts.Any())
{
return responses;
}
return null;
// 补充字典中该科室不存在,但有其它绩效的人员信息
foreach (var second in disAgains.Select(w => new { w.UnitType, w.Department }).Distinct())
{
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))
{
per_employee employee = employees?.FirstOrDefault(t => t.UnitType == second.UnitType && t.AccountingUnit == second.Department && t.PersonnelNumber == jobNumber);
if (employee != null && employee.UnitType == second.UnitType)
{
var bc = new ComputeResponse("二次绩效", second.Department, employee.DoctorName, jobNumber, employee.JobTitle);
bc.UnitType = employee.UnitType;
responses.Add(bc);
}
}
}
}
return responses;
}
/// <summary>
......@@ -877,21 +903,17 @@ private List<ComputeResponse> GetSecondPerformance(int allotId)
/// </summary>
/// <param name="allotId"></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())
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>();
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 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 ?? "")}";
if (apramount != null && !uses.Contains(tag))
......@@ -899,16 +921,6 @@ public List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> com
emp.OthePerfor = apramount?.Sum(w => w.Amount) ?? 0;
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;
......
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