Commit 8f2d0d65 by ruyun.zhang

签字表下载

parent 51e9dcf7
using System; using FluentValidation.AspNetCore;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles; using Microsoft.AspNetCore.StaticFiles;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.Request; using Performance.DtoModels.Request;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Performance.Api.Controllers namespace Performance.Api.Controllers
{ {
[Route("api/[controller]")] [Route("api/[controller]")]
public class ComputeController : Controller public class ComputeController : Controller
{ {
private ComputeService _computeService; private readonly ComputeService _computeService;
private readonly DapperService _service; private readonly DapperService _service;
private AllotService _allotService; private readonly AllotService _allotService;
private ClaimService _claim; private readonly HospitalService _hospitalService;
private EmployeeService _employeeService; private readonly ClaimService _claim;
private readonly DownloadService downloadService; private readonly DownloadService downloadService;
public ComputeController( public ComputeController(
DapperService service, DapperService service,
AllotService allotService, AllotService allotService,
HospitalService hospitalService,
ComputeService computeService, ComputeService computeService,
EmployeeService employeeService,
DownloadService downloadService, DownloadService downloadService,
ClaimService claim) ClaimService claim)
{ {
_service = service; _service = service;
_allotService = allotService; _allotService = allotService;
_hospitalService = hospitalService;
_computeService = computeService; _computeService = computeService;
_employeeService = employeeService;
this.downloadService = downloadService; this.downloadService = downloadService;
_claim = claim; _claim = claim;
} }
...@@ -711,17 +713,37 @@ public ApiResponse GethosdataView([FromBody] ComputerRequest request) ...@@ -711,17 +713,37 @@ public ApiResponse GethosdataView([FromBody] ComputerRequest request)
/// 全院核算绩效发放(视图) 下载 /// 全院核算绩效发放(视图) 下载
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns> /// <returns></returns>
[Route("gethosdataView/download/{allotId}")] [Route("gethosdataView/download/{allotId}")]
[HttpPost] [HttpPost]
public IActionResult GethosdataView(int allotId) public IActionResult GethosdataView(int allotId, [FromQuery] string? unitType, [FromQuery] string? accountingUnit, [FromQuery] string? content)
{ {
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var hospital = _hospitalService.GetHopital(allot.HospitalId);
var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept");
var ser = JsonHelper.Serialize(result);
var dict = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept"); var data = new List<Dictionary<string, object>>();
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/print/compute", "全院核算绩效发放"); foreach (var obj in dict)
{
Dictionary<string, object> nobj = new Dictionary<string, object>();
foreach (var item in obj)
{
nobj[item.Key.ToLower()] = item.Value;
}
var values = nobj.Select(item => item.Value == null ? "" : item.Value.ToString());
if (values.Any(w => w.Contains(unitType)) && values.Any(w => w.Contains(accountingUnit)) && values.Any(w => w.Contains(content)))
data.Add(nobj);
}
var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- 全院核算绩效发放";
var filepath = downloadService.AllComputerDown(hospital, data, "/result/print/compute", title, "全院核算绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -757,17 +779,38 @@ public ApiResponse AllComputeView([FromBody] ComputerRequest request) ...@@ -757,17 +779,38 @@ public ApiResponse AllComputeView([FromBody] ComputerRequest request)
/// 下载全院绩效列表 /// 下载全院绩效列表
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns> /// <returns></returns>
[Route("allcomputeView/download/{allotId}")] [Route("allcomputeView/download/{allotId}")]
[HttpPost] [HttpPost]
public IActionResult AllComputeViewDownload(int allotId) public IActionResult AllComputeViewDownload(int allotId, [FromQuery] string? unitType, [FromQuery] string? accountingUnit, [FromQuery] string? content)
{ {
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var hospital = _hospitalService.GetHopital(allot.HospitalId);
var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp");
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp"); var ser = JsonHelper.Serialize(result);
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/compute", "全院绩效发放"); var dict = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var data = new List<Dictionary<string, object>>();
foreach (var obj in dict)
{
Dictionary<string, object> nobj = new Dictionary<string, object>();
foreach (var item in obj)
{
nobj[item.Key.ToLower()] = item.Value;
}
var values = nobj.Select(item => item.Value == null ? "" : item.Value.ToString());
if (values.Any(w => w.Contains(unitType)) && values.Any(w => w.Contains(accountingUnit)) && values.Any(w => w.Contains(content)))
data.Add(nobj);
}
var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- 全院绩效发放";
var filepath = downloadService.AllComputerDown(hospital, data, "/result/compute", title, "全院绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -807,17 +850,38 @@ public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request) ...@@ -807,17 +850,38 @@ public ApiResponse AllComputeViewByPM([FromBody] ComputerRequest request)
/// 下载全院绩效列表(人事科) /// 下载全院绩效列表(人事科)
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="allotId"></param>
/// <param name="unitType"></param>
/// <param name="accountingUnit"></param>
/// <param name="content"></param>
/// <returns></returns> /// <returns></returns>
[Route("allcomputeView/personnel/download/{allotId}")] [Route("allcomputeView/personnel/download/{allotId}")]
[HttpPost] [HttpPost]
public IActionResult AllComputeByPMViewDownLoad(int allotId) public IActionResult AllComputeByPMViewDownLoad(int allotId, [FromQuery] string? unitType, [FromQuery] string? accountingUnit, [FromQuery] string? content)
{ {
var allot = _allotService.GetAllot(allotId); var allot = _allotService.GetAllot(allotId);
if (null == allot) if (null == allot)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var hospital = _hospitalService.GetHopital(allot.HospitalId);
unitType ??= ""; accountingUnit ??= ""; content ??= "";
var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp_finance"); var result = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_emp_finance");
var filepath = downloadService.AllComputerViewReport(allotId, result, "/result/wholehospital", "财务全院绩效发放"); var ser = JsonHelper.Serialize(result);
var dict = JsonHelper.Deserialize<List<Dictionary<string, object>>>(ser);
var data = new List<Dictionary<string, object>>();
foreach (var obj in dict)
{
Dictionary<string, object> nobj = new Dictionary<string, object>();
foreach (var item in obj)
{
nobj[item.Key.ToLower()] = item.Value;
}
var values = nobj.Select(item => item.Value == null ? "" : item.Value.ToString());
if (values.Any(w => w.Contains(unitType)) && values.Any(w => w.Contains(accountingUnit)) && values.Any(w => w.Contains(content)))
data.Add(nobj);
}
var title = $"{allot.Year}{allot.Month}{hospital.HosName}医院 --- 财务全院绩效发放";
var filepath = downloadService.AllComputerDown(hospital, data, "/result/wholehospital", title, "财务全院绩效发放");
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
......
...@@ -1227,11 +1227,14 @@ ...@@ -1227,11 +1227,14 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.GethosdataView(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.GethosdataView(System.Int32,System.String,System.String,System.String)">
<summary> <summary>
全院核算绩效发放(视图) 下载 全院核算绩效发放(视图) 下载
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></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.AllComputeView(Performance.DtoModels.ComputerRequest)">
...@@ -1241,11 +1244,14 @@ ...@@ -1241,11 +1244,14 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewDownload(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewDownload(System.Int32,System.String,System.String,System.String)">
<summary> <summary>
下载全院绩效列表 下载全院绩效列表
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)">
...@@ -1255,11 +1261,14 @@ ...@@ -1255,11 +1261,14 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeByPMViewDownLoad(System.Int32)"> <member name="M:Performance.Api.Controllers.ComputeController.AllComputeByPMViewDownLoad(System.Int32,System.String,System.String,System.String)">
<summary> <summary>
下载全院绩效列表(人事科) 下载全院绩效列表(人事科)
</summary> </summary>
<param name="allotId"></param> <param name="allotId"></param>
<param name="unitType"></param>
<param name="accountingUnit"></param>
<param name="content"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)"> <member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)">
......
...@@ -213,7 +213,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -213,7 +213,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
} }
data.Add(nobj); data.Add(nobj);
} }
return AllComputerDown(hospital, data, route, title, name, headlist);
}
public string AllComputerDown(sys_hospital hospital, List<Dictionary<string, object>> data, string route, string title, string name, params string[] headlist)
{
var headList = _computeService.CustomColumnHeaders(hospital.ID, route, headlist).Where(w => w.States == 1).ToList(); var headList = _computeService.CustomColumnHeaders(hospital.ID, route, headlist).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}");
...@@ -226,16 +230,16 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -226,16 +230,16 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
using (ExcelPackage package = new ExcelPackage(fs)) using (ExcelPackage package = new ExcelPackage(fs))
{ {
var worksheet = package.Workbook.Worksheets.Add(name); var worksheet = package.Workbook.Worksheets.Add(name);
if (dynamics != null && dynamics.Count() > 0)
{
worksheet.SetValue(1, 1, title); worksheet.SetValue(1, 1, title);
worksheet.Cells[1, 1, 1, headList.Count].Merge = true;
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++)
{ {
worksheet.SetValue(2, col + 1, headList[col].Alias); worksheet.SetValue(2, col + 1, headList[col].Alias);
} }
if (data != null && data.Count() > 0)
{
for (int col = 0; col < headList.Count; col++) for (int col = 0; col < headList.Count; col++)
{ {
for (int row = 0; row < data.Count(); row++) for (int row = 0; row < data.Count(); row++)
...@@ -246,11 +250,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -246,11 +250,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
worksheet.Cells[row + 3, col + 1].Value = value; worksheet.Cells[row + 3, col + 1].Value = value;
} }
if (col == 0) if (col == 0)
worksheet.SetValue(dynamics.Count() + 3, col + 1, "合计"); worksheet.SetValue(data.Count() + 3, col + 1, "合计");
else if (!notSum.Contains(headList[col].Name.ToLower())) else if (!notSum.Contains(headList[col].Name.ToLower()))
worksheet.Cells[dynamics.Count() + 3, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(3, col + 1, dynamics.Count() + 2, col + 1).Address); worksheet.Cells[data.Count() + 3, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(3, col + 1, data.Count() + 2, col + 1).Address);
}
} }
#region 样式设置 #region 样式设置
for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++) for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
{ {
...@@ -277,11 +281,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -277,11 +281,11 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width; worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width;
} }
#endregion #endregion
}
package.Save(); package.Save();
} }
return filepath; return filepath;
} }
public string ExcelDownload(List<Dictionary<string, object>> rows, string name, List<ExcelDownloadHeads> excelDownloadHeads, string[] notSum, string[] ignoreColumns) public string ExcelDownload(List<Dictionary<string, object>> rows, string name, List<ExcelDownloadHeads> excelDownloadHeads, string[] notSum, string[] ignoreColumns)
{ {
var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease"); var dpath = Path.Combine(evn.ContentRootPath, "Files", "PerformanceRelease");
......
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