绩效发放表 改为视图

parent 5143bb0a
...@@ -386,7 +386,7 @@ public ApiResponse<res_baiscnorm> EditHospitalAvg([FromBody] ComputerAvgRequest ...@@ -386,7 +386,7 @@ public ApiResponse<res_baiscnorm> EditHospitalAvg([FromBody] ComputerAvgRequest
[HttpPost] [HttpPost]
public ApiResponse CustomColumnHeaders([FromBody] ComputerAliasRequest request) public ApiResponse CustomColumnHeaders([FromBody] ComputerAliasRequest request)
{ {
var result = _computeService.CustomColumnHeaders(request); var result = _computeService.CustomColumnHeaders(request.HospitalId, request.Route);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
...@@ -498,43 +498,68 @@ public IActionResult AllComputeByPMDownLoad(int allotId) ...@@ -498,43 +498,68 @@ public IActionResult AllComputeByPMDownLoad(int allotId)
#region 发放表视图、下载 #region 发放表视图、下载
/// <summary> /// <summary>
/// 获取全院绩效列表(视图) /// 全院核算绩效发放(视图)
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("allcomputeView")] [Route("gethosdataView")]
[HttpPost] [HttpPost]
public ApiResponse AllComputeView([FromBody] ComputerRequest request) public ApiResponse GethosdataView([FromBody] ComputerRequest request)
{ {
var allot = _allotService.GetAllot(request.AllotId); var allot = _allotService.GetAllot(request.AllotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var list = _computeService.GetAllComputeView(allot.HospitalId, request.AllotId, true); var list = _computeService.GetAllComputeView(allot.HospitalId, request.AllotId, "view_allot_sign_dept");
return new ApiResponse(ResponseType.OK, "ok", list); return new ApiResponse(ResponseType.OK, "ok", list);
} }
/// <summary> /// <summary>
/// 获取全院绩效列表(人事科) /// 全院核算绩效发放(视图) 下载
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
[Route("allcomputeView/personnel")] [Route("gethosdataView/download/{allotId}")]
[HttpPost] [HttpPost]
public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request) public IActionResult GethosdataView(int allotId)
{ {
var allot = _allotService.GetAllot(request.AllotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var result = _computeService.GetAllComputeView(allot.HospitalId, request.AllotId, false); var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept");
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/print/compute", "全院核算绩效发放");
//var result = _computeService.ComputerGroupBy(list);
return new ApiResponse(ResponseType.OK, "ok", result); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
var provider = new FileExtensionContentTypeProvider();
FileInfo fileInfo = new FileInfo(filepath);
var memi = provider.Mappings[".xlsx"];
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
} }
/// <summary>
/// 获取全院绩效列表(视图)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("allcomputeView")]
[HttpPost]
public ApiResponse AllComputeView([FromBody] ComputerRequest request)
{
var allot = _allotService.GetAllot(request.AllotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var list = _computeService.GetAllComputeView(allot.HospitalId, request.AllotId, "view_allot_sign_emp");
return new ApiResponse(ResponseType.OK, "ok", list);
}
/// <summary> /// <summary>
/// 下载全院绩效列表 /// 下载全院绩效列表
...@@ -549,8 +574,8 @@ public IActionResult AllComputeViewDownload(int allotId) ...@@ -549,8 +574,8 @@ public IActionResult AllComputeViewDownload(int allotId)
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, true); var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp");
var filepath = downloadService.AllComputerViewReport(allotId, list, true, "全院绩效发放"); var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/compute", "全院绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -564,8 +589,28 @@ public IActionResult AllComputeViewDownload(int allotId) ...@@ -564,8 +589,28 @@ public IActionResult AllComputeViewDownload(int allotId)
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name)); return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
} }
/// <summary> /// <summary>
/// 下载全院绩效列表(人事科/视图) /// 获取全院绩效列表(人事科)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("allcomputeView/personnel")]
[HttpPost]
public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request)
{
var allot = _allotService.GetAllot(request.AllotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var result = _computeService.GetAllComputeView(allot.HospitalId, request.AllotId, "view_allot_sign_emp_finance");
//var result = _computeService.ComputerGroupBy(list);
return new ApiResponse(ResponseType.OK, "ok", result);
}
/// <summary>
/// 下载全院绩效列表(人事科)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <returns></returns> /// <returns></returns>
...@@ -576,9 +621,9 @@ public IActionResult AllComputeByPMViewDownLoad(int allotId) ...@@ -576,9 +621,9 @@ public IActionResult AllComputeByPMViewDownLoad(int allotId)
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var result =_computeService.GetAllComputeView(allot.HospitalId, allotId, false); var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp_finance");
var filepath = downloadService.AllComputerViewReport(allotId, result, false, "财务全院绩效"); var filepath = downloadService.AllComputerViewReport(allotId, result, "/result/wholehospital", "财务全院绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
......
...@@ -575,16 +575,23 @@ ...@@ -575,16 +575,23 @@
<param name="allotId"></param> <param name="allotId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeView(Performance.DtoModels.ComputerRequest)"> <member name="M:Performance.Api.Controllers.ComputeController.GethosdataView(Performance.DtoModels.ComputerRequest)">
<summary> <summary>
获取全院绩效列表(视图) 全院核算绩效发放(视图)
</summary> </summary>
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllManageComputeView(Performance.DtoModels.ComputerRequest)"> <member name="M:Performance.Api.Controllers.ComputeController.GethosdataView(System.Int32)">
<summary>
全院核算绩效发放(视图) 下载
</summary>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeView(Performance.DtoModels.ComputerRequest)">
<summary> <summary>
获取全院管理绩效列表(视图) 获取全院绩效列表(视图)
</summary> </summary>
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
...@@ -596,9 +603,16 @@ ...@@ -596,9 +603,16 @@
<param name="allotId"></param> <param name="allotId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)">
<summary>
获取全院绩效列表(人事科)
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeByPMViewDownLoad(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeByPMViewDownLoad(System.Int32)">
<summary> <summary>
下载全院绩效列表(人事科/视图 下载全院绩效列表(人事科)
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<returns></returns> <returns></returns>
......
...@@ -61,6 +61,6 @@ public class view_allot_result ...@@ -61,6 +61,6 @@ public class view_allot_result
public string JobCategory { get; set; } public string JobCategory { get; set; }
public string Duty { get; set; } public string Duty { get; set; }
public string TitlePosition { get; set; } public string TitlePosition { get; set; }
} }
} }
namespace Performance.DtoModels
{
public class view_allot_sign_dept
{
public int HospitalId { get; set; }
public int AllotID { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public int UnitName { get; set; }
public int AccountingUnit { get; set; }
public int PerforFee { get; set; }
public int WorkloadFee { get; set; }
public int AssessBeforeOtherFee { get; set; }
public int PerforTotal { get; set; }
public int ScoringAverage { get; set; }
public int Extra { get; set; }
public int MedicineExtra { get; set; }
public int MaterialsExtra { get; set; }
public int AssessLaterOtherFee { get; set; }
public int AssessLaterPerforTotal { get; set; }
public int AdjustFactor { get; set; }
public int AdjustLaterOtherFee { get; set; }
public int AprPerforAmount { get; set; }
public int HideAprOtherPerforAmount { get; set; }
public int AssessLaterManagementFee { get; set; }
public int RealGiveFee { get; set; }
}
}
namespace Performance.DtoModels
{
public class view_allot_sign_emp
{
public int HospitalID { get; set; }
public int Year { get; set; }
public int Month { get; set; }
public int Source { get; set; }
public int AllotId { get; set; }
public int SecondId { get; set; }
public int States { get; set; }
public string UnitType { get; set; }
public string AccountingUnit { get; set; }
public string IsShowManage { get; set; }
public string EmployeeName { get; set; }
public string JobNumber { get; set; }
public string JobTitle { get; set; }
public string Emp_UnitType { get; set; }
public string Emp_AccountingUnit { get; set; }
public string BankCard { get; set; }
public string Batch { get; set; }
public string JobCategory { get; set; }
public string Duty { get; set; }
public string TitlePosition { get; set; }
public string PerforSumFee { get; set; }
public decimal PerforManagementFee { get; set; }
public decimal NightWorkPerfor { get; set; }
public decimal AdjustLaterOtherFee { get; set; }
public decimal OtherPerfor { get; set; }
public decimal HideOtherPerfor { get; set; }
public decimal ShouldGiveFee { get; set; }
public decimal ReservedRatioFee { get; set; }
public decimal RealGiveFee { get; set; }
}
}
...@@ -389,18 +389,11 @@ public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string ...@@ -389,18 +389,11 @@ public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string
return DapperQuery<view_allot_result>(sql, new { HospitalID = hospitalId, JobNumber = jobNumber })?.ToList(); return DapperQuery<view_allot_result>(sql, new { HospitalID = hospitalId, JobNumber = jobNumber })?.ToList();
} }
public List<dynamic> QueryAllCompute(int hospitalId,int allotId) public List<dynamic> QueryCompute(int allotId, string viewName)
{ {
var sql = $@"SELECT * FROM view_allot_result WHERE hospitalId = @hospitalId AND AllotId = @AllotId ORDER BY UnitType,AccountingUnit; "; var sql = $@"SELECT * FROM {viewName} WHERE AllotId = @AllotId; ";
return DapperQuery<dynamic>(sql, new { hospitalId, allotId })?.ToList(); return DapperQuery<dynamic>(sql, new { allotId })?.ToList();
}
public List<dynamic> QueryAdminCompute(int hospitalId, int allotId)
{
var sql = $@"SELECT * FROM view_allot_result_finance WHERE hospitalId=@hospitalId AND allotId=@allotId ORDER BY UnitType,AccountingUnit;";
return DapperQuery<dynamic>(sql, new { hospitalId, allotId })?.ToList();
} }
} }
} }
...@@ -605,7 +605,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId) ...@@ -605,7 +605,7 @@ public List<DeptResponse> GetAdminPerformance(int allotId)
AdjustFactor = t.FirstOrDefault()?.Adjust ?? 1, AdjustFactor = t.FirstOrDefault()?.Adjust ?? 1,
AdjustLaterOtherFee = t.Sum(w => w.AdjustLaterOtherFee), AdjustLaterOtherFee = t.Sum(w => w.AdjustLaterOtherFee),
RealGiveFee = t.Sum(w => Math.Round((w.GiveFee * w.Adjust + w.AdjustLaterOtherFee) ?? 0, MidpointRounding.AwayFromZero)), RealGiveFee = t.Sum(w => Math.Round((w.GiveFee * w.Adjust + w.AdjustLaterOtherFee) ?? 0, MidpointRounding.AwayFromZero)),
AssessLaterManagementFee = 0, AssessLaterManagementFee = 0,
}); ; }); ;
result.AddRange(officeResult); result.AddRange(officeResult);
#endregion #endregion
...@@ -1998,11 +1998,43 @@ private decimal GetDecimal(decimal? value, decimal _ = 0) ...@@ -1998,11 +1998,43 @@ private decimal GetDecimal(decimal? value, decimal _ = 0)
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
public List<cof_alias> CustomColumnHeaders(ComputerAliasRequest request) public List<cof_alias> CustomColumnHeaders(int hospitalId, string route)
{ {
var result = cofaliasRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Route == request.Route && t.States == 1); var alias = cofaliasRepository.GetEntities(t => t.HospitalId == hospitalId && t.Route.Equals(route, StringComparison.OrdinalIgnoreCase));
if (result == null || !result.Any()) return new List<cof_alias>();
return result; var pairs = new Dictionary<string, List<cof_alias>>
{
{ "/result/compute" , ComputeConfig.AllComputeView },
{ "/result/wholehospital" , ComputeConfig.AllComputePersonView },
{ "/result/print/compute" , ComputeConfig.AllComputeDepartmentView },
};
var init = pairs.ContainsKey(route.ToLower()) ? pairs[route.ToLower()] : new List<cof_alias>();
foreach (var item in init)
{
item.HospitalId = hospitalId;
item.Route = route;
item.OriginalName = item.Alias;
}
if (alias != null && alias.Count > 0)
{
foreach (var item in alias)
{
var x = init.FirstOrDefault(w => w.Name == item.Name);
if (x == null)
{
init.Add(item);
}
else
{
x.HospitalId = hospitalId;
x.Route = route;
x.Alias = item.Alias;
x.States = item.States;
}
}
}
return init;
} }
public bool Batch(BatchRequest request) public bool Batch(BatchRequest request)
...@@ -2029,26 +2061,76 @@ public bool Batch(BatchRequest request) ...@@ -2029,26 +2061,76 @@ public bool Batch(BatchRequest request)
return perforPerbatchRepository.AddRange(data.ToArray()); return perforPerbatchRepository.AddRange(data.ToArray());
} }
public List<dynamic> GetAllComputeView(int hospitalId,int AllotId,bool isAllCompte) public List<dynamic> GetAllComputeView(int hospitalId, int AllotId, string viewName)
{ {
var viewResult = new List<dynamic>(); return reportRepository.QueryCompute(AllotId, viewName);
if (isAllCompte)
viewResult = reportRepository.QueryAllCompute(hospitalId, AllotId);
else
viewResult = reportRepository.QueryAdminCompute(hospitalId, AllotId);
// 人员字典
var employees = perforPeremployeeRepository.GetEntities(w => w.AllotId == AllotId);
viewResult.ForEach(t =>
{
var employee=employees?.FirstOrDefault(w => w.PersonnelNumber == t.JobNumber);
var real = Math.Round((t.PerforSumFee ?? 0) + (t.PerforManagementFee ?? 0) + (t.AdjustLaterOtherFee ?? 0), 2, MidpointRounding.AwayFromZero);
t.ReservedRatioFee = Math.Round(real * (employee?.ReservedRatio ?? 0), 2, MidpointRounding.AwayFromZero);
t.RealPerformance = Math.Round(t.ShouldGiveFee - (t.ReservedRatioFee ?? 0) ?? 0, 2, MidpointRounding.AwayFromZero);
});
return viewResult;
} }
} }
public class ComputeConfig
{
public static List<cof_alias> AllComputeView { get; } = new List<cof_alias>
{
new cof_alias{ Alias = "来源", Name = nameof(view_allot_sign_emp.Source), States = 1},
new cof_alias{ Alias = "科室类别", Name = nameof(view_allot_sign_emp.UnitType), States = 1},
new cof_alias{ Alias = "核算单元", Name = nameof(view_allot_sign_emp.AccountingUnit), States = 1},
new cof_alias{ Alias = "员工号", Name = nameof(view_allot_sign_emp.JobNumber), States = 1},
new cof_alias{ Alias = "人员姓名", Name = nameof(view_allot_sign_emp.EmployeeName), States = 1},
new cof_alias{ Alias = "职务", Name = nameof(view_allot_sign_emp.JobTitle), States = 1},
new cof_alias{ Alias = "批次", Name = nameof(view_allot_sign_emp.Batch), States = 1},
new cof_alias{ Alias = "银行卡号", Name = nameof(view_allot_sign_emp.BankCard), States = 1},
new cof_alias{ Alias = "正式/临聘", Name = nameof(view_allot_sign_emp.JobCategory), States = 1},
new cof_alias{ Alias = "职务", Name = nameof(view_allot_sign_emp.Duty), States = 1},
new cof_alias{ Alias = "职称", Name = nameof(view_allot_sign_emp.TitlePosition), States = 1},
new cof_alias{ Alias = "调节后业绩绩效", Name = nameof(view_allot_sign_emp.PerforSumFee), States = 1},
new cof_alias{ Alias = "调节后实发管理绩效", Name = nameof(view_allot_sign_emp.PerforManagementFee), States = 1},
new cof_alias{ Alias = "调节后其他绩效", Name = nameof(view_allot_sign_emp.AdjustLaterOtherFee), States = 1},
new cof_alias{ Alias = "夜班费", Name = nameof(view_allot_sign_emp.NightWorkPerfor), States = 1},
new cof_alias{ Alias = "医院其他绩效", Name = nameof(view_allot_sign_emp.OtherPerfor), States = 1},
new cof_alias{ Alias = "不公示其他绩效", Name = nameof(view_allot_sign_emp.HideOtherPerfor), States = 1},
new cof_alias{ Alias = "应发小计", Name = nameof(view_allot_sign_emp.ShouldGiveFee), States = 1},
new cof_alias{ Alias = "预留绩效", Name = nameof(view_allot_sign_emp.ReservedRatioFee), States = 1},
new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_emp.RealGiveFee), States = 1},
};
public static List<cof_alias> AllComputePersonView { get; } = new List<cof_alias>
{
new cof_alias{ Alias = "科室类别", Name = nameof(view_allot_sign_emp.UnitType), States = 1},
new cof_alias{ Alias = "核算单元", Name = nameof(view_allot_sign_emp.AccountingUnit), States = 1},
new cof_alias{ Alias = "员工号", Name = nameof(view_allot_sign_emp.JobNumber), States = 1},
new cof_alias{ Alias = "人员姓名", Name = nameof(view_allot_sign_emp.EmployeeName), States = 1},
new cof_alias{ Alias = "调节后业绩绩效", Name = nameof(view_allot_sign_emp.PerforSumFee), States = 1},
new cof_alias{ Alias = "调节后实发管理绩效", Name = nameof(view_allot_sign_emp.PerforManagementFee), States = 1},
new cof_alias{ Alias = "调节后其他绩效", Name = nameof(view_allot_sign_emp.AdjustLaterOtherFee), States = 1},
new cof_alias{ Alias = "夜班费", Name = nameof(view_allot_sign_emp.NightWorkPerfor), States = 1},
new cof_alias{ Alias = "医院其他绩效", Name = nameof(view_allot_sign_emp.OtherPerfor), States = 1},
new cof_alias{ Alias = "不公示其他绩效", Name = nameof(view_allot_sign_emp.HideOtherPerfor), States = 1},
new cof_alias{ Alias = "应发小计", Name = nameof(view_allot_sign_emp.ShouldGiveFee), States = 1},
new cof_alias{ Alias = "预留绩效", Name = nameof(view_allot_sign_emp.ReservedRatioFee), States = 1},
new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_emp.RealGiveFee), States = 1},
};
public static List<cof_alias> AllComputeDepartmentView { get; } = new List<cof_alias>
{
new cof_alias{ Alias = "核算群体", Name = nameof(view_allot_sign_dept.UnitName), States = 1},
new cof_alias{ Alias = "核算单元", Name = nameof(view_allot_sign_dept.AccountingUnit), States = 1},
new cof_alias{ Alias = "业绩绩效", Name = nameof(view_allot_sign_dept.PerforFee), States = 1},
new cof_alias{ Alias = "工作量绩效", Name = nameof(view_allot_sign_dept.WorkloadFee), States = 1},
new cof_alias{ Alias = "考核前其他绩效", Name = nameof(view_allot_sign_dept.AssessBeforeOtherFee), States = 1},
new cof_alias{ Alias = "考核前绩效合计", Name = nameof(view_allot_sign_dept.PerforTotal), States = 1},
new cof_alias{ Alias = "科室考核得分", Name = nameof(view_allot_sign_dept.ScoringAverage), States = 1},
new cof_alias{ Alias = "药占比奖罚", Name = nameof(view_allot_sign_dept.MedicineExtra), States = 1},
new cof_alias{ Alias = "材料占比奖罚", Name = nameof(view_allot_sign_dept.MaterialsExtra), States = 1},
new cof_alias{ Alias = "医院奖罚", Name = nameof(view_allot_sign_dept.Extra), States = 1},
new cof_alias{ Alias = "考核后其他绩效", Name = nameof(view_allot_sign_dept.AssessLaterOtherFee), States = 1},
new cof_alias{ Alias = "考核后绩效", Name = nameof(view_allot_sign_dept.AssessLaterPerforTotal), States = 1},
new cof_alias{ Alias = "调节系数", Name = nameof(view_allot_sign_dept.AdjustFactor), States = 1},
new cof_alias{ Alias = "调节后其他绩效", Name = nameof(view_allot_sign_dept.AdjustLaterOtherFee), States = 1},
new cof_alias{ Alias = "科主任实发管理绩效", Name = nameof(view_allot_sign_dept.AssessLaterManagementFee), States = 1},
new cof_alias{ Alias = "医院其他绩效", Name = nameof(view_allot_sign_dept.AprPerforAmount), States = 1},
new cof_alias{ Alias = "不公示其他绩效", Name = nameof(view_allot_sign_dept.HideAprOtherPerforAmount), States = 1},
new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_dept.RealGiveFee), States = 1},
};
}
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
using NPOI.HSSF.UserModel; using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
...@@ -11,6 +13,7 @@ ...@@ -11,6 +13,7 @@
using Performance.Services.ExtractExcelService; using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -24,6 +27,7 @@ public class DownloadService : IAutoInjection ...@@ -24,6 +27,7 @@ public class DownloadService : IAutoInjection
private readonly PerforHospitalRepository perforHospital; private readonly PerforHospitalRepository perforHospital;
private readonly PerforCofaliasRepository perforCofalias; private readonly PerforCofaliasRepository perforCofalias;
private readonly ConfigService configService; private readonly ConfigService configService;
private readonly ComputeService _computeService;
private readonly IHostingEnvironment evn; private readonly IHostingEnvironment evn;
public DownloadService(ILogger<DownloadService> logger, public DownloadService(ILogger<DownloadService> logger,
...@@ -31,6 +35,7 @@ public class DownloadService : IAutoInjection ...@@ -31,6 +35,7 @@ public class DownloadService : IAutoInjection
PerforHospitalRepository perforHospital, PerforHospitalRepository perforHospital,
PerforCofaliasRepository perforCofalias, PerforCofaliasRepository perforCofalias,
ConfigService configService, ConfigService configService,
ComputeService computeService,
IHostingEnvironment evn) IHostingEnvironment evn)
{ {
this.logger = logger; this.logger = logger;
...@@ -38,6 +43,7 @@ public class DownloadService : IAutoInjection ...@@ -38,6 +43,7 @@ public class DownloadService : IAutoInjection
this.perforHospital = perforHospital; this.perforHospital = perforHospital;
this.perforCofalias = perforCofalias; this.perforCofalias = perforCofalias;
this.configService = configService; this.configService = configService;
_computeService = computeService;
this.evn = evn; this.evn = evn;
} }
...@@ -54,7 +60,7 @@ public class DownloadService : IAutoInjection ...@@ -54,7 +60,7 @@ public class DownloadService : IAutoInjection
/// <param name="allData"></param> /// <param name="allData"></param>
/// <param name="isAll"></param> /// <param name="isAll"></param>
/// <returns></returns> /// <returns></returns>
public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool isAll,string name) public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool isAll, string name)
{ {
var allot = perallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var hospital = perforHospital.GetEntity(t => t.ID == allot.HospitalId); var hospital = perforHospital.GetEntity(t => t.ID == allot.HospitalId);
...@@ -171,112 +177,73 @@ public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool ...@@ -171,112 +177,73 @@ public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool
/// <param name="allData"></param> /// <param name="allData"></param>
/// <param name="isAll"></param> /// <param name="isAll"></param>
/// <returns></returns> /// <returns></returns>
public string AllComputerViewReport(int allotId, List<view_allot_result> allData, bool isAll, string name) public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string route, string name)
{ {
var allot = perallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var hospital = perforHospital.GetEntity(t => t.ID == allot.HospitalId); var hospital = perforHospital.GetEntity(t => t.ID == allot.HospitalId);
var alias = perforCofalias.GetEntities(t => t.HospitalId == hospital.ID && t.States == 1); var alias = perforCofalias.GetEntities(t => t.HospitalId == hospital.ID);
var headShow = new List<string> { "银行卡号", "正式/临聘", "职务", "职称" };
var headList = AllComputeView;
if (!isAll)
{
headList = PersonView;
alias = alias?.Where(t => t.Route == "/result/wholeHospital")?.ToList();
if (alias != null)
headShow = headShow.Except(alias.Select(t => t.OriginalName)).ToList();
} var headList = _computeService.CustomColumnHeaders(hospital.ID, route);
else
{
alias = alias?.Where(t => t.Route == "/result/compute")?.ToList();
if (alias != null)
headShow = headShow.Except(alias.Select(t => t.OriginalName)).ToList();
}
var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{allot.HospitalId}"); var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{allot.HospitalId}");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
string filepath = Path.Combine(dpath, $"{hospital.HosName}-{name}-{DateTime.Now:yyyyMMdd}");
FileHelper.DeleteFile(filepath);
string fileName = $"{hospital.HosName}-{name}-{DateTime.Now:yyyyMMdd}"; using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
string filepath = Path.Combine(dpath, fileName); using (ExcelPackage package = new ExcelPackage(fs))
FileStream stream = new FileStream(filepath, FileMode.Create);
try
{ {
XSSFWorkbook workbook = new XSSFWorkbook(); var worksheet = package.Workbook.Worksheets.Add(name);
//设置单元格样式 worksheet.View.FreezePanes(2, 1);
ICellStyle style = workbook.CreateCellStyle(); if (dynamics != null && dynamics.Count() > 0)
style.Alignment = HorizontalAlignment.Center;
style.BorderBottom = BorderStyle.Thin;
style.BorderRight = BorderStyle.Thin;
ISheet sheet = workbook.CreateSheet($"{name}");
sheet.ForceFormulaRecalculation = true;
ICellStyle cellStyle = workbook.CreateCellStyle();
cellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("0.00");
IRow row1 = sheet.CreateRow(0);
row1.CreateCell(0).SetCellValue("序号");
row1.GetCell(0).CellStyle = style;
int cellIndex = 1;
foreach (var item in headList)
{ {
if (headShow.Contains(item.Item1)) var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys;
continue; for (int col = 0; col < headList.Count; col++)
row1.CreateCell(cellIndex).SetCellValue(item.Item1);
row1.GetCell(cellIndex).CellStyle = style;
sheet.SetColumnWidth(cellIndex, 14 * 256);
cellIndex++;
}
int startIndex = 1;
foreach (var item in allData)
{
var row = sheet.CreateRow(startIndex);
cellIndex = 1;
var serial = row.CreateCell(0);
serial.SetCellOValue(startIndex);
serial.CellStyle = style;
foreach (var field in headList)
{ {
if (headShow.Contains(field.Item1)) worksheet.SetValue(1, col + 1, headList[col].Alias);
continue; worksheet.Cells[1, col + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells[1, col + 1].Style.Border.Top.Style = ExcelBorderStyle.Thin;
worksheet.Cells[1, col + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin;
worksheet.Cells[1, col + 1].Style.Border.Left.Style = ExcelBorderStyle.Thin;
var cell = row.CreateCell(cellIndex);
cell.SetCellOValue(field.Item2?.Invoke(item));
cell.CellStyle = style;
cellIndex++;
} }
startIndex++; for (int col = 0; col < headList.Count; col++)
} {
//合计 for (int row = 0; row < dynamics.Count(); row++)
cellIndex = 1; {
var totalRow = sheet.CreateRow(startIndex); var data = dynamics.ElementAt(row);
var totalSerial = totalRow.CreateCell(0); var temp = (IDictionary<string, object>)data;
totalSerial.SetCellOValue("合计"); var value = temp[headList[col].Name];
totalSerial.CellStyle = style;
foreach (var value in headList) worksheet.Cells[row + 2, col + 1].Value = value;
{ worksheet.Cells[row + 2, col + 1].Style.Numberformat.Format = "#,##0.00";//这是保留两位小数
if (headShow.Contains(value.Item1)) worksheet.Cells[row + 2, col + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
continue; worksheet.Cells[row + 2, col + 1].Style.Border.Top.Style = ExcelBorderStyle.Thin;
worksheet.Cells[row + 2, col + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin;
var cell = totalRow.CreateCell(cellIndex); worksheet.Cells[row + 2, col + 1].Style.Border.Left.Style = ExcelBorderStyle.Thin;
cell.SetCellOValue(value.Item3?.Invoke(allData)); }
cell.CellStyle = style; if (col == 0)
cellIndex++; {
worksheet.SetValue(dynamics.Count() + 2, col + 1, "合计");
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Top.Style = ExcelBorderStyle.Thin;
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin;
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Left.Style = ExcelBorderStyle.Thin;
}
else
{
string address = new ExcelAddress(2, col + 1, dynamics.Count() + 1, col + 1).Address;
worksheet.Cells[dynamics.Count() + 2, col + 1].Formula = string.Format("SUM({0})", address);
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Numberformat.Format = "#,##0.00";//这是保留两位小数
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Top.Style = ExcelBorderStyle.Thin;
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin;
worksheet.Cells[dynamics.Count() + 2, col + 1].Style.Border.Left.Style = ExcelBorderStyle.Thin;
}
}
} }
workbook.Write(stream); package.Save();
}
catch (Exception ex)
{
Console.WriteLine("下载异常" + ex);
}
finally
{
stream.Close();
} }
return filepath; return filepath;
} }
...@@ -321,75 +288,7 @@ public string AllComputerViewReport(int allotId, List<view_allot_result> allData ...@@ -321,75 +288,7 @@ public string AllComputerViewReport(int allotId, List<view_allot_result> allData
("实发绩效",t=>t.RealGiveFee,(t) => Math.Round(t.Sum(item => item.RealGiveFee ?? 0), 2, MidpointRounding.AwayFromZero)) ("实发绩效",t=>t.RealGiveFee,(t) => Math.Round(t.Sum(item => item.RealGiveFee ?? 0), 2, MidpointRounding.AwayFromZero))
}; };
//public static List<(string, Func<view_allot_result, object>, Func<List<view_allot_result>, decimal>)> AllComputeView { get; } = new List<(string, Func<view_allot_result, object>, Func<List<view_allot_result>, decimal>)>
//{
// ("来源",t=>t.Source,null),
// ("科室类别",t=>t.UnitType,null),
// ("核算单元",t=>t.AccountingUnit,null),
// ("员工号",t=>t.JobNumber,null),
// ("人员姓名",t=>t.EmployeeName,null),
// ("职务",t=>t.JobTitle,null),
// //("批次",t=>t.Batch,null),
// ("调节后业绩绩效",t=>t.PerforSumFee,(t) => Math.Round(t.Sum(item => item.PerforSumFee ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("调节后实发管理绩效",t=>t.PerforManagementFee,(t) => Math.Round(t.Sum(item => item.PerforManagementFee ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("调节后其他绩效",t=>t.AdjustLaterOtherFee,(t) => Math.Round(t.Sum(item => item.AdjustLaterOtherFee ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("夜班费",t=>t.NightWorkPerfor,(t) => Math.Round(t.Sum(item => item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("医院其他绩效",t=>t.OtherPerfor,(t) => Math.Round(t.Sum(item => item.OtherPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("不公示其他绩效",t=>t.HideOtherPerfor,(t) => Math.Round(t.Sum(item => item.HideOtherPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("应发小计",t=>t.ShouldGiveFee,(t) => Math.Round(t.Sum(item => item.ShouldGiveFee ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("预留绩效",t=>t.ReservedRatioFee,(t) => Math.Round(t.Sum(item => item.ReservedRatioFee ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("实发绩效",t=>t.RealPerformance,(t) => Math.Round(t.Sum(item => item.RealPerformance ?? 0), 2, MidpointRounding.AwayFromZero)),
// ("银行卡号",t=>t.BankCard,null),
// ("正式/临聘",t=>t.JobCategory,null),
// ("职务",t=>t.Duty,null),
// ("职称",t=>t.TitlePosition,null),
//};
public static List<cof_alias>AllComputeView { get; } = new List<cof_alias>
{
new cof_alias{ Alias = "来源",Name = nameof(view_allot_result.Source), States = 1},
new cof_alias{ Alias = "科室类别",Name = nameof(view_allot_result.UnitType), States = 1},
new cof_alias{ Alias = "核算单元",Name = nameof(view_allot_result.AccountingUnit), States = 1},
//("",t=>t.UnitType,null),
//("",t=>t.AccountingUnit,null),
//("员工号",t=>t.JobNumber,null),
//("人员姓名",t=>t.EmployeeName,null),
//("职务",t=>t.JobTitle,null),
////("批次",t=>t.Batch,null),
//("调节后业绩绩效",t=>t.PerforSumFee,(t) => Math.Round(t.Sum(item => item.PerforSumFee ?? 0), 2, MidpointRounding.AwayFromZero)),
//("调节后实发管理绩效",t=>t.PerforManagementFee,(t) => Math.Round(t.Sum(item => item.PerforManagementFee ?? 0), 2, MidpointRounding.AwayFromZero)),
//("调节后其他绩效",t=>t.AdjustLaterOtherFee,(t) => Math.Round(t.Sum(item => item.AdjustLaterOtherFee ?? 0), 2, MidpointRounding.AwayFromZero)),
//("夜班费",t=>t.NightWorkPerfor,(t) => Math.Round(t.Sum(item => item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
//("医院其他绩效",t=>t.OtherPerfor,(t) => Math.Round(t.Sum(item => item.OtherPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
//("不公示其他绩效",t=>t.HideOtherPerfor,(t) => Math.Round(t.Sum(item => item.HideOtherPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
//("应发小计",t=>t.ShouldGiveFee,(t) => Math.Round(t.Sum(item => item.ShouldGiveFee ?? 0), 2, MidpointRounding.AwayFromZero)),
//("预留绩效",t=>t.ReservedRatioFee,(t) => Math.Round(t.Sum(item => item.ReservedRatioFee ?? 0), 2, MidpointRounding.AwayFromZero)),
//("实发绩效",t=>t.RealPerformance,(t) => Math.Round(t.Sum(item => item.RealPerformance ?? 0), 2, MidpointRounding.AwayFromZero)),
//("银行卡号",t=>t.BankCard,null),
//("正式/临聘",t=>t.JobCategory,null),
//("职务",t=>t.Duty,null),
//("职称",t=>t.TitlePosition,null),
};
public static List<(string, Func<view_allot_result, object>, Func<List<view_allot_result>, decimal>)> PersonView { get; } = new List<(string, Func<view_allot_result, object>, Func<List<view_allot_result>, decimal>)>
{
("科室类别",t=>t.UnitType,null),
("核算单元",t=>t.AccountingUnit,null),
("员工号",t=>t.JobNumber,null),
("人员姓名",t=>t.EmployeeName,null),
("调节后业绩绩效",t=>t.PerforSumFee,(t) => Math.Round(t.Sum(item => item.PerforSumFee ?? 0), 2, MidpointRounding.AwayFromZero)),
("调节后实发管理绩效",t=>t.PerforManagementFee,(t) => Math.Round(t.Sum(item => item.PerforManagementFee ?? 0), 2, MidpointRounding.AwayFromZero)),
("调节后其他绩效",t=>t.AdjustLaterOtherFee,(t) => Math.Round(t.Sum(item => item.AdjustLaterOtherFee ?? 0), 2, MidpointRounding.AwayFromZero)),
("夜班费",t=>t.NightWorkPerfor,(t) => Math.Round(t.Sum(item => item.NightWorkPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
("医院其他绩效",t=>t.OtherPerfor,(t) => Math.Round(t.Sum(item => item.OtherPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
("不公示其他绩效",t=>t.HideOtherPerfor,(t) => Math.Round(t.Sum(item => item.HideOtherPerfor ?? 0), 2, MidpointRounding.AwayFromZero)),
("应发小计",t=>t.ShouldGiveFee,(t) => Math.Round(t.Sum(item => item.ShouldGiveFee ?? 0), 2, MidpointRounding.AwayFromZero)),
("预留绩效",t=>t.ReservedRatioFee,(t) => Math.Round(t.Sum(item => item.ReservedRatioFee ?? 0), 2, MidpointRounding.AwayFromZero)),
("实发绩效",t=>t.RealPerformance,(t) => Math.Round(t.Sum(item => item.RealPerformance ?? 0), 2, MidpointRounding.AwayFromZero))
};
#endregion #endregion
#region 全院绩效核算 #region 全院绩效核算
......
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