Commit ffd4feff by lcx

抽取人员字典

parent 9e183ed8
......@@ -185,6 +185,12 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
if (!string.IsNullOrEmpty(message))
return new ApiResponse(ResponseType.Fail, message);
if (!string.IsNullOrEmpty(filePath))
{
var data = configService.CheckHasNewDepartmentOrCategory(request.AllotId);
return new ApiResponse(ResponseType.Fail, message);
}
//检验科室、费用类型是否需要补充
allot.IsExtracting = allot.IsExtracting ?? 0;
......
......@@ -664,7 +664,7 @@ public string Judge(int allotId, int hospitalId, int useTemplate, ref bool isSin
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 null;
if (prevAllot == null) return null;
var modDics = moddicRepository.GetEntities(t => t.HospitalId == allot.HospitalId && t.Type == "checksql");
if (modDics == null || !modDics.Any()) return null;
......
......@@ -14,6 +14,8 @@ namespace Performance.Services.ExtractExcelService
public class DictionaryService : IAutoInjection
{
private readonly ILogger<DictionaryService> logger;
private readonly QueryService queryService;
private readonly LogManageService logService;
private readonly PerforPeremployeeRepository peremployeeRepository;
private readonly PerforHospitalconfigRepository hospitalconfigRepository;
private readonly PerforExtypeRepository extypeRepository;
......@@ -21,6 +23,8 @@ public class DictionaryService : IAutoInjection
public DictionaryService(
ILogger<DictionaryService> logger,
QueryService queryService,
LogManageService logService,
PerforPeremployeeRepository peremployeeRepository,
PerforHospitalconfigRepository hospitalconfigRepository,
PerforExtypeRepository extypeRepository,
......@@ -28,13 +32,15 @@ PerforExscriptRepository exscriptRepository
)
{
this.logger = logger;
this.queryService = queryService;
this.logService = logService;
this.peremployeeRepository = peremployeeRepository;
this.hospitalconfigRepository = hospitalconfigRepository;
this.extypeRepository = extypeRepository;
this.exscriptRepository = exscriptRepository;
}
public void Handle(int hospitalId, per_allot allot)
public void Handler(int hospitalId, per_allot allot, string groupName, bool isSingle)
{
try
{
......@@ -44,6 +50,7 @@ public void Handle(int hospitalId, per_allot allot)
var types = extypeRepository.GetEntities(t => t.HospitalId == hospitalId && new int[] { 2 }.Contains(t.Source));
if (types == null || !types.Any()) return;
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"提取人员信息数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => types.Select(s => s.Id).Contains(t.TypeId) && t.IsEnable == 1);
if (scripts != null && scripts.Any())
{
......@@ -69,7 +76,7 @@ private void Employee(per_allot allot, sys_hospitalconfig config, string sql)
{
if (config == null || string.IsNullOrEmpty(sql)) return;
var data = QueryData<per_employee>(config, allot, sql);
var data = queryService.QueryData<per_employee>(config, allot, sql);
if (data == null || !data.Any()) return;
var employees = peremployeeRepository.GetEntities(t => t.AllotId == allot.ID);
......@@ -77,7 +84,7 @@ private void Employee(per_allot allot, sys_hospitalconfig config, string sql)
{
peremployeeRepository.RemoveRange(employees.ToArray());
}
employees.AddRange(data);
peremployeeRepository.AddRange(data.ToArray());
}
catch (Exception ex)
{
......@@ -88,53 +95,5 @@ private void Employee(per_allot allot, sys_hospitalconfig config, string sql)
private void Department()
{
}
#region QueryData
/// <summary>
/// 查询数据
/// </summary>
/// <param name="config"></param>
/// <param name="allot"></param>
/// <param name="execsql"></param>
/// <param name="source"></param>
/// <param name="category"></param>
/// <returns></returns>
private IEnumerable<T> QueryData<T>(sys_hospitalconfig config, per_allot allot, string execsql)
{
var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
{
foreach (var item in parameters)
{
execsql = Regex.Replace(execsql, item.Key, item.Value, RegexOptions.IgnoreCase);
}
logger.LogInformation($"提取绩效数据SQL脚本{execsql}");
var result = connection.Query<T>(execsql, commandTimeout: 20000);
logger.LogInformation($"提取绩效数据执行脚本获取数据{result?.Count() ?? 0}条记录");
return result;
}
}
/// <summary>
/// 获取参数
/// </summary>
/// <param name="allot"></param>
/// <returns></returns>
private Dictionary<string, string> GetParameters(per_allot allot)
{
DateTime beginTime = new DateTime(allot.Year, allot.Month, 1);
Dictionary<string, string> pairs = new Dictionary<string, string>
{
{ "@beginTime", $"'{beginTime.ToString("yyyy-MM-dd")}'" },
{ "@endTime", $"'{beginTime.AddMonths(1).ToString("yyyy-MM-dd")}'"},
};
return pairs;
}
#endregion QueryData
}
}
......@@ -18,7 +18,7 @@ public class ExtractService : IAutoInjection
private readonly QueryService queryService;
private readonly PersonService personService;
private readonly PerSheetService perSheetService;
private readonly PerforHospitalRepository hospitalRepository;
private readonly DictionaryService dictionaryService;
private readonly PerforPerallotRepository perallotRepository;
private readonly PerforcollectdataRepository collectdataRepository;
private readonly PerforPeremployeeRepository peremployeeRepository;
......@@ -29,7 +29,7 @@ public class ExtractService : IAutoInjection
QueryService queryService,
PersonService personService,
PerSheetService perSheetService,
PerforHospitalRepository hospitalRepository,
DictionaryService dictionaryService,
PerforPerallotRepository perallotRepository,
PerforcollectdataRepository collectdataRepository,
PerforPeremployeeRepository peremployeeRepository
......@@ -40,7 +40,7 @@ PerforPeremployeeRepository peremployeeRepository
this.queryService = queryService;
this.personService = personService;
this.perSheetService = perSheetService;
this.hospitalRepository = hospitalRepository;
this.dictionaryService = dictionaryService;
this.perallotRepository = perallotRepository;
this.collectdataRepository = collectdataRepository;
this.peremployeeRepository = peremployeeRepository;
......@@ -73,6 +73,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
var dict = new Dictionary<ExDataDict, object>();
logService.ReturnTheLog(allotId, groupName, 3, "", 5, 1, isSingle);
dictionaryService.Handler(hospitalId, allot, groupName, isSingle);
var data = queryService.Handler(hospitalId, allot, groupName, isSingle, ref dict);
var standData = StandDataFormat(hospitalId, data);
......
......@@ -80,7 +80,7 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, string groupName
var data = new List<ex_result>();
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"开始提取数据");
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"开始提取数据", isSingle: isSingle);
var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
if (scripts != null && scripts.Any())
......@@ -386,6 +386,33 @@ public IEnumerable<ExtractDto> QueryData(sys_hospitalconfig config, per_allot al
}
/// <summary>
/// 查询数据
/// </summary>
/// <param name="config"></param>
/// <param name="allot"></param>
/// <param name="execsql"></param>
/// <param name="source"></param>
/// <param name="category"></param>
/// <returns></returns>
public IEnumerable<T> QueryData<T>(sys_hospitalconfig config, per_allot allot, string execsql)
{
var parameters = GetParameters(allot);
using (var connection = ConnectionBuilder.Create((DatabaseType)config.DataBaseType, config.DbSource, config.DbName, config.DbUser, config.DbPassword))
{
foreach (var item in parameters)
{
execsql = Regex.Replace(execsql, item.Key, item.Value, RegexOptions.IgnoreCase);
}
logger.LogInformation($"提取绩效数据SQL脚本{execsql}");
var result = connection.Query<T>(execsql, commandTimeout: 20000);
logger.LogInformation($"提取绩效数据执行脚本获取数据{result?.Count() ?? 0}条记录");
return result;
}
}
/// <summary>
/// 获取参数
/// </summary>
/// <param name="allot"></param>
......
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