Commit 18e7c8b9 by ruyun.zhang@suvalue.com

Merge branch 'feature/发放表视图' into develop

parents f94a93c7 b03bdaad
......@@ -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);
}
......@@ -449,7 +449,7 @@ public IActionResult AllComputeDownload(int allotId)
var list = _computeService.AllCompute(allotId, allot.HospitalId, isShowManage);
var filepath = downloadService.AllComputerReport(allotId, list, true,"全院绩效发放");
var filepath = downloadService.AllComputerReport(allotId, list, true, "全院绩效发放");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......@@ -481,7 +481,7 @@ public IActionResult AllComputeByPMDownLoad(int allotId)
var result = _computeService.ComputerGroupBy(list);
var filepath = downloadService.AllComputerReport(allotId, result, false,"财务全院绩效");
var filepath = downloadService.AllComputerReport(allotId, result, false, "财务全院绩效");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open))
......@@ -495,5 +495,148 @@ public IActionResult AllComputeByPMDownLoad(int allotId)
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
}
#endregion
#region 发放表视图、下载
/// <summary>
/// 全院核算绩效发放(视图)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("gethosdataView")]
[HttpPost]
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, "view_allot_sign_dept");
return new ApiResponse(ResponseType.OK, "ok", list);
}
/// <summary>
/// 全院核算绩效发放(视图) 下载
/// </summary>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("gethosdataView/download/{allotId}")]
[HttpPost]
public IActionResult GethosdataView(int allotId)
{
var allot = _allotService.GetAllot(allotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
var list = _computeService.GetAllComputeView(allot.HospitalId, allotId, "view_allot_sign_dept");
var filepath = downloadService.AllComputerViewReport(allotId, list, "/result/print/compute", "全院核算绩效发放");
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>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("allcomputeView/download/{allotId}")]
[HttpPost]
public IActionResult AllComputeViewDownload(int allotId)
{
var allot = _allotService.GetAllot(allotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
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))
{
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/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>
[Route("allcomputeView/personnel/download/{allotId}")]
[HttpPost]
public IActionResult AllComputeByPMViewDownLoad(int allotId)
{
var allot = _allotService.GetAllot(allotId);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
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))
{
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));
#endregion
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
},
"AppConnection": {
//"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_performance_screen;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_test_zhangye;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
},
......
......@@ -575,6 +575,48 @@
<param name="allotId"></param>
<returns></returns>
</member>
<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.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>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.AllComputeViewDownload(System.Int32)">
<summary>
下载全院绩效列表
</summary>
<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>
</member>
<member name="M:Performance.Api.Controllers.ConfigController.GetDrugtypeList(Performance.DtoModels.DrugpropRequest)">
<summary>
获取 药占比类型信息列表
......
......@@ -7620,5 +7620,20 @@
不公示其他绩效
</summary>
</member>
<member name="P:Performance.DtoModels.view_allot_result.RealPerformance">
<summary>
实发绩效
</summary>
</member>
<member name="P:Performance.DtoModels.view_allot_result.ShouldGiveFee">
<summary>
应发小计
</summary>
</member>
<member name="P:Performance.DtoModels.view_allot_result.ReservedRatioFee">
<summary>
预留金额
</summary>
</member>
</members>
</doc>
......@@ -43,6 +43,25 @@ public class view_allot_result
/// 不公示其他绩效
/// </summary>
public decimal? HideOtherPerfor { get; set; }
/// <summary>
/// 实发绩效
/// </summary>
public decimal? RealPerformance { get; set; }
/// <summary>
/// 应发小计
/// </summary>
public decimal? ShouldGiveFee { get; set; }
/// <summary>
/// 预留金额
/// </summary>
public decimal? ReservedRatioFee { get; set; }
public string Emp_UnitType { get; set; }
public string Emp_AccountingUnit { get; set; }
public string BankCard { get; set; }
public string JobCategory { get; set; }
public string Duty { 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; }
}
}
......@@ -388,5 +388,12 @@ public List<view_allot_result> GetOwnerPerformance(List<int> hospitalId, string
string sql = "SELECT * FROM view_allot_result WHERE HospitalID IN @HospitalID AND JobNumber=@JobNumber";
return DapperQuery<view_allot_result>(sql, new { HospitalID = hospitalId, JobNumber = jobNumber })?.ToList();
}
public List<dynamic> QueryCompute(int allotId, string viewName)
{
var sql = $@"SELECT * FROM {viewName} WHERE AllotId = @AllotId; ";
return DapperQuery<dynamic>(sql, new { allotId })?.ToList();
}
}
}
......@@ -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);
......@@ -164,6 +170,84 @@ public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool
return filepath;
}
/// <summary>
/// 财务、全院绩效发放下载
/// </summary>
/// <param name="allotId"></param>
/// <param name="allData"></param>
/// <param name="isAll"></param>
/// <returns></returns>
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);
var headList = _computeService.CustomColumnHeaders(hospital.ID, route).Where(w => w.States == 1).ToList();
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);
using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
using (ExcelPackage package = new ExcelPackage(fs))
{
var worksheet = package.Workbook.Worksheets.Add(name);
worksheet.View.FreezePanes(2, 1);
if (dynamics != null && dynamics.Count() > 0)
{
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;
}
for (int col = 0; col < headList.Count; col++)
{
for (int row = 0; row < dynamics.Count(); row++)
{
var data = dynamics.ElementAt(row);
var temp = (IDictionary<string, object>)data;
var value = temp[headList[col].Name];
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;
}
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;
}
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;
}
}
}
package.Save();
}
return filepath;
}
public static List<(string, Func<ComputeResponse, object>, Func<List<ComputeResponse>, decimal>)> AllCompute { get; } = new List<(string, Func<ComputeResponse, object>, Func<List<ComputeResponse>, decimal>)>
{
("来源",t=>t.Source,null),
......@@ -203,6 +287,8 @@ public string AllComputerReport(int allotId, List<ComputeResponse> allData, bool
("预留绩效",t=>t.ReservedRatioFee,(t) => Math.Round(t.Sum(item => item.ReservedRatioFee ?? 0), 2, MidpointRounding.AwayFromZero)),
("实发绩效",t=>t.RealGiveFee,(t) => Math.Round(t.Sum(item => item.RealGiveFee ?? 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