Commit 8f0e0aa2 by 纪旭 韦

完成全院绩效发放

parent 69d9b7ea
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.Services; using Performance.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -16,19 +18,25 @@ namespace Performance.Api.Controllers ...@@ -16,19 +18,25 @@ namespace Performance.Api.Controllers
public class ReportController : Controller public class ReportController : Controller
{ {
private AllotService allotService; private AllotService allotService;
private ComputeService _computeService;
private ReportService reportService; private ReportService reportService;
private ReportDataService reportDataService; private ReportDataService reportDataService;
private ClaimService claimService; private ClaimService claimService;
private readonly DownloadService downloadService;
public ReportController( public ReportController(
ClaimService claimService, ClaimService claimService,
AllotService allotService, AllotService allotService,
ReportService reportService, ReportService reportService,
ReportDataService reportDataService) ReportDataService reportDataService,
ComputeService computeService,
DownloadService downloadService)
{ {
this.allotService = allotService; this.allotService = allotService;
this.reportService = reportService; this.reportService = reportService;
this.reportDataService = reportDataService; this.reportDataService = reportDataService;
this.claimService = claimService; this.claimService = claimService;
this._computeService = computeService;
this.downloadService = downloadService;
} }
[Route("rank")] [Route("rank")]
...@@ -265,5 +273,109 @@ public ApiResponse TableSpecial([FromBody] ConditionRequest request) ...@@ -265,5 +273,109 @@ public ApiResponse TableSpecial([FromBody] ConditionRequest request)
var list = reportService.TableSpecial(request); var list = reportService.TableSpecial(request);
return new ApiResponse(ResponseType.OK, "", list); return new ApiResponse(ResponseType.OK, "", list);
} }
#region 发放表视图、下载
/// <summary>
/// 全院绩效发放(视图)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("getAllComputeView")]
[HttpPost]
public ApiResponse GetAllComputeView([FromBody] BeginEndTime request)
{
var data = _computeService.GetAllComputeViewByDate( "view_allot_complete", request.BeginTime, request.EndTime);
var list = new QueryComputeByDateGetPage
{
Data = data.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize).ToList(),
TotalCount = data.Count(),
TotalPages = (int)Math.Ceiling((double)data.Count() / request.PageSize),
CurrentPage = request.CurrentPage,
PageSize = request.PageSize
};
return new ApiResponse(ResponseType.OK, "ok", list);
}
/// <summary>
/// 全院绩效发放(视图)下载
/// </summary>
/// <param name="BeginTime"></param>
/// <param name="EndTime"></param>
/// <param name="HospitalId"></param>
/// <returns></returns>
[Route("getAllComputeViewDown/download/{HospitalId},{BeginTime},{EndTime}")]
[HttpPost]
public IActionResult AllComputeViewDownload(int HospitalId,string BeginTime,string EndTime)
{
var list = _computeService.GetAllComputeViewByDate("view_allot_complete", BeginTime, EndTime);
if (null == list)
throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(HospitalId, list, "/report/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 @@ ...@@ -8,7 +8,7 @@
}, },
"AppConnection": { "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=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_test_srfy;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_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;",
"HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;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" "RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
}, },
......
...@@ -1610,6 +1610,36 @@ ...@@ -1610,6 +1610,36 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.ReportController.GetAllComputeView(Performance.DtoModels.BeginEndTime)">
<summary>
全院绩效发放(视图)
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportController.AllComputeViewDownload(System.Int32,System.String,System.String)">
<summary>
全院绩效发放(视图)下载
</summary>
<param name="BeginTime"></param>
<param name="EndTime"></param>
<param name="HospitalId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportController.AllComputeViewByPM(Performance.DtoModels.ComputerRequest)">
<summary>
获取全院绩效列表(人事科)
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportController.AllComputeByPMViewDownLoad(System.Int32)">
<summary>
下载全院绩效列表(人事科)
</summary>
<param name="allotId"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ReportGlobalController.GetAllReportGlobal(System.Int32)"> <member name="M:Performance.Api.Controllers.ReportGlobalController.GetAllReportGlobal(System.Int32)">
<summary> <summary>
获取报表配置信息 获取报表配置信息
......
...@@ -52,4 +52,22 @@ public class ComputerAliasRequest ...@@ -52,4 +52,22 @@ public class ComputerAliasRequest
public string Route { get; set; } public string Route { get; set; }
} }
public class BeginEndTime
{
public string BeginTime { get; set; } // 2021-01
public string EndTime { get; set; } // 2021-08
public int CurrentPage { get; set; }
public int PageSize { get; set; }
}
public class QueryComputeByDateGetPage
{
public List<dynamic> Data { get; set; }
public int CurrentPage { get; set; }
public int TotalPages { get; set; }
public int PageSize { get; set; }
public int TotalCount { get; set; }
}
} }
...@@ -396,6 +396,12 @@ public List<dynamic> QueryCompute(int allotId, string viewName) ...@@ -396,6 +396,12 @@ public List<dynamic> QueryCompute(int allotId, string viewName)
return DapperQuery<dynamic>(sql, new { allotId })?.ToList(); return DapperQuery<dynamic>(sql, new { allotId })?.ToList();
} }
public List<dynamic> QueryComputeByDate(int allotId, string viewName, string BeginTime, string EndTime)
{
var sql = $@"SELECT * FROM {viewName} where STR_TO_DATE(concat(Year,'-',Month),'%Y-%m') >= '{BeginTime}' and STR_TO_DATE(concat(Year,'-',Month),'%Y-%m') <= '{EndTime}'";
return DapperQuery<dynamic>(sql, new { allotId }).ToList();
}
public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead) public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
{ {
......
...@@ -2008,6 +2008,10 @@ public List<cof_alias> CustomColumnHeaders(int hospitalId, string route) ...@@ -2008,6 +2008,10 @@ public List<cof_alias> CustomColumnHeaders(int hospitalId, string route)
{ "/result/compute" , ComputeConfig.AllComputeView }, { "/result/compute" , ComputeConfig.AllComputeView },
{ "/result/wholehospital" , ComputeConfig.AllComputePersonView }, { "/result/wholehospital" , ComputeConfig.AllComputePersonView },
{ "/result/print/compute" , ComputeConfig.AllComputeDepartmentView }, { "/result/print/compute" , ComputeConfig.AllComputeDepartmentView },
{ "/report/compute" , ComputeConfig.AllComputeViewByDate },
{ "/report/wholehospital" , ComputeConfig.AllComputePersonViewByDate },
{ "/report/print/compute" , ComputeConfig.AllComputeDepartmentViewByDate },
}; };
var init = pairs.ContainsKey(route.ToLower()) ? pairs[route.ToLower()] : new List<cof_alias>(); var init = pairs.ContainsKey(route.ToLower()) ? pairs[route.ToLower()] : new List<cof_alias>();
foreach (var item in init) foreach (var item in init)
...@@ -2066,6 +2070,11 @@ public List<dynamic> GetAllComputeView(int hospitalId, int AllotId, string viewN ...@@ -2066,6 +2070,11 @@ public List<dynamic> GetAllComputeView(int hospitalId, int AllotId, string viewN
{ {
return reportRepository.QueryCompute(AllotId, viewName); return reportRepository.QueryCompute(AllotId, viewName);
} }
public List<dynamic> GetAllComputeViewByDate(string viewName, string BeginTime, string EndTime)
{
return reportRepository.QueryComputeByDate(0, viewName, BeginTime, EndTime);
}
} }
public class ComputeConfig public class ComputeConfig
...@@ -2096,6 +2105,22 @@ public class ComputeConfig ...@@ -2096,6 +2105,22 @@ public class ComputeConfig
new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_emp.RealGiveFee), States = 1}, new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_emp.RealGiveFee), States = 1},
}; };
private static List<cof_alias> _allComputeViewByDate = new List<cof_alias>();
public static List<cof_alias> AllComputeViewByDate
{
get
{
if (_allComputeViewByDate == null || _allComputeViewByDate.Count == 0)
{
_allComputeViewByDate.Add(new cof_alias { Alias = "年份", Name = nameof(view_allot_sign_emp.Year), States = 1 });
_allComputeViewByDate.Add(new cof_alias { Alias = "月份", Name = nameof(view_allot_sign_emp.Month), States = 1 });
_allComputeViewByDate.AddRange(AllComputeView);
}
return _allComputeViewByDate;
}
}
public static List<cof_alias> AllComputePersonView { get; } = new List<cof_alias> 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.UnitType), States = 1},
...@@ -2112,6 +2137,21 @@ public class ComputeConfig ...@@ -2112,6 +2137,21 @@ public class ComputeConfig
new cof_alias{ Alias = "预留绩效", Name = nameof(view_allot_sign_emp.ReservedRatioFee), 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}, new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_emp.RealGiveFee), States = 1},
}; };
private static List<cof_alias> _allComputePersonViewByDate = new List<cof_alias>();
public static List<cof_alias> AllComputePersonViewByDate
{
get
{
if (_allComputePersonViewByDate == null || _allComputePersonViewByDate.Count == 0)
{
_allComputePersonViewByDate.Add(new cof_alias { Alias = "年份", Name = nameof(view_allot_sign_emp.Year), States = 1 });
_allComputePersonViewByDate.Add(new cof_alias { Alias = "月份", Name = nameof(view_allot_sign_emp.Month), States = 1 });
_allComputePersonViewByDate.AddRange(AllComputePersonView);
}
return _allComputeViewByDate;
}
}
public static List<cof_alias> AllComputeDepartmentView { get; } = new List<cof_alias> 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.UnitName), States = 1},
...@@ -2133,5 +2173,19 @@ public class ComputeConfig ...@@ -2133,5 +2173,19 @@ public class ComputeConfig
new cof_alias{ Alias = "不公示其他绩效", Name = nameof(view_allot_sign_dept.HideAprOtherPerforAmount), 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}, new cof_alias{ Alias = "实发绩效", Name = nameof(view_allot_sign_dept.RealGiveFee), States = 1},
}; };
private static List<cof_alias> _allComputeDepartmentViewByDate = new List<cof_alias>();
public static List<cof_alias> AllComputeDepartmentViewByDate
{
get
{
if (_allComputeDepartmentViewByDate == null || _allComputeDepartmentViewByDate.Count == 0)
{
_allComputeDepartmentViewByDate.Add(new cof_alias { Alias = "年份", Name = nameof(view_allot_sign_emp.Year), States = 1 });
_allComputeDepartmentViewByDate.Add(new cof_alias { Alias = "月份", Name = nameof(view_allot_sign_emp.Month), States = 1 });
_allComputeDepartmentViewByDate.AddRange(AllComputeDepartmentView);
}
return _allComputeDepartmentViewByDate;
}
}
} }
} }
...@@ -233,6 +233,68 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string ...@@ -233,6 +233,68 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string
} }
return filepath; return filepath;
} }
/// <summary>
/// 财务、全院绩效发放下载(时间段)
/// </summary>
/// <param name="allotId"></param>
/// <param name="allData"></param>
/// <param name="isAll"></param>
/// <returns></returns>
public string AllComputerViewReportByDate(int HospitalId, List<dynamic> dynamics, string route, string name)
{
var hospital = perforHospital.GetEntity(t => t.ID == 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", $"{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);
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);
}
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;
}
if (col == 0)
worksheet.SetValue(dynamics.Count() + 2, col + 1, "合计");
else
worksheet.Cells[dynamics.Count() + 2, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(2, col + 1, dynamics.Count() + 1, col + 1).Address);
}
}
worksheet.View.FreezePanes(2, 1);
for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
{
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";
}
}
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>)> public static List<(string, Func<ComputeResponse, object>, Func<List<ComputeResponse>, decimal>)> AllCompute { get; } = new List<(string, Func<ComputeResponse, object>, Func<List<ComputeResponse>, decimal>)>
{ {
......
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