Commit d5978a17 by 李承祥

报表

parent 69dfb15b
......@@ -27,8 +27,7 @@ public ReportController(ReportService reportService, ClaimService claimService)
[Route("survey")]
public ApiResponse Survey([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var user = claimService.At(request);
var result = reportService.Survey(user.UserID, request.HospitalId);
var result = reportService.Survey(request.HospitalId);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -39,8 +38,7 @@ public ApiResponse Survey([CustomizeValidator(RuleSet = "Query"), FromBody]Repor
[Route("doctoravg")]
public ApiResponse DoctorAvg([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var user = claimService.At(request);
var result = reportService.DoctorAvg(user.UserID, request.HospitalId);
var result = reportService.DoctorAvg(request.HospitalId, request.IsIndex);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -51,8 +49,7 @@ public ApiResponse DoctorAvg([CustomizeValidator(RuleSet = "Query"), FromBody]Re
[Route("nurseavg")]
public ApiResponse NurseAvg([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var user = claimService.At(request);
var result = reportService.NurseAvg(user.UserID, request.HospitalId);
var result = reportService.NurseAvg(request.HospitalId, request.IsIndex);
return new ApiResponse(ResponseType.OK, result);
}
......@@ -61,9 +58,9 @@ public ApiResponse NurseAvg([CustomizeValidator(RuleSet = "Query"), FromBody]Rep
/// </summary>
/// <returns></returns>
[Route("outfeeavg")]
public ApiResponse OutFeeAvg()
public ApiResponse OutFeeAvg([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var list = reportService.OutFeeAvg();
var list = reportService.OutFeeAvg(request.HospitalId);
return new ApiResponse(ResponseType.OK, "", list);
}
......@@ -72,9 +69,9 @@ public ApiResponse OutFeeAvg()
/// </summary>
/// <returns></returns>
[Route("inpatfeeavg")]
public ApiResponse InpatFeeAvg()
public ApiResponse InpatFeeAvg([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var list = reportService.InpatFeeAvg();
var list = reportService.InpatFeeAvg(request.HospitalId);
return new ApiResponse(ResponseType.OK, "", list);
}
......@@ -83,9 +80,9 @@ public ApiResponse InpatFeeAvg()
/// </summary>
/// <returns></returns>
[Route("medicine")]
public ApiResponse Medicine()
public ApiResponse Medicine([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var list = reportService.Medicine();
var list = reportService.Medicine(request.HospitalId, request.IsIndex);
return new ApiResponse(ResponseType.OK, "", list);
}
......@@ -94,9 +91,9 @@ public ApiResponse Medicine()
/// </summary>
/// <returns></returns>
[Route("income")]
public ApiResponse Income()
public ApiResponse Income([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
var list = reportService.Income();
var list = reportService.Income(request.HospitalId, request.IsIndex);
return new ApiResponse(ResponseType.OK, "", list);
}
......
......@@ -8,6 +8,8 @@ namespace Performance.DtoModels
public class ReportRequest : ApiRequest
{
public int HospitalId { get; set; }
public int IsIndex { get; set; }
}
public class ReportRequestValidator : AbstractValidator<ReportRequest>
{
......
......@@ -10,7 +10,7 @@ public class PerReport
public string Y { get; set; }
public string Value { get; set; }
public decimal Value { get; set; }
public string Type { get; set; }
......
......@@ -18,7 +18,7 @@ public PerforReportRepository(PerformanceDbContext context) : base(context)
public List<PerReport> GetAvgPerfor(int hospitalid)
{
string sql = @"select concat(allot.year,'-',lpad(allot.month,2,'0')) x, positionname y,avgvalue value
string sql = @"select concat(allot.year,'-',lpad(allot.month,2,'0')) x, positionname y,round(avgvalue,2) value
from res_baiscnorm bc left join per_allot allot on bc.allotid = allot.id where allot.hospitalid = @hospitalid
order by str_to_date(concat(allot.month, '/', allot.year),'%m/%Y')";
return DapperQuery(sql, new { hospitalid }).ToList();
......@@ -42,40 +42,48 @@ public List<PerReport> AvgRatio(int hospitalid)
/// 门诊患者均次费用
/// </summary>
/// <returns></returns>
public List<PerReport> OutFeeAvg()
public List<PerReport> OutFeeAvg(List<string> date)
{
string sql = @"select concat(year,'-',lpad(month,2,'0')) x,deptname y,sum(fee) / sum(persontime) value from hos_personfee where source = '门诊' group by year,month,deptname;";
return DapperQuery(sql, null).ToList();
string sql = @"select concat(year,'-',lpad(month,2,'0')) y,deptname x,round(sum(fee) / sum(persontime),2) value from hos_personfee where source = '门诊' and concat(year,'-',lpad(month,2,'0')) in @date group by year,month,deptname order by y;";
return DapperQuery(sql, new { date }).ToList();
}
/// <summary>
/// 住院患者均次费用
/// </summary>
/// <returns></returns>
public List<PerReport> InpatFeeAvg()
public List<PerReport> InpatFeeAvg(List<string> date)
{
string sql = @"select concat(year,'-',lpad(month,2,'0')) x,deptname y,sum(fee) / sum(persontime) value from hos_personfee where source = '住院' group by year,month,deptname;";
return DapperQuery(sql, null).ToList();
string sql = @"select concat(year,'-',lpad(month,2,'0')) y,deptname x,round(sum(fee) / sum(persontime),2) value from hos_personfee where source = '住院' and concat(year,'-',lpad(month,2,'0')) in @date group by year,month,deptname order by y;";
return DapperQuery(sql, new { date }).ToList();
}
/// <summary>
/// 科室药占比
/// </summary>
/// <returns></returns>
public List<PerReport> Medicine()
public List<PerReport> Medicine(List<string> date)
{
string sql = @"select concat(year,'-',lpad(month,2,'0')) x,deptname y,sum(if(category in ('中成药','西药','中草药'),fee,0)) / sum(fee) value from hos_personfee group by year,month,deptname;";
return DapperQuery(sql, null).ToList();
string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(dt.TypeName in
('中成药费','西药费','中草药费'),cellvalue,0)) / sum(cellvalue))*100,2) value from per_allot aot
join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id where unittype=1 and sheettype=3
and sheetname like '%就诊收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0'))
in @date group by year,month,accountingunit order by y;";
return DapperQuery(sql, new { date }).ToList();
}
/// <summary>
/// 科室有效收入占比
/// </summary>
/// <returns></returns>
public List<PerReport> Income()
public List<PerReport> Income(List<string> date)
{
string sql = @"select concat(year,'-',lpad(month,2,'0')) x,deptname y,sum(if(category not in ('中成药','西药','中草药','医材费'),fee,0)) / sum(fee) value from hos_personfee group by year,month,deptname;";
return DapperQuery(sql, null).ToList();
string sql = @"select accountingunit x,concat(year,'-',lpad(month,2,'0')) y,round((sum(if(dt.TypeName not in
('中成药费','西药费','中草药费','医材费'),cellvalue,0)) / sum(cellvalue))*100,2) value from per_allot aot
join per_sheet sht on aot.id=sht.allotid join im_data dt on dt.sheetid=sht.id where unittype=1 and sheettype=3
and sheetname like '%就诊收入' and ifnull(accountingunit,'') not in ('') and concat(year,'-',lpad(month,2,'0'))
in @date group by year,month,accountingunit order by y;";
return DapperQuery(sql, new { date }).ToList();
}
}
}
......@@ -89,7 +89,7 @@ public List<ResComputeResponse> GetCompute(int allotId, int type)
}
data = Mapper.Map<List<ResComputeResponse>>(conpute);
data?.ForEach(t => t.WorkTime = string.IsNullOrEmpty(t.WorkTime) ? null : Convert.ToDateTime(t.WorkTime).ToString("yyyy-MM-dd"));
return data;
return data?.OrderByDescending(t => t.AccountingUnit).ToList();
}
/// <summary>
......@@ -102,7 +102,7 @@ public List<res_specialunit> GetSpecial(int allotId)
var list = _perforResspecialunitRepository.GetEntities(t => t.AllotID == allotId);
if (list != null && list.Any())
{
list = list.OrderByDescending(t => t.RealGiveFee).ThenBy(t => t.AccountingUnit).ToList();
list = list.OrderByDescending(t => t.AccountingUnit).ThenBy(t => t.RealGiveFee).ToList();
return Mapper.Map<List<res_specialunit>>(list);
}
return new List<res_specialunit>();
......@@ -115,7 +115,7 @@ public List<res_specialunit> GetSpecial(int allotId)
/// <returns></returns>
public List<DoctorResponse> GetDoctorPerformance(int allotId)
{
var list = _perforResAccountdoctorRepository.GetEntities(t => t.AllotID == allotId);
var list = _perforResAccountdoctorRepository.GetEntities(t => t.AllotID == allotId)?.OrderByDescending(t => t.AccountingUnit);
List<DoctorResponse> doctor = Mapper.Map<List<DoctorResponse>>(list);
doctor?.ForEach(t => t.UnitName = "医生组");
return doctor;
......@@ -128,7 +128,7 @@ public List<DoctorResponse> GetDoctorPerformance(int allotId)
/// <returns></returns>
public List<NurseResponse> GetNursePerformance(int allotId)
{
var list = _perforResAccountnurseRepository.GetEntities(t => t.AllotID == allotId);
var list = _perforResAccountnurseRepository.GetEntities(t => t.AllotID == allotId)?.OrderByDescending(t => t.AccountingUnit);
List<NurseResponse> nurse = Mapper.Map<List<NurseResponse>>(list);
nurse?.ForEach(t => t.UnitName = "护理组");
return nurse;
......@@ -233,7 +233,7 @@ public DeptDetailResponse GetDepartmentDetail(int allotId, int accountId, int ty
public List<ComputeResponse> AllCompute(int allotId)
{
var list = new List<ComputeResponse>();
var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId);
var allot = _perforRescomputeRepository.GetEntities(t => t.AllotID == allotId)?.OrderByDescending(t => t.AccountingUnit);
list = Mapper.Map<List<ComputeResponse>>(allot);
list?.ForEach(t => t.Source = "一次绩效");
var employee = _perforAgemployeeRepository.GetEntities(t => t.AllotID == allotId);
......@@ -254,7 +254,7 @@ public List<ComputeResponse> AllCompute(int allotId)
JobTitle = e.JobTitle,
RealGiveFee = e.RealGiveFee
};
list = list.Union(list1.OrderBy(t => t.AccountingUnit)).ToList();
list = list.Union(list1?.OrderByDescending(t => t.AccountingUnit)).ToList();
}
}
return list;
......
......@@ -2,6 +2,7 @@
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Repository;
using Performance.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -105,7 +106,7 @@ public SheetExportResponse SheetExport(int sheetID)
private void SpecialUnitExport(int sheetID, SheetExportResponse response)
{
var list = _perforImspecialunitRepository.GetEntities(t => t.SheetID == sheetID);
var list = _perforImspecialunitRepository.GetEntities(t => t.SheetID == sheetID)?.OrderByDescending(t => t.AccountingUnit);
if (list != null && list.Count() > 0)
{
......@@ -145,7 +146,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
var headList = _perforImHeaderRepository.GetEntities(t => t.SheetID == sheetID)?.OrderBy(t => t.PointCell);
if (headList == null) return;
var dataList = _perforImDataRepository.GetEntities(t => t.SheetID == sheetID);
var dataList = _perforImDataRepository.GetEntities(t => t.SheetID == sheetID)?.OrderByDescending(t => t.AccountingUnit).ToList();
if (dataList == null || dataList.Count == 0) return;
......@@ -198,7 +199,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
//创建数据行
Row rowbody = null;
foreach (var rowNumber in dataList.Select(t => t.RowNumber).OrderBy(t => t).Distinct())
foreach (var rowNumber in dataList.Select(t => t.RowNumber).Distinct()) //.OrderBy(t => t)
{
foreach (var head in headers)
{
......@@ -248,7 +249,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
private void AccountNurseExport(int sheetID, SheetExportResponse response)
{
var list = _perforImaccountnurseRepository.GetEntities(t => t.SheetID == sheetID);
var list = _perforImaccountnurseRepository.GetEntities(t => t.SheetID == sheetID)?.OrderByDescending(t => t.AccountingUnit);
if (list != null && list.Count() > 0)
{
......@@ -296,7 +297,7 @@ private void AccountNurseExport(int sheetID, SheetExportResponse response)
private void AccountDoctorExport(int sheetID, SheetExportResponse response)
{
var list = _perforImaccountdoctorRepository.GetEntities(t => t.SheetID == sheetID);
var list = _perforImaccountdoctorRepository.GetEntities(t => t.SheetID == sheetID)?.OrderByDescending(t => t.AccountingUnit);
if (list != null && list.Count() > 0)
{
......@@ -346,7 +347,7 @@ private void AccountDoctorExport(int sheetID, SheetExportResponse response)
private void AccountBaiscExport(int sheetID, SheetExportResponse response)
{
var list = _perforImaccountbasicRepository.GetEntities(t => t.SheetID == sheetID);
var list = _perforImaccountbasicRepository.GetEntities(t => t.SheetID == sheetID)?.OrderByDescending(t => t.AccountingUnit);
if (list != null && list.Count() > 0)
{
......@@ -408,7 +409,7 @@ private void AccountBaiscExport(int sheetID, SheetExportResponse response)
private void EmployeeExport(int sheetID, SheetExportResponse response)
{
var employeeList = _perforImEmployeeRepository.GetEntities(t => t.SheetID == sheetID).OrderBy(t => t.RowNumber);
var employeeList = _perforImEmployeeRepository.GetEntities(t => t.SheetID == sheetID)?.OrderByDescending(t => t.AccountingUnit);//.OrderBy(t => t.RowNumber);
if (employeeList != null && employeeList.Count() > 0)
{
......
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