科室二次收入工作量

parent 66b19ddc
...@@ -8,6 +8,7 @@ namespace Performance.DtoModels ...@@ -8,6 +8,7 @@ namespace Performance.DtoModels
public class WorkDetailRequest public class WorkDetailRequest
{ {
public int AllotId { get; set; } public int AllotId { get; set; }
public int SecondId { get; set; }
public string AccountingUnit { get; set; } public string AccountingUnit { get; set; }
} }
...@@ -19,6 +20,7 @@ public WorkDetailRequestValidator() ...@@ -19,6 +20,7 @@ public WorkDetailRequestValidator()
RuleSet("Select", () => RuleSet("Select", () =>
{ {
RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0); RuleFor(x => x.AllotId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.SecondId).NotNull().NotEmpty().GreaterThan(0);
RuleFor(x => x.AccountingUnit).NotNull().NotEmpty(); RuleFor(x => x.AccountingUnit).NotNull().NotEmpty();
}); });
} }
......
...@@ -158,14 +158,23 @@ public void ImportWorkloadData(per_allot allot, object parameters) ...@@ -158,14 +158,23 @@ public void ImportWorkloadData(per_allot allot, object parameters)
/// 查询工作量数据 /// 查询工作量数据
/// </summary> /// </summary>
/// <param name="allotid"></param> /// <param name="allotid"></param>
public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, string accountingunit, string[] unittype) public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, string accountingunit, string unittype)
{ {
using (var connection = context.Database.GetDbConnection()) using (var connection = context.Database.GetDbConnection())
{ {
if (connection.State != ConnectionState.Open) connection.Open(); if (connection.State != ConnectionState.Open) connection.Open();
try try
{ {
string clear = "select t1.* from report_original_workload t1 join per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber where t1.allotid = @allotid and t2.allotid = @allotid and t1.accountingunit = @accountingunit and t2.unittype in @unittype order by fee desc,convert(t1.doctorname using gbk);"; string clear = @"SELECT t3.AccountingUnit as Department,t1.DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = 45) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t2.allotid = @allotid
AND t3.unittype = @unittype
AND t3.accountingunit = @accountingunit
AND t1.Source LIKE CONCAT('%',@unittype,'工作量%')
AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;";
return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittype }, commandTimeout: 60 * 60); return connection.Query<report_original_workload>(clear, new { allotid, accountingunit, unittype }, commandTimeout: 60 * 60);
} }
catch (Exception ex) catch (Exception ex)
...@@ -179,28 +188,24 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri ...@@ -179,28 +188,24 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
/// 查询门诊收入数据 /// 查询门诊收入数据
/// </summary> /// </summary>
/// <param name="allotid"></param> /// <param name="allotid"></param>
public IEnumerable<ex_result> QueryIncomeData(int hospitalId, int allotid, string accountingunit, string[] unittype) public IEnumerable<ex_result> QueryIncomeData(int allotid, string accountingunit, string unittype)
{ {
using (var connection = context.Database.GetDbConnection()) using (var connection = context.Database.GetDbConnection())
{ {
if (connection.State != ConnectionState.Open) connection.Open(); if (connection.State != ConnectionState.Open) connection.Open();
try try
{ {
string clear = @"SELECT t3.AccountingUnit Department,t1.DoctorName,t1.PersonnelNumber,t1.Category,ifnull(t1.Fee,0) Fee string clear = @"SELECT t3.AccountingUnit as Department,t1.DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
FROM
ex_result t1
JOIN per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber JOIN per_employee t2 on t1.doctorname = t2.doctorname and t1.personnelnumber = t2.personnelnumber
JOIN per_dept_dic t3 ON t1.Department = t3.Department JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = 45) t3 ON t1.Department = t3.HISDeptName
WHERE WHERE t1.allotid = @allotid
t1.allotid = @allotid AND t2.allotid = @allotid
AND t3.HospitalId = @hospitalId AND t3.unittype = @unittype
AND t3.Source = '门诊'
AND t3.accountingunit = @accountingunit AND t3.accountingunit = @accountingunit
AND t1.Source like '%门诊开单%' AND t1.Source like '%门诊开单%'
AND t2.unittype in @unittype AND T1.IsDelete = 0
AND t2.allotid = @allotid ORDER BY t1.doctorname,t1.Category;";
ORDER BY fee DESC,CONVERT ( t1.doctorname USING gbk );"; return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype }, commandTimeout: 60 * 60);
return connection.Query<ex_result>(clear, new { hospitalId, allotid, accountingunit, unittype }, commandTimeout: 60 * 60);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -24,6 +24,7 @@ public class PersonService : IAutoInjection ...@@ -24,6 +24,7 @@ public class PersonService : IAutoInjection
private readonly PerforUserRepository perforUserRepository; private readonly PerforUserRepository perforUserRepository;
private readonly PerforUserroleRepository perforUserroleRepository; private readonly PerforUserroleRepository perforUserroleRepository;
private readonly PerforRoleRepository perforRoleRepository; private readonly PerforRoleRepository perforRoleRepository;
private readonly PerforAgsecondallotRepository agsecondallotRepository;
private readonly Application application; private readonly Application application;
private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)> private readonly Dictionary<string, (string, string)> dict = new Dictionary<string, (string, string)>
{ {
...@@ -44,6 +45,7 @@ public class PersonService : IAutoInjection ...@@ -44,6 +45,7 @@ public class PersonService : IAutoInjection
PerforUserRepository perforUserRepository, PerforUserRepository perforUserRepository,
PerforUserroleRepository perforUserroleRepository, PerforUserroleRepository perforUserroleRepository,
PerforRoleRepository perforRoleRepository, PerforRoleRepository perforRoleRepository,
PerforAgsecondallotRepository agsecondallotRepository,
IOptions<Application> application) IOptions<Application> application)
{ {
this.logger = logger; this.logger = logger;
...@@ -53,6 +55,7 @@ public class PersonService : IAutoInjection ...@@ -53,6 +55,7 @@ public class PersonService : IAutoInjection
this.perforUserRepository = perforUserRepository; this.perforUserRepository = perforUserRepository;
this.perforUserroleRepository = perforUserroleRepository; this.perforUserroleRepository = perforUserroleRepository;
this.perforRoleRepository = perforRoleRepository; this.perforRoleRepository = perforRoleRepository;
this.agsecondallotRepository = agsecondallotRepository;
this.application = application.Value; this.application = application.Value;
} }
...@@ -490,8 +493,11 @@ public List<TitleValue> DeptDics(int hospitalId, int type) ...@@ -490,8 +493,11 @@ public List<TitleValue> DeptDics(int hospitalId, int type)
/// <returns></returns> /// <returns></returns>
public object DeptWorkloadDetail(WorkDetailRequest request, int userId) public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
{ {
var (dept, unittype) = GetDeptByUser(userId); var second = agsecondallotRepository.GetEntity(w => w.Id == request.SecondId);
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, unittype); if (second == null)
return null;
var data = perallotRepository.QueryWorkloadData(request.AllotId, request.AccountingUnit, second.UnitType);
if (data != null && data.Any()) if (data != null && data.Any())
{ {
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }) return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
...@@ -515,12 +521,11 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId) ...@@ -515,12 +521,11 @@ public object DeptWorkloadDetail(WorkDetailRequest request, int userId)
/// <returns></returns> /// <returns></returns>
public object DeptIncomeDetail(WorkDetailRequest request, int userId) public object DeptIncomeDetail(WorkDetailRequest request, int userId)
{ {
var (dept, unittype) = GetDeptByUser(userId); var second = agsecondallotRepository.GetEntity(w => w.Id == request.SecondId);
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); if (second == null)
if (allot == null)
return null; return null;
var data = perallotRepository.QueryIncomeData(allot.HospitalId, request.AllotId, request.AccountingUnit, unittype); var data = perallotRepository.QueryIncomeData(request.AllotId, request.AccountingUnit, second.UnitType);
if (data != null && data.Any()) if (data != null && data.Any())
{ {
return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category }) return data.GroupBy(t => new { t.Department, t.DoctorName, t.PersonnelNumber, t.Category })
......
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