Commit 514df09d by lcx

Merge branch 'readExcel' into v2020

parents 148ac0e2 58367fb6
...@@ -50,7 +50,8 @@ public ApiResponse Rank([FromBody]HospitalIdRequest request) ...@@ -50,7 +50,8 @@ public ApiResponse Rank([FromBody]HospitalIdRequest request)
[HttpPost] [HttpPost]
public ApiResponse Selection([FromBody]SelectionRequest report) public ApiResponse Selection([FromBody]SelectionRequest report)
{ {
var result = reportDataService.GetReportSelection(report.GroupId); var userId = claimService.GetUserId();
var result = reportDataService.GetReportSelection(report.GroupId, userId);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
...@@ -66,7 +67,8 @@ public ApiResponse Info([FromBody]SelectionRequest report) ...@@ -66,7 +67,8 @@ public ApiResponse Info([FromBody]SelectionRequest report)
[HttpPost] [HttpPost]
public ApiResponse Search([FromBody]SearchReportRequest report) public ApiResponse Search([FromBody]SearchReportRequest report)
{ {
var result = reportDataService.GetReportData(report.HospitalId, report.GroupId, report.ReportId, report.Values ?? new List<SelectionValues>()); var userId = claimService.GetUserId();
var result = reportDataService.GetReportData(report.HospitalId, report.GroupId, report.ReportId, report.Values ?? new List<SelectionValues>(), userId);
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
......
...@@ -242,6 +242,13 @@ ...@@ -242,6 +242,13 @@
<param name="request"></param> <param name="request"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.BudgetController.UseResult(System.Int32)">
<summary>
使用预算比例
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.GetCompute(Performance.DtoModels.ComputerRequest)"> <member name="M:Performance.Api.Controllers.ComputeController.GetCompute(Performance.DtoModels.ComputerRequest)">
<summary> <summary>
获取绩效发放列表 获取绩效发放列表
......
...@@ -2822,6 +2822,11 @@ ...@@ -2822,6 +2822,11 @@
成本合计实际比例 成本合计实际比例
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.per_budget_result.States">
<summary>
1.初始 2. 确认使用发放/调节系数
</summary>
</member>
<member name="P:Performance.EntityModels.per_budget_result.CreateDate"> <member name="P:Performance.EntityModels.per_budget_result.CreateDate">
<summary> <summary>
......
...@@ -17,6 +17,7 @@ public class ResultComputeService : IAutoInjection ...@@ -17,6 +17,7 @@ public class ResultComputeService : IAutoInjection
{ {
private readonly BaiscNormService baiscNormService; private readonly BaiscNormService baiscNormService;
private readonly ComputeDirector computeDirector; private readonly ComputeDirector computeDirector;
private readonly BudgetService budgetService;
private readonly PerforImemployeeRepository perforImEmployeeRepository; private readonly PerforImemployeeRepository perforImEmployeeRepository;
private readonly PerforRescomputeRepository perforRescomputeRepository; private readonly PerforRescomputeRepository perforRescomputeRepository;
private readonly PerforResbaiscnormRepository perforResbaiscnormRepository; private readonly PerforResbaiscnormRepository perforResbaiscnormRepository;
...@@ -32,7 +33,7 @@ public class ResultComputeService : IAutoInjection ...@@ -32,7 +33,7 @@ public class ResultComputeService : IAutoInjection
PerforResspecialunitRepository perforResspecialunitRepository, PerforResspecialunitRepository perforResspecialunitRepository,
PerforImaccountbasicRepository perforImaccountbasicRepository, PerforImaccountbasicRepository perforImaccountbasicRepository,
BaiscNormService baiscNormService, ComputeDirector computeDirector, BaiscNormService baiscNormService, ComputeDirector computeDirector,
LogManageService logManageService, LogManageService logManageService, BudgetService budgetService,
PerforImemployeeclinicRepository perforImemployeeclinicRepository) PerforImemployeeclinicRepository perforImemployeeclinicRepository)
{ {
this.baiscNormService = baiscNormService; this.baiscNormService = baiscNormService;
...@@ -43,6 +44,7 @@ public class ResultComputeService : IAutoInjection ...@@ -43,6 +44,7 @@ public class ResultComputeService : IAutoInjection
this.perforResspecialunitRepository = perforResspecialunitRepository; this.perforResspecialunitRepository = perforResspecialunitRepository;
this.perforImaccountbasicRepository = perforImaccountbasicRepository; this.perforImaccountbasicRepository = perforImaccountbasicRepository;
this.logManageService = logManageService; this.logManageService = logManageService;
this.budgetService = budgetService;
this.perforImemployeeclinicRepository = perforImemployeeclinicRepository; this.perforImemployeeclinicRepository = perforImemployeeclinicRepository;
} }
...@@ -100,6 +102,11 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -100,6 +102,11 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
var typeList = EnumHelper.GetItems<PerforType>(); var typeList = EnumHelper.GetItems<PerforType>();
var dataList = specialUnit.PerData.Select(t => (PerDataSpecialUnit)t); var dataList = specialUnit.PerData.Select(t => (PerDataSpecialUnit)t);
var specialEmployee = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allot.ID); var specialEmployee = perforImemployeeclinicRepository.GetEntities(t => t.AllotID == allot.ID);
decimal adjust = 1m;
decimal grant = 1m;
var isBudget = budgetService.GetAdjustAndGrant(allot, ref adjust, ref grant);
//替换考核基数 //替换考核基数
foreach (var item in dataList) foreach (var item in dataList)
{ {
...@@ -161,6 +168,8 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -161,6 +168,8 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
headcount = 1; headcount = 1;
return t.Quantity * t.QuantitativeIndicatorsValue * headcount; return t.Quantity * t.QuantitativeIndicatorsValue * headcount;
}); });
var groupAdjust = isBudget ? adjust : group.Adjust;
foreach (var item in accountDataList) foreach (var item in accountDataList)
{ {
var res = new res_specialunit var res = new res_specialunit
...@@ -175,10 +184,10 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -175,10 +184,10 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
ScoringAverage = group.ScoringAverage, ScoringAverage = group.ScoringAverage,
OtherPerfor = group.OtherPerfor, OtherPerfor = group.OtherPerfor,
Punishment = group.Punishment, Punishment = group.Punishment,
Adjust = group.Adjust == 0 ? 1 : group.Adjust, Adjust = (groupAdjust == 0) ? 1 : groupAdjust,
}; };
res.GiveFee = (sumValue + (group.OtherPerfor ?? 0) + (group.Punishment ?? 0)); res.GiveFee = (sumValue + (group.OtherPerfor ?? 0) + (group.Punishment ?? 0));
res.RealGiveFee = res.GiveFee * (group.Adjust == 0 ? 1 : group.Adjust); res.RealGiveFee = res.GiveFee * (groupAdjust == 0 ? 1 : groupAdjust);
res.Avg = group.Number != 0 ? res.GiveFee / group.Number : null; res.Avg = group.Number != 0 ? res.GiveFee / group.Number : null;
res.ResultsTotalFee = sumValue; res.ResultsTotalFee = sumValue;
resDataList.Add(res); resDataList.Add(res);
...@@ -201,6 +210,8 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -201,6 +210,8 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
// Adjust = 1, // Adjust = 1,
// }; // };
//} //}
var empolyeeAdjust = isBudget ? adjust : empolyee.Adjust;
var compute = new ComputeResult var compute = new ComputeResult
{ {
UnitType = UnitType.特殊核算组.ToString(), UnitType = UnitType.特殊核算组.ToString(),
...@@ -218,14 +229,14 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno ...@@ -218,14 +229,14 @@ public void SpecialUnitCompute(PerExcel excel, per_allot allot, List<res_baiscno
Number = group.Number, Number = group.Number,
PerforTotal = sumValue, PerforTotal = sumValue,
Avg = group.Number == 0 ? 0 : (sumValue / group.Number), Avg = group.Number == 0 ? 0 : (sumValue / group.Number),
Adjust = empolyee.Adjust, Adjust = empolyeeAdjust,
Grant = empolyee.Management Grant = isBudget ? grant : empolyee.Management
}; };
compute.Efficiency = compute.Avg * (empolyee.Efficiency ?? 1); compute.Efficiency = compute.Avg * (empolyee.Efficiency ?? 1);
compute.Scale = compute.PerforTotal * (empolyee.Scale ?? 1); compute.Scale = compute.PerforTotal * (empolyee.Scale ?? 1);
//应发管理绩效 //应发管理绩效
compute.ShouldGiveFee = (compute.Efficiency + compute.Scale) * empolyee.Management; compute.ShouldGiveFee = (compute.Efficiency + compute.Scale) * compute.Grant;
//绩效合计 //绩效合计
compute.PerforSumFee = compute.Avg + compute.ShouldGiveFee; compute.PerforSumFee = compute.Avg + compute.ShouldGiveFee;
//应发绩效 //应发绩效
......
...@@ -279,26 +279,27 @@ public bool UseResult(int id) ...@@ -279,26 +279,27 @@ public bool UseResult(int id)
return perbudgetresultRepository.Update(result); return perbudgetresultRepository.Update(result);
} }
public void GetAdjust(int allotId, ref decimal adjust) public bool GetAdjustAndGrant(int allotId, ref decimal adjust, ref decimal grant)
{ {
var allot = perallotRepository.GetEntity(t => t.ID == allotId); var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) return; if (allot == null) return false;
var result = perbudgetresultRepository.GetEntity(t => t.HospitalId == allot.HospitalId && t.Year == allot.Year && t.Month == allot.Month); var result = perbudgetresultRepository.GetEntity(t => t.HospitalId == allot.HospitalId && t.Year == allot.Year && t.Month == allot.Month);
if (result == null || result.States != 2) return; if (result == null || result.States != 2) return false;
adjust = result.Adjust.Value; adjust = result.Adjust.Value;
grant = result.Grant.Value;
return true;
} }
public void GetGrant(int allotId, ref decimal grant) public bool GetAdjustAndGrant(per_allot allot, ref decimal adjust, ref decimal grant)
{ {
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) return;
var result = perbudgetresultRepository.GetEntity(t => t.HospitalId == allot.HospitalId && t.Year == allot.Year && t.Month == allot.Month); var result = perbudgetresultRepository.GetEntity(t => t.HospitalId == allot.HospitalId && t.Year == allot.Year && t.Month == allot.Month);
if (result == null || result.States != 2) return; if (result == null || result.States != 2) return false;
adjust = result.Adjust.Value;
grant = result.Grant.Value; grant = result.Grant.Value;
return true;
} }
} }
} }
...@@ -19,17 +19,20 @@ public class ComputeDirector : IAutoInjection ...@@ -19,17 +19,20 @@ public class ComputeDirector : IAutoInjection
private readonly PerforCofdirectorRepository perforCofdirectorRepository; private readonly PerforCofdirectorRepository perforCofdirectorRepository;
private readonly PerforCofworkyearRepository perforCofworkyearRepository; private readonly PerforCofworkyearRepository perforCofworkyearRepository;
private readonly PerforResaccountRepository perforResaccountRepository; private readonly PerforResaccountRepository perforResaccountRepository;
private readonly BudgetService budgetService;
//private readonly PerforResaccountdoctorRepository perforResAccountdoctorRepository; //private readonly PerforResaccountdoctorRepository perforResAccountdoctorRepository;
public ComputeDirector(BaiscNormService baiscNormService, public ComputeDirector(BaiscNormService baiscNormService,
PerforCofdirectorRepository perforCofdirectorRepository, PerforCofdirectorRepository perforCofdirectorRepository,
PerforCofworkyearRepository perforCofworkyearRepository, PerforCofworkyearRepository perforCofworkyearRepository,
PerforResaccountRepository perforResaccountRepository) PerforResaccountRepository perforResaccountRepository,
BudgetService budgetService)
{ {
this.baiscNormService = baiscNormService; this.baiscNormService = baiscNormService;
this.perforCofdirectorRepository = perforCofdirectorRepository; this.perforCofdirectorRepository = perforCofdirectorRepository;
this.perforCofworkyearRepository = perforCofworkyearRepository; this.perforCofworkyearRepository = perforCofworkyearRepository;
this.perforResaccountRepository = perforResaccountRepository; this.perforResaccountRepository = perforResaccountRepository;
this.budgetService = budgetService;
} }
#region 老版计算 #region 老版计算
...@@ -292,6 +295,10 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<im_a ...@@ -292,6 +295,10 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<im_a
} }
List<ComputeResult> computeList = new List<ComputeResult>(); List<ComputeResult> computeList = new List<ComputeResult>();
var adjust = 1m;
var grant = 1m;
var isBudget = budgetService.GetAdjustAndGrant(allot, ref adjust, ref grant);
var empDis = empolyeeList.Select(w => new { w.DoctorName, w.JobNumber }).Distinct(); var empDis = empolyeeList.Select(w => new { w.DoctorName, w.JobNumber }).Distinct();
foreach (var emp in empDis) foreach (var emp in empDis)
{ {
...@@ -338,7 +345,6 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<im_a ...@@ -338,7 +345,6 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<im_a
var efficiency = avg * (empolyee.Efficiency ?? 1); var efficiency = avg * (empolyee.Efficiency ?? 1);
var scale = resAccount.PerforTotal * (empolyee.Scale ?? 1); var scale = resAccount.PerforTotal * (empolyee.Scale ?? 1);
var compute = new ComputeResult var compute = new ComputeResult
{ {
UnitType = basicRule.UnitType.ToString(), UnitType = basicRule.UnitType.ToString(),
...@@ -359,9 +365,9 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<im_a ...@@ -359,9 +365,9 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, List<im_a
Avg = avg, Avg = avg,
Efficiency = effAvg * (empolyee.Efficiency ?? 1), Efficiency = effAvg * (empolyee.Efficiency ?? 1),
Scale = resAccount.PerforTotal * (empolyee.Scale ?? 1), Scale = resAccount.PerforTotal * (empolyee.Scale ?? 1),
Adjust = empolyee.Adjust, Adjust = isBudget ? adjust : empolyee.Adjust,
Remark = empolyees.Count() > 1 ? "特殊科室主任,共用核算单元" : "", Remark = empolyees.Count() > 1 ? "特殊科室主任,共用核算单元" : "",
Grant = empolyee.Management, Grant = isBudget ? grant : empolyee.Management,
ManagerNumber = resAccount.ManagerNumber, ManagerNumber = resAccount.ManagerNumber,
MedicalNumber = resAccount.Number, MedicalNumber = resAccount.Number,
PermanentStaff = resAccount.PermanentStaff, PermanentStaff = resAccount.PermanentStaff,
...@@ -404,16 +410,21 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot ...@@ -404,16 +410,21 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot
if (!needCompute.Any()) return computeList; if (!needCompute.Any()) return computeList;
decimal adjust = 1m;
decimal grant = 1m;
var isBudget = budgetService.GetAdjustAndGrant(allot, ref adjust, ref grant);
var perforTypeArray = EnumHelper.GetItems<PerforType>(); var perforTypeArray = EnumHelper.GetItems<PerforType>();
foreach (var item in needCompute) foreach (var item in needCompute)
{ {
var itemAdjust = isBudget ? adjust : item.Adjust;
var compute = new ComputeResult var compute = new ComputeResult
{ {
AccountType = item.AccountType, AccountType = item.AccountType,
AccountingUnit = item.AccountingUnit, AccountingUnit = item.AccountingUnit,
EmployeeName = item.DoctorName, EmployeeName = item.DoctorName,
FitPeople = item.FitPeople, FitPeople = item.FitPeople,
Grant = item.Management ?? 1, Grant = isBudget ? grant : (item.Management ?? 1),
WorkTime = item.WorkTime, WorkTime = item.WorkTime,
PostCoefficient = item.PostCoefficient, PostCoefficient = item.PostCoefficient,
Attendance = item.Attendance, Attendance = item.Attendance,
...@@ -422,7 +433,7 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot ...@@ -422,7 +433,7 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot
OtherPerfor = item.OtherPerfor, OtherPerfor = item.OtherPerfor,
JobTitle = item.JobTitle, JobTitle = item.JobTitle,
JobNumber = item.JobNumber, JobNumber = item.JobNumber,
Adjust = item.Adjust, Adjust = itemAdjust,
//Workload = item.Workload //Workload = item.Workload
}; };
...@@ -447,7 +458,7 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot ...@@ -447,7 +458,7 @@ public List<ComputeResult> Compute(List<ComputeEmployee> empolyeeList, per_allot
compute.GiveFee = compute.BaiscNormValue * compute.PostCoefficient * (compute.WorkYear ?? 1) * compute.Attendance * compute.ScoreAverageRate compute.GiveFee = compute.BaiscNormValue * compute.PostCoefficient * (compute.WorkYear ?? 1) * compute.Attendance * compute.ScoreAverageRate
+ (compute.OtherPerfor ?? 0) + (compute.Punishment ?? 0); + (compute.OtherPerfor ?? 0) + (compute.Punishment ?? 0);
//实发绩效 //实发绩效
compute.RealGiveFee = compute.GiveFee * (item.Adjust ?? 1); compute.RealGiveFee = compute.GiveFee * (itemAdjust ?? 1);
computeList.Add(compute); computeList.Add(compute);
} }
......
...@@ -21,7 +21,30 @@ public class PerSheetDataReadClinicEmployee : IPerSheetDataRead ...@@ -21,7 +21,30 @@ public class PerSheetDataReadClinicEmployee : IPerSheetDataRead
public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
List<IPerData> dataList = new List<IPerData>(); List<IPerData> dataList = new List<IPerData>();
string[] headers = new string[]
{
"核算单元分类",
"核算单元",
"核算单元",
"人员工号",
"医生姓名",
"职务分类",
"基础绩效系数",
"岗位系数",
"效率绩效系数",
"规模绩效系数",
"管理绩效发放系数",
"考核得分率",
"出勤率",
"其他绩效",
"医院奖罚",
"调节系数",
};
foreach (var item in headers)
{
if (!perHeader.Any(p => p.CellValue == item))
throw new NullReferenceException($"{sheet.SheetName}{item}列为空");
}
for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++) for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++)
{ {
var row = sheet.GetRow(r); var row = sheet.GetRow(r);
......
...@@ -24,7 +24,30 @@ public class PerSheetDataReadDeptAccounting : IPerSheetDataRead ...@@ -24,7 +24,30 @@ public class PerSheetDataReadDeptAccounting : IPerSheetDataRead
public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
List<IPerData> dataList = new List<IPerData>(); List<IPerData> dataList = new List<IPerData>();
string[] headers = new string[]
{
"核算单元类型",
"核算单元",
"科室名称",
"效率绩效人数",
"科主任/护士长人数",
"核算单元人员数量",
"预算比例",
"倾斜系数",
"工作量倾斜系数",
"保底绩效参考标准",
"保底绩效系数",
"其他绩效1",
"其他绩效2",
"医院奖罚",
"考核得分率",
"调节系数",
};
foreach (var item in headers)
{
if (!perHeader.Any(p => p.CellValue == item))
throw new NullReferenceException($"{sheet.SheetName}{item}列为空");
}
for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++) for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++)
{ {
var row = sheet.GetRow(r); var row = sheet.GetRow(r);
......
...@@ -24,7 +24,29 @@ public class PerSheetDataReadEmployee : IPerSheetDataRead ...@@ -24,7 +24,29 @@ public class PerSheetDataReadEmployee : IPerSheetDataRead
public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
List<IPerData> dataList = new List<IPerData>(); List<IPerData> dataList = new List<IPerData>();
string[] headers = new string[]
{
"核算单元",
"核算单元",
"人员工号",
"医生姓名",
"职务分类",
"绩效基数核算参考对象",
"绩效基数核算系数",
"人员分类",
"岗位系数",
"参加工作时间",
"考核得分率",
"出勤率",
"其他绩效",
"医院奖罚",
"调节系数",
};
foreach (var item in headers)
{
if (!perHeader.Any(p => p.CellValue == item))
throw new NullReferenceException($"{sheet.SheetName}{item}列为空");
}
for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++) for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++)
{ {
var row = sheet.GetRow(r); var row = sheet.GetRow(r);
......
...@@ -23,6 +23,23 @@ public class PerSheetDataReadSpecialUnit : IPerSheetDataRead ...@@ -23,6 +23,23 @@ public class PerSheetDataReadSpecialUnit : IPerSheetDataRead
public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader) public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
{ {
List<IPerData> dataList = new List<IPerData>(); List<IPerData> dataList = new List<IPerData>();
string[] headers = new string[]
{
"量化指标",
"数量",
"量化指标绩效分值",
"科室",
"人数",
"考核得分率",
"其他绩效",
"医院奖罚",
"调节系数",
};
foreach (var item in headers)
{
if (!perHeader.Any(p => p.CellValue == item))
throw new NullReferenceException($"{sheet.SheetName}{item}列为空");
}
// 特殊科室多科室聚合,合并时保留科室名称 // 特殊科室多科室聚合,合并时保留科室名称
string lastAccount = ""; string lastAccount = "";
for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++) for (int r = Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++)
......
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
...@@ -19,19 +21,31 @@ public class ReportDataService : IAutoInjection ...@@ -19,19 +21,31 @@ public class ReportDataService : IAutoInjection
private readonly PerforRepselectionRepository selectionRepository; private readonly PerforRepselectionRepository selectionRepository;
private readonly PerforRepgroupRepository groupRepository; private readonly PerforRepgroupRepository groupRepository;
private readonly PerforRepgroupselectionRepository groupselectionRepository; private readonly PerforRepgroupselectionRepository groupselectionRepository;
private readonly PerforUserroleRepository userroleRepository;
private readonly PerforRoleRepository roleRepository;
private readonly PerforUserRepository userRepository;
private readonly Application application;
public ReportDataService( public ReportDataService(
ILogger<ReportDataService> logger, ILogger<ReportDataService> logger,
PerforRepreportRepository reportRepository, PerforRepreportRepository reportRepository,
PerforRepselectionRepository selectionRepository, PerforRepselectionRepository selectionRepository,
PerforRepgroupRepository groupRepository, PerforRepgroupRepository groupRepository,
PerforRepgroupselectionRepository groupselectionRepository) PerforRepgroupselectionRepository groupselectionRepository,
PerforUserroleRepository userroleRepository,
PerforRoleRepository roleRepository,
PerforUserRepository userRepository,
IOptions<Application> application)
{ {
this.logger = logger; this.logger = logger;
this.reportRepository = reportRepository; this.reportRepository = reportRepository;
this.selectionRepository = selectionRepository; this.selectionRepository = selectionRepository;
this.groupRepository = groupRepository; this.groupRepository = groupRepository;
this.groupselectionRepository = groupselectionRepository; this.groupselectionRepository = groupselectionRepository;
this.userroleRepository = userroleRepository;
this.roleRepository = roleRepository;
this.userRepository = userRepository;
this.application = application.Value;
} }
/// <summary> /// <summary>
...@@ -39,7 +53,7 @@ public class ReportDataService : IAutoInjection ...@@ -39,7 +53,7 @@ public class ReportDataService : IAutoInjection
/// </summary> /// </summary>
/// <param name="groupId"></param> /// <param name="groupId"></param>
/// <returns></returns> /// <returns></returns>
public List<SelectionOptions> GetReportSelection(int groupId) public List<SelectionOptions> GetReportSelection(int groupId, int userId)
{ {
List<SelectionOptions> options = new List<SelectionOptions>(); List<SelectionOptions> options = new List<SelectionOptions>();
...@@ -51,6 +65,8 @@ public List<SelectionOptions> GetReportSelection(int groupId) ...@@ -51,6 +65,8 @@ public List<SelectionOptions> GetReportSelection(int groupId)
if (selections == null) if (selections == null)
return options; return options;
var isMedical = IsMedical(userId);
var dispaly = new int[] { (int)SelectionState.UsableAndNotDispaly, (int)SelectionState.NotUsableAndNotDispaly }; var dispaly = new int[] { (int)SelectionState.UsableAndNotDispaly, (int)SelectionState.NotUsableAndNotDispaly };
foreach (var item in selections.Where(t => t.State.HasValue && !dispaly.Contains(t.State.Value))) foreach (var item in selections.Where(t => t.State.HasValue && !dispaly.Contains(t.State.Value)))
{ {
...@@ -59,6 +75,10 @@ public List<SelectionOptions> GetReportSelection(int groupId) ...@@ -59,6 +75,10 @@ public List<SelectionOptions> GetReportSelection(int groupId)
// handle = new SelectionOptionDynamic(); // handle = new SelectionOptionDynamic();
SelectionOptions selection = new SelectionOptions(item); SelectionOptions selection = new SelectionOptions(item);
selection.Options = handle.GetOptions(item); selection.Options = handle.GetOptions(item);
if (isMedical)
{
selection.Options.RemoveAll(t => t.Title == "全院");
}
options.Add(selection); options.Add(selection);
} }
return options; return options;
...@@ -92,7 +112,7 @@ public object GetReportInfo(int groupId) ...@@ -92,7 +112,7 @@ public object GetReportInfo(int groupId)
/// <param name="groupId"></param> /// <param name="groupId"></param>
/// <param name="values"></param> /// <param name="values"></param>
/// <returns></returns> /// <returns></returns>
public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId, List<SelectionValues> values) public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId, List<SelectionValues> values, int userId)
{ {
var groups = groupRepository.GetEntities(w => w.GroupId == groupId); var groups = groupRepository.GetEntities(w => w.GroupId == groupId);
var arr1 = groups.Select(w => w.ReportId); var arr1 = groups.Select(w => w.ReportId);
...@@ -112,6 +132,9 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId, ...@@ -112,6 +132,9 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value)) var selections = selectionRepository.GetEntities(w => arr2.Contains(w.ID) && w.State.HasValue && dispaly.Contains(w.State.Value))
?? new List<rep_selection>(); ?? new List<rep_selection>();
var isMedical = IsMedical(userId);
var department = GetUserDepartment(userId);
List<ReportData> result = new List<ReportData>(); List<ReportData> result = new List<ReportData>();
foreach (var report in reports) foreach (var report in reports)
{ {
...@@ -125,6 +148,8 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId, ...@@ -125,6 +148,8 @@ public List<ReportData> GetReportData(int hospitalId, int groupId, int reportId,
@where = GetFilterSelection(selections, values); @where = GetFilterSelection(selections, values);
} }
@where += $" and hospitalid={hospitalId}"; @where += $" and hospitalid={hospitalId}";
if (isMedical)
@where += $" and department='{department}'";
// 固定占位符 // 固定占位符
var pairs = PredefinePlaceholder(values); var pairs = PredefinePlaceholder(values);
pairs.Add("wh", @where); pairs.Add("wh", @where);
...@@ -328,6 +353,22 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection ...@@ -328,6 +353,22 @@ private string ReplacePlaceholder(List<rep_selection> selections, List<Selection
} }
return content; return content;
} }
private bool IsMedical(int userId)
{
var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
var role = roleRepository.GetEntity(t => t.ID == userrole.RoleID);
if (role.Type == application.DirectorRole || role.Type == application.NurseRole)
return true;
else
return false;
}
private string GetUserDepartment(int userId)
{
var user = userRepository.GetEntity(t => t.ID == userId);
return user.Department;
}
} }
......
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