Commit a8f6ea6d by 纪旭 韦

修改下载时excel顶部时间显示

parents 235e54d3 3bf7c507
...@@ -291,10 +291,10 @@ public ApiResponse GetAllComputeView([FromBody] BeginEndTime request) ...@@ -291,10 +291,10 @@ public ApiResponse GetAllComputeView([FromBody] BeginEndTime request)
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime);
var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_emp", date.BeginTime, date.EndTime); var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_emp", date.BeginTime, date.EndTime);
if (null == datas) if (null == datas)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var list = new QueryComputeByDateGetPage var list = new QueryComputeByDateGetPage
{ {
Data = datas.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(), Data = datas.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(),
TotalData = _computeService.SumDatas(datas), TotalData = _computeService.SumDatas(datas),
...@@ -324,7 +324,7 @@ public IActionResult AllComputeViewDownload([FromBody] BeginEndTimeDown request) ...@@ -324,7 +324,7 @@ public IActionResult AllComputeViewDownload([FromBody] BeginEndTimeDown request)
if (null == list) if (null == list)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_grant", "全院绩效发放"); var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_grant", "全院绩效发放", date);
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -385,7 +385,7 @@ public IActionResult GethosdataView([FromBody] BeginEndTimeDown request) ...@@ -385,7 +385,7 @@ public IActionResult GethosdataView([FromBody] BeginEndTimeDown request)
if (null == list) if (null == list)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_accounting_grant", "全院核算绩效发放"); var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_accounting_grant", "全院核算绩效发放", date);
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -415,8 +415,8 @@ public ApiResponse AllComputeViewByPM([FromBody] BeginEndTime request) ...@@ -415,8 +415,8 @@ public ApiResponse AllComputeViewByPM([FromBody] BeginEndTime request)
if (null == datas) if (null == datas)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var list = new QueryComputeByDateGetPage var list = new QueryComputeByDateGetPage
{ {
Data = datas.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(), Data = datas.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(),
TotalData = _computeService.SumDatas(datas), TotalData = _computeService.SumDatas(datas),
...@@ -446,7 +446,7 @@ public IActionResult AllComputeByPMViewDownLoad([FromBody] BeginEndTimeDown requ ...@@ -446,7 +446,7 @@ public IActionResult AllComputeByPMViewDownLoad([FromBody] BeginEndTimeDown requ
if (null == list) if (null == list)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_finance_grant", "财务全院绩效发放"); var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_finance_grant", "财务全院绩效发放", date);
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
......
...@@ -181,7 +181,8 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string ...@@ -181,7 +181,8 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string
{ {
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);
return AllComputerDown(hospital, dynamics, route, name); var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- {name}";
return AllComputerDown(hospital, dynamics, route, title, name);
} }
/// <summary> /// <summary>
/// 财务、全院绩效发放下载(时间段) /// 财务、全院绩效发放下载(时间段)
...@@ -190,18 +191,21 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string ...@@ -190,18 +191,21 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string
/// <param name="allData"></param> /// <param name="allData"></param>
/// <param name="isAll"></param> /// <param name="isAll"></param>
/// <returns></returns> /// <returns></returns>
public string AllComputerViewReportByDate(int HospitalId, List<dynamic> dynamics, string route, string name) public string AllComputerViewReportByDate(int hospitalId, List<dynamic> dynamics, string route, string name, BeginEndTime date)
{ {
var hospital = perforHospital.GetEntity(t => t.ID == HospitalId); var hospital = perforHospital.GetEntity(t => t.ID == hospitalId);
return AllComputerDown(hospital, dynamics, route, name); var title = $"{date.BeginTime}{date.EndTime} {hospital.HosName}医院 --- {name}";
return AllComputerDown(hospital, dynamics, route, title, name);
} }
public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, string route, string name) public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, string route, string title, string name)
{ {
var headList = _computeService.CustomColumnHeaders(hospital.ID, route).Where(w => w.States == 1).ToList(); var headList = _computeService.CustomColumnHeaders(hospital.ID, route).Where(w => w.States == 1).ToList();
var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{hospital.ID}"); var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease", $"{hospital.ID}");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
string filepath = Path.Combine(dpath, $"{hospital.HosName}-{name}-{DateTime.Now:yyyyMMdd}"); string filepath = Path.Combine(dpath, $"{hospital.HosName}-{name}-{DateTime.Now:yyyyMMdd}");
FileHelper.DeleteFile(filepath); FileHelper.DeleteFile(filepath);
string[] notSum = new string[] { "year", "month" };
using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate)) using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
using (ExcelPackage package = new ExcelPackage(fs)) using (ExcelPackage package = new ExcelPackage(fs))
{ {
...@@ -209,7 +213,7 @@ public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, stri ...@@ -209,7 +213,7 @@ public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, stri
if (dynamics != null && dynamics.Count() > 0) if (dynamics != null && dynamics.Count() > 0)
{ {
worksheet.SetValue(1, 1, $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- {name}"); worksheet.SetValue(1, 1, title);
var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys; var headers = ((IDictionary<string, object>)dynamics.ElementAt(0)).Keys;
for (int col = 0; col < headList.Count; col++) for (int col = 0; col < headList.Count; col++)
...@@ -228,7 +232,7 @@ public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, stri ...@@ -228,7 +232,7 @@ public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, stri
} }
if (col == 0) if (col == 0)
worksheet.SetValue(dynamics.Count() + 2, col + 1, "合计"); worksheet.SetValue(dynamics.Count() + 2, col + 1, "合计");
else else if (!notSum.Contains(headList[col].Name.ToLower()))
worksheet.Cells[dynamics.Count() + 2, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(2, col + 1, dynamics.Count() + 1, col + 1).Address); worksheet.Cells[dynamics.Count() + 2, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(2, col + 1, dynamics.Count() + 1, col + 1).Address);
} }
...@@ -238,8 +242,8 @@ public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, stri ...@@ -238,8 +242,8 @@ public string AllComputerDown(sys_hospital hospital,List<dynamic> dynamics, stri
worksheet.Row(row).Height = 20; worksheet.Row(row).Height = 20;
for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++) for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
{ {
worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, col].Style.Numberformat.Format = "#,##0.00"; worksheet.Cells[row, col].Style.Numberformat.Format = "#,##0.00";
worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center; worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
} }
} }
......
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