自定义抽取sql语句下载

parent 08a32b60
......@@ -9,7 +9,7 @@ public class WorkDetailRequest
{
public int AllotId { get; set; }
public int SecondId { get; set; }
public string Source { get; set; }
public string AccountingUnit { get; set; }
}
......
......@@ -165,8 +165,7 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,if(ifnull(t2.PersonnelNumber,'')='', ifnull(t2.JobNumber,ifnull(t1.DoctorName, '未知')), t2.PersonnelNumber) PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
LEFT JOIN per_employee t2 on t1.personnelnumber = t2.jobnumber AND t2.allotid = @allotid
string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t3.unittype = @unittype
......@@ -187,20 +186,19 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
/// 查询门诊收入数据
/// </summary>
/// <param name="allotid"></param>
public IEnumerable<ex_result> QueryIncomeData(int allotid, string accountingunit, string unittype, int hospitalid)
public IEnumerable<ex_result> QueryIncomeData(int allotid, string source, string accountingunit, string unittype, int hospitalid)
{
using (var connection = context.Database.GetDbConnection())
{
if (connection.State != ConnectionState.Open) connection.Open();
try
{
string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,if(ifnull(t2.PersonnelNumber,'')='',ifnull(t2.JobNumber,ifnull(t1.DoctorName, '未知')), t2.PersonnelNumber) PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
LEFT JOIN per_employee t2 on t1.personnelnumber = t2.jobnumber AND t2.allotid = @allotid
string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid
AND t3.unittype = @unittype
AND t3.accountingunit = @accountingunit
AND t1.Source like '%门诊开单%'
AND t1.Source like '%{source}开单%'
AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;";
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60);
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Services
{
public class CustomExtractService : IAutoInjection
{
}
}
......@@ -532,8 +532,11 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null)
return null;
var sources = new[] { "门诊", "住院" };
if (!sources.Contains(request.Source))
throw new PerformanceException($"数据来源错误,只支持:{string.Join(";", sources)}");
var data = perallotRepository.QueryIncomeData(request.AllotId, request.AccountingUnit, second.UnitType, allot.HospitalId);
var data = perallotRepository.QueryIncomeData(request.AllotId, request.Source, request.AccountingUnit, second.UnitType, allot.HospitalId);
if (data != null && data.Any())
{
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