绩效发放表 改为视图

parent 5143bb0a
......@@ -386,7 +386,7 @@ public ApiResponse<res_baiscnorm> EditHospitalAvg([FromBody] ComputerAvgRequest
[HttpPost]
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);
}
......@@ -498,43 +498,68 @@ public IActionResult AllComputeByPMDownLoad(int allotId)
#region 发放表视图、下载
/// <summary>
/// 获取全院绩效列表(视图)
/// 全院核算绩效发放(视图)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("allcomputeView")]
[Route("gethosdataView")]
[HttpPost]
public ApiResponse AllComputeView([FromBody] ComputerRequest request)
public ApiResponse GethosdataView([FromBody] ComputerRequest request)
{
var allot = _allotService.GetAllot(request.AllotId);
if (null == allot)
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);
}
/// <summary>
/// 获取全院绩效列表(人事科)
/// 全院核算绩效发放(视图) 下载
/// </summary>
/// <param name="request"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("allcomputeView/personnel")]
[Route("gethosdataView/download/{allotId}")]
[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)
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>
/// 下载全院绩效列表
......@@ -549,8 +574,8 @@ public IActionResult AllComputeViewDownload(int allotId)
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, true);
var filepath = downloadService.AllComputerViewReport(allotId, list, true, "全院绩效发放");
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp");
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/compute", "全院绩效发放");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......@@ -564,8 +589,28 @@ public IActionResult AllComputeViewDownload(int allotId)
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
}
/// <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>
/// <param name="allotId"></param>
/// <returns></returns>
......@@ -577,8 +622,8 @@ public IActionResult AllComputeByPMViewDownLoad(int allotId)
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var result =_computeService.GetAllComputeView(allot.HospitalId, allotId, false);
var filepath = downloadService.AllComputerViewReport(allotId, result, false, "财务全院绩效");
var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp_finance");
var filepath = downloadService.AllComputerViewReport(allotId, result, "/result/wholehospital", "财务全院绩效发放");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......
......@@ -575,16 +575,23 @@
<param name="allotId"></param>
<returns></returns>
</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>
<param name="request"></param>
<returns></returns>
</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>
<param name="request"></param>
<returns></returns>
......@@ -596,9 +603,16 @@
<param name="allotId"></param>
<returns></returns>
</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)">
<summary>
下载全院绩效列表(人事科/视图
下载全院绩效列表(人事科)
</summary>
<param name="allotId"></param>
<returns></returns>
......
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
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();
}
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();
return DapperQuery<dynamic>(sql, new { allotId })?.ToList();
}
}
}
......@@ -1998,11 +1998,43 @@ private decimal GetDecimal(decimal? value, decimal _ = 0)
/// </summary>
/// <param name="request"></param>
/// <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);
if (result == null || !result.Any()) return new List<cof_alias>();
return result;
var alias = cofaliasRepository.GetEntities(t => t.HospitalId == hospitalId && t.Route.Equals(route, StringComparison.OrdinalIgnoreCase));
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)
......@@ -2029,26 +2061,76 @@ public bool Batch(BatchRequest request)
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>();
if (isAllCompte)
viewResult = reportRepository.QueryAllCompute(hospitalId, AllotId);
else
viewResult = reportRepository.QueryAdminCompute(hospitalId, AllotId);
// 人员字典
var employees = perforPeremployeeRepository.GetEntities(w => w.AllotId == AllotId);
return reportRepository.QueryCompute(AllotId, viewName);
}
}
viewResult.ForEach(t =>
public class ComputeConfig
{
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);
});
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},
return viewResult;
}
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 @@
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
......@@ -11,6 +13,7 @@
using Performance.Services.ExtractExcelService;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
......@@ -24,6 +27,7 @@ public class DownloadService : IAutoInjection
private readonly PerforHospitalRepository perforHospital;
private readonly PerforCofaliasRepository perforCofalias;
private readonly ConfigService configService;
private readonly ComputeService _computeService;
private readonly IHostingEnvironment evn;
public DownloadService(ILogger<DownloadService> logger,
......@@ -31,6 +35,7 @@ public class DownloadService : IAutoInjection
PerforHospitalRepository perforHospital,
PerforCofaliasRepository perforCofalias,
ConfigService configService,
ComputeService computeService,
IHostingEnvironment evn)
{
this.logger = logger;
......@@ -38,6 +43,7 @@ public class DownloadService : IAutoInjection
this.perforHospital = perforHospital;
this.perforCofalias = perforCofalias;
this.configService = configService;
_computeService = computeService;
this.evn = evn;
}
......@@ -54,7 +60,7 @@ public class DownloadService : IAutoInjection
/// <param name="allData"></param>
/// <param name="isAll"></param>
/// <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 hospital = perforHospital.GetEntity(t => t.ID == allot.HospitalId);
......@@ -171,112 +177,73 @@ public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool
/// <param name="allData"></param>
/// <param name="isAll"></param>
/// <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 hospital = perforHospital.GetEntity(t => t.ID == allot.HospitalId);
var alias = perforCofalias.GetEntities(t => t.HospitalId == hospital.ID && t.States == 1);
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();
}
else
{
alias = alias?.Where(t => t.Route == "/result/compute")?.ToList();
if (alias != null)
headShow = headShow.Except(alias.Select(t => t.OriginalName)).ToList();
var alias = perforCofalias.GetEntities(t => t.HospitalId == hospital.ID);
}
var headList = _computeService.CustomColumnHeaders(hospital.ID, route);
var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{allot.HospitalId}");
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}";
string filepath = Path.Combine(dpath, fileName);
FileStream stream = new FileStream(filepath, FileMode.Create);
try
using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
using (ExcelPackage package = new ExcelPackage(fs))
{
XSSFWorkbook workbook = new XSSFWorkbook();
//设置单元格样式
ICellStyle style = workbook.CreateCellStyle();
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)
var worksheet = package.Workbook.Worksheets.Add(name);
worksheet.View.FreezePanes(2, 1);
if (dynamics != null && dynamics.Count() > 0)
{
if (headShow.Contains(item.Item1))
continue;
var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys;
for (int col = 0; col < headList.Count; col++)
{
worksheet.SetValue(1, col + 1, headList[col].Alias);
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;
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)
for (int col = 0; col < headList.Count; col++)
{
var row = sheet.CreateRow(startIndex);
cellIndex = 1;
var serial = row.CreateCell(0);
serial.SetCellOValue(startIndex);
serial.CellStyle = style;
foreach (var field in headList)
for (int row = 0; row < dynamics.Count(); row++)
{
if (headShow.Contains(field.Item1))
continue;
var data = dynamics.ElementAt(row);
var temp = (IDictionary<string, object>)data;
var value = temp[headList[col].Name];
var cell = row.CreateCell(cellIndex);
cell.SetCellOValue(field.Item2?.Invoke(item));
cell.CellStyle = style;
cellIndex++;
worksheet.Cells[row + 2, col + 1].Value = value;
worksheet.Cells[row + 2, col + 1].Style.Numberformat.Format = "#,##0.00";//这是保留两位小数
worksheet.Cells[row + 2, col + 1].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
worksheet.Cells[row + 2, col + 1].Style.Border.Top.Style = ExcelBorderStyle.Thin;
worksheet.Cells[row + 2, col + 1].Style.Border.Right.Style = ExcelBorderStyle.Thin;
worksheet.Cells[row + 2, col + 1].Style.Border.Left.Style = ExcelBorderStyle.Thin;
}
startIndex++;
if (col == 0)
{
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;
}
//合计
cellIndex = 1;
var totalRow = sheet.CreateRow(startIndex);
var totalSerial = totalRow.CreateCell(0);
totalSerial.SetCellOValue("合计");
totalSerial.CellStyle = style;
foreach (var value in headList)
else
{
if (headShow.Contains(value.Item1))
continue;
var cell = totalRow.CreateCell(cellIndex);
cell.SetCellOValue(value.Item3?.Invoke(allData));
cell.CellStyle = style;
cellIndex++;
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);
}
catch (Exception ex)
{
Console.WriteLine("下载异常" + ex);
}
finally
{
stream.Close();
package.Save();
}
return filepath;
}
......@@ -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))
};
//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
#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