Commit 392ad5fc by 纪旭 韦

修复下载,修复查询少一个月的bug

parent 1d203b9e
...@@ -288,9 +288,13 @@ public ApiResponse TableSpecial([FromBody] ConditionRequest request) ...@@ -288,9 +288,13 @@ public ApiResponse TableSpecial([FromBody] ConditionRequest request)
[HttpPost] [HttpPost]
public ApiResponse GetAllComputeView([FromBody] BeginEndTime request) public ApiResponse GetAllComputeView([FromBody] BeginEndTime request)
{ {
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); DateTime bdate = DateTime.Now;
DateTime edate = DateTime.Now;
if (string.IsNullOrEmpty(request.BeginTime) || !DateTime.TryParse(request.BeginTime, out bdate) ||
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_emp", date.BeginTime, date.EndTime); var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_emp", bdate, edate.AddMonths(1));
if (null == datas) if (null == datas)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
...@@ -318,13 +322,18 @@ public IActionResult AllComputeViewDownload([FromBody] BeginEndTimeDown request) ...@@ -318,13 +322,18 @@ public IActionResult AllComputeViewDownload([FromBody] BeginEndTimeDown request)
if (request.HospitalId == 0) if (request.HospitalId == 0)
throw new PerformanceException("医院ID不能为空"); throw new PerformanceException("医院ID不能为空");
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); DateTime bdate = DateTime.Now;
DateTime edate = DateTime.Now;
if (string.IsNullOrEmpty(request.BeginTime) || !DateTime.TryParse(request.BeginTime, out bdate) ||
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var list = _computeService.GetAllComputeViewByDate("view_allot_sign_emp", date.BeginTime, date.EndTime);
var list = _computeService.GetAllComputeViewByDate("view_allot_sign_emp", bdate, edate.AddMonths(1));
if (null == list) if (null == list)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_grant", "全院绩效发放", date); var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_grant", "全院绩效发放", bdate, edate);
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -348,9 +357,13 @@ public IActionResult AllComputeViewDownload([FromBody] BeginEndTimeDown request) ...@@ -348,9 +357,13 @@ public IActionResult AllComputeViewDownload([FromBody] BeginEndTimeDown request)
[HttpPost] [HttpPost]
public ApiResponse GethosdataView([FromBody] BeginEndTime request) public ApiResponse GethosdataView([FromBody] BeginEndTime request)
{ {
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); DateTime bdate = DateTime.Now;
DateTime edate = DateTime.Now;
if (string.IsNullOrEmpty(request.BeginTime) || !DateTime.TryParse(request.BeginTime, out bdate) ||
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_dept", date.BeginTime, date.EndTime); var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_dept", bdate, edate.AddMonths(1));
if (null == datas) if (null == datas)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
...@@ -379,13 +392,17 @@ public IActionResult GethosdataView([FromBody] BeginEndTimeDown request) ...@@ -379,13 +392,17 @@ public IActionResult GethosdataView([FromBody] BeginEndTimeDown request)
if (request.HospitalId == 0) if (request.HospitalId == 0)
throw new PerformanceException("医院ID不能为空"); throw new PerformanceException("医院ID不能为空");
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); DateTime bdate = DateTime.Now;
DateTime edate = DateTime.Now;
if (string.IsNullOrEmpty(request.BeginTime) || !DateTime.TryParse(request.BeginTime, out bdate) ||
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var list = _computeService.GetAllComputeViewByDate("view_allot_sign_dept", date.BeginTime, date.EndTime); var list = _computeService.GetAllComputeViewByDate("view_allot_sign_dept", bdate, edate.AddMonths(1));
if (null == list) if (null == list)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_accounting_grant", "全院核算绩效发放", date); var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_accounting_grant", "全院核算绩效发放", bdate, edate);
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
...@@ -409,9 +426,13 @@ public IActionResult GethosdataView([FromBody] BeginEndTimeDown request) ...@@ -409,9 +426,13 @@ public IActionResult GethosdataView([FromBody] BeginEndTimeDown request)
[HttpPost] [HttpPost]
public ApiResponse AllComputeViewByPM([FromBody] BeginEndTime request) public ApiResponse AllComputeViewByPM([FromBody] BeginEndTime request)
{ {
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); DateTime bdate = DateTime.Now;
DateTime edate = DateTime.Now;
if (string.IsNullOrEmpty(request.BeginTime) || !DateTime.TryParse(request.BeginTime, out bdate) ||
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_emp_finance", date.BeginTime, date.EndTime); var datas = _computeService.GetAllComputeViewByDate("view_allot_sign_emp_finance", bdate, edate.AddMonths(1));
if (null == datas) if (null == datas)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
...@@ -440,13 +461,17 @@ public IActionResult AllComputeByPMViewDownLoad([FromBody] BeginEndTimeDown requ ...@@ -440,13 +461,17 @@ public IActionResult AllComputeByPMViewDownLoad([FromBody] BeginEndTimeDown requ
if (request.HospitalId == 0) if (request.HospitalId == 0)
throw new PerformanceException("医院ID不能为空"); throw new PerformanceException("医院ID不能为空");
var date = _computeService.performanceImposeDate(request.BeginTime, request.EndTime); DateTime bdate = DateTime.Now;
DateTime edate = DateTime.Now;
if (string.IsNullOrEmpty(request.BeginTime) || !DateTime.TryParse(request.BeginTime, out bdate) ||
string.IsNullOrEmpty(request.EndTime) || !DateTime.TryParse(request.EndTime, out edate))
throw new PerformanceException("请输入正确的时间");
var list = _computeService.GetAllComputeViewByDate("view_allot_sign_emp_finance", date.BeginTime, date.EndTime); var list = _computeService.GetAllComputeViewByDate("view_allot_sign_emp_finance", bdate, edate.AddMonths(1));
if (null == list) if (null == list)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_finance_grant", "财务全院绩效发放", date); var filepath = downloadService.AllComputerViewReportByDate(request.HospitalId, list, "/report/wholehospital_finance_grant", "财务全院绩效发放", bdate, edate);
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
using (var stream = new FileStream(filepath, FileMode.Open)) using (var stream = new FileStream(filepath, FileMode.Open))
......
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -396,11 +397,13 @@ public List<dynamic> QueryCompute(int allotId, string viewName) ...@@ -396,11 +397,13 @@ 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) public List<dynamic> QueryComputeByDate(string viewName, DateTime beginTime, DateTime 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}'"; var sql = $@"SELECT * FROM {viewName}
where STR_TO_DATE(concat(Year,'-',Month,'-01'),'%Y-%m-%d') >= @beginTime
and STR_TO_DATE(concat(Year,'-',Month,'-01'),'%Y-%m-%d') < @endTime";
return DapperQuery<dynamic>(sql, new { allotId }).ToList(); return DapperQuery<dynamic>(sql, new { beginTime = beginTime.ToString("yyyy-MM-dd"), endTime = endTime.ToString("yyyy-MM-dd") }).ToList();
} }
public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead) public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
...@@ -418,7 +421,7 @@ public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead) ...@@ -418,7 +421,7 @@ public CustonPagingData QueryCustom(CustomPagingRequest request, bool IsHead)
else else
sql = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId {Query} order by UnitType,AccountingUnit LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} "; sql = $@"SELECT * FROM {request.TableName} WHERE AllotId = @AllotId {Query} order by UnitType,AccountingUnit LIMIT {(request.PageIndex - 1) * request.PageSize},{request.PageSize} ";
result.DataList = DapperQuery<dynamic>(sql, new { request.AllotId })?.ToList(); result.DataList = DapperQuery<dynamic>(sql, new { request.AllotId })?.ToList();
sql = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId {Query} "; sql = $@"SELECT COUNT(*) FROM {request.TableName} WHERE AllotId = @AllotId {Query} ";
...@@ -432,7 +435,7 @@ public bool QueryIsAllotId(string tableName) ...@@ -432,7 +435,7 @@ public bool QueryIsAllotId(string tableName)
var sql = $@"SELECT column_name FROM information_schema.COLUMNS s var sql = $@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND (column_name='allotId' or column_name='AccountingUnit' or column_name='UnitType');"; WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND (column_name='allotId' or column_name='AccountingUnit' or column_name='UnitType');";
var result = DapperQuery<string>(sql, new { database = database, table_name = tableName }); var result = DapperQuery<string>(sql, new { database = database, table_name = tableName });
var isExist=result ?.Count() == 3; var isExist = result?.Count() == 3;
return isExist; return isExist;
......
...@@ -2069,9 +2069,9 @@ public List<dynamic> GetAllComputeView(int hospitalId, int AllotId, string viewN ...@@ -2069,9 +2069,9 @@ 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) public List<dynamic> GetAllComputeViewByDate(string viewName, DateTime beginTime, DateTime endTime)
{ {
return reportRepository.QueryComputeByDate(0, viewName, BeginTime, EndTime); return reportRepository.QueryComputeByDate(viewName, beginTime, endTime);
} }
/// <summary> /// <summary>
...@@ -2105,34 +2105,12 @@ public List<dynamic> GetAllComputeViewByDate(string viewName, string BeginTime, ...@@ -2105,34 +2105,12 @@ public List<dynamic> GetAllComputeViewByDate(string viewName, string BeginTime,
} }
} }
} }
return pairs; foreach (var item in pairs)
}
/// <summary>
/// 限制绩效发放输入的时间格式
/// </summary>
/// <param name="BeginTime"></param>
/// <param name="EndTime"></param>
/// <returns></returns>
public BeginEndTime performanceImposeDate(string BeginTime, string EndTime)
{
var Bdate = DateTime.Now;
var Edate = DateTime.Now;
if (string.IsNullOrEmpty(BeginTime) || !DateTime.TryParse(BeginTime, out Bdate) ||
string.IsNullOrEmpty(EndTime) || !DateTime.TryParse(EndTime, out Edate))
throw new PerformanceException("请输入正确的时间");
if (Bdate > Edate)
throw new PerformanceException("开始时间不能大于结束时间");
string beginDate = Bdate.Year + $"-{Bdate.Month.ToString().PadLeft(2, '0')}";
string endDate = Edate.Year + $"-{Edate.Month.ToString().PadLeft(2, '0')}";
return new BeginEndTime
{ {
BeginTime = beginDate, pairs[item.Key] = Math.Round(item.Value, 2, MidpointRounding.AwayFromZero);
EndTime = endDate }
}; return pairs;
} }
} }
public class ComputeConfig public class ComputeConfig
......
...@@ -191,10 +191,13 @@ public string AllComputerViewReport(int allotId, List<dynamic> dynamics, string ...@@ -191,10 +191,13 @@ 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, BeginEndTime date) public string AllComputerViewReportByDate(int hospitalId, List<dynamic> dynamics, string route, string name, DateTime beginTime, DateTime endTime)
{ {
var hospital = perforHospital.GetEntity(t => t.ID == hospitalId); var hospital = perforHospital.GetEntity(t => t.ID == hospitalId);
var title = $"{date.BeginTime}{date.EndTime} {hospital.HosName}医院 --- {name}";
var title = (beginTime.AddMonths(1).Date == endTime.Date)
? $"{beginTime.ToString("yyyy年MM月")} {hospital.HosName}医院 --- {name}"
: $"{beginTime.ToString("yyyy年MM月")}{endTime.ToString("yyyy年MM月")} {hospital.HosName}医院 --- {name}";
return AllComputerDown(hospital, dynamics, route, title, name); return AllComputerDown(hospital, dynamics, route, title, name);
} }
public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, string route, string title, string name) public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, string route, string title, string name)
...@@ -231,7 +234,7 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -231,7 +234,7 @@ 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() + 2, col + 1, "合计"); worksheet.SetValue(dynamics.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[dynamics.Count() + 3, col + 1].Formula = string.Format("SUM({0})", new ExcelAddress(3, col + 1, dynamics.Count() + 2, col + 1).Address);
} }
...@@ -242,7 +245,7 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str ...@@ -242,7 +245,7 @@ public string AllComputerDown(sys_hospital hospital, List<dynamic> dynamics, str
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++)
{ {
if (!notSum.Contains(headList[col].Name.ToLower())) if (headList.Count < col && !notSum.Contains(headList[col - 1].Name.ToLower()))
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.Border.BorderAround(ExcelBorderStyle.Thin);
......
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