Commit 4a447221 by 李承祥

Merge branch 'feature/report' into feature/mergereport

# Conflicts:
#	performance/Performance.Api/wwwroot/Performance.Api.xml
parents 93691577 d9b592cf
...@@ -29,17 +29,19 @@ public class AllotController : Controller ...@@ -29,17 +29,19 @@ public class AllotController : Controller
private IHostingEnvironment _evn; private IHostingEnvironment _evn;
private ILogger<AllotController> _logger; private ILogger<AllotController> _logger;
private ClaimService _claim; private ClaimService _claim;
private readonly LogManageService logManageService;
public AllotController(AllotService allotService, public AllotController(AllotService allotService,
HospitalService hospitalService, ConfigService configService, HospitalService hospitalService, ConfigService configService,
ILogger<AllotController> logger, IHostingEnvironment evn, ILogger<AllotController> logger, IHostingEnvironment evn,
ClaimService claim) ClaimService claim, LogManageService logManageService)
{ {
_allotService = allotService; _allotService = allotService;
_hospitalService = hospitalService; _hospitalService = hospitalService;
_logger = logger; _logger = logger;
_evn = evn; _evn = evn;
_claim = claim; _claim = claim;
this.logManageService = logManageService;
_configService = configService; _configService = configService;
} }
...@@ -164,7 +166,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al ...@@ -164,7 +166,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al
_allotService.Generate(allot, email); _allotService.Generate(allot, email);
else else
BackgroundJob.Schedule(() => _allotService.Generate(allot, email), TimeSpan.FromSeconds(1)); BackgroundJob.Schedule(() => _allotService.Generate(allot, email), TimeSpan.FromSeconds(1));
logManageService.WriteMsg("等待绩效生成", $"等待绩效生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效!", 1, allot.ID, "ReceiveMessage");
//_allotService.Generate(allot, email); //_allotService.Generate(allot, email);
////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email)); ////BackgroundJob.Enqueue(() => _allotService.Generate(allot, email));
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
......
...@@ -130,5 +130,31 @@ public ApiResponse AvgRatio([CustomizeValidator(RuleSet = "Query"), FromBody]Rep ...@@ -130,5 +130,31 @@ public ApiResponse AvgRatio([CustomizeValidator(RuleSet = "Query"), FromBody]Rep
var list = reportService.AvgRatio(request.HospitalId); var list = reportService.AvgRatio(request.HospitalId);
return new ApiResponse(ResponseType.OK, "", list); return new ApiResponse(ResponseType.OK, "", list);
} }
/// <summary>
/// 首页报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("index")]
[HttpPost]
public ApiResponse IndexReport([CustomizeValidator(RuleSet = "Index"), FromBody]ReportRequest request)
{
var list = reportService.IndexReport(request.HospitalId, request.Source);
return new ApiResponse(ResponseType.OK, "", list);
}
/// <summary>
/// 菜单报表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("menu")]
[HttpPost]
public ApiResponse MenuReport([CustomizeValidator(RuleSet = "Menu"), FromBody]ReportRequest request)
{
var list = reportService.MenuReport(request.HospitalId, request.OnlyYear, request.Source, request.IsInHos);
return new ApiResponse(ResponseType.OK, "", list);
}
} }
} }
\ No newline at end of file
...@@ -9,7 +9,17 @@ public class ReportRequest ...@@ -9,7 +9,17 @@ public class ReportRequest
{ {
public int HospitalId { get; set; } public int HospitalId { get; set; }
/// <summary> 是否为首页 </summary>
public int IsIndex { get; set; } public int IsIndex { get; set; }
/// <summary> 是否以年为单位 </summary>
public int OnlyYear { get; set; }
/// <summary> 是否住院 </summary>
public int IsInHos { get; set; }
/// <summary> 报表名称 </summary>
public string Source { get; set; }
} }
public class ReportRequestValidator : AbstractValidator<ReportRequest> public class ReportRequestValidator : AbstractValidator<ReportRequest>
{ {
...@@ -19,6 +29,19 @@ public ReportRequestValidator() ...@@ -19,6 +29,19 @@ public ReportRequestValidator()
{ {
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0); RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
}); });
RuleSet("Index", () =>
{
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
RuleFor(x => x.Source).NotNull().NotEmpty();
});
RuleSet("Menu", () =>
{
RuleFor(x => x.HospitalId).NotNull().GreaterThan(0);
RuleFor(x => x.OnlyYear).NotNull();
RuleFor(x => x.Source).NotNull().NotEmpty();
});
} }
} }
} }
...@@ -21,5 +21,12 @@ public bool UpdateAllotStates(int allotId, int states, string remark) ...@@ -21,5 +21,12 @@ public bool UpdateAllotStates(int allotId, int states, string remark)
allot.Remark = remark; allot.Remark = remark;
return Update(allot); return Update(allot);
} }
public int ImportData(int allotId)
{
string sql = @"select * from view_report_allot_summary where allotid=@allotId;
select * from view_report_original_income where allotid=@allotId;";
return Execute(sql, new { allotId });
}
} }
} }
...@@ -19,8 +19,8 @@ public List<PerReport> GetAvgPerfor(int hospitalid) ...@@ -19,8 +19,8 @@ public List<PerReport> GetAvgPerfor(int hospitalid)
{ {
string sql = @"select concat(allot.year,'-',lpad(allot.month,2,'0')) x, positionname y,round(avgvalue,2) 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 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')"; order by str_to_date(concat(allot.month, '/', allot.year),'%m/%Y')";
return DapperQuery(sql, new { hospitalid }).ToList(); return DapperQuery(sql, new { hospitalid }).ToList();
} }
...@@ -32,9 +32,9 @@ public List<PerReport> GetAvgPerfor(int hospitalid) ...@@ -32,9 +32,9 @@ public List<PerReport> GetAvgPerfor(int hospitalid)
public List<PerReport> AvgRatio(int hospitalid) 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 string sql = @"select concat(allot.year,'-',lpad(allot.month,2,'0')) x, bc.PositionName y,round(bc.AvgValue / rbn.AvgValue,2) value
from res_baiscnorm bc left join res_baiscnorm rbn on bc.allotid = rbn.allotid and rbn.positionname = '临床科室主任人均绩效' from res_baiscnorm bc left join res_baiscnorm rbn on bc.allotid = rbn.allotid and rbn.positionname = '临床科室主任人均绩效'
left join per_allot allot on bc.allotid = allot.id where allot.hospitalid = @hospitalid 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');"; order by str_to_date(concat(allot.month, '/', allot.year),'%m/%Y');";
return DapperQuery(sql, new { hospitalid }).ToList(); return DapperQuery(sql, new { hospitalid }).ToList();
} }
...@@ -85,5 +85,196 @@ public List<PerReport> Income(int hospitalId, List<string> date) ...@@ -85,5 +85,196 @@ public List<PerReport> Income(int hospitalId, List<string> date)
in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;"; in @date and hospitalid = @hospitalId group by year,month,accountingunit order by y asc,value desc;";
return DapperQuery(sql, new { hospitalId, date }).ToList(); return DapperQuery(sql, new { hospitalId, date }).ToList();
} }
#region 首页报表
/// <summary>
/// 绩效发放金额
/// </summary>
/// <param name="currentDate"></param>
/// <param name="yoyDate"></param>
/// <param name="chainDate"></param>
/// <returns></returns>
public List<PerReport> PerforPayment(int hospitalId, string currentDate, string yoyDate, string chainDate)
{
string sql = $"select t1.*,ifnull(t2.RealGiveFee, 0.0000) value from (select '{currentDate}' x,'当月发放金额' y union select '{yoyDate}' x,'同期发放金额' y union select '{chainDate}' x,'环比发放金额' y)t1 left join report_allot_summary t2 on t1.x = concat(t2.year,'-',lpad(t2.month,2,'0')) and t2.HospitalId = @hospitalId;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 绩效发放金额占全院收入占比
/// </summary>
/// <param name="currentDate"></param>
/// <param name="yoyDate"></param>
/// <param name="chainDate"></param>
/// <returns></returns>
public List<PerReport> IndexPerforRatio(int hospitalId, string currentDate, string yoyDate, string chainDate)
{
string sql = $"select t1.*, round(ifnull(t2.RealGiveFee, 0.0000)/t3.income*100, 2)value from(select '{currentDate}' x,'当月发放占比' y union select '{yoyDate}' x,'同期发放占比' y union select '{chainDate}' x,'环比发放占比' y)t1 left join report_allot_summary t2 on t1.x = concat(t2.year,'-', lpad(t2.month,2,'0')) and t2.HospitalId = @hospitalId left join (select year, month, sum(CellValue) income from report_original_income where HospitalId = @hospitalId group by year, month)t3 on t1.x = concat(t3.year,'-', lpad(t3.month,2,'0'));";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 首页药占比(本月、环比、同期)
/// </summary>
/// <param name="hospitalId">医院Id</param>
/// <param name="currentDate">本月日期</param>
/// <param name="yoyDate">同比日期</param>
/// <param name="chainDate">环比日期</param>
/// <returns></returns>
public List<PerReport> IndexDrugRatio(int hospitalId, string currentDate, string yoyDate, string chainDate)
{
string sql = $"select t1.*,round(t2.CellValue/t3.`value`*100, 2) value from (select '{currentDate}' x,'当月药占比' y union select '{yoyDate}' x,'同期药占比' y union select '{chainDate}' x,'环比药占比' y)t1 left join (select concat(year,'-',lpad(month,2,'0')) date,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId group by year,month) t2 on t1.x = t2.date left join (select concat(year,'-',lpad(month,2,'0')) date,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t3 on t1.x = t3.date;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 首页材料占比(本月、环比、同期)
/// </summary>
/// <param name="hospitalId">医院Id</param>
/// <param name="currentDate">本月日期</param>
/// <param name="yoyDate">同比日期</param>
/// <param name="chainDate">环比日期</param>
/// <returns></returns>
public List<PerReport> IndexMaterialRatio(int hospitalId, string currentDate, string yoyDate, string chainDate)
{
string sql = $"select t1.*,round(t2.CellValue/t3.`value`*100, 2) value from (select '{currentDate}' x,'当月材料占比' y union select '{yoyDate}' x,'同期材料占比' y union select '{chainDate}' x,'环比材料占比' y)t1 left join (select concat(year,'-',lpad(month,2,'0')) date,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId group by year,month) t2 on t1.x = t2.date left join (select concat(year,'-',lpad(month,2,'0')) date,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t3 on t1.x = t3.date;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 首页结构占比
/// </summary>
/// <returns></returns>
public List<PerReport> IndexStructRatio(int hospitalId, string currentDate)
{
string sql = $"select TypeName y,t1.y x,round(CellValue/t2.`value`*100,2) value from (select '{currentDate}' y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId and concat(year,'-',lpad(month,2,'0')) = '{currentDate}' group by TypeName) t1 inner join (select '{currentDate}' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId and concat(year,'-',lpad(month,2,'0')) = '{currentDate}')t2 on t1.y = t2.y order by value desc;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
#endregion
#region 菜单报表
/// <summary>
/// 业务总收入
/// </summary>
/// <returns></returns>
public List<PerReport> GeneralIncome(int hospitalId, int isOnlyYear)
{
string sql = $"select year x,'业务总收入(年)' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year;";
if (isOnlyYear != 1)
sql = $"select concat(year,'-',lpad(month,2,'0')) x,'业务总收入(月)' y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 门诊、住院业务收入占比
/// </summary>
/// <returns></returns>
public List<PerReport> InHosIncome(int hospitalId, int isOnlyYear, int isInHos)
{
string xAxis = isInHos == 1 ? "住院" : "门诊";
string formula = isInHos == 1 ? "t.InHos/(t.InHos+t.Outpatient)" : "t.Outpatient/(t.InHos+t.Outpatient)";
string sql = $"select '{xAxis}' x,year y,round({formula} * 100, 2) value from (select year,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId group by year)t;";
if (isOnlyYear != 1)
sql = $"select '{xAxis}' x,concat(year,'-',lpad(month,2,'0')) y,round({formula} * 100, 2) value from (select year,month,sum(case SourceType when '住院' then CellValue else 0 end) InHos,sum(case SourceType when '门诊' then CellValue else 0 end) Outpatient from report_original_income where hospitalid = @hospitalId group by year,month)t;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 业务收入结构占比
/// </summary>
/// <returns></returns>
public List<PerReport> StructRatio(int hospitalId, int isOnlyYear)
{
string sql = $"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year)t2 on t1.y = t2.y order by y asc,value desc;";
if (isOnlyYear != 1)
sql = $"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income where HospitalID = @hospitalId group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t2 on t1.y = t2.y order by y asc,value desc;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 药占比
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="isOnlyYear"></param>
/// <returns></returns>
public List<PerReport> DrugRatio(int hospitalId, int isOnlyYear)
{
string sql = $"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year)t2 on t1.y = t2.y;";
if (isOnlyYear != 1)
sql = $"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '药品' where HospitalID = @hospitalId group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t2 on t1.y = t2.y;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 材料占比
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="isOnlyYear"></param>
/// <returns></returns>
public List<PerReport> MaterialRatio(int hospitalId, int isOnlyYear)
{
string sql = $"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select year y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId group by year,TypeName) t1 inner join (select year y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year)t2 on t1.y = t2.y;";
if (isOnlyYear != 1)
sql = $"select TypeName x,t1.y,round(CellValue/t2.`value`*100,2) value from (select concat(year,'-',lpad(month,2,'0')) y,TypeName,sum(CellValue) CellValue from report_original_income t1 inner join cof_drugtype t2 on t1.TypeName = t2.Charge and t1.AllotID = t2.AllotId and t2.ChargeType = '耗材' where HospitalID = @hospitalId group by year,month,TypeName) t1 inner join (select concat(year,'-',lpad(month,2,'0')) y,sum(CellValue) value from report_original_income where hospitalid = @hospitalId group by year,month)t2 on t1.y = t2.y;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 绩效发放金额占全院收入占比
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="isOnlyYear"></param>
/// <returns></returns>
public List<PerReport> PerforRatio(int hospitalId, int isOnlyYear)
{
string sql = $"select t2.x,'绩效发放金额占全院收入占比(年)' y,round(t1.RealGiveFee/t2.income * 100, 2) value from (select `year`,sum(realgivefee) realgivefee from report_allot_summary where HospitalID = @hospitalId group by year) t1 inner join (select year x,sum(CellValue) income from report_original_income where HospitalId = @hospitalId group by year)t2 on t1.`Year` = t2.x;";
if (isOnlyYear != 1)
sql = $"select t2.x,'绩效发放金额占全院收入占比(月)' y,round(t1.RealGiveFee/t2.income * 100, 2) value from report_allot_summary t1 inner join (select concat(year,'-',lpad(month,2,'0')) x,sum(CellValue) income from report_original_income where HospitalId = @hospitalId group by year,month)t2 on concat(t1.year,'-',lpad(t1.month,2,'0')) = t2.x where t1.HospitalID = @hospitalId;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 绩效群体收入
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="isOnlyYear"></param>
/// <returns></returns>
public List<PerReport> PerforGroup(int hospitalId, int isOnlyYear)
{
string sql = $"select PositionName x,year y,round(sum(avgvalue), 2) value from (select t1.PositionName,year,AvgValue from res_baiscnorm t1 inner join per_allot t2 on t1.AllotID = t2.Id and t2.HospitalId = @hospitalId and locate('保底', t1.PositionName) = 0)t group by PositionName,year;";
if (isOnlyYear != 1)
sql = $"select t1.PositionName x, concat(t2.year, '-', lpad(t2.month, 2, '0')) y,round(AvgValue, 2) value from res_baiscnorm t1 inner join per_allot t2 on t1.AllotID = t2.Id and t2.HospitalId = @hospitalId and locate('保底', t1.PositionName) = 0;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 医生核算单元人均绩效
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="isOnlyYear"></param>
/// <returns></returns>
public List<PerReport> DoctorAvg(int hospitalId, int isOnlyYear)
{
string sql = $"select `Year` y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType != 2)t group by year,AccountingUnit;";
if (isOnlyYear != 1)
sql = $"select concat(year,'-',lpad(month,2,'0')) y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType != 2)t group by year,month,AccountingUnit;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
/// <summary>
/// 护理核算单元人均绩效
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="isOnlyYear"></param>
/// <returns></returns>
public List<PerReport> NurseAvg(int hospitalId, int isOnlyYear)
{
string sql = $"select `Year` y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType = 2)t group by year,AccountingUnit;";
if (isOnlyYear != 1)
sql = $"select concat(year,'-',lpad(month,2,'0')) y,AccountingUnit x,round(sum(avg),2) value from (select t1.AccountingUnit,t1.Avg,t2.`Year`,t2.`Month`,t2.ID from res_account t1 inner join per_allot t2 on t1.AllotID = t2.ID and t2.HospitalId = @hospitalId and t1.UnitType = 2)t group by year,month,AccountingUnit;";
return DapperQuery(sql, new { hospitalId }).ToList();
}
#endregion
} }
} }
...@@ -38,6 +38,7 @@ public class AllotService : IAutoInjection ...@@ -38,6 +38,7 @@ public class AllotService : IAutoInjection
//private readonly IHubContext<AllotLogHub> hubContext; //private readonly IHubContext<AllotLogHub> hubContext;
private readonly LogManageService logManageService; private readonly LogManageService logManageService;
private readonly ReportService reportService;
public AllotService(PerforPerallotRepository allotRepository, public AllotService(PerforPerallotRepository allotRepository,
BaiscNormService baiscNormService, BaiscNormService baiscNormService,
...@@ -55,7 +56,8 @@ public class AllotService : IAutoInjection ...@@ -55,7 +56,8 @@ public class AllotService : IAutoInjection
PerforHospitalRepository perforHospitalRepository, PerforHospitalRepository perforHospitalRepository,
PerforResbaiscnormRepository perforResbaiscnormRepository, PerforResbaiscnormRepository perforResbaiscnormRepository,
//IHubContext<AllotLogHub> hubContext //IHubContext<AllotLogHub> hubContext
LogManageService logManageService) LogManageService logManageService,
ReportService reportService)
{ {
_allotRepository = allotRepository; _allotRepository = allotRepository;
_againallotRepository = againallotRepository; _againallotRepository = againallotRepository;
...@@ -75,6 +77,7 @@ public class AllotService : IAutoInjection ...@@ -75,6 +77,7 @@ public class AllotService : IAutoInjection
this.perforResbaiscnormRepository = perforResbaiscnormRepository; this.perforResbaiscnormRepository = perforResbaiscnormRepository;
//this.hubContext = hubContext; //this.hubContext = hubContext;
this.logManageService = logManageService; this.logManageService = logManageService;
this.reportService = reportService;
} }
#region 基础功能 #region 基础功能
...@@ -294,7 +297,13 @@ public void Generate(per_allot allot, string mail) ...@@ -294,7 +297,13 @@ public void Generate(per_allot allot, string mail)
perforResbaiscnormRepository.AddRange(baiscnormList.ToArray()); perforResbaiscnormRepository.AddRange(baiscnormList.ToArray());
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed)); UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
var res = reportService.ImportData(allot.ID);
logManageService.WriteMsg("正在生成报表数据", $"报表数据生成完成;受影响:{res}行", 1, allot.ID, "ReceiveMessage", true);
//发送邮件 //发送邮件
logManageService.WriteMsg("正在发送邮件", "正在发送邮件", 1, allot.ID, "ReceiveMessage", true);
SendEmail(allot, mail, 1, time); SendEmail(allot, mail, 1, time);
//logdbug.Add(allot.ID, "绩效开始执行", "绩效生成成功"); //logdbug.Add(allot.ID, "绩效开始执行", "绩效生成成功");
logManageService.WriteMsg("绩效生成结束", "绩效生成成功", 5, allot.ID, "ReceiveMessage", true); logManageService.WriteMsg("绩效生成结束", "绩效生成成功", 5, allot.ID, "ReceiveMessage", true);
......
...@@ -63,7 +63,7 @@ public dynamic Survey(int hospitalId) ...@@ -63,7 +63,7 @@ public dynamic Survey(int hospitalId)
var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault(); var allot = allotList.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).FirstOrDefault();
var keyvalue = new Dictionary<string, decimal>(); var keyvalue = new Dictionary<string, decimal>();
var basicList = perforResbaiscnormRepository.GetEntities(t => t.AllotID == allot.ID); var basicList = perforResbaiscnormRepository.GetEntities(t => t.AllotID == allot.ID && t.PositionName.IndexOf("保底") < 0);
if (basicList != null) if (basicList != null)
{ {
foreach (var basic in basicList) foreach (var basic in basicList)
...@@ -71,17 +71,6 @@ public dynamic Survey(int hospitalId) ...@@ -71,17 +71,6 @@ public dynamic Survey(int hospitalId)
keyvalue.Add(basic.PositionName, Math.Round(basic.AvgValue.Value, 2)); keyvalue.Add(basic.PositionName, Math.Round(basic.AvgValue.Value, 2));
} }
} }
var fee = perforHospersonfeeRepository.GetEntities(t => t.Year == allot.Year && t.Month == allot.Month);
if (fee != null)
{
keyvalue.Add("门诊患者均次", Math.Round(fee.Where(t => t.Source == "门诊").Sum(t => t.Fee.Value) / fee.Where(t => t.Source == "门诊").Sum(t => t.PersonTime.Value), 2));
keyvalue.Add("住院患者均次", Math.Round(fee.Where(t => t.Source == "住院").Sum(t => t.Fee.Value) / fee.Where(t => t.Source == "住院").Sum(t => t.PersonTime.Value), 2));
}
else
{
keyvalue.Add("门诊患者均次", 0M);
keyvalue.Add("住院患者均次", 0M);
}
return new return new
{ {
year = allot.Year, year = allot.Year,
...@@ -123,7 +112,7 @@ public List<PerReport> DoctorAvg(int hospitalId, int isIndex) ...@@ -123,7 +112,7 @@ public List<PerReport> DoctorAvg(int hospitalId, int isIndex)
} }
/// <summary> /// <summary>
/// 科室医生人均绩效(含科主任 /// 科室护理人均绩效(含护士长
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<PerReport> NurseAvg(int hospitalId, int isIndex) public List<PerReport> NurseAvg(int hospitalId, int isIndex)
...@@ -234,5 +223,98 @@ public List<PerReport> Income(int hospitalId, int isIndex) ...@@ -234,5 +223,98 @@ public List<PerReport> Income(int hospitalId, int isIndex)
} }
return perforReportRepository.Income(hospitalId, date); return perforReportRepository.Income(hospitalId, date);
} }
internal int ImportData(int allotId)
{
try
{
return perforPerallotRepository.ImportData(allotId);
}
catch { }
return 0;
}
/// <summary>
/// 首页
/// </summary>
/// <param name="hospitalId"></param>
/// <returns></returns>
public List<PerReport> IndexReport(int hospitalId, string source)
{
var states = new List<int>() { 6, 8 };
var allotList = perforPerallotRepository.GetEntities(t => 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 currentDate = allot.Year + "-" + allot.Month.ToString().PadLeft(2, '0'); //本月
var yoyDate = (allot.Year - 1) + "-" + allot.Month.ToString().PadLeft(2, '0'); //同比
var chainDate = allot.Year + "-" + (allot.Month - 1).ToString().PadLeft(2, '0'); //环比
var report = new List<PerReport>();
switch (source)
{
case "绩效发放金额":
report = perforReportRepository.PerforPayment(hospitalId, currentDate, yoyDate, chainDate);
break;
case "绩效发放金额占全院收入占比":
report = perforReportRepository.IndexPerforRatio(hospitalId, currentDate, yoyDate, chainDate);
break;
case "药占比":
report = perforReportRepository.IndexDrugRatio(hospitalId, currentDate, yoyDate, chainDate);
break;
case "材料占比":
report = perforReportRepository.IndexMaterialRatio(hospitalId, currentDate, yoyDate, chainDate);
break;
case "结构占比":
report = perforReportRepository.IndexStructRatio(hospitalId, currentDate);
break;
}
return report;
}
/// <summary>
/// 菜单
/// </summary>
/// <param name="hospitalId"></param>
/// <returns></returns>
public List<PerReport> MenuReport(int hospitalId, int isOnlyYear, string source, int? isInHos = null)
{
var report = new List<PerReport>();
switch (source)
{
case "业务总收入":
report = perforReportRepository.GeneralIncome(hospitalId, isOnlyYear);
break;
case "门诊、住院业务收入占比":
report = perforReportRepository.InHosIncome(hospitalId, isOnlyYear, isInHos.Value);
break;
case "业务收入结构占比":
report = perforReportRepository.StructRatio(hospitalId, isOnlyYear);
break;
case "药占比":
report = perforReportRepository.DrugRatio(hospitalId, isOnlyYear);
break;
case "材料占比":
report = perforReportRepository.MaterialRatio(hospitalId, isOnlyYear);
break;
case "绩效发放金额占全院收入占比":
report = perforReportRepository.PerforRatio(hospitalId, isOnlyYear);
break;
case "绩效群体收入":
report = perforReportRepository.PerforGroup(hospitalId, isOnlyYear);
break;
case "医生核算单元人均绩效":
report = perforReportRepository.DoctorAvg(hospitalId, isOnlyYear);
break;
case "护理核算单元人均绩效":
report = perforReportRepository.NurseAvg(hospitalId, isOnlyYear);
break;
}
return report;
}
} }
} }
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