Commit bbfd60a6 by ruyun.zhang@suvalue.com

Merge branch 'hotfix/医院其他绩效大改'

parents b68a8a78 27e9051f
...@@ -405,9 +405,7 @@ public ApiResponse<res_baiscnorm> EditHospitalAvg([FromBody] ComputerAvgRequest ...@@ -405,9 +405,7 @@ public ApiResponse<res_baiscnorm> EditHospitalAvg([FromBody] ComputerAvgRequest
[HttpPost] [HttpPost]
public ApiResponse OtherPerStats(int allotId) public ApiResponse OtherPerStats(int allotId)
{ {
var employee = _employeeService.GetAprList(allotId, _claim.GetUserId()); var relust = _employeeService.GetOtherPerStats(allotId);
var relust = _computeService.GetOtherPerStats(employee);
return new ApiResponse(ResponseType.OK, relust); return new ApiResponse(ResponseType.OK, relust);
} }
......
...@@ -42,6 +42,7 @@ public static void Main(string[] args) ...@@ -42,6 +42,7 @@ public static void Main(string[] args)
.ConfigureLogging(logging => .ConfigureLogging(logging =>
{ {
logging.ClearProviders(); logging.ClearProviders();
logging.AddConsole();
logging.SetMinimumLevel(LogLevel.Trace); logging.SetMinimumLevel(LogLevel.Trace);
}) })
.UseNLog() .UseNLog()
......
...@@ -4361,11 +4361,6 @@ ...@@ -4361,11 +4361,6 @@
录入科室 录入科室
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.per_apr_amount.AccountingUnit">
<summary>
核算单元
</summary>
</member>
<member name="P:Performance.EntityModels.per_apr_amount.Status"> <member name="P:Performance.EntityModels.per_apr_amount.Status">
<summary> <summary>
状态 1 未提交 2 等待审核 3 审核通过 4 驳回 状态 1 未提交 2 等待审核 3 审核通过 4 驳回
...@@ -7326,5 +7321,15 @@ ...@@ -7326,5 +7321,15 @@
费用 费用
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.view_per_apr_amount.UnitType">
<summary>
核算单元组别
</summary>
</member>
<member name="P:Performance.EntityModels.view_per_apr_amount.AccountingUnit">
<summary>
核算单元
</summary>
</member>
</members> </members>
</doc> </doc>
...@@ -50,12 +50,12 @@ public class per_apr_amount ...@@ -50,12 +50,12 @@ public class per_apr_amount
/// 录入科室 /// 录入科室
/// </summary> /// </summary>
public string TypeInDepartment { get; set; } public string TypeInDepartment { get; set; }
/// <summary> ///// <summary>
/// 核算单元 ///// 核算单元
/// </summary> ///// </summary>
public string AccountingUnit { get; set; } //public string AccountingUnit { get; set; }
/// <summary> /// <summary>
/// 状态 1 未提交 2 等待审核 3 审核通过 4 驳回 /// 状态 1 未提交 2 等待审核 3 审核通过 4 驳回
/// </summary> /// </summary>
......
namespace Performance.EntityModels
{
public class view_per_apr_amount : per_apr_amount
{
/// <summary>
/// 核算单元组别
/// </summary>
public string UnitType { get; set; }
/// <summary>
/// 核算单元
/// </summary>
public string AccountingUnit { get; set; }
}
}
//-----------------------------------------------------------------------
// <copyright file=" per_apr_amount.cs">
// * FileName: per_apr_amount.cs
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using Performance.EntityModels;
namespace Performance.Repository
{
/// <summary>
/// per_apr_amount Repository
/// </summary>
public partial class PerforPerapramountRepository : PerforRepository<per_apr_amount>
{
public List<view_per_apr_amount> GetFullAmount(Func<per_apr_amount, bool> predicate)
{
var employees = this.context.Set<per_employee>().AsEnumerable();
var amounts = this.context.Set<per_apr_amount>().Where(predicate);
var res = amounts.Join(employees,
outer => new { outer.AllotId, outer.PersonnelNumber },
inner => new { AllotId = inner.AllotId ?? 0, inner.PersonnelNumber },
(outer, inner) => new view_per_apr_amount
{
Id = outer.Id,
AllotId = outer.AllotId,
PersonnelNumber = outer.PersonnelNumber,
DoctorName = outer.DoctorName,
PerforType = outer.PerforType,
Amount = outer.Amount,
AccountingUnit = inner.AccountingUnit,
UnitType = inner.UnitType,
TypeInDepartment = outer.TypeInDepartment,
Status = outer.Status,
AuditTime = outer.AuditTime,
AuditUser = outer.AuditUser,
CreateDate = outer.CreateDate,
CreateUser = outer.CreateUser,
Remark = outer.Remark,
IsVerify = outer.IsVerify,
VerifyMessage = outer.VerifyMessage,
});
return res.ToList() ?? new List<view_per_apr_amount>();
}
}
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
// </copyright> // </copyright>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
using System; using System;
using System.Collections.Generic;
using System.Linq;
using Performance.EntityModels; using Performance.EntityModels;
namespace Performance.Repository namespace Performance.Repository
...@@ -13,7 +15,7 @@ namespace Performance.Repository ...@@ -13,7 +15,7 @@ namespace Performance.Repository
/// </summary> /// </summary>
public partial class PerforPerapramountRepository : PerforRepository<per_apr_amount> public partial class PerforPerapramountRepository : PerforRepository<per_apr_amount>
{ {
public PerforPerapramountRepository(PerformanceDbContext context) : base(context) public PerforPerapramountRepository(PerformanceDbContext context) : base(context)
{ {
} }
} }
......
...@@ -468,25 +468,16 @@ public List<DeptResponse> GetOfficePerformance(int allotId) ...@@ -468,25 +468,16 @@ 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 amounts = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3) ?? new List<per_apr_amount>();
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 otherPerformances = amounts.Join(employees, var amounts = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Status == 3);
outer => new { outer.AccountingUnit, outer.PersonnelNumber }, var otherPerformances = amounts.GroupBy(t => new { t.AccountingUnit, t.UnitType }).Select(t => new
inner => new { inner.AccountingUnit, inner.PersonnelNumber }, {
(outer, inner) => new AccountingUnit = t.Key.AccountingUnit,
{ UnitType = t.Key.UnitType == "行政后勤" ? "行政工勤" : t.Key.UnitType,
AccountingUnit = outer.AccountingUnit, Amount = t.Sum(s => s.Amount)
UnitType = inner.UnitType, }).ToList();
PersonnelNumber = inner.PersonnelNumber,
PersonnelName = outer.DoctorName,
Amount = outer.Amount
})?.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)
});
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();
...@@ -720,22 +711,24 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty ...@@ -720,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);
...@@ -758,21 +751,21 @@ public List<ComputeResponse> AllCompute(int allotId, int hospitalId, int isShowM ...@@ -758,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>
...@@ -846,39 +839,63 @@ private List<ComputeResponse> GetAllotPerformance(int allotId, int hospitalId, i ...@@ -846,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())
{
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 =>
{
var comp = new ComputeResponse("二次绩效", t.Key.Department, t.Key.PersonName, t.Key.JobNumber, t.Key.WorkPost);
comp.UnitType = t.Key.UnitType;
comp.PerforSumFee = t.Sum(g => g.PerforSumFee);
comp.NightWorkPerfor = t.Sum(g => g.NightWorkPerfor);
return comp;
})?.ToList();
if (fullAmounts == null || !fullAmounts.Any())
{
return responses;
}
// 补充字典中该科室不存在,但有其它绩效的人员信息
foreach (var second in disAgains.Select(w => new { w.UnitType, w.Department }).Distinct())
{ {
var disAgains = again.Select(w => new 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)
{ {
w.AllotId, if (!responses.Any(w => w.UnitType == second.UnitType && w.AccountingUnit == second.Department && w.JobNumber == jobNumber))
w.SecondId,
w.UnitType,
w.Department,
w.WorkPost,
w.JobNumber,
w.PersonName,
w.PerforSumFee,
w.OthePerfor,
w.NightWorkPerfor,
w.RealGiveFee
}).Distinct();
var group = disAgains
.GroupBy(t => new { t.UnitType, t.Department, t.WorkPost, t.JobNumber, t.PersonName })
.Select(t =>
{ {
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>
...@@ -886,21 +903,17 @@ private List<ComputeResponse> GetSecondPerformance(int allotId) ...@@ -886,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.GetEntities(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.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 && !string.IsNullOrEmpty(t.PersonnelNumber) && 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))
...@@ -908,16 +921,6 @@ public List<ComputeResponse> AddAprAmount(int allotId, List<ComputeResponse> com ...@@ -908,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;
...@@ -1789,44 +1792,45 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request) ...@@ -1789,44 +1792,45 @@ public res_baiscnorm EditHospitalAvg(ComputerAvgRequest request)
} }
} }
public List<Dictionary<string, string>> GetOtherPerStats(List<per_apr_amount> employees)
{
var others = new List<Dictionary<string, string>>();
if (employees == null)
return others;
var perForType = employees.Where(c => c.Status == 3).Select(t => t.PerforType).Distinct(); //public List<Dictionary<string, string>> GetOtherPerStats(List<per_apr_amount> employees)
var doctorNum = employees.Where(c => c.Status == 3).Select(t => t.PersonnelNumber).Distinct().ToList(); //{
// var others = new List<Dictionary<string, string>>();
// if (employees == null)
// return others;
if (!doctorNum.Any()) // var perForType = employees.Where(c => c.Status == 3).Select(t => t.PerforType).Distinct();
return others; // var doctorNum = employees.Where(c => c.Status == 3).Select(t => t.PersonnelNumber).Distinct().ToList();
foreach (var num in doctorNum) // if (!doctorNum.Any())
{ // return others;
var dicData = new Dictionary<string, string>();
var amount = employees.Find(t => t.PersonnelNumber == num);
if (amount == null)
continue;
dicData.Add("核算单元", amount?.AccountingUnit ?? "");
dicData.Add("工号", amount?.PersonnelNumber ?? "");
dicData.Add("人员姓名", amount?.DoctorName ?? "");
foreach (var type in perForType) // foreach (var num in doctorNum)
{ // {
var emp = employees.Where(t => t.PerforType == type && t.PersonnelNumber == num)?.ToList(); // var dicData = new Dictionary<string, string>();
if (!emp.Any()) // var amount = employees.Find(t => t.PersonnelNumber == num);
dicData.Add(type, "0"); // if (amount == null)
else // continue;
dicData.Add(type, Math.Round(Convert.ToDecimal(emp?.Sum(c => c.Amount))).ToString()); // dicData.Add("核算单元", amount?.AccountingUnit ?? "");
} // dicData.Add("工号", amount?.PersonnelNumber ?? "");
// dicData.Add("人员姓名", amount?.DoctorName ?? "");
// foreach (var type in perForType)
// {
// var emp = employees.Where(t => t.PerforType == type && t.PersonnelNumber == num)?.ToList();
// if (!emp.Any())
// dicData.Add(type, "0");
// else
// dicData.Add(type, Math.Round(Convert.ToDecimal(emp?.Sum(c => c.Amount))).ToString());
// }
var sum = employees.Where(c => c.PersonnelNumber == num)?.Sum(t => t.Amount); // var sum = employees.Where(c => c.PersonnelNumber == num)?.Sum(t => t.Amount);
dicData.Add("合计", Math.Round(Convert.ToDecimal(sum), 0).ToString()); // dicData.Add("合计", Math.Round(Convert.ToDecimal(sum), 0).ToString());
others.Add(dicData); // others.Add(dicData);
} // }
return others; // return others;
} //}
private decimal GetDecimal(decimal? value, decimal _ = 0) private decimal GetDecimal(decimal? value, decimal _ = 0)
{ {
......
...@@ -31,9 +31,11 @@ public class EmployeeService : IAutoInjection ...@@ -31,9 +31,11 @@ public class EmployeeService : IAutoInjection
private PerforUserroleRepository userroleRepository; private PerforUserroleRepository userroleRepository;
private PerforPeremployeeRepository peremployeeRepository; private PerforPeremployeeRepository peremployeeRepository;
private PerforUserRepository userRepository; private PerforUserRepository userRepository;
private readonly PerforRoleRepository _roleRepository;
private ILogger<EmployeeService> logger; private ILogger<EmployeeService> logger;
public EmployeeService(PerforImemployeeRepository perforImemployeeRepository, public EmployeeService(
PerforImemployeeRepository perforImemployeeRepository,
PerforPersheetRepository perforPersheetRepository, PerforPersheetRepository perforPersheetRepository,
PerforImdataRepository perforImdataRepository, PerforImdataRepository perforImdataRepository,
PerforPerallotRepository perforPerallotRepository, PerforPerallotRepository perforPerallotRepository,
...@@ -45,6 +47,7 @@ public class EmployeeService : IAutoInjection ...@@ -45,6 +47,7 @@ public class EmployeeService : IAutoInjection
PerforUserroleRepository userroleRepository, PerforUserroleRepository userroleRepository,
PerforPeremployeeRepository peremployeeRepository, PerforPeremployeeRepository peremployeeRepository,
PerforUserRepository userRepository, PerforUserRepository userRepository,
PerforRoleRepository roleRepository,
ILogger<EmployeeService> logger) ILogger<EmployeeService> logger)
{ {
this.perforImemployeeRepository = perforImemployeeRepository; this.perforImemployeeRepository = perforImemployeeRepository;
...@@ -59,6 +62,7 @@ public class EmployeeService : IAutoInjection ...@@ -59,6 +62,7 @@ public class EmployeeService : IAutoInjection
this.userroleRepository = userroleRepository; this.userroleRepository = userroleRepository;
this.peremployeeRepository = peremployeeRepository; this.peremployeeRepository = peremployeeRepository;
this.userRepository = userRepository; this.userRepository = userRepository;
_roleRepository = roleRepository;
this.logger = logger; this.logger = logger;
} }
...@@ -402,9 +406,9 @@ public List<per_apr_amount> GetAprList(int allotId, int userId) ...@@ -402,9 +406,9 @@ public List<per_apr_amount> GetAprList(int allotId, int userId)
return list; return list;
} }
public List<per_apr_amount> GetAprList(int allotId, string department) public List<view_per_apr_amount> GetAprList(int allotId, string department)
{ {
var list = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Amount.HasValue && t.Amount != 0 && (t.TypeInDepartment ?? "") == department); var list = perapramountRepository.GetFullAmount(t => t.AllotId == allotId && t.Amount.HasValue && t.Amount != 0 && (t.TypeInDepartment ?? "") == department);
if (list != null && list.Any()) if (list != null && list.Any())
list = list.OrderBy(t => t.DoctorName).ToList(); list = list.OrderBy(t => t.DoctorName).ToList();
...@@ -416,9 +420,12 @@ public bool InsertApr(per_apr_amount request, int userId) ...@@ -416,9 +420,12 @@ public bool InsertApr(per_apr_amount request, int userId)
if (request == null) if (request == null)
return false; return false;
//var data = perapramountRepository.GetEntity(t => t.PersonnelNumber == request.PersonnelNumber && t.AllotId == request.AllotId); if (string.IsNullOrEmpty(request.PersonnelNumber))
//if (data != null) throw new PerformanceException("文件中存在“工号”为空的数据");
// throw new PerformanceException("人员工号已存在"); if (string.IsNullOrEmpty(request.PerforType) && request.Amount != 0)
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
request.TypeInDepartment = GetTypeInDepartment(userId);
request.Status = 2; request.Status = 2;
request.CreateDate = DateTime.Now; request.CreateDate = DateTime.Now;
request.CreateUser = userId; request.CreateUser = userId;
...@@ -430,6 +437,12 @@ public bool UpdateApr(per_apr_amount request) ...@@ -430,6 +437,12 @@ public bool UpdateApr(per_apr_amount request)
if (request == null) if (request == null)
return false; return false;
if (string.IsNullOrEmpty(request.PersonnelNumber))
throw new PerformanceException("文件中存在“工号”为空的数据");
if (string.IsNullOrEmpty(request.PerforType) && request.Amount != 0)
throw new PerformanceException("文件中存在“绩效类型”为空的数据");
var data = perapramountRepository.GetEntity(t => t.Id == request.Id); var data = perapramountRepository.GetEntity(t => t.Id == request.Id);
if (data == null) if (data == null)
throw new PerformanceException("修改数据无效"); throw new PerformanceException("修改数据无效");
...@@ -438,8 +451,7 @@ public bool UpdateApr(per_apr_amount request) ...@@ -438,8 +451,7 @@ public bool UpdateApr(per_apr_amount request)
data.PersonnelNumber = request.PersonnelNumber; data.PersonnelNumber = request.PersonnelNumber;
data.DoctorName = request.DoctorName; data.DoctorName = request.DoctorName;
data.PerforType = request.PerforType; data.PerforType = request.PerforType;
data.TypeInDepartment = request.TypeInDepartment; //data.AccountingUnit = request.AccountingUnit;
data.AccountingUnit = request.AccountingUnit;
data.Amount = request.Amount; data.Amount = request.Amount;
return perapramountRepository.Update(data); return perapramountRepository.Update(data);
...@@ -490,6 +502,27 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request) ...@@ -490,6 +502,27 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
return true; return true;
} }
/// <summary>
/// 更加用户ID获取录入科室
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public string GetTypeInDepartment(int userId)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
string typeIn = "";
// 护士长/科主任/特殊科室/行政科室 录入科室为核算单元
if (new int[] { 3, 4, 9, 10 }.Contains(userrole.RoleID))
typeIn = userRepository.GetEntity(w => w.ID == userId)?.Department ?? "";
// 非 护士长/科主任/特殊科室/行政科室 则为角色名称
else
typeIn = _roleRepository.GetEntity(w => w.ID == userrole.RoleID)?.RoleName ?? "";
return typeIn;
}
public void ImpoerAprEmployees(int allotid, string path, int userid) public void ImpoerAprEmployees(int allotid, string path, int userid)
{ {
var userrole = userroleRepository.GetEntity(t => t.UserID == userid); var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
...@@ -532,7 +565,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -532,7 +565,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
Dictionary<string, int> dict = new Dictionary<string, int> Dictionary<string, int> dict = new Dictionary<string, int>
{ {
{ "录入科室", -1 },{ "核算单元", -1 },{ "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -1 }, { "人员工号", -1 }, { "姓名", -1 }, { "绩效类型", -1 }, { "金额", -1 },
}; };
foreach (var key in dict.Keys.ToList()) foreach (var key in dict.Keys.ToList())
...@@ -543,7 +576,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -543,7 +576,7 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
var entities = new List<per_apr_amount>(); var entities = new List<per_apr_amount>();
var createtime = DateTime.Now; var createtime = DateTime.Now;
var typeIn = GetTypeInDepartment(userid);
for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++) for (int rowindex = 1; rowindex < sheet.LastRowNum + 1; rowindex++)
{ {
var row = sheet.GetRow(rowindex); var row = sheet.GetRow(rowindex);
...@@ -556,8 +589,8 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -556,8 +589,8 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
DoctorName = dict["姓名"] < 0 ? "" : row.GetCell(dict["姓名"]).GetValue(), DoctorName = dict["姓名"] < 0 ? "" : row.GetCell(dict["姓名"]).GetValue(),
PerforType = dict["绩效类型"] < 0 ? "" : row.GetCell(dict["绩效类型"]).GetValue(), PerforType = dict["绩效类型"] < 0 ? "" : row.GetCell(dict["绩效类型"]).GetValue(),
Amount = dict["金额"] < 0 ? 0 : ConvertHelper.To<decimal>(row.GetCell(dict["金额"]).GetValue(), 0), Amount = dict["金额"] < 0 ? 0 : ConvertHelper.To<decimal>(row.GetCell(dict["金额"]).GetValue(), 0),
TypeInDepartment = dict["录入科室"] < 0 ? "" : row.GetCell(dict["录入科室"]).GetValue(), TypeInDepartment = typeIn,
AccountingUnit = dict["核算单元"] < 0 ? "" : row.GetCell(dict["核算单元"]).GetValue(), //AccountingUnit = dict["核算单元"] < 0 ? "" : row.GetCell(dict["核算单元"]).GetValue(),
AllotId = allotid, AllotId = allotid,
CreateDate = createtime, CreateDate = createtime,
CreateUser = userid, CreateUser = userid,
...@@ -572,14 +605,14 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -572,14 +605,14 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
throw new PerformanceException("文件中存在“工号”为空的数据"); throw new PerformanceException("文件中存在“工号”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0)) if (entities.Any(w => string.IsNullOrEmpty(w.PerforType) && w.Amount != 0))
throw new PerformanceException("文件中存在“绩效类型”为空的数据"); throw new PerformanceException("文件中存在“绩效类型”为空的数据");
if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0)) //if (entities.Any(w => string.IsNullOrEmpty(w.TypeInDepartment) && w.Amount != 0))
throw new PerformanceException("文件中存在“录入科室”为空的数据"); // throw new PerformanceException("文件中存在“录入科室”为空的数据");
var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid); //var employees = peremployeeRepository.GetEntities(w => w.AllotId == allotid);
foreach (var item in entities.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber))) //foreach (var item in entities.Where(w => !string.IsNullOrEmpty(w.PersonnelNumber)))
{ //{
item.AccountingUnit = employees?.FirstOrDefault(w => w.PersonnelNumber == item.PersonnelNumber)?.AccountingUnit ?? ""; // item.AccountingUnit = employees?.FirstOrDefault(w => w.PersonnelNumber == item.PersonnelNumber)?.AccountingUnit ?? "";
} //}
perapramountRepository.AddRange(entities.ToArray()); perapramountRepository.AddRange(entities.ToArray());
} }
} }
...@@ -599,17 +632,17 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -599,17 +632,17 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="jobNumber"></param> /// <param name="jobNumber"></param>
/// <returns></returns> /// <returns></returns>
public per_apr_amount GetEmployeeMessage(int allotId, string personnelNumber, int userId) public view_per_apr_amount GetEmployeeMessage(int allotId, string personnelNumber, int userId)
{ {
if (string.IsNullOrEmpty(personnelNumber)) return new per_apr_amount(); if (string.IsNullOrEmpty(personnelNumber)) return new view_per_apr_amount();
var user = userRepository.GetEntity(w => w.ID == userId && w.IsDelete == 1); var user = userRepository.GetEntity(w => w.ID == userId && w.IsDelete == 1);
if (user == null) throw new PerformanceException("操作用户不存在或用户信息错误!"); if (user == null) throw new PerformanceException("操作用户不存在或用户信息错误!");
var employee = peremployeeRepository.GetEntity(w => w.AllotId == allotId && w.PersonnelNumber.Trim() == personnelNumber.Trim()); var employee = peremployeeRepository.GetEntity(w => w.AllotId == allotId && w.PersonnelNumber.Trim() == personnelNumber.Trim());
if (employee == null) return new per_apr_amount(); if (employee == null) return new view_per_apr_amount();
return new per_apr_amount return new view_per_apr_amount
{ {
AllotId = allotId, AllotId = allotId,
PersonnelNumber = employee.PersonnelNumber, PersonnelNumber = employee.PersonnelNumber,
...@@ -690,5 +723,36 @@ public List<TitleValue> GetPerforTypeDict(int allotId) ...@@ -690,5 +723,36 @@ public List<TitleValue> GetPerforTypeDict(int allotId)
} }
#endregion #endregion
public List<Dictionary<string, string>> GetOtherPerStats(int allotId)
{
var others = new List<Dictionary<string, string>>();
var aprAmountList = perapramountRepository.GetFullAmount(w => w.AllotId == allotId && w.Status == 3);
var perForType = aprAmountList.Select(t => t.PerforType).Distinct();
foreach (var num in aprAmountList.Select(t => t.PersonnelNumber).Distinct())
{
var dicData = new Dictionary<string, string>();
var amount = aprAmountList.FirstOrDefault(t => t.PersonnelNumber == num);
if (amount == null) continue;
dicData.Add("核算单元", amount?.AccountingUnit ?? "");
dicData.Add("工号", amount?.PersonnelNumber ?? "");
dicData.Add("人员姓名", amount?.DoctorName ?? "");
foreach (var type in perForType)
{
var emp = aprAmountList.Where(t => t.PerforType == type && t.PersonnelNumber == num);
dicData.Add(type, Math.Round(emp?.Sum(c => c.Amount) ?? 0).ToString());
}
var sum = aprAmountList.Where(c => c.PersonnelNumber == num)?.Sum(t => t.Amount);
dicData.Add("合计", Math.Round(sum ?? 0, 0).ToString());
others.Add(dicData);
}
return others;
}
} }
} }
...@@ -481,7 +481,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<BodyItem> bo ...@@ -481,7 +481,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<BodyItem> bo
{ {
if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return; if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return;
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == secondAllot.AllotId && t.Status == 3); var perapramounts = perapramountRepository.GetFullAmount(t => t.AllotId == secondAllot.AllotId && t.Status == 3);
if (perapramounts == null || !perapramounts.Any()) return; if (perapramounts == null || !perapramounts.Any()) return;
var rowNumberList = bodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct().OrderBy(t => t).ToList(); var rowNumberList = bodyItems.Where(w => w.RowNumber > -1).Select(w => w.RowNumber).Distinct().OrderBy(t => t).ToList();
...@@ -808,7 +808,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is ...@@ -808,7 +808,7 @@ public List<ag_othersource> GetOtherTempDetails(int userId, int secondId, int is
private void SupplementSecondDetail(ag_secondallot second, List<per_employee> employees, List<ag_othersource> result, bool isTitlePerformance = true) private void SupplementSecondDetail(ag_secondallot second, List<per_employee> employees, List<ag_othersource> result, bool isTitlePerformance = true)
{ {
// 补充医院其他绩效 及 预留比例 // 补充医院其他绩效 及 预留比例
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId && t.Status == 3); var perapramounts = perapramountRepository.GetFullAmount(t => t.AllotId == second.AllotId && t.Status == 3);
var distPerformance = rescomputeRepository.GetEntities(t => t.AllotID == second.AllotId); var distPerformance = rescomputeRepository.GetEntities(t => t.AllotID == second.AllotId);
foreach (var item in result) foreach (var item in result)
......
...@@ -185,7 +185,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc ...@@ -185,7 +185,7 @@ private void SupplementOtherPerfor(ag_secondallot secondAllot, List<ag_bodysourc
{ {
if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return; if (bodyItems == null || !bodyItems.Any(w => w.RowNumber > -1)) return;
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == secondAllot.AllotId && t.Status == 3); var perapramounts = perapramountRepository.GetFullAmount(t => t.AllotId == secondAllot.AllotId && t.Status == 3);
if (perapramounts == null || !perapramounts.Any()) return; if (perapramounts == null || !perapramounts.Any()) return;
foreach (var rowitem in bodyItems) foreach (var rowitem in bodyItems)
......
...@@ -2145,7 +2145,7 @@ public List<SecPrintResponse> Print(int secondId) ...@@ -2145,7 +2145,7 @@ public List<SecPrintResponse> Print(int secondId)
} }
// 补充医院其他绩效 及 预留比例 // 补充医院其他绩效 及 预留比例
var perapramounts = perapramountRepository.GetEntities(t => t.AllotId == second.AllotId && t.Status == 3); var perapramounts = perapramountRepository.GetFullAmount(t => t.AllotId == second.AllotId && t.Status == 3);
var employees = personService.GetPerEmployee(second.AllotId.Value); var employees = personService.GetPerEmployee(second.AllotId.Value);
// 补充字典中该科室不存在,但有其它绩效的人员信息 // 补充字典中该科室不存在,但有其它绩效的人员信息
...@@ -2314,26 +2314,26 @@ private List<SecondPerforResponse> GetAllotPerformance(int allotId, List<res_com ...@@ -2314,26 +2314,26 @@ private List<SecondPerforResponse> GetAllotPerformance(int allotId, List<res_com
}).ToList(); }).ToList();
} }
public List<SecondPerforResponse> AddAprAmount(int allotId, List<SecondPerforResponse> computes) //public List<SecondPerforResponse> AddAprAmount(int allotId, List<SecondPerforResponse> computes)
{ //{
if (computes == null || !computes.Any()) // if (computes == null || !computes.Any())
return computes; // return computes;
var list = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3); // var list = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Status == 3);
if (list == null || !list.Any()) // if (list == null || !list.Any())
return computes; // return computes;
foreach (var item in computes.GroupBy(w => new { w.AccountingUnit, w.JobNumber })) // foreach (var item in computes.GroupBy(w => new { w.AccountingUnit, w.JobNumber }))
{ // {
// 补充过一次就不在补充了 // // 补充过一次就不在补充了
var emp = computes.Where(w => w.AccountingUnit == item.Key.AccountingUnit && w.JobNumber == item.Key.JobNumber) // var emp = computes.Where(w => w.AccountingUnit == item.Key.AccountingUnit && w.JobNumber == item.Key.JobNumber)
.OrderByDescending(w => w.Source).FirstOrDefault(); // .OrderByDescending(w => w.Source).FirstOrDefault();
var apramount = list.Where(t => t.AccountingUnit == emp.AccountingUnit // var apramount = list.Where(t => t.AccountingUnit == emp.AccountingUnit
&& !string.IsNullOrEmpty(t.PersonnelNumber) && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim()); // && !string.IsNullOrEmpty(t.PersonnelNumber) && emp.JobNumber?.Trim() == t.PersonnelNumber?.Trim());
emp.OthePerfor = apramount?.Sum(w => w.Amount) ?? 0; // 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