自定义抽取sql语句下载

parent 08a32b60
//using FluentValidation.AspNetCore; using Microsoft.AspNetCore.Mvc;
//using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging;
//using Microsoft.Extensions.Logging; using Performance.Services;
//using Microsoft.Extensions.Options;
//using Performance.DtoModels; namespace Performance.Api.Controllers
//using Performance.DtoModels.AppSettings; {
//using Performance.Infrastructure; [Route("api/[controller]")]
//using Performance.Services; public class ModExtractController : Controller
//using System; {
//using System.Collections.Generic; private readonly ILogger<ModExtractController> _logger;
//using System.Linq; private readonly CustomExtractService _service;
//using System.Threading.Tasks;
public ModExtractController(
//namespace Performance.Api.Controllers ILogger<ModExtractController> logger,
//{ CustomExtractService service)
// [Route("api/[controller]")] {
// public class ModExtractController : Controller _logger = logger;
// { _service = service;
// private readonly ILogger<ModExtractController> logger; }
// private ModExtractService modExtractService; }
// private WebapiUrl url; }
// public ModExtractController( \ No newline at end of file
// ILogger<ModExtractController> logger,
// ModExtractService modExtractService,
// IOptions<WebapiUrl> url)
// {
// this.logger = logger;
// this.modExtractService = modExtractService;
// this.url = url.Value;
// }
// /// <summary>
// /// 绩效数据抽取模板
// /// </summary>
// /// <returns></returns>
// [Route("scheme")]
// [HttpPost]
// public ApiResponse Extract([CustomizeValidator(RuleSet = "Query"), FromBody] ModModuleRequest request)
// {
// if (request.HospitalId == null || request.HospitalId.Value == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 不存在,请重新选择!");
// if (request.ExecuteType == null || !request.ExecuteType.Any())
// return new ApiResponse(ResponseType.ParameterError, "ExecuteType 不存在,请重新选择!");
// var list = modExtractService.ExtractScheme(request.HospitalId.Value, request.ExecuteType);
// return new ApiResponse(ResponseType.OK, list);
// }
// /// <summary>
// /// 费用类型
// /// </summary>
// /// <returns></returns>
// [Route("type")]
// [HttpPost]
// public ApiResponse FeeType()
// {
// var list = modExtractService.FeeType();
// return new ApiResponse(ResponseType.OK, list);
// }
// /// <summary>
// /// 绩效考核项费用来源
// /// </summary>
// /// <returns></returns>
// [Route("source")]
// [HttpPost]
// public ApiResponse FeeSource([FromBody] ModModuleRequest request)
// {
// if (request.HospitalId == null || request.HospitalId.Value == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!");
// string retJson = HttpHelper.HttpPost(url.HttpPost + "/modextract/source", JsonHelper.Serialize(request), true);
// var ret = JsonHelper.Deserialize<ApiResponse>(retJson);
// return new ApiResponse(ResponseType.OK, ret.Data);
// }
// /// <summary>
// /// 费用字典新增
// /// </summary>
// /// <returns></returns>
// [Route("addmodule")]
// [HttpPost]
// public ApiResponse AddModule([CustomizeValidator(RuleSet = "Add"), FromBody] ModModuleRequest request)
// {
// if (request.HospitalId == null || request.HospitalId.Value == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!");
// var entity = modExtractService.AddModule(request);
// return new ApiResponse(ResponseType.OK, "添加成功!", entity);
// }
// /// <summary>
// /// 费用字典(绩效模板)
// /// </summary>
// /// <returns></returns>
// [Route("modules")]
// [HttpPost]
// public ApiResponse Module([CustomizeValidator(RuleSet = "Query"), FromBody] ModModuleRequest request)
// {
// if (request.HospitalId == null || request.HospitalId.Value == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 不存在,请重新选择!");
// var list = modExtractService.Module(request.HospitalId.Value);
// return new ApiResponse(ResponseType.OK, list);
// }
// /// <summary>
// /// 绩效模板修改
// /// </summary>
// /// <returns></returns>
// [Route("editmodule")]
// [HttpPost]
// public ApiResponse EditModule([FromBody] ModModuleRequest request)
// {
// if (request.ModuleId == null || request.ModuleId == 0)
// return new ApiResponse(ResponseType.ParameterError, "ModuleId 参数错误!");
// var entity = modExtractService.EditModule(request);
// return new ApiResponse(ResponseType.OK, "修改成功!", entity);
// }
// /// <summary>
// /// 绩效模板删除
// /// </summary>
// /// <returns></returns>
// [Route("deletemodule")]
// [HttpPost]
// public ApiResponse DelModule([FromBody] ModModuleRequest request)
// {
// if (request.ModuleId == null || request.ModuleId == 0)
// return new ApiResponse(ResponseType.ParameterError, "ModuleId 参数错误!");
// modExtractService.DelModule(request.ModuleId.Value);
// return new ApiResponse(ResponseType.OK, "删除成功!");
// }
// /// <summary>
// /// 绩效收入模板配置项新增
// /// </summary>
// /// <returns></returns>
// [Route("additem")]
// [HttpPost]
// public ApiResponse AddItem([FromBody] ItemListRequest request)
// {
// if (request.ModuleId == null && request.ModuleId == 0)
// return new ApiResponse(ResponseType.ParameterError, "ModuleId 参数错误!");
// if (request.Items == null && !request.Items.Any())
// return new ApiResponse(ResponseType.ParameterError, "Items 未发现任添加何项!");
// var list = modExtractService.AddItem(request);
// return new ApiResponse(ResponseType.OK, "添加成功!", list);
// }
// /// <summary>
// /// 绩效收入模板配置项列表
// /// </summary>
// /// <returns></returns>
// [Route("items")]
// [HttpPost]
// public ApiResponse Items([FromBody] ModItemRequest request)
// {
// logger.LogInformation($"绩效收入模板配置项列表 : 请求地址 {url.HttpPost}/modextract/items");
// HttpHelper.HttpPost(url.HttpPost + "/modextract/items", JsonHelper.Serialize(request), true);
// logger.LogInformation($"绩效收入模板配置项列表在{DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss完成请求")}");
// var list = modExtractService.Items(request.ModuleId.Value);
// return new ApiResponse(ResponseType.OK, list);
// }
// /// <summary>
// /// 绩效收入模板配置项修改
// /// </summary>
// /// <returns></returns>
// [Route("edititem")]
// [HttpPost]
// public ApiResponse EditItem([FromBody] ItemListRequest request)
// {
// if (request.Items == null || !request.Items.Any())
// return new ApiResponse(ResponseType.ParameterError, "请选择需要修改的数据!");
// var entity = 0;//= modExtractService.EditItem(request.Items[0]);
// return new ApiResponse(ResponseType.OK, "修改成功!", entity);
// }
// /// <summary>
// /// 绩效收入模板配置项删除
// /// </summary>
// /// <returns></returns>
// [Route("deleteitem")]
// [HttpPost]
// public ApiResponse DelItem([FromBody] ModItemRequest request)
// {
// if (request.ItemId == null && request.ItemId == 0)
// return new ApiResponse(ResponseType.ParameterError, "ItemId 参数错误!");
// modExtractService.DelItem(request.ItemId.Value);
// return new ApiResponse(ResponseType.OK, "删除成功!");
// }
// #region 特殊科室模板
// /// <summary>
// /// 特殊科室模板配置项新增
// /// </summary>
// /// <returns></returns>
// [Route("addspecial")]
// [HttpPost]
// public ApiResponse AddSpecial([FromBody] SpecialListRequest request)
// {
// if (request.HospitalId == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!");
// if (request.Items == null && !request.Items.Any())
// return new ApiResponse(ResponseType.ParameterError, "Items 未发现任添加何项!");
// var list = modExtractService.AddSpecial(request);
// return new ApiResponse(ResponseType.OK, "添加成功!", list);
// }
// /// <summary>
// /// 特殊科室模板配置项列表
// /// </summary>
// /// <returns></returns>
// [Route("specials")]
// [HttpPost]
// public ApiResponse Specials([FromBody] ModSpecialRequest request)
// {
// var list = modExtractService.Special(request.HospitalId.Value);
// return new ApiResponse(ResponseType.OK, list);
// }
// /// <summary>
// /// 特殊科室模板配置项修改
// /// </summary>
// /// <returns></returns>
// [Route("editspecial")]
// [HttpPost]
// public ApiResponse EditSpecial([FromBody] SpecialListRequest request)
// {
// if (request.Items == null || !request.Items.Any())
// return new ApiResponse(ResponseType.ParameterError, "请选择需要修改的数据!");
// var entity = modExtractService.EditSpecial(request.Items[0]);
// return new ApiResponse(ResponseType.OK, "修改成功!", entity);
// }
// /// <summary>
// /// 特殊科室模板配置项删除
// /// </summary>
// /// <returns></returns>
// [Route("deletespecial")]
// [HttpPost]
// public ApiResponse DelSpecial([FromBody] ModSpecialRequest request)
// {
// if (request.SpecialId == null && request.SpecialId == 0)
// return new ApiResponse(ResponseType.ParameterError, "SpecialId 参数错误!");
// modExtractService.DelSpecial(request.SpecialId.Value);
// return new ApiResponse(ResponseType.OK, "删除成功!");
// }
// /// <summary>
// /// 特殊科室人均
// /// </summary>
// /// <returns></returns>
// [Route("perfortype")]
// [HttpPost]
// public ApiResponse PerforType()
// {
// var list = modExtractService.PerforType();
// return new ApiResponse(ResponseType.OK, list);
// }
// #endregion
// /// <summary>
// /// 数据配置项
// /// </summary>
// /// <returns></returns>
// [Route("config")]
// [HttpPost]
// public ApiResponse Config([FromBody] ModModuleRequest request)
// {
// if (request.HospitalId == null || request.HospitalId.Value == 0)
// return new ApiResponse(ResponseType.ParameterError, "HospitalId 不存在,请重新选择!");
// var configs = modExtractService.GetHospitalconfigs(request.HospitalId.Value);
// return new ApiResponse(ResponseType.OK, "绩效抽取数据地址!", configs);
// }
// }
//}
\ No newline at end of file
...@@ -9,7 +9,7 @@ public class WorkDetailRequest ...@@ -9,7 +9,7 @@ public class WorkDetailRequest
{ {
public int AllotId { get; set; } public int AllotId { get; set; }
public int SecondId { get; set; } public int SecondId { get; set; }
public string Source { get; set; }
public string AccountingUnit { get; set; } public string AccountingUnit { get; set; }
} }
......
...@@ -165,8 +165,7 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri ...@@ -165,8 +165,7 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri
if (connection.State != ConnectionState.Open) connection.Open(); if (connection.State != ConnectionState.Open) connection.Open();
try 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 string clear = @"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
LEFT JOIN per_employee t2 on t1.personnelnumber = t2.jobnumber AND t2.allotid = @allotid
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid WHERE t1.allotid = @allotid
AND t3.unittype = @unittype AND t3.unittype = @unittype
...@@ -187,20 +186,19 @@ public IEnumerable<report_original_workload> QueryWorkloadData(int allotid, stri ...@@ -187,20 +186,19 @@ 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 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()) 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 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 string clear = $@"SELECT DISTINCT t3.AccountingUnit as Department,ifnull(t1.DoctorName, '未知') DoctorName,t1.PersonnelNumber,t1.Category,t1.Fee FROM ex_result t1
LEFT JOIN per_employee t2 on t1.personnelnumber = t2.jobnumber AND t2.allotid = @allotid
JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName JOIN (select distinct AccountingUnit,HISDeptName,unittype from per_dept_dic where HospitalId = @hospitalid) t3 ON t1.Department = t3.HISDeptName
WHERE t1.allotid = @allotid WHERE t1.allotid = @allotid
AND t3.unittype = @unittype AND t3.unittype = @unittype
AND t3.accountingunit = @accountingunit AND t3.accountingunit = @accountingunit
AND t1.Source like '%门诊开单%' AND t1.Source like '%{source}开单%'
AND T1.IsDelete = 0 AND T1.IsDelete = 0
ORDER BY t1.doctorname,t1.Category;"; ORDER BY t1.doctorname,t1.Category;";
return connection.Query<ex_result>(clear, new { allotid, accountingunit, unittype, hospitalid }, commandTimeout: 60 * 60); 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) ...@@ -532,8 +532,11 @@ public object DeptIncomeDetail(WorkDetailRequest request, int userId)
var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId); var allot = perallotRepository.GetEntity(w => w.ID == request.AllotId);
if (allot == null) if (allot == null)
return 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()) 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