Commit 716adc59 by lcx

绩效抽取日志

parent 4de40ffa
...@@ -70,7 +70,7 @@ public IActionResult DownFile(int type = 1) ...@@ -70,7 +70,7 @@ public IActionResult DownFile(int type = 1)
switch (type) switch (type)
{ {
case 1: case 1:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xlsx"); path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xls");
break; break;
case 2: case 2:
path = Path.Combine(env.ContentRootPath, "Template", "医院二次分配绩效模板.xlsx"); path = Path.Combine(env.ContentRootPath, "Template", "医院二次分配绩效模板.xlsx");
...@@ -78,6 +78,9 @@ public IActionResult DownFile(int type = 1) ...@@ -78,6 +78,9 @@ public IActionResult DownFile(int type = 1)
case 3: case 3:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板(无执行科室).xlsx"); path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板(无执行科室).xlsx");
break; break;
case 4:
path = Path.Combine(env.ContentRootPath, "Template", "医院人员绩效模板.xls");
break;
} }
var memoryStream = new MemoryStream(); var memoryStream = new MemoryStream();
...@@ -238,9 +241,9 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest ...@@ -238,9 +241,9 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody] ExtractRequest
//HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true); //HttpHelper.HttpPostNoRequest(url.HttpPost + "/extract/extract", JsonHelper.Serialize(request), true);
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&groupName = {request.GroupName}", ""); HttpHelper.HttpPostNoRequest(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&userId={claim.GetUserId()}", "");
else else
HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&groupName = {request.GroupName}", filePath, true); HttpHelper.HttpClient(url.HttpPost + $"/extract/extract?allotId={request.AllotId}&hospitalId={request.HospitalId}&email={claim.GetUserClaim(JwtClaimTypes.Mail)}&userId={claim.GetUserId()}", filePath, true);
return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!", new { IsExtracting = false }); return new ApiResponse(ResponseType.OK, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!", new { IsExtracting = false });
} }
...@@ -357,24 +360,25 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho ...@@ -357,24 +360,25 @@ public ApiResponse SaveFile([FromForm] IFormCollection form, int allotId, int ho
/// <summary> /// <summary>
/// 返回日志 /// 返回日志
/// </summary> /// </summary>
/// <param name="allotId">绩效Id</param>
/// <param name="type">1 进度条 2 信息</param> /// <param name="type">1 进度条 2 信息</param>
/// <param name="tag"></param> /// <param name="tag"></param>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="level"></param> /// <param name="level"></param>
/// <param name="success"></param> /// <param name="success"></param>
/// <param name="groupName"></param>
[Route("returnlog")] [Route("returnlog")]
[HttpPost] [HttpPost]
[AllowAnonymous] [AllowAnonymous]
public void ReturnLog(int allotId, int type, string tag, string message, int level = 1, bool success = false) public void ReturnLog(int type, string tag, string message, int level, string groupName)
{ {
logger.LogInformation("返回日志:" + JsonHelper.Serialize(new { type, tag, message, level, groupName }));
if (type == 3) if (type == 3)
{ {
logService.Schedule(allotId, ConvertHelper.To<decimal>(message), level, success); logService.Schedule(groupName, ConvertHelper.To<decimal>(message), level);
} }
else else
{ {
logService.ExtractLog(allotId, tag, message, level); logService.ExtractLog(groupName, tag, message, level);
} }
} }
......
...@@ -83,9 +83,15 @@ ...@@ -83,9 +83,15 @@
<None Update="Template\医院二次分配绩效模板.xlsx"> <None Update="Template\医院二次分配绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="Template\医院人员绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板%28无执行科室%29.xlsx"> <None Update="Template\医院绩效模板%28无执行科室%29.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Update="Template\医院绩效模板.xls">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Template\医院绩效模板.xlsx"> <None Update="Template\医院绩效模板.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
......
...@@ -1190,16 +1190,16 @@ ...@@ -1190,16 +1190,16 @@
<param name="hospitalId"></param> <param name="hospitalId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(System.Int32,System.Int32,System.String,System.String,System.Int32,System.Boolean)"> <member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(System.Int32,System.String,System.String,System.Int32,System.Boolean,System.String)">
<summary> <summary>
返回日志 返回日志
</summary> </summary>
<param name="allotId">绩效Id</param>
<param name="type">1 进度条 2 信息</param> <param name="type">1 进度条 2 信息</param>
<param name="tag"></param> <param name="tag"></param>
<param name="message"></param> <param name="message"></param>
<param name="level"></param> <param name="level"></param>
<param name="success"></param> <param name="success"></param>
<param name="groupName"></param>
</member> </member>
<member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(Performance.EntityModels.log_dbug)"> <member name="M:Performance.Api.Controllers.TemplateController.ReturnLog(Performance.EntityModels.log_dbug)">
<summary> <summary>
......
...@@ -112,9 +112,9 @@ public ApiResponse Import([FromForm] IFormCollection form, int type, int hospita ...@@ -112,9 +112,9 @@ public ApiResponse Import([FromForm] IFormCollection form, int type, int hospita
/// <returns></returns> /// <returns></returns>
[Route("extract")] [Route("extract")]
[HttpPost] [HttpPost]
public void ExtractData([FromForm] IFormCollection form, int allotId, int hospitalId, string email) public void ExtractData([FromForm] IFormCollection form, int allotId, int hospitalId, string email, string userId)
{ {
logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(new { allotId, hospitalId, email })); logger.LogInformation("提取绩效数据请求参数:" + JsonHelper.Serialize(new { allotId, hospitalId, email, userId }));
if (allotId == 0 || hospitalId == 0) if (allotId == 0 || hospitalId == 0)
return; return;
...@@ -149,7 +149,7 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit ...@@ -149,7 +149,7 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
#endregion #endregion
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId); //string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
string filePath = extractService.ExtractData(allotId, email, hospitalId, path); //抽取 string filePath = extractService.ExtractData(allotId, email, hospitalId, "User" + userId, path); //抽取
#region 保存文件到网站下 #region 保存文件到网站下
......
...@@ -38,7 +38,7 @@ public int DeleteData(int allotId) ...@@ -38,7 +38,7 @@ public int DeleteData(int allotId)
}; };
string sql = ""; string sql = "";
tableArray.ForEach(t => sql += $"delete from {t} where allotid=@allotId;"); tableArray.ForEach(t => sql += $"delete from {t} where allotid=@allotId;");
sql += "delete from log_dbug where allotid=@allotId and source=1;"; sql += "delete from log_dbug where allotid=@allotId and type=1;";
return Execute(sql, new { allotId }); return Execute(sql, new { allotId });
} }
......
...@@ -109,6 +109,9 @@ public void ClearResultData(int allotid) ...@@ -109,6 +109,9 @@ public void ClearResultData(int allotid)
if (connection.State != ConnectionState.Open) connection.Open(); if (connection.State != ConnectionState.Open) connection.Open();
try try
{ {
string update = "update ex_result set isdelete = 1 where allotid = @allotid ";
connection.Execute(update, new { allotid }, commandTimeout: 60 * 60);
string clear = "delete from ex_result where allotid = @allotid and isdelete = 1 and createtime < (select min(createtime) from (select distinct createtime from ex_result where allotid = @allotid and isdelete = 1 order by createtime desc limit 4) t);"; string clear = "delete from ex_result where allotid = @allotid and isdelete = 1 and createtime < (select min(createtime) from (select distinct createtime from ex_result where allotid = @allotid and isdelete = 1 order by createtime desc limit 4) t);";
connection.Execute(clear, new { allotid }, commandTimeout: 60 * 60); connection.Execute(clear, new { allotid }, commandTimeout: 60 * 60);
} }
......
...@@ -49,6 +49,7 @@ public class DFExtractService : IAutoInjection ...@@ -49,6 +49,7 @@ public class DFExtractService : IAutoInjection
private const string specialname = "4.2 特殊核算单元绩效测算表"; private const string specialname = "4.2 特殊核算单元绩效测算表";
private DateTime? CreateTime = null; private DateTime? CreateTime = null;
private decimal ratio = 5; private decimal ratio = 5;
private string GroupName = "";
public DFExtractService(ILogger<DFExtractService> logger, public DFExtractService(ILogger<DFExtractService> logger,
IEmailService emailService, IEmailService emailService,
...@@ -96,14 +97,17 @@ public class DFExtractService : IAutoInjection ...@@ -96,14 +97,17 @@ public class DFExtractService : IAutoInjection
#region 抽取 #region 抽取
public string ExtractData(int allotId, string email, int hospitalId, string filePath = null) public string ExtractData(int allotId, string email, int hospitalId, string groupName, string filePath = null)
{ {
var hospital = perforHospitalRepository.GetEntity(t => t.ID == hospitalId); var hospital = perforHospitalRepository.GetEntity(t => t.ID == hospitalId);
try try
{ {
GroupName = groupName;
logManage.ClearExtractLog(allotId); logManage.ClearExtractLog(allotId);
logManage.ReturnTheLog(allotId, 2, "等待提取", $"确认配置信息是否可完成数据提取..."); logManage.ReturnTheLog(allotId, GroupName, 3, "", 1);
logManage.ReturnTheLog(allotId, GroupName, 2, "等待提取", $"确认配置信息是否可完成数据提取...");
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
Allot = allot ?? throw new PerformanceException(""); Allot = allot ?? throw new PerformanceException("");
...@@ -133,7 +137,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file ...@@ -133,7 +137,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
var data = new List<ex_result>(); var data = new List<ex_result>();
var scripts = perforExscriptRepository.GetEntities(t => typeIds.Contains(t.TypeId)); var scripts = perforExscriptRepository.GetEntities(t => typeIds.Contains(t.TypeId));
logManage.ReturnTheLog(allotId, 3, "", 5); logManage.ReturnTheLog(allotId, GroupName, 3, "", 5);
ClearHistData(allot); ClearHistData(allot);
...@@ -141,9 +145,12 @@ public string ExtractData(int allotId, string email, int hospitalId, string file ...@@ -141,9 +145,12 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
var otherItems = items.Where(t => modules.Where(m => m.SheetType != (int)SheetType.Income).Select(m => m.Id).Contains(t.ModuleId.Value)).ToList(); var otherItems = items.Where(t => modules.Where(m => m.SheetType != (int)SheetType.Income).Select(m => m.Id).Contains(t.ModuleId.Value)).ToList();
if (scripts != null && scripts.Any()) if (scripts != null && scripts.Any())
{ {
data.AddRange(ExtractIncome(modules, scripts, configs, allot)); var incomedata = ExtractIncome(modules, scripts, configs, allot);
data.AddRange(ExtractItems(otherItems, scripts, configs, allot, modules)); data.AddRange(incomedata);
data.AddRange(ExtractSpcial(specials, scripts, configs, allot)); var itemdata = ExtractItems(otherItems, scripts, configs, allot, modules);
data.AddRange(itemdata);
var specialdata = ExtractSpcial(specials, scripts, configs, allot);
data.AddRange(specialdata);
} }
var standData = StandData(data); var standData = StandData(data);
...@@ -153,8 +160,8 @@ public string ExtractData(int allotId, string email, int hospitalId, string file ...@@ -153,8 +160,8 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
} }
catch (Exception ex) catch (Exception ex)
{ {
logManage.ReturnTheLog(allotId, 2, "发生异常", $"提取绩效数据异常", 4); logManage.ReturnTheLog(allotId, GroupName, 2, "发生异常", $"提取绩效数据异常", 4);
logManage.ReturnTheLog(allotId, 3, "", ratio, 4); logManage.ReturnTheLog(allotId, GroupName, 3, "", ratio, 4);
logger.LogError($"提取绩效数据异常 数据写入出现异常{ex.ToString()}"); logger.LogError($"提取绩效数据异常 数据写入出现异常{ex.ToString()}");
//SendEmail(email, "", $"{hospital.HosName}HIS数据提取失败", $"{hospital.HosName}提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!"); //SendEmail(email, "", $"{hospital.HosName}HIS数据提取失败", $"{hospital.HosName}提取数据过程中出现异常情况,我们将尽快解决问题。给您带来的不便我们深感歉意!");
throw ex; throw ex;
...@@ -166,8 +173,8 @@ public string ExtractData(int allotId, string email, int hospitalId, string file ...@@ -166,8 +173,8 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
if (workbook != null) if (workbook != null)
workbook.Close(); workbook.Close();
GC.Collect(); GC.Collect();
logManage.ReturnTheLog(allotId, 2, "提取完成", $"绩效数据提取成功", 5); logManage.ReturnTheLog(allotId, GroupName, 3, "", 100, 5);
logManage.ReturnTheLog(allotId, 3, "", 100, 5, true); logManage.ReturnTheLog(allotId, GroupName, 2, "提取完成", $"绩效数据提取成功", 5);
} }
} }
...@@ -193,9 +200,9 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s ...@@ -193,9 +200,9 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s
var incomemodules = modules.Where(t => t.SheetType == (int)SheetType.Income && t.TypeId > 0); var incomemodules = modules.Where(t => t.SheetType == (int)SheetType.Income && t.TypeId > 0);
foreach (var module in incomemodules) foreach (var module in incomemodules)
{ {
logManage.ReturnTheLog(Allot.ID, 2, "提取数据", $"开始提取模块“{module.ModuleName}”的数据"); ratio += 15m / incomemodules.Count();
ratio += 15 / incomemodules.Count(); logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 20 ? 20 : ratio);
logManage.ReturnTheLog(Allot.ID, 3, "", ratio); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"开始提取模块“{module.ModuleName}”的数据");
foreach (var config in configs) foreach (var config in configs)
{ {
var item = scripts.FirstOrDefault(t => t.TypeId == module.TypeId && t.DatabaseType == config.DataBaseType); var item = scripts.FirstOrDefault(t => t.TypeId == module.TypeId && t.DatabaseType == config.DataBaseType);
...@@ -207,12 +214,7 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s ...@@ -207,12 +214,7 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s
data.AddRange(querydata); data.AddRange(querydata);
} }
} }
logManage.ReturnTheLog(Allot.ID, 2, "提取数据", $"模块“{module.ModuleName}”的数据已完成提取"); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"模块“{module.ModuleName}”的数据已完成提取");
}
if (Math.Round(ratio) < 20)
{
ratio = 20;
logManage.ReturnTheLog(Allot.ID, 3, "", ratio);
} }
return data; return data;
...@@ -230,6 +232,12 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s ...@@ -230,6 +232,12 @@ private List<ex_result> ExtractIncome<TEntity>(List<TEntity> entities, List<ex_s
/// <returns></returns> /// <returns></returns>
private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_script> scripts, List<sys_hospitalconfig> configs, per_allot allot, List<ex_module> modules) private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_script> scripts, List<sys_hospitalconfig> configs, per_allot allot, List<ex_module> modules)
{ {
if (Math.Round(ratio) < 20)
{
ratio = 20;
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio);
}
var data = new List<ex_result>(); var data = new List<ex_result>();
var items = entities as List<ex_item>; var items = entities as List<ex_item>;
if (items == null || !items.Any(t => t.TypeId > 0)) if (items == null || !items.Any(t => t.TypeId > 0))
...@@ -237,9 +245,9 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc ...@@ -237,9 +245,9 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc
foreach (var exitem in items.Where(t => t.TypeId > 0)) foreach (var exitem in items.Where(t => t.TypeId > 0))
{ {
logManage.ReturnTheLog(Allot.ID, 2, "提取数据", $"开始提取项目“{exitem.ItemName}”的数据"); ratio += 30m / items.Where(t => t.TypeId > 0).Count();
ratio += 30 / items.Where(t => t.TypeId > 0).Count(); logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 50 ? 50 : ratio);
logManage.ReturnTheLog(Allot.ID, 3, "", ratio); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"开始提取项目“{exitem.ItemName}”的数据");
var module = modules.FirstOrDefault(t => t.Id == exitem.ModuleId); var module = modules.FirstOrDefault(t => t.Id == exitem.ModuleId);
foreach (var config in configs) foreach (var config in configs)
{ {
...@@ -258,12 +266,7 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc ...@@ -258,12 +266,7 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc
data.AddRange(result); data.AddRange(result);
} }
} }
logManage.ReturnTheLog(Allot.ID, 2, "提取数据", $"项目“{exitem.ItemName}”的数据已完成提取"); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"项目“{exitem.ItemName}”的数据已完成提取");
}
if (Math.Round(ratio) < 50)
{
ratio = 50;
logManage.ReturnTheLog(Allot.ID, 3, "", ratio);
} }
return data; return data;
...@@ -280,6 +283,12 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc ...@@ -280,6 +283,12 @@ private List<ex_result> ExtractItems<TEntity>(List<TEntity> entities, List<ex_sc
/// <returns></returns> /// <returns></returns>
private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_script> scripts, List<sys_hospitalconfig> configs, per_allot allot) private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_script> scripts, List<sys_hospitalconfig> configs, per_allot allot)
{ {
if (Math.Round(ratio) < 50)
{
ratio = 50;
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio);
}
var data = new List<ex_result>(); var data = new List<ex_result>();
var specials = entities as List<ex_special>; var specials = entities as List<ex_special>;
if (specials == null || !specials.Any(t => t.TypeId > 0)) if (specials == null || !specials.Any(t => t.TypeId > 0))
...@@ -287,9 +296,9 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s ...@@ -287,9 +296,9 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s
foreach (var special in specials.Where(t => t.TypeId > 0)) foreach (var special in specials.Where(t => t.TypeId > 0))
{ {
logManage.ReturnTheLog(Allot.ID, 2, "提取数据", $"开始提取特殊核算项“{special.Target}”的数据"); ratio += 10m / specials.Where(t => t.TypeId > 0).Count();
ratio += 10 / specials.Where(t => t.TypeId > 0).Count(); logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 60 ? 60 : ratio);
logManage.ReturnTheLog(Allot.ID, 3, "", ratio); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"开始提取特殊核算项“{special.Target}”的数据");
foreach (var config in configs) foreach (var config in configs)
{ {
var item = scripts.FirstOrDefault(t => t.TypeId == special.TypeId && t.DatabaseType == config.DataBaseType); var item = scripts.FirstOrDefault(t => t.TypeId == special.TypeId && t.DatabaseType == config.DataBaseType);
...@@ -303,12 +312,7 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s ...@@ -303,12 +312,7 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s
}); });
data.AddRange(result); data.AddRange(result);
} }
logManage.ReturnTheLog(Allot.ID, 2, "提取数据", $"特殊核算项“{special.Target}”的数据已完成提取"); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "提取数据", $"特殊核算项“{special.Target}”的数据已完成提取");
}
if (Math.Round(ratio) < 60)
{
ratio = 60;
logManage.ReturnTheLog(Allot.ID, 3, "", ratio);
} }
if (data != null && data.Any()) if (data != null && data.Any())
perforExresultRepository.AddRange(data.ToArray()); perforExresultRepository.AddRange(data.ToArray());
...@@ -323,14 +327,18 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s ...@@ -323,14 +327,18 @@ private List<ex_result> ExtractSpcial<TEntity>(List<TEntity> entities, List<ex_s
private void ClearHistData(per_allot allot) private void ClearHistData(per_allot allot)
{ {
logger.LogInformation($"开始清除历史提取数据"); logger.LogInformation($"开始清除历史提取数据");
var data = perforExresultRepository.GetEntities(t => t.AllotId == allot.ID && t.IsDelete == 0);
if (data != null && data.Any(t => t.Id > 0))
{
data.ForEach(t => t.IsDelete = 1);
perforExresultRepository.UpdateRange(data.ToArray());
perforPerallotRepository.ClearResultData(allot.ID); perforPerallotRepository.ClearResultData(allot.ID);
}
logger.LogInformation($"清除历史提取数据已完成");
//var data = perforExresultRepository.GetEntities(t => t.AllotId == allot.ID && t.IsDelete == 0);
//if (data != null && data.Any(t => t.Id > 0))
//{
// data.ForEach(t => t.IsDelete = 1);
// perforExresultRepository.UpdateRange(data.ToArray());
// perforPerallotRepository.ClearResultData(allot.ID);
//}
} }
/// <summary> /// <summary>
...@@ -347,6 +355,12 @@ private void ClearHistData(per_allot allot) ...@@ -347,6 +355,12 @@ private void ClearHistData(per_allot allot)
/// <returns></returns> /// <returns></returns>
public string TemplateExecute(string email, sys_hospital hospital, List<sys_hospitalconfig> configs, List<ex_module> modules, List<ex_item> items, List<ex_special> specials, List<NewExtractDto> data) public string TemplateExecute(string email, sys_hospital hospital, List<sys_hospitalconfig> configs, List<ex_module> modules, List<ex_item> items, List<ex_special> specials, List<NewExtractDto> data)
{ {
if (Math.Round(ratio) < 60)
{
ratio = 60;
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio);
}
logger.LogInformation("空白模板提取"); logger.LogInformation("空白模板提取");
string originalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xls"); string originalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xls");
var (tempPath, newPath) = CopyOriginalFile(hospital.ID, originalPath); var (tempPath, newPath) = CopyOriginalFile(hospital.ID, originalPath);
...@@ -365,16 +379,19 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp ...@@ -365,16 +379,19 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
style = CellStyle.CreateCellStyle(workbook, StyleType.数据); style = CellStyle.CreateCellStyle(workbook, StyleType.数据);
logger.LogInformation($"共有{workbook?.NumberOfSheets ?? 0}个sheet");
for (int i = 0; i < workbook.NumberOfSheets; i++) for (int i = 0; i < workbook.NumberOfSheets; i++)
{ {
var sheet = workbook.GetSheetAt(i); var sheet = workbook.GetSheetAt(i);
ratio += 40m / workbook.NumberOfSheets;
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 99 ? 99 : ratio);
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "写入数据", $"sheet“{sheet.SheetName}”开始写入数据");
var sheetType = perSheetService.GetSheetType(sheet.SheetName); var sheetType = perSheetService.GetSheetType(sheet.SheetName);
if (sheetType == SheetType.Unidentifiable) continue; if (sheetType == SheetType.Unidentifiable) continue;
logManage.ReturnTheLog(Allot.ID, 2, "写入数据", $"sheet“{sheet.SheetName}”开始写入数据");
ratio += 40 / 8;
logManage.ReturnTheLog(Allot.ID, 3, "", ratio);
var sheetRead = PerSheetDataFactory.GetDataRead(sheetType); var sheetRead = PerSheetDataFactory.GetDataRead(sheetType);
switch (sheetType) switch (sheetType)
{ {
...@@ -403,7 +420,7 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp ...@@ -403,7 +420,7 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
WriteSpecialUnit(sheet, sheetRead, specials, data); WriteSpecialUnit(sheet, sheetRead, specials, data);
break; break;
} }
logManage.ReturnTheLog(Allot.ID, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入"); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入");
} }
using (FileStream file = new FileStream(newPath, FileMode.OpenOrCreate)) using (FileStream file = new FileStream(newPath, FileMode.OpenOrCreate))
{ {
...@@ -429,6 +446,12 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp ...@@ -429,6 +446,12 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
/// <returns></returns> /// <returns></returns>
public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospitalconfig> configs, List<ex_module> modules, List<ex_item> items, List<ex_special> specials, List<NewExtractDto> extracts, per_allot lastAllot, string path) public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospitalconfig> configs, List<ex_module> modules, List<ex_item> items, List<ex_special> specials, List<NewExtractDto> extracts, per_allot lastAllot, string path)
{ {
if (Math.Round(ratio) < 60)
{
ratio = 60;
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio);
}
if (string.IsNullOrEmpty(path)) throw new PerformanceException("历史绩效文件不存在!"); if (string.IsNullOrEmpty(path)) throw new PerformanceException("历史绩效文件不存在!");
logger.LogInformation("Copy File"); logger.LogInformation("Copy File");
...@@ -448,16 +471,19 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit ...@@ -448,16 +471,19 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
style = CellStyle.CreateCellStyle(workbook, StyleType.数据); style = CellStyle.CreateCellStyle(workbook, StyleType.数据);
logger.LogInformation($"共有{workbook?.NumberOfSheets ?? 0}个sheet");
for (int i = 0; i < workbook.NumberOfSheets; i++) for (int i = 0; i < workbook.NumberOfSheets; i++)
{ {
var sheet = workbook.GetSheetAt(i); var sheet = workbook.GetSheetAt(i);
ratio += 40m / workbook.NumberOfSheets;
logManage.ReturnTheLog(Allot.ID, GroupName, 3, "", ratio > 99 ? 99 : ratio);
logManage.ReturnTheLog(Allot.ID, GroupName, 2, "写入数据", $"sheet“{sheet.SheetName}”开始写入数据");
var sheetType = perSheetService.GetSheetType(sheet.SheetName); var sheetType = perSheetService.GetSheetType(sheet.SheetName);
if (sheetType == SheetType.Unidentifiable) continue; if (sheetType == SheetType.Unidentifiable) continue;
logManage.ReturnTheLog(Allot.ID, 2, "写入数据", $"sheet“{sheet.SheetName}”开始写入数据");
ratio += 40 / 8;
logManage.ReturnTheLog(Allot.ID, 3, "", ratio);
var sheetRead = PerSheetDataFactory.GetDataRead(sheetType); var sheetRead = PerSheetDataFactory.GetDataRead(sheetType);
switch (sheetType) switch (sheetType)
{ {
...@@ -491,7 +517,7 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit ...@@ -491,7 +517,7 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
WriteSpecialUnit(sheet, sheetRead, specials, extracts, lastAllot, false); WriteSpecialUnit(sheet, sheetRead, specials, extracts, lastAllot, false);
break; break;
} }
logManage.ReturnTheLog(Allot.ID, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入"); logManage.ReturnTheLog(Allot.ID, GroupName, 2, "写入数据", $"sheet“{sheet.SheetName}”已完成数据写入");
} }
using (FileStream file = new FileStream(newPath, FileMode.OpenOrCreate)) using (FileStream file = new FileStream(newPath, FileMode.OpenOrCreate))
{ {
......
using AutoMapper; using AutoMapper;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using NPOI.SS.Util; using NPOI.SS.Util;
using NPOI.XSSF.UserModel; using NPOI.XSSF.UserModel;
...@@ -330,7 +331,15 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -330,7 +331,15 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
try try
{ {
IWorkbook workbook = new XSSFWorkbook(path); IWorkbook workbook = null;
var version = FileHelper.GetExtension(path) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls;
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
{
workbook = (version == ExcelVersion.xlsx)
? (IWorkbook)(new XSSFWorkbook(fs))
: (IWorkbook)(new HSSFWorkbook(fs));
}
if (workbook == null) return; if (workbook == null) return;
var sheet = workbook.GetSheetAt(0); var sheet = workbook.GetSheetAt(0);
......
...@@ -64,6 +64,7 @@ public override Task OnDisconnectedAsync(Exception exception) ...@@ -64,6 +64,7 @@ public override Task OnDisconnectedAsync(Exception exception)
cache.Set(key, groupName, new TimeSpan(1, 0, 0)); cache.Set(key, groupName, new TimeSpan(1, 0, 0));
logger.LogDebug($"日志推送 添加用户组{connectionId}-{groupName}"); logger.LogDebug($"日志推送 添加用户组{connectionId}-{groupName}");
//2 将用户插入分组 //2 将用户插入分组
await Groups.AddToGroupAsync(connectionId, groupName); await Groups.AddToGroupAsync(connectionId, groupName);
} }
......
using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Performance.DtoModels.AppSettings; using Performance.DtoModels.AppSettings;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Repository; using Performance.Repository;
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -52,36 +48,47 @@ public void WriteMsg(string tag, string message, int level, int allotId, string ...@@ -52,36 +48,47 @@ public void WriteMsg(string tag, string message, int level, int allotId, string
/// <summary> /// <summary>
/// 抽取进度 /// 抽取进度
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="groupName"></param>
/// <param name="ratio"></param> /// <param name="ratio"></param>
/// <param name="level">等级1、信息(info)2、警告(warn)3、错误(error)4、异常(exception)5、成功(success)</param> /// <param name="level">等级1、信息(info)2、警告(warn)3、错误(error)4、异常(exception)5、成功(success)</param>
/// <param name="success"></param> /// <param name="success"></param>
public void Schedule(int allotId, decimal ratio, int level = 1, bool success = false) public void Schedule(string groupName, decimal ratio, int level)
{ {
if (!success && ratio > 100) ratio = 99; ratio = Math.Round(ratio);
if (success && ratio != 100) ratio = 100; if (level != 5 && ratio > 100) ratio = 99;
hubContext.Clients.Group($"Extract{allotId}").SendAsync("Schedule", ratio, level); if (level == 5 && ratio != 100) ratio = 100;
hubContext.Clients.Group(groupName).SendAsync("Schedule", ratio, level);
} }
/// <summary> /// <summary>
/// 抽取日志 /// 抽取日志
/// </summary> /// </summary>
/// <param name="allotId"></param> /// <param name="groupName"></param>
/// <param name="tag"></param> /// <param name="tag"></param>
/// <param name="message"></param> /// <param name="message"></param>
/// <param name="level">等级1、信息(info)2、警告(warn)3、错误(error)4、异常(exception)5、成功(success)</param> /// <param name="level">等级1、信息(info)2、警告(warn)3、错误(error)4、异常(exception)5、成功(success)</param>
public void ExtractLog(int allotId, string tag, string message, int level = 1) public void ExtractLog(string groupName, string tag, string message, int level)
{ {
hubContext.Clients.Group($"Extract{allotId}").SendAsync("ExtractLog", tag, message, level); hubContext.Clients.Group(groupName).SendAsync("ExtractLog", tag, message, level);
} }
public void ReturnTheLog(int allotId, int type, string tag, object message, int level = 1, bool success = false) public void ReturnTheLog(int allotId, string groupName, int type, string tag, object message, int level = 1)
{ {
logdbug.Add(allotId, tag, message.ToString(), level, type); try
HttpHelper.HttpPostNoRequest(url.ImportFile + $"/template/returnlog?allotId={allotId}&type={type}&tag={tag}&message={message}&level={level}&success={success}", ""); {
var http = url.ImportFile + $"/template/returnlog?type={type}&tag={tag}&message={message}&level={level}&groupName={groupName}";
logger.LogInformation("发送日志:" + http);
logdbug.Add(allotId, tag, message.ToString(), level, type);
HttpHelper.HttpPostNoRequest(http, "");
}
catch (Exception ex)
{
logger.LogInformation("发送日志失败:" + ex.ToString());
}
} }
public bool ClearExtractLog(int allotId) public bool ClearExtractLog(int allotId)
......
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