Commit 72a97144 by lcx

提取bug修改

parent 3dd3d5a8
...@@ -197,14 +197,14 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -197,14 +197,14 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
{ {
var departments = data.Select(s => s.Department ?? "")/*.Where(w => !string.IsNullOrEmpty(w))*/.Distinct().ToList(); var departments = data.Select(s => s.Department ?? "")/*.Where(w => !string.IsNullOrEmpty(w))*/.Distinct().ToList();
var filed = new Dictionary<string, Func<ExtractTransDto, string>>(); var filed = fieldOut;
if (sheetType == SheetType.Income) if (sheetType == SheetType.Income)
{ {
if (sheet.SheetName.Contains("住院") || sheet.SheetName.Contains("门诊")) if (sheet.SheetName.Contains("住院") || sheet.SheetName.Contains("门诊"))
filed = sheet.SheetName.Contains("住院") ? fieldInpat : fieldOut; filed = sheet.SheetName.Contains("住院") ? fieldInpat : fieldOut;
var ename = data.Where(w => w.SheetName == sheet.SheetName)?.FirstOrDefault(w => !string.IsNullOrEmpty(w.EName))?.EName; var ename = data.Where(w => w.SheetName == sheet.SheetName)?.FirstOrDefault(w => !string.IsNullOrEmpty(w.EName))?.EName;
if (ename.Contains("住院") || ename.Contains("门诊")) if (string.IsNullOrEmpty(ename) || ename.Contains("住院") || ename.Contains("门诊"))
filed = ename.Contains("住院") ? fieldInpatOut : fieldOutInpat; filed = ename.Contains("住院") ? fieldInpatOut : fieldOutInpat;
} }
else if (sheet.SheetName.Contains("工作量")) else if (sheet.SheetName.Contains("工作量"))
......
...@@ -106,17 +106,18 @@ public string Main(int allotId, int hospitalId, string email, string groupName, ...@@ -106,17 +106,18 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
var templateFilePath = ExtractHelper.GetExtractFile(hospitalId, allot, ref extractFilePath, filePath); var templateFilePath = ExtractHelper.GetExtractFile(hospitalId, allot, ref extractFilePath, filePath);
logService.ReturnTheLog(allotId, groupName, 2, "创建文件", $"模板文件: {templateFilePath}", 1, isSingle); logService.ReturnTheLog(allotId, groupName, 2, "创建文件", $"模板文件: {templateFilePath}", 1, isSingle);
if (!FileHelper.IsExistFile(templateFilePath)) throw new PerformanceException("抽取文件创建失败"); if (!FileHelper.IsExistFile(templateFilePath)) throw new Exception("抽取文件创建失败");
workbook = ExcelHelper.GetWorkbook(templateFilePath); workbook = ExcelHelper.GetWorkbook(templateFilePath);
if (workbook == null) throw new PerformanceException("文件读取失败"); if (workbook == null) throw new Exception("文件读取失败");
WriteDataToFile(workbook, allot, dict, standData, groupName, isSingle); WriteDataToFile(workbook, allot, dict, standData, groupName, isSingle);
logService.ReturnTheLog(allotId, groupName, 2, "提取完成", $"绩效数据提取成功", 5, isSingle);
allot.IsExtracting = isSingle ? 2 : 0; allot.IsExtracting = isSingle ? 2 : 0;
allot.ExtractPath = extractFilePath; allot.ExtractPath = extractFilePath;
logService.ReturnTheLog(allotId, groupName, 2, "写入数据", $"写入数据至Excel文件", 1, isSingle);
workbook.EvaluateAll(); workbook.EvaluateAll();
using (FileStream file = new FileStream(extractFilePath, FileMode.OpenOrCreate)) using (FileStream file = new FileStream(extractFilePath, FileMode.OpenOrCreate))
{ {
...@@ -133,6 +134,8 @@ public string Main(int allotId, int hospitalId, string email, string groupName, ...@@ -133,6 +134,8 @@ public string Main(int allotId, int hospitalId, string email, string groupName,
finally finally
{ {
logService.ReturnTheLog(allotId, groupName, 3, "", 100, 5, isSingle); logService.ReturnTheLog(allotId, groupName, 3, "", 100, 5, isSingle);
if (allot.IsExtracting != 3)
logService.ReturnTheLog(allotId, groupName, 2, "提取完成", $"绩效数据提取成功", 5, isSingle);
UpdateAllot(connection, allot); UpdateAllot(connection, allot);
} }
return extractFilePath; return extractFilePath;
......
...@@ -272,33 +272,38 @@ private List<ex_result> ExtractItemData(per_allot allot, string groupName, bool ...@@ -272,33 +272,38 @@ private List<ex_result> ExtractItemData(per_allot allot, string groupName, bool
{ {
var config = configs.FirstOrDefault(t => t.Id == script.ConfigId); var config = configs.FirstOrDefault(t => t.Id == script.ConfigId);
if (config == null) continue; if (config == null) continue;
try
var querydata = QueryData<ExtractDto>(config, script.ExecScript, allot, isSingle);
if (querydata != null && querydata.Any())
{ {
thisItems.ForEach(f => var querydata = QueryData<ExtractDto>(config, script.ExecScript, allot, isSingle);
if (querydata != null && querydata.Any())
{ {
var modulename = modules.FirstOrDefault(t => t.Id == f.ModuleId)?.ModuleName; thisItems.ForEach(f =>
var result = querydata.Select(t => new ex_result
{ {
Department = t.Department, var modulename = modules.FirstOrDefault(t => t.Id == f.ModuleId)?.ModuleName;
Category = f.ItemName, var result = querydata.Select(t => new ex_result
Fee = t.Value, {
DoctorName = t.DoctorName, Department = t.Department,
PersonnelNumber = t.PersonnelNumber, Category = f.ItemName,
Source = modulename, Fee = t.Value,
TypeId = typeId, DoctorName = t.DoctorName,
DatabaseType = config.DataBaseType, PersonnelNumber = t.PersonnelNumber,
ConfigId = config.Id, Source = modulename,
AllotId = allot.ID, TypeId = typeId,
CreateTime = CreateTime, DatabaseType = config.DataBaseType,
}).ToList(); ConfigId = config.Id,
exresultRepository.InsertExecute(result.ToArray()); AllotId = allot.ID,
data.AddRange(result); CreateTime = CreateTime,
}); }).ToList();
exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
}
catch (Exception ex)
{
logger.LogError($"typeId: {typeId}提取数据异常{ex}{Infrastructure.JsonHelper.Serialize(script)}");
} }
} }
logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"项目“{string.Join("、", thisItems.Select(t => t.ItemName))}”的数据已完成提取", 1, isSingle); logService.ReturnTheLog(allot.ID, groupName, 2, "提取数据", $"项目“{string.Join("、", thisItems.Select(t => t.ItemName))}”的数据已完成提取", 1, isSingle);
} }
} }
...@@ -336,29 +341,35 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo ...@@ -336,29 +341,35 @@ private List<ex_result> ExtractSpecialData(per_allot allot, string groupName, bo
{ {
var config = configs.FirstOrDefault(t => t.Id == script.ConfigId); var config = configs.FirstOrDefault(t => t.Id == script.ConfigId);
if (config == null) continue; if (config == null) continue;
try
var querydata = QueryData<ExtractDto>(config, script.ExecScript, allot, isSingle);
if (querydata != null && querydata.Any())
{ {
thisSpecials.ForEach(f => var querydata = QueryData<ExtractDto>(config, script.ExecScript, allot, isSingle);
if (querydata != null && querydata.Any())
{ {
var result = querydata.Select(t => new ex_result thisSpecials.ForEach(f =>
{ {
Department = f.Department, var result = querydata.Select(t => new ex_result
Category = f.Target, {
Fee = t.Value, Department = f.Department,
DoctorName = t.DoctorName, Category = f.Target,
PersonnelNumber = t.PersonnelNumber, Fee = t.Value,
Source = "4.2 特殊核算单元绩效测算表", DoctorName = t.DoctorName,
TypeId = typeId, PersonnelNumber = t.PersonnelNumber,
DatabaseType = config.DataBaseType, Source = "4.2 特殊核算单元绩效测算表",
ConfigId = config.Id, TypeId = typeId,
AllotId = allot.ID, DatabaseType = config.DataBaseType,
CreateTime = CreateTime, ConfigId = config.Id,
}).ToList(); AllotId = allot.ID,
exresultRepository.InsertExecute(result.ToArray()); CreateTime = CreateTime,
data.AddRange(result); }).ToList();
}); exresultRepository.InsertExecute(result.ToArray());
data.AddRange(result);
});
}
}
catch (Exception ex)
{
logger.LogError($"typeId: {typeId}提取数据异常{ex}{Infrastructure.JsonHelper.Serialize(script)}");
} }
} }
......
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