Commit 4669183f by lcx

Merge branch '抽取公式消失' into 医护工作量

parents 9f088395 be2a2085
using Dapper; using Dapper;
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;
...@@ -135,6 +136,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file ...@@ -135,6 +136,7 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
} }
var standData = StandData(data); var standData = StandData(data);
logger.LogInformation("Execute Main");
return lastAllot == null ? TemplateExecute(email, hospital, configs, modules, items, specials, standData) return lastAllot == null ? TemplateExecute(email, hospital, configs, modules, items, specials, standData)
: AlllotExecute(email, hospital, configs, modules, items, specials, standData, lastAllot, filePath); : AlllotExecute(email, hospital, configs, modules, items, specials, standData, lastAllot, filePath);
} }
...@@ -302,9 +304,17 @@ private void ClearHistData(per_allot allot) ...@@ -302,9 +304,17 @@ 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)
{ {
string originalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xlsx"); string originalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xls");
var (tempPath, newPath) = CopyOriginalFile(hospital.ID, originalPath); var (tempPath, newPath) = CopyOriginalFile(hospital.ID, originalPath);
workbook = new XSSFWorkbook(tempPath);
var version = FileHelper.GetExtension(originalPath) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls;
using (FileStream fs = new FileStream(tempPath, FileMode.OpenOrCreate))
{
workbook = (version == ExcelVersion.xlsx)
? (IWorkbook)(new XSSFWorkbook(fs))
: (IWorkbook)(new HSSFWorkbook(fs));
}
CreateNotExistSheet(modules, workbook); CreateNotExistSheet(modules, workbook);
...@@ -371,8 +381,18 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit ...@@ -371,8 +381,18 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
{ {
if (string.IsNullOrEmpty(path)) throw new PerformanceException("历史绩效文件不存在!"); if (string.IsNullOrEmpty(path)) throw new PerformanceException("历史绩效文件不存在!");
logger.LogInformation("Copy File");
var (tempPath, newPath) = CopyOriginalFile(hospital.ID, path); var (tempPath, newPath) = CopyOriginalFile(hospital.ID, path);
workbook = new XSSFWorkbook(tempPath); logger.LogInformation(tempPath);
var version = FileHelper.GetExtension(path) == ".xlsx" ? ExcelVersion.xlsx : ExcelVersion.xls;
using (FileStream fs = new FileStream(tempPath, FileMode.OpenOrCreate))
{
workbook = (version == ExcelVersion.xlsx)
? (IWorkbook)(new XSSFWorkbook(fs))
: (IWorkbook)(new HSSFWorkbook(fs));
}
CreateNotExistSheet(modules, workbook); CreateNotExistSheet(modules, workbook);
...@@ -649,9 +669,10 @@ private void SaveWorkload(IEnumerable<NewExtractDto> dtos) ...@@ -649,9 +669,10 @@ private void SaveWorkload(IEnumerable<NewExtractDto> dtos)
private (string TempPath, string NewPath) CopyOriginalFile(int hospitalId, string originalPath) private (string TempPath, string NewPath) CopyOriginalFile(int hospitalId, string originalPath)
{ {
var ext = FileHelper.GetExtension(originalPath);
var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", $"{hospitalId}", "autoextract"); var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", $"{hospitalId}", "autoextract");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
string tempPath = Path.Combine(dpath, $"Template{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx"); string tempPath = Path.Combine(dpath, $"Template{DateTime.Now.ToString("yyyyMMddHHmmssfff")}{ext}");
FileHelper.Copy(originalPath, tempPath); FileHelper.Copy(originalPath, tempPath);
string newPath = Path.Combine(dpath, $"绩效提取数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xls"); string newPath = Path.Combine(dpath, $"绩效提取数据{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xls");
...@@ -858,7 +879,8 @@ private void WriteEmployee(ISheet sheet, IPerSheetDataRead sheetRead, bool isNew ...@@ -858,7 +879,8 @@ private void WriteEmployee(ISheet sheet, IPerSheetDataRead sheetRead, bool isNew
private void WriteClinicEmployee(ISheet sheet, IPerSheetDataRead sheetRead, bool isNewTemp = true) private void WriteClinicEmployee(ISheet sheet, IPerSheetDataRead sheetRead, bool isNewTemp = true)
{ {
var accountingunits = new string[] { AccountUnitType.行政高层.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政工勤.ToString() }; var accountingunits = new string[] { AccountUnitType.行政高层.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政工勤.ToString() };
var validData = perforPeremployeeRepository.GetEntities(t => t.AllotId == Allot.ID && !accountingunits.Contains(t.UnitType))?.ToList(); var validData = perforPeremployeeRepository.GetEntities(t => t.AllotId == Allot.ID && !accountingunits.Contains(t.UnitType)
&& (t.Duty.Contains("主任") || t.Duty.Contains("护士长")))?.ToList();
if (validData == null || !validData.Any()) return; if (validData == null || !validData.Any()) return;
Dictionary<string, Func<per_employee, object>> dict = new Dictionary<string, Func<per_employee, object>> Dictionary<string, Func<per_employee, object>> dict = new Dictionary<string, Func<per_employee, object>>
...@@ -939,8 +961,8 @@ private void WriteClinicEmployee(ISheet sheet, IPerSheetDataRead sheetRead, bool ...@@ -939,8 +961,8 @@ private void WriteClinicEmployee(ISheet sheet, IPerSheetDataRead sheetRead, bool
private void WriteAccountBasic(ISheet sheet, IPerSheetDataRead sheetRead, bool isNewTemp = true) private void WriteAccountBasic(ISheet sheet, IPerSheetDataRead sheetRead, bool isNewTemp = true)
{ {
var accountingunits = new string[] { AccountUnitType.行政高层.ToString(), AccountUnitType.行政中层.ToString(), AccountUnitType.行政工勤.ToString() }; var unittypes = new string[] { UnitType.医生组.ToString(), UnitType.医技组.ToString(), UnitType.护理组.ToString(), UnitType.专家组.ToString(), UnitType.其他医生组.ToString(), UnitType.其他医技组.ToString(), UnitType.其他护理组.ToString(), UnitType.特殊核算组.ToString(), };
var validData = perforPeremployeeRepository.GetEntities(t => t.AllotId == Allot.ID && !accountingunits.Contains(t.UnitType))?.ToList(); var validData = perforPeremployeeRepository.GetEntities(t => t.AllotId == Allot.ID && unittypes.Contains(t.UnitType))?.ToList();
if (validData == null || !validData.Any()) return; if (validData == null || !validData.Any()) return;
#region 计算数据 #region 计算数据
...@@ -1356,7 +1378,7 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewE ...@@ -1356,7 +1378,7 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewE
var lastrowIndex = (isNewTemp || isIncom) ? rowIndex : sheet.LastRowNum + 1; var lastrowIndex = (isNewTemp || isIncom) ? rowIndex : sheet.LastRowNum + 1;
foreach (var department in allExtract.Select(t => t.Department).Where(t => !string.IsNullOrEmpty(t)).Distinct()) foreach (var department in allExtract.Select(t => t.Department).Where(t => !string.IsNullOrEmpty(t)).Distinct())
{ {
var row = sheet.CreateRow(lastrowIndex); var row = GetOrCreate(sheet, lastrowIndex);
for (int i = head.FirstCellNum + 3; i < head.LastCellNum; i++) for (int i = head.FirstCellNum + 3; i < head.LastCellNum; i++)
{ {
var headName = head.GetCell(i).StringCellValue; var headName = head.GetCell(i).StringCellValue;
......
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