Commit fb1f594a by 李承祥

报表

parent ef244e32
......@@ -13,9 +13,11 @@ namespace Performance.Api.Controllers
public class ReportController : Controller
{
private ReportService reportService;
public ReportController(ReportService reportService)
private ClaimService claimService;
public ReportController(ReportService reportService, ClaimService claimService)
{
this.reportService = reportService;
this.claimService = claimService;
}
/// <summary>
......@@ -23,16 +25,11 @@ public ReportController(ReportService reportService)
/// </summary>
/// <returns></returns>
[Route("survey")]
public ApiResponse Survey()
public ApiResponse Survey([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
//拿最新有效的绩效年月
//hos_personfee 门诊患者均次 住院患者均次
//res_baiscnorm 全部拿出来
//xxxx年 xx月 数组
throw new NotImplementedException();
var user = claimService.At(request);
var result = reportService.Survey(user.UserID, request.HospitalId);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
......@@ -40,11 +37,11 @@ public ApiResponse Survey()
/// </summary>
/// <returns></returns>
[Route("doctoravg")]
public ApiResponse DoctorAvg()
public ApiResponse DoctorAvg([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
// res_accountdoctor 人数 所有有效绩效 (6,8)
throw new NotImplementedException();
var user = claimService.At(request);
var result = reportService.DoctorAvg(user.UserID, request.HospitalId);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
......@@ -52,10 +49,11 @@ public ApiResponse DoctorAvg()
/// </summary>
/// <returns></returns>
[Route("nurseavg")]
public ApiResponse NurseAvg()
public ApiResponse NurseAvg([CustomizeValidator(RuleSet = "Query"), FromBody]ReportRequest request)
{
// res_accountnurse 人数 所有有效绩效 (6,8)
throw new NotImplementedException();
var user = claimService.At(request);
var result = reportService.NurseAvg(user.UserID, request.HospitalId);
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
......@@ -65,7 +63,8 @@ public ApiResponse NurseAvg()
[Route("outfeeavg")]
public ApiResponse OutFeeAvg()
{
throw new NotImplementedException();
var list = reportService.OutFeeAvg();
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
......@@ -75,7 +74,8 @@ public ApiResponse OutFeeAvg()
[Route("inpatfeeavg")]
public ApiResponse InpatFeeAvg()
{
throw new NotImplementedException();
var list = reportService.InpatFeeAvg();
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
......@@ -85,7 +85,8 @@ public ApiResponse InpatFeeAvg()
[Route("medicine")]
public ApiResponse Medicine()
{
throw new NotImplementedException();
var list = reportService.Medicine();
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
......@@ -95,7 +96,8 @@ public ApiResponse Medicine()
[Route("income")]
public ApiResponse Income()
{
throw new NotImplementedException();
var list = reportService.Income();
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
......
......@@ -24,6 +24,11 @@ public List<PerReport> GetAvgPerfor(int hospitalid)
return DapperQuery(sql, new { hospitalid }).ToList();
}
/// <summary>
/// 人群绩效比
/// </summary>
/// <param name="hospitalid"></param>
/// <returns></returns>
public List<PerReport> AvgRatio(int hospitalid)
{
string sql = @"select concat(allot.year,'-',lpad(allot.month,2,'0')) x, bc.PositionName y,round(bc.AvgValue / rbn.AvgValue,2) value
......@@ -32,5 +37,45 @@ public List<PerReport> AvgRatio(int hospitalid)
order by str_to_date(concat(allot.month, '/', allot.year),'%m/%Y');";
return DapperQuery(sql, new { hospitalid }).ToList();
}
/// <summary>
/// 门诊患者均次费用
/// </summary>
/// <returns></returns>
public List<PerReport> OutFeeAvg()
{
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();
}
/// <summary>
/// 住院患者均次费用
/// </summary>
/// <returns></returns>
public List<PerReport> InpatFeeAvg()
{
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();
}
/// <summary>
/// 科室药占比
/// </summary>
/// <returns></returns>
public List<PerReport> Medicine()
{
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();
}
/// <summary>
/// 科室有效收入占比
/// </summary>
/// <returns></returns>
public List<PerReport> Income()
{
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();
}
}
}
using Performance.EntityModels;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Performance.Services
......@@ -9,9 +12,25 @@ namespace Performance.Services
public class ReportService : IAutoInjection
{
private PerforReportRepository perforReportRepository;
public ReportService(PerforReportRepository perforReportRepository)
private PerforPerallotRepository perforPerallotRepository;
private PerforResbaiscnormRepository perforResbaiscnormRepository;
private PerforHospersonfeeRepository perforHospersonfeeRepository;
private PerforResaccountdoctorRepository perforResaccountdoctorRepository;
private PerforResaccountnurseRepository perforResaccountnurseRepository;
public ReportService(PerforReportRepository perforReportRepository,
PerforPerallotRepository perforPerallotRepository,
PerforResbaiscnormRepository perforResbaiscnormRepository,
PerforHospersonfeeRepository perforHospersonfeeRepository,
PerforResaccountdoctorRepository perforResaccountdoctorRepository,
PerforResaccountnurseRepository perforResaccountnurseRepository)
{
this.perforReportRepository = perforReportRepository;
this.perforPerallotRepository = perforPerallotRepository;
this.perforResbaiscnormRepository = perforResbaiscnormRepository;
this.perforHospersonfeeRepository = perforHospersonfeeRepository;
this.perforResaccountdoctorRepository = perforResaccountdoctorRepository;
this.perforResaccountnurseRepository = perforResaccountnurseRepository;
}
/// <summary>
......@@ -30,5 +49,131 @@ public List<PerReport> AvgRatio(int hospitalid)
{
return perforReportRepository.AvgRatio(hospitalid);
}
/// <summary>
/// 首页数据概况
/// </summary>
/// <param name="request"></param>
public dynamic Survey(int userId, int hospitalId)
{
var states = new List<int>() { 6, 8 };
var allotList = perforPerallotRepository.GetEntities(t => t.CreateUser == userId && t.HospitalId == hospitalId && states.Contains(t.States));
if (allotList == null || !allotList.Any())
throw new PerformanceException("用户未创建绩效!");
var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault();
var keyvalue = new Dictionary<string, decimal>();
var basicList = perforResbaiscnormRepository.GetEntities(t => t.AllotID == allot.ID);
if (basicList != null)
{
foreach (var basic in basicList)
{
keyvalue.Add(basic.PositionName, basic.AvgValue.Value);
}
}
var fee = perforHospersonfeeRepository.GetEntities(t => t.Year == allot.Year && t.Month == allot.Month);
if (fee != null)
{
keyvalue.Add("门诊患者均次", fee.Sum(t => t.Fee.Value) / fee.Sum(t => t.PersonTime.Value));
keyvalue.Add("住院患者均次", fee.Sum(t => t.Fee.Value) / fee.Sum(t => t.PersonTime.Value));
}
return new
{
year = allot.Year,
month = allot.Month,
avgperfor = keyvalue
};
}
/// <summary>
/// 科室医生人均绩效(含科主任)
/// </summary>
/// <returns></returns>
public List<PerReport> DoctorAvg(int userId, int hospitalId)
{
var states = new List<int>() { 6, 8 };
var allotList = perforPerallotRepository.GetEntities(t => t.CreateUser == userId && t.HospitalId == hospitalId && states.Contains(t.States));
if (allotList == null || !allotList.Any())
throw new PerformanceException("用户未创建绩效!");
var result = new List<PerReport>();
var doctorList = perforResaccountdoctorRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotID.Value));
if (doctorList == null)
return result;
var s = from a in allotList
join d in doctorList on a.ID equals d.AllotID into data
from t in data
select new PerReport
{
X = a.Year + "-" + a.Month.ToString().PadLeft(2, '0'),
Y = t.AccountingUnit,
Value = t.Avg.ToString()
};
return s.OrderBy(t => t.X).ToList();
}
/// <summary>
/// 科室医生人均绩效(含科主任)
/// </summary>
/// <returns></returns>
public List<PerReport> NurseAvg(int userId, int hospitalId)
{
var states = new List<int>() { 6, 8 };
var allotList = perforPerallotRepository.GetEntities(t => t.CreateUser == userId && t.HospitalId == hospitalId && states.Contains(t.States));
if (allotList == null || !allotList.Any())
throw new PerformanceException("用户未创建绩效!");
var result = new List<PerReport>();
var doctorList = perforResaccountnurseRepository.GetEntities(t => allotList.Select(a => a.ID).Contains(t.AllotID.Value));
if (doctorList == null)
return result;
var s = from a in allotList
join d in doctorList on a.ID equals d.AllotID into data
from t in data
select new PerReport
{
X = a.Year + "-" + a.Month.ToString().PadLeft(2, '0'),
Y = t.AccountingUnit,
Value = t.Avg.ToString()
};
return s.OrderBy(t => t.X).ToList();
}
/// <summary>
/// 门诊患者均次费用
/// </summary>
/// <returns></returns>
public List<PerReport> OutFeeAvg()
{
return perforReportRepository.OutFeeAvg();
}
/// <summary>
/// 住院患者均次费用
/// </summary>
/// <returns></returns>
public List<PerReport> InpatFeeAvg()
{
return perforReportRepository.InpatFeeAvg();
}
/// <summary>
/// 科室药占比
/// </summary>
/// <returns></returns>
public List<PerReport> Medicine()
{
return perforReportRepository.Medicine();
}
/// <summary>
/// 科室有效收入占比
/// </summary>
/// <returns></returns>
public List<PerReport> Income()
{
return perforReportRepository.Income();
}
}
}
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