医院其他绩效大改,第二版医院其他绩效匹配不到则强制补充

parent 27e9051f
...@@ -7331,5 +7331,15 @@ ...@@ -7331,5 +7331,15 @@
核算单元 核算单元
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.view_per_total_amount.UnitType">
<summary>
核算单元组别
</summary>
</member>
<member name="P:Performance.EntityModels.view_per_total_amount.AccountingUnit">
<summary>
核算单元
</summary>
</member>
</members> </members>
</doc> </doc>
...@@ -11,4 +11,24 @@ public class view_per_apr_amount : per_apr_amount ...@@ -11,4 +11,24 @@ public class view_per_apr_amount : per_apr_amount
/// </summary> /// </summary>
public string AccountingUnit { get; set; } public string AccountingUnit { get; set; }
} }
public class view_per_total_amount
{
/// <summary>
/// 核算单元组别
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
public string PersonnelNumber { get; set; }
/// <summary>
/// 医院其他绩效
/// </summary>
public decimal Amount { get; set; }
/// <summary>
/// 是否被使用 默认false
/// </summary>
public bool Use { get; set; }
}
} }
...@@ -468,16 +468,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId) ...@@ -468,16 +468,7 @@ public List<DeptResponse> GetOfficePerformance(int allotId)
public List<DeptResponse> GetAdminPerformance(int allotId) public List<DeptResponse> GetAdminPerformance(int allotId)
{ {
var result = new List<DeptResponse>(); var result = new List<DeptResponse>();
//var employees = perforPeremployeeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_employee>();
var employees = perforPeremployeeRepository.GetEntities(t => t.AllotId == allotId) ?? new List<per_employee>();
// 获取各科室 医院其他绩效
var amounts = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Status == 3);
var otherPerformances = amounts.GroupBy(t => new { t.AccountingUnit, t.UnitType }).Select(t => new
{
AccountingUnit = t.Key.AccountingUnit,
UnitType = t.Key.UnitType == "行政后勤" ? "行政工勤" : t.Key.UnitType,
Amount = t.Sum(s => s.Amount)
}).ToList();
var clinicalTypes = new UnitType[] { UnitType.医生组, UnitType.其他医生组, UnitType.医技组, UnitType.其他医技组, UnitType.护理组, UnitType.其他护理组, UnitType.特殊核算组 }; var clinicalTypes = new UnitType[] { UnitType.医生组, UnitType.其他医生组, UnitType.医技组, UnitType.其他医技组, UnitType.护理组, UnitType.其他护理组, UnitType.特殊核算组 };
var clinicalTypesString = clinicalTypes.Select(w => w.ToString()).ToList(); var clinicalTypesString = clinicalTypes.Select(w => w.ToString()).ToList();
...@@ -596,13 +587,56 @@ public List<DeptResponse> GetAdminPerformance(int allotId) ...@@ -596,13 +587,56 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
RealGiveFee = t.Sum(w => w.RealGiveFee), RealGiveFee = t.Sum(w => w.RealGiveFee),
}); ; }); ;
result.AddRange(officeResult); result.AddRange(officeResult);
// 获取各科室 医院其他绩效
var amounts = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Status == 3);
var otherPerformances = amounts
?.GroupBy(t => new { t.AccountingUnit, t.UnitType })
.Select(t => new view_per_total_amount
{
AccountingUnit = t.Key.AccountingUnit,
UnitType = t.Key.UnitType == "行政后勤" ? "行政工勤" : t.Key.UnitType,
Amount = t.Sum(s => s.Amount) ?? 0,
Use = false
}).ToList();
// 医院其他绩效、科主任护士长管理绩效、合并实发 // 医院其他绩效、科主任护士长管理绩效、合并实发
foreach (var item in result) foreach (var item in result)
{ {
item.AprPerforAmount = otherPerformances?.Where(w => w.AccountingUnit == item.AccountingUnit && w.UnitType == item.UnitName)?.Sum(w => w.Amount) ?? 0; item.AprPerforAmount = 0;
var other = otherPerformances?.FirstOrDefault(w => w.AccountingUnit == item.AccountingUnit && w.UnitType == item.UnitName);
if (other != null)
{
other.Use = true;
item.AprPerforAmount = other?.Amount ?? 0;
}
item.AssessLaterManagementFee = item.AssessLaterManagementFee ?? 0; item.AssessLaterManagementFee = item.AssessLaterManagementFee ?? 0;
item.RealGiveFee = (item.RealGiveFee ?? 0) + item.AssessLaterManagementFee + item.AprPerforAmount; item.RealGiveFee = (item.RealGiveFee ?? 0) + item.AssessLaterManagementFee + item.AprPerforAmount;
} }
// 医院其他绩效匹配不上补充
var otherResult = otherPerformances
?.Where(w => w.Use == false)
.Select(t => new DeptResponse
{
UnitName = "医院其他绩效",
AccountingUnit = t.AccountingUnit,
Department = t.AccountingUnit,
PerforFee = 0,
WorkloadFee = 0,
AssessBeforeOtherFee = 0,
PerforTotal = 0,
ScoringAverage = 1,
Extra = 0,
MedicineExtra = 0,
MaterialsExtra = 0,
AssessLaterOtherFee = 0,
AssessLaterPerforTotal = 0,
AdjustFactor = 1,
AdjustLaterOtherFee = 0,
AprPerforAmount = t.Amount,
RealGiveFee = t.Amount,
}); ;
result.AddRange(otherResult);
var enumItems = EnumHelper.GetItems<AccountUnitType>(); var enumItems = EnumHelper.GetItems<AccountUnitType>();
result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value)/*.ThenBy(t => t.AccountingUnit)*/.ToList(); result = result.OrderBy(t => enumItems.FirstOrDefault(e => e.Name == t.UnitName)?.Value)/*.ThenBy(t => t.AccountingUnit)*/.ToList();
...@@ -711,18 +745,38 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty ...@@ -711,18 +745,38 @@ 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 employees = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
// 获取一次次绩效结果 // 获取医院其他绩效汇总结果
var response = GetAllotPerformance(allotId, hospitalId, isShowManage); var totalAmounts = GetTotalAmount(allotId);
// 获取一次绩效结果
var one = GetAllotPerformance(allotId, hospitalId, isShowManage);
// 获取二次绩效结果 // 获取二次绩效结果
var seconds = GetSecondPerformance(allotId, employees, fullAmounts); var two = GetSecondPerformance(allotId);
if (seconds != null)
response?.AddRange(seconds);
// 补充医院其他绩效 var response = new List<ComputeResponse>();
if (fullAmounts != null && fullAmounts.Any()) if (one != null)
response = AddAprAmount(allotId, response, fullAmounts); response.AddRange(one);
if (two != null)
response.AddRange(two);
// 补充医院其他绩效
AddAprAmount(response, totalAmounts);
// 补充一次二次分配不存在,但医院其他绩效的人员信息
var notMatchs = totalAmounts
?.Where(w => w.Use == false)
.Select(other =>
{
per_employee employee = employees?.FirstOrDefault(t => t.UnitType == other.UnitType && t.AccountingUnit == other.AccountingUnit && t.PersonnelNumber == other.PersonnelNumber);
var bc = new ComputeResponse("医院其他绩效", other.AccountingUnit, employee?.DoctorName ?? "", other.PersonnelNumber, employee?.JobTitle ?? "");
bc.UnitType = other.UnitType;
bc.OthePerfor = other.Amount;
bc.RealGiveFee = other.Amount;
return bc;
});
if (notMatchs != null)
response.AddRange(notMatchs);
// 预留比例 // 预留比例
if (response != null) if (response != null)
...@@ -765,7 +819,30 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM ...@@ -765,7 +819,30 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM
} }
} }
response.RemoveAll(w => w.PerforSumFee == 0 && w.PerforManagementFee == 0 && w.ShouldGiveFee == 0 && w.OthePerfor == 0 && w.RealGiveFee == 0); 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(); return response?.OrderByDescending(t => t.UnitType).ThenBy(t => t.AccountingUnit).ToList();
}
/// <summary>
/// 获取医院其他绩效汇总结果
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
private List<view_per_total_amount> GetTotalAmount(int allotId)
{
var fullAmounts = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Status == 3);
var totalAmounts = fullAmounts
?.GroupBy(w => new { w.AccountingUnit, w.UnitType, w.PersonnelNumber })
.Select(w => new view_per_total_amount
{
AccountingUnit = w.Key.AccountingUnit,
UnitType = w.Key.UnitType,
PersonnelNumber = w.Key.PersonnelNumber,
Amount = w.Sum(t => t.Amount) ?? 0,
Use = false,
});
return totalAmounts?.ToList() ?? new List<view_per_total_amount>();
} }
/// <summary> /// <summary>
...@@ -839,7 +916,7 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i ...@@ -839,7 +916,7 @@ 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, List<per_employee> employees, List<view_per_apr_amount> fullAmounts) private List<ComputeResponse> GetSecondPerformance(int allotId)
{ {
List<ComputeResponse> responses = new List<ComputeResponse>(); List<ComputeResponse> responses = new List<ComputeResponse>();
...@@ -864,37 +941,6 @@ private List<ComputeResponse> GetSecondPerformance(int allotId, List<per_employe ...@@ -864,37 +941,6 @@ private List<ComputeResponse> GetSecondPerformance(int allotId, List<per_employe
return comp; return comp;
})?.ToList(); })?.ToList();
if (fullAmounts == null || !fullAmounts.Any())
{
return responses;
}
// 补充字典中该科室不存在,但有其它绩效的人员信息
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; return responses;
} }
...@@ -903,91 +949,20 @@ private List<ComputeResponse> GetSecondPerformance(int allotId, List<per_employe ...@@ -903,91 +949,20 @@ private List<ComputeResponse> GetSecondPerformance(int allotId, List<per_employe
/// </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, List<view_per_apr_amount> fullAmounts) public void AddAprAmount(List<ComputeResponse> computes, List<view_per_total_amount> totalAmounts)
{ {
if (computes == null || !computes.Any()) foreach (var item in computes?.Where(w => !string.IsNullOrEmpty(w.JobNumber)).GroupBy(w => new { w.UnitType, w.AccountingUnit, w.JobNumber }))
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 apramount = totalAmounts?.FirstOrDefault(t => t.UnitType == item.Key.UnitType && t.AccountingUnit == item.Key.AccountingUnit && item.Key.JobNumber?.Trim() == t.PersonnelNumber?.Trim());
var emp = computes.Where(w => w.AccountingUnit == item.Key.AccountingUnit && w.JobNumber == item.Key.JobNumber).OrderByDescending(w => w.Source).FirstOrDefault();
var apramount = fullAmounts?.Where(t => t.AccountingUnit == emp.AccountingUnit && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim());
// 如果医院其他绩效 已经被使用,则不再多次带出,防止单个人多次出现造成金额叠加 // 如果医院其他绩效 已经被使用,则不再多次带出,防止单个人多次出现造成金额叠加
var tag = $"{(emp.AccountingUnit ?? "")}-{(emp.JobNumber ?? "")}"; if (apramount != null)
if (apramount != null && !uses.Contains(tag))
{ {
emp.OthePerfor = apramount?.Sum(w => w.Amount) ?? 0; item.First().OthePerfor = apramount.Amount;
uses.Add(tag); apramount.Use = true;
} }
} }
return computes;
} }
///// <summary>
///// 返回绩效发放列表
///// 科主任护士长返回管理绩效
///// </summary>
///// <param name="allotId">绩效ID</param>
///// <returns></returns>
//public List<ComputeResponse> AllManageCompute(int allotId)
//{
// var list = new List<ComputeResponse>();
// var mTypes = new[] { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政高层.ToString() };
// var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId && mTypes.Contains(t.AccountType))?.OrderByDescending(t => t.AccountingUnit);
// if (allot != null && allot.Any(t => t.AllotID == allotId))
// {
// var types = new List<string> { AccountUnitType.护士长.ToString(), AccountUnitType.科主任.ToString() };
// list = allot.Select(t => new ComputeResponse
// {
// Source = "一次绩效",
// AccountingUnit = t.AccountingUnit,
// EmployeeName = t.EmployeeName,
// JobNumber = t.JobNumber,
// JobTitle = t.JobTitle,
// RealGiveFee = types.Contains(t.AccountType) ? t.ShouldGiveFee : t.RealGiveFee
// }).ToList();
// }
// var again = _perforAgcomputeRepository.GetEntities(t => t.AllotId == allotId);
// if (again != null && again.Any())
// {
// var group = again.GroupBy(t => new { t.Department, t.WorkPost, t.JobNumber, t.PersonName })
// .Select(t => new
// {
// department = t.Key.Department,
// jobtitle = t.Key.WorkPost,
// jobnumber = t.Key.JobNumber,
// name = t.Key.PersonName,
// fee = t.Sum(g => g.RealGiveFee)
// });
// list.AddRange(group.Select(t => new ComputeResponse
// {
// Source = "二次绩效",
// AccountingUnit = t.department,
// JobNumber = t.jobnumber,
// JobTitle = t.jobtitle,
// EmployeeName = t.name,
// RealGiveFee = t.fee
// }).OrderByDescending(t => t.AccountingUnit));
// }
// var result = AddAprAmount(allotId, list);
// if (result != null)
// {
// var empDic = perforPeremployeeRepository.GetEntities(w => w.AllotId == allotId);
// foreach (var item in result)
// {
// var temp = item.RealGiveFee ?? 0;
// item.ReservedRatio = empDic?.FirstOrDefault(w => w.DoctorName == item.EmployeeName && w.PersonnelNumber == item.JobNumber)?.ReservedRatio ?? 0;
// item.ReservedRatioFee = temp * item.ReservedRatio;
// item.RealGiveFee = temp - item.ReservedRatioFee;
// }
// }
// return result;
//}
#endregion 绩效发放列表 #endregion 绩效发放列表
public res_compute GetComputeSingle(int computeid) public res_compute GetComputeSingle(int computeid)
......
...@@ -744,11 +744,11 @@ public List<TitleValue> GetPerforTypeDict(int allotId) ...@@ -744,11 +744,11 @@ public List<TitleValue> GetPerforTypeDict(int allotId)
foreach (var type in perForType) foreach (var type in perForType)
{ {
var emp = aprAmountList.Where(t => t.PerforType == type && t.PersonnelNumber == num); var emp = aprAmountList.Where(t => t.PerforType == type && t.PersonnelNumber == num);
dicData.Add(type, Math.Round(emp?.Sum(c => c.Amount) ?? 0).ToString()); dicData.Add(type, Math.Round(emp?.Sum(c => c.Amount) ?? 0, 2).ToString());
} }
var sum = aprAmountList.Where(c => c.PersonnelNumber == num)?.Sum(t => t.Amount); var sum = aprAmountList.Where(c => c.PersonnelNumber == num)?.Sum(t => t.Amount);
dicData.Add("合计", Math.Round(sum ?? 0, 0).ToString()); dicData.Add("合计", Math.Round(sum ?? 0, 2).ToString());
others.Add(dicData); others.Add(dicData);
} }
......
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