Commit 22358275 by ruyun.zhang

提取记录日志

parent 6b20f279
...@@ -214,7 +214,7 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD ...@@ -214,7 +214,7 @@ private void WriteDataToFile(IWorkbook workbook, per_allot allot, Dictionary<ExD
HandleSheet(workbook, allot, exdict, extractDto, groupName, isSingle, sheet, ratio, types, factory, style, employeeDict, collectData); HandleSheet(workbook, allot, exdict, extractDto, groupName, isSingle, sheet, ratio, types, factory, style, employeeDict, collectData);
} }
customDataWrite.WriteDataToCustom(workbook, allot, style); customDataWrite.WriteDataToCustom(workbook, allot, style, allot.ID, groupName, isSingle);
} }
private void HandleSheet(IWorkbook workbook, per_allot allot, Dictionary<ExDataDict, object> exdict, List<ExtractTransDto> extractDto, string groupName, bool isSingle, private void HandleSheet(IWorkbook workbook, per_allot allot, Dictionary<ExDataDict, object> exdict, List<ExtractTransDto> extractDto, string groupName, bool isSingle,
......
using Microsoft.Extensions.Logging; using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Logging;
using NPOI.SS.UserModel; using NPOI.SS.UserModel;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
using Performance.Repository; using Performance.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Performance.Services.ExtractExcelService.SheetDataWrite namespace Performance.Services.ExtractExcelService.SheetDataWrite
{ {
...@@ -16,20 +16,22 @@ public class CustomDataWrite : IAutoInjection ...@@ -16,20 +16,22 @@ public class CustomDataWrite : IAutoInjection
private readonly PerforExmoduleRepository exmoduleRepository; private readonly PerforExmoduleRepository exmoduleRepository;
private readonly PerforExscriptRepository exscriptRepository; private readonly PerforExscriptRepository exscriptRepository;
private readonly CustomExtractService customExtractService; private readonly CustomExtractService customExtractService;
private readonly LogManageService _logService;
public CustomDataWrite( public CustomDataWrite(
ILogger<CustomDataWrite> logger, ILogger<CustomDataWrite> logger,
PerforHospitalconfigRepository hospitalconfigRepository, PerforHospitalconfigRepository hospitalconfigRepository,
PerforExmoduleRepository exmoduleRepository, PerforExmoduleRepository exmoduleRepository,
PerforExscriptRepository exscriptRepository, PerforExscriptRepository exscriptRepository,
CustomExtractService customExtractService CustomExtractService customExtractService,
) LogManageService logService)
{ {
this.logger = logger; this.logger = logger;
this.hospitalconfigRepository = hospitalconfigRepository; this.hospitalconfigRepository = hospitalconfigRepository;
this.exmoduleRepository = exmoduleRepository; this.exmoduleRepository = exmoduleRepository;
this.exscriptRepository = exscriptRepository; this.exscriptRepository = exscriptRepository;
this.customExtractService = customExtractService; this.customExtractService = customExtractService;
_logService = logService;
} }
public PerSheetPoint Point => new PerSheetPoint public PerSheetPoint Point => new PerSheetPoint
...@@ -40,8 +42,9 @@ CustomExtractService customExtractService ...@@ -40,8 +42,9 @@ CustomExtractService customExtractService
DataFirstCellNum = 6, DataFirstCellNum = 6,
}; };
public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle style) public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle style, int allotId, string groupName, bool isSingle)
{ {
_logService.ReturnTheLog(allotId, groupName, 2, "自定义提取", $"测算表自定义提取准备执行", 1, isSingle);
var modules = exmoduleRepository.GetEntities(t => t.SheetType == (int)SheetType.Custom)?.OrderBy(t => t.ModuleName); var modules = exmoduleRepository.GetEntities(t => t.SheetType == (int)SheetType.Custom)?.OrderBy(t => t.ModuleName);
if (modules == null || !modules.Any()) return; if (modules == null || !modules.Any()) return;
...@@ -49,7 +52,11 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st ...@@ -49,7 +52,11 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
if (exscripts == null || !exscripts.Any()) return; if (exscripts == null || !exscripts.Any()) return;
var configs = hospitalconfigRepository.GetEntities(t => t.HospitalId == allot.HospitalId); var configs = hospitalconfigRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (configs == null || !configs.Any()) throw new Exception("医院未配置绩效抽取信息"); if (configs == null || !configs.Any())
{
_logService.ReturnTheLog(allotId, groupName, 2, "自定义提取", $"测算表自定义提取医院未配置绩效抽取信息", 1, isSingle);
throw new Exception("医院未配置绩效抽取信息");
}
var parameters = customExtractService.GetParameters(allot); var parameters = customExtractService.GetParameters(allot);
var headerStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头); var headerStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.列头);
...@@ -57,6 +64,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st ...@@ -57,6 +64,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
foreach (var module in modules) foreach (var module in modules)
{ {
_logService.ReturnTheLog(allotId, groupName, 2, "自定义提取", $"测算表自定义提取:“{module.ModuleName}”", 1, isSingle);
var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank()); var sheet = workbook.GetSheet(module.ModuleName) ?? workbook.GetSheet(module.ModuleName.NoBlank());
if (sheet == null) if (sheet == null)
{ {
...@@ -75,6 +83,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st ...@@ -75,6 +83,7 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
try try
{ {
_logService.ReturnTheLog(allotId, groupName, 2, "自定义提取", $"测算表自定义提取“{module.ModuleName}”数据:{dynamics?.Count() ?? 0}条记录", 1, isSingle);
// 没数据跳过 // 没数据跳过
if (dynamics == null || dynamics.Count() == 0) if (dynamics == null || dynamics.Count() == 0)
continue; continue;
...@@ -109,9 +118,11 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st ...@@ -109,9 +118,11 @@ public void WriteDataToCustom(IWorkbook workbook, per_allot allot, ExcelStyle st
} }
rowindex++; rowindex++;
} }
_logService.ReturnTheLog(allotId, groupName, 2, "自定义提取", $"测算表自定义提取“{module.ModuleName}”提取完成", 1, isSingle);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logService.ReturnTheLog(allotId, groupName, 2, "自定义提取", $"测算表自定义提取“{module.ModuleName}”提取失败;失败原因:{ex.Message}", 3, isSingle);
logger.LogError($"自定义模板 - {sheet.SheetName}抽取异常:" + ex); logger.LogError($"自定义模板 - {sheet.SheetName}抽取异常:" + ex);
} }
} }
......
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