Commit a81b9382 by lcx

抽取数据前检查科室、收费类型是否缺失,配置成本收入抽取项时根据sheettype返回相应的数据

parent b4ee3f44
...@@ -44,7 +44,7 @@ public ApiResponse Extract([CustomizeValidator(RuleSet = "Query"), FromBody] Mod ...@@ -44,7 +44,7 @@ public ApiResponse Extract([CustomizeValidator(RuleSet = "Query"), FromBody] Mod
if (request.ExecuteType == null || !request.ExecuteType.Any()) if (request.ExecuteType == null || !request.ExecuteType.Any())
return new ApiResponse(ResponseType.ParameterError, "ExecuteType 不存在,请重新选择!"); return new ApiResponse(ResponseType.ParameterError, "ExecuteType 不存在,请重新选择!");
var list = configService.ExtractScheme(request.HospitalId.Value, request.ExecuteType); var list = configService.ExtractScheme(request.HospitalId.Value, request.ExecuteType, request.SheetType);
return new ApiResponse(ResponseType.OK, list); return new ApiResponse(ResponseType.OK, list);
} }
......
...@@ -31,9 +31,8 @@ public class TemplateController : Controller ...@@ -31,9 +31,8 @@ public class TemplateController : Controller
private readonly WebapiUrl url; private readonly WebapiUrl url;
private readonly Application application; private readonly Application application;
private readonly TemplateService templateService; private readonly TemplateService templateService;
private readonly DFExtractService extractService;
private readonly ExtractIncomeService extractIncomeService; private readonly ExtractIncomeService extractIncomeService;
private readonly ExtractService extractEService; private readonly ExConfigService configService;
private readonly HospitalService hospitalService; private readonly HospitalService hospitalService;
private readonly AllotService allotService; private readonly AllotService allotService;
private readonly LogManageService logService; private readonly LogManageService logService;
...@@ -46,9 +45,8 @@ public class TemplateController : Controller ...@@ -46,9 +45,8 @@ public class TemplateController : Controller
IOptions<WebapiUrl> url, IOptions<WebapiUrl> url,
IOptions<Application> options, IOptions<Application> options,
TemplateService templateService, TemplateService templateService,
DFExtractService extractService,
ExtractIncomeService extractIncomeService, ExtractIncomeService extractIncomeService,
ExtractService extractEService, ExConfigService configService,
HospitalService hospitalService, HospitalService hospitalService,
AllotService allotService, AllotService allotService,
LogManageService logService, LogManageService logService,
...@@ -60,9 +58,8 @@ public class TemplateController : Controller ...@@ -60,9 +58,8 @@ public class TemplateController : Controller
this.url = url.Value; this.url = url.Value;
this.application = options.Value; this.application = options.Value;
this.templateService = templateService; this.templateService = templateService;
this.extractService = extractService;
this.extractIncomeService = extractIncomeService; this.extractIncomeService = extractIncomeService;
this.extractEService = extractEService; this.configService = configService;
this.hospitalService = hospitalService; this.hospitalService = hospitalService;
this.allotService = allotService; this.allotService = allotService;
this.logService = logService; this.logService = logService;
...@@ -184,7 +181,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest ...@@ -184,7 +181,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
try try
{ {
bool isSingle = false; bool isSingle = false;
string message = extractService.Judge(request.AllotId, request.HospitalId, request.UseScheme, ref isSingle, out string filePath); string message = configService.Judge(request.AllotId, request.HospitalId, request.UseScheme, ref isSingle, out string filePath);
if (!string.IsNullOrEmpty(message)) if (!string.IsNullOrEmpty(message))
return new ApiResponse(ResponseType.Fail, message); return new ApiResponse(ResponseType.Fail, message);
......
...@@ -180,11 +180,11 @@ ...@@ -180,11 +180,11 @@
<summary> 日期 </summary> <summary> 日期 </summary>
</member> </member>
<member name="M:Performance.DtoModels.HandsonTable.SetRowData(System.Collections.Generic.IEnumerable{Performance.DtoModels.HandsonRowData},System.Boolean)"> <member name="M:Performance.DtoModels.HandsonTable.SetRowData(System.Collections.Generic.IEnumerable{Performance.DtoModels.HandsonRowData},System.Boolean)">
<summary> <summary>
</summary> </summary>
<param name="datas"></param> <param name="datas"></param>
<param name="isTypein">是否是用户录入的 是:true 不是:false</param> <param name="isTypein">是否是用户录入的 是:true 不是:false</param>
</member> </member>
<member name="P:Performance.DtoModels.HistoryData.Year"> <member name="P:Performance.DtoModels.HistoryData.Year">
<summary> <summary>
......
...@@ -16,6 +16,7 @@ public class ModExtractController : Controller ...@@ -16,6 +16,7 @@ public class ModExtractController : Controller
{ {
private readonly ILogger<ModExtractController> logger; private readonly ILogger<ModExtractController> logger;
private ExConfigService service; private ExConfigService service;
public ModExtractController( public ModExtractController(
ILogger<ModExtractController> logger, ILogger<ModExtractController> logger,
ExConfigService service) ExConfigService service)
...@@ -24,34 +25,38 @@ public class ModExtractController : Controller ...@@ -24,34 +25,38 @@ public class ModExtractController : Controller
this.service = service; this.service = service;
} }
/// <summary> #region 弃用
/// 绩效数据抽取模板
/// </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 = service.ExtractScheme(request.HospitalId.Value, request.ExecuteType); ///// <summary>
return new ApiResponse(ResponseType.OK, list); ///// 绩效数据抽取模板
} ///// </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 不存在,请重新选择!");
/// <summary> // var list = service.ExtractScheme(request.HospitalId.Value, request.ExecuteType);
/// 费用类型 // return new ApiResponse(ResponseType.OK, list);
/// </summary> //}
/// <returns></returns>
[Route("type")] ///// <summary>
[HttpPost] ///// 费用类型
public ApiResponse FeeType() ///// </summary>
{ ///// <returns></returns>
var list = service.FeeType(); //[Route("type")]
return new ApiResponse(ResponseType.OK, list); //[HttpPost]
} //public ApiResponse FeeType()
//{
// var list = service.FeeType();
// return new ApiResponse(ResponseType.OK, list);
//}
#endregion 弃用
/// <summary> /// <summary>
/// 绩效考核项费用来源 /// 绩效考核项费用来源
...@@ -59,7 +64,7 @@ public ApiResponse FeeType() ...@@ -59,7 +64,7 @@ public ApiResponse FeeType()
/// <returns></returns> /// <returns></returns>
[Route("source")] [Route("source")]
[HttpPost] [HttpPost]
public ApiResponse FeeSource([FromBody]ModModuleRequest request) public ApiResponse FeeSource([FromBody] ModModuleRequest request)
{ {
if (request.HospitalId == null || request.HospitalId.Value == 0) if (request.HospitalId == null || request.HospitalId.Value == 0)
return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!"); return new ApiResponse(ResponseType.ParameterError, "HospitalId 参数错误!");
...@@ -75,11 +80,11 @@ public ApiResponse FeeSource([FromBody]ModModuleRequest request) ...@@ -75,11 +80,11 @@ public ApiResponse FeeSource([FromBody]ModModuleRequest request)
/// <returns></returns> /// <returns></returns>
[Route("items")] [Route("items")]
[HttpPost] [HttpPost]
public ApiResponse Items([FromBody]ModItemRequest request) public ApiResponse Items([FromBody] ModItemRequest request)
{ {
logger.LogInformation($"绩效收入模板配置项列表:{JsonHelper.Serialize(request)}"); logger.LogInformation($"绩效收入模板配置项列表:{JsonHelper.Serialize(request)}");
service.AddItems(request.ModuleId.Value); service.AddItems(request.ModuleId.Value);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
} }
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using Performance.Services.ExtractExcelService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
...@@ -22,10 +23,13 @@ public class ExConfigService : IAutoInjection ...@@ -22,10 +23,13 @@ public class ExConfigService : IAutoInjection
private readonly PerforExitemRepository exitemRepository; private readonly PerforExitemRepository exitemRepository;
private readonly PerforExspecialRepository exspecialRepository; private readonly PerforExspecialRepository exspecialRepository;
private readonly PerforPerallotRepository perallotRepository; private readonly PerforPerallotRepository perallotRepository;
private readonly PerforPersheetRepository persheetRepository;
private readonly PerforImdataRepository imdataRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository; private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforHospitalRepository hospitalRepository; private readonly PerforHospitalRepository hospitalRepository;
private readonly PerforExtractRepository extractRepository; private readonly PerforExtractRepository extractRepository;
private readonly PerforModdicRepository moddicRepository; private readonly PerforModdicRepository moddicRepository;
private readonly QueryService queryService;
private readonly ILogger logger; private readonly ILogger logger;
public ExConfigService(PerforExtypeRepository extypeRepository, public ExConfigService(PerforExtypeRepository extypeRepository,
...@@ -34,11 +38,15 @@ public class ExConfigService : IAutoInjection ...@@ -34,11 +38,15 @@ public class ExConfigService : IAutoInjection
PerforExitemRepository exitemRepository, PerforExitemRepository exitemRepository,
PerforExspecialRepository exspecialRepository, PerforExspecialRepository exspecialRepository,
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
PerforPersheetRepository persheetRepository,
PerforImdataRepository imdataRepository,
PerforHospitalconfigRepository hospitalconfigRepository, PerforHospitalconfigRepository hospitalconfigRepository,
PerforHospitalRepository hospitalRepository, PerforHospitalRepository hospitalRepository,
PerforExtractRepository extractRepository, PerforExtractRepository extractRepository,
PerforModdicRepository moddicRepository, PerforModdicRepository moddicRepository,
ILogger<ExConfigService> logger) QueryService queryService,
ILogger<ExConfigService> logger
)
{ {
this.extypeRepository = extypeRepository; this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository; this.exscriptRepository = exscriptRepository;
...@@ -46,10 +54,13 @@ public class ExConfigService : IAutoInjection ...@@ -46,10 +54,13 @@ public class ExConfigService : IAutoInjection
this.exitemRepository = exitemRepository; this.exitemRepository = exitemRepository;
this.exspecialRepository = exspecialRepository; this.exspecialRepository = exspecialRepository;
this.perallotRepository = perallotRepository; this.perallotRepository = perallotRepository;
this.persheetRepository = persheetRepository;
this.imdataRepository = imdataRepository;
this.hospitalconfigRepository = hospitalconfigRepository; this.hospitalconfigRepository = hospitalconfigRepository;
this.hospitalRepository = hospitalRepository; this.hospitalRepository = hospitalRepository;
this.extractRepository = extractRepository; this.extractRepository = extractRepository;
this.moddicRepository = moddicRepository; this.moddicRepository = moddicRepository;
this.queryService = queryService;
this.logger = logger; this.logger = logger;
} }
...@@ -476,12 +487,14 @@ public List<sys_hospitalconfig> GetHospitalconfigs(int hospitalId) ...@@ -476,12 +487,14 @@ public List<sys_hospitalconfig> GetHospitalconfigs(int hospitalId)
/// 绩效数据抽取模板 /// 绩效数据抽取模板
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType) public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType, int? sheetType)
{ {
var titlevalue = new List<TitleValue>(); var titlevalue = new List<TitleValue>();
Expression<Func<ex_type, bool>> exp = t => new List<int> { 0, hospitalId }.Contains(t.HospitalId); Expression<Func<ex_type, bool>> exp = t => new List<int> { 0, hospitalId }.Contains(t.HospitalId);
if (executeType.FirstOrDefault() == 1) if (executeType.FirstOrDefault() == 1)
exp = exp.And(t => t.Source == (int)SheetType.Income); exp = exp.And(t => t.Source == (int)SheetType.Income);
else if (sheetType != null && !new int[] { 0, (int)SheetType.Income }.Contains(sheetType.Value))
exp = exp.And(t => t.Source == sheetType);
else else
exp = exp.And(t => t.Source != (int)SheetType.Income); exp = exp.And(t => t.Source != (int)SheetType.Income);
...@@ -513,7 +526,15 @@ public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType) ...@@ -513,7 +526,15 @@ public List<TitleValue> ExtractScheme(int hospitalId, List<int> executeType)
public List<TitleValue> FeeType() public List<TitleValue> FeeType()
{ {
var titlevalue = new List<TitleValue>(); var titlevalue = new List<TitleValue>();
var type = EnumHelper.GetItems<SheetType>().Where(t => new List<int> { (int)SheetType.Income, (int)SheetType.OtherIncome, (int)SheetType.Expend, (int)SheetType.Workload, (int)SheetType.SpecialUnit, (int)SheetType.OtherWorkload }.Contains(t.Value)); var type = EnumHelper.GetItems<SheetType>().Where(t => new List<int>
{
(int)SheetType.Income,
(int)SheetType.OtherIncome,
(int)SheetType.Expend,
(int)SheetType.Workload,
(int)SheetType.SpecialUnit,
(int)SheetType.OtherWorkload
}.Contains(t.Value));
if (type != null && type.Any()) if (type != null && type.Any())
{ {
titlevalue = type.Select(t => new TitleValue titlevalue = type.Select(t => new TitleValue
...@@ -571,5 +592,107 @@ public ModFeeResponse FeeSource(ModModuleRequest request) ...@@ -571,5 +592,107 @@ public ModFeeResponse FeeSource(ModModuleRequest request)
return new ModFeeResponse(); return new ModFeeResponse();
} }
#region 配置校验
/// <summary>
/// 配置校验
/// </summary>
/// <param name="allotId"></param>
/// <param name="hospitalId"></param>
/// <param name="useTemplate"></param>
public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSingle, out string filePath)
{
string result = null;
filePath = "";
try
{
// 获取绩效信息
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null)
throw new PerformanceException("AllotID错误");
// 获取医院信息
var hospital = hospitalRepository.GetEntity(t => t.ID == hospitalId);
if (hospital == null)
throw new PerformanceException("医院ID错误");
isSingle = (hospital.IsSingleProject ?? 2) == 1;
// 获取医院配置信息
var hospitalConfigList = hospitalconfigRepository.GetEntities(t => t.HospitalId == hospitalId);
if (hospitalConfigList == null || hospitalConfigList.Count == 0)
throw new PerformanceException("当前医院暂不支持HIS数据抽取");
// 获取最近一次绩效
var statesArray = new int[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive };
var allotList = perallotRepository.GetEntities(t => t.HospitalId == hospitalId && statesArray.Contains(t.States));
var allotLast = allotList?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
if (allotLast != null)
filePath = allotLast.Path;
// 获取当前医院模版信息
var modulesList = exmoduleRepository.GetEntities(t => t.HospitalId == hospitalId);
if (modulesList == null || modulesList.Count == 0)
throw new PerformanceException("当前医院还未配置模版");
// 获取模板项
var moduleIdList = modulesList.Select(t => t.Id).ToList();
var itemsList = exitemRepository.GetEntities(t => t.ModuleId.HasValue && moduleIdList.Contains(t.ModuleId.Value));
if (itemsList == null || itemsList.Count == 0)
throw new PerformanceException("当前医院还未配置模版项");
// 获取当前模板所有相关抽取SQL语句
var extypeIds = itemsList.Select(t => t.TypeId).Union(modulesList.Select(t => t.TypeId)).Distinct().ToList();
var extractList = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
if (extractList == null || extractList.Count == 0)
throw new PerformanceException("当前医院配置模板无需抽取");
}
catch (PerformanceException ex)
{
logger.LogError($"提取绩效数据异常 {ex.ToString()}");
result = ex.Message;
}
catch (Exception ex)
{
logger.LogError($"提取绩效数据异常 {ex.ToString()}");
throw new Exception(ex.Message);
}
return result;
}
#endregion 配置校验
#region 检查是否有新增的科室或费用类别
public void CheckHasNewDepartmentOrCategory(int allotId)
{
var allot = perallotRepository.GetEntity(t => t.ID == allotId);
var allotList = perallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId && new int[] { (int)AllotStates.GenerateSucceed, (int)AllotStates.Archive }.Contains(t.States));
var prevAllot = allotList?.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).First();
if (prevAllot != null) return;
var modDics = moddicRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Type == "checksql");
if (modDics == null || !modDics.Any()) return;
var hospitalconfigs = hospitalconfigRepository.GetEntities(t => modDics.Select(s => s.ConfigId).Distinct().Contains(t.Id));
if (hospitalconfigs == null || !hospitalconfigs.Any()) return;
var sheets = persheetRepository.GetEntities(t => t.AllotID == prevAllot.ID && t.SheetType == (int)SheetType.Income);
var importdata = imdataRepository.GetEntities(t => sheets.Select(s => s.ID).Contains(t.SheetID.Value));
Dictionary<string, object> paramtemers = new Dictionary<string, object>();
foreach (var dic in modDics)
{
if (paramtemers.ContainsKey(dic.Remark)) continue;
var config = hospitalconfigs.FirstOrDefault(t => t.Id == dic.ConfigId);
if (config == null) continue;
var data = queryService.QueryData(config, allot, dic.Content);
if (data == null || !data.Any()) continue;
var sheet = sheets.FirstOrDefault(t => t.SheetName.Contains(dic.Remark));
if (sheet == null) continue;
var sheetdata = importdata.Where(t => t.SheetID == sheet.ID)?.ToList() ?? new List<im_data>();
}
}
#endregion 检查是否有新增的科室或费用类别
} }
} }
...@@ -367,7 +367,7 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo ...@@ -367,7 +367,7 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo
/// <param name="source"></param> /// <param name="source"></param>
/// <param name="category"></param> /// <param name="category"></param>
/// <returns></returns> /// <returns></returns>
private IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot allot, string execsql) public IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot allot, string execsql)
{ {
var parameters = GetParameters(allot); var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword)) using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
......
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