Commit 1c1701d3 by lcx

抽取 科室修改

parent 495470c8
......@@ -10,5 +10,6 @@ public class AccountUnitEntity
public string AccountingUnit { get; set; }
public string Department { get; set; }
public int UnitType { get; set; }
public string HisDepartment { get; set; }
}
}
using Dapper;
using Dapper;
......@@ -37,6 +37,7 @@ public class DFExtractService1 : IAutoInjection
private readonly PerforPerdeptdicRepository perforPerdeptdicRepository;
private readonly PerforPeremployeeRepository perforPeremployeeRepository;
private readonly PersonService personService;
private IWorkbook workbook = null;
private ICellStyle style;
......@@ -60,7 +61,8 @@ public class DFExtractService1 : IAutoInjection
PerforExscriptRepository perforExscriptRepository,
PerforPerdeptdicRepository perforPerdeptdicRepository,
PerforPeremployeeRepository perforPeremployeeRepository)
PerforPeremployeeRepository perforPeremployeeRepository,
PersonService personService)
{
this.logger = logger;
this.emailService = emailService;
......@@ -80,6 +82,7 @@ public class DFExtractService1 : IAutoInjection
this.perforPerdeptdicRepository = perforPerdeptdicRepository;
this.perforPeremployeeRepository = perforPeremployeeRepository;
this.personService = personService;
}
#endregion
......@@ -127,8 +130,9 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
data.AddRange(ExtractSpcial(specials, scripts, configs, allot));
}
return lastAllot == null ? TemplateExecute(email, hospital, configs, modules, items, specials, data)
: AlllotExecute(email, hospital, configs, modules, items, specials, data, lastAllot, filePath);
var standData = StandData(data);
return lastAllot == null ? TemplateExecute(email, hospital, configs, modules, items, specials, standData)
: AlllotExecute(email, hospital, configs, modules, items, specials, standData, lastAllot, filePath);
}
catch (Exception ex)
{
......@@ -146,6 +150,9 @@ public string ExtractData(int allotId, string email, int hospitalId, string file
}
}
/// <summary>
/// 抽取收入费用
/// </summary>
......@@ -283,7 +290,7 @@ private void ClearHistData(per_allot allot)
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <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<ex_result> 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");
var (tempPath, newPath) = CopyOriginalFile(hospital.ID, originalPath);
......@@ -293,20 +300,6 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
style = CellStyle.CreateCellStyle(workbook, StyleType.数据);
List<AccountUnitEntity> unitList = new List<AccountUnitEntity>();
var deptDict = perforPerdeptdicRepository.GetEntities(t => t.HospitalId == Allot.HospitalId);
var units = EnumHelper.GetItems<UnitType>();
if (deptDict != null && deptDict.Any())
{
unitList = deptDict.Select(t => new AccountUnitEntity
{
AccountingUnit = t.AccountingUnit,
Department = t.Department,
UnitType = units.FirstOrDefault(en => en.Description == t.UnitType)?.Value ?? 0
}).ToList();
}
logger.LogInformation($"unitList count: {unitList?.Count ?? 0}");
for (int i = 0; i < workbook.NumberOfSheets; i++)
{
var sheet = workbook.GetSheetAt(i);
......@@ -323,16 +316,16 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
WriteClinicEmployee(sheet, sheetRead);
break;
case SheetType.OtherIncome:
WriteOtherIncome(sheet, sheetRead, unitList, modules, items, data);
WriteOtherIncome(sheet, sheetRead, modules, items, data);
break;
case SheetType.Income:
WriteIncome(sheet, sheetRead, unitList, modules, items, data);
WriteIncome(sheet, sheetRead, modules, items, data);
break;
case SheetType.Expend:
WriteExpend(sheet, sheetRead, unitList, modules, items, data);
WriteExpend(sheet, sheetRead, modules, items, data);
break;
case SheetType.Workload:
WriteWorkload(sheet, sheetRead, unitList, modules, items, data);
WriteWorkload(sheet, sheetRead, modules, items, data);
break;
case SheetType.AccountBasic:
WriteAccountBasic(sheet, sheetRead);
......@@ -364,7 +357,7 @@ public string TemplateExecute(string email, sys_hospital hospital, List<sys_hosp
/// <param name="specials"></param>
/// <param name="extracts"></param>
/// <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<ex_result> 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 (string.IsNullOrEmpty(path)) throw new PerformanceException("历史绩效文件不存在!");
......@@ -375,23 +368,6 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
style = CellStyle.CreateCellStyle(workbook, StyleType.数据);
List<AccountUnitEntity> unitList = new List<AccountUnitEntity>();
if (lastAllot != null)
{
var deptDict = perforPerdeptdicRepository.GetEntities(t => t.HospitalId == Allot.HospitalId);
var units = EnumHelper.GetItems<UnitType>();
if (deptDict != null && deptDict.Any())
{
unitList = deptDict.Select(t => new AccountUnitEntity
{
AccountingUnit = t.AccountingUnit,
Department = t.Department,
UnitType = units.FirstOrDefault(en => en.Description == t.UnitType)?.Value ?? 0
}).ToList();
}
logger.LogInformation($"lastAllot.ID: {lastAllot.ID}, lastAllot date: {lastAllot.Year}-{lastAllot.Month}, unitList count: {unitList?.Count ?? 0}");
}
for (int i = 0; i < workbook.NumberOfSheets; i++)
{
var sheet = workbook.GetSheetAt(i);
......@@ -408,19 +384,19 @@ public string AlllotExecute(string email, sys_hospital hospital, List<sys_hospit
break;
case SheetType.OtherIncome:
ClearData(sheet, 5, 7);
WriteOtherIncome(sheet, sheetRead, unitList, modules, items, extracts, false);
WriteOtherIncome(sheet, sheetRead, modules, items, extracts, false);
break;
case SheetType.Income:
ClearData(sheet, 5, 7, true);
WriteIncome(sheet, sheetRead, unitList, modules, items, extracts, false);
WriteIncome(sheet, sheetRead, modules, items, extracts, false);
break;
case SheetType.Expend:
ClearData(sheet, 5, 7);
WriteExpend(sheet, sheetRead, unitList, modules, items, extracts, false);
WriteExpend(sheet, sheetRead, modules, items, extracts, false);
break;
case SheetType.Workload:
ClearData(sheet, 3, 3);
WriteWorkload(sheet, sheetRead, unitList, modules, items, extracts, false);
WriteWorkload(sheet, sheetRead, modules, items, extracts, false);
break;
case SheetType.AccountBasic:
WriteAccountBasic(sheet, sheetRead, false);
......@@ -506,7 +482,7 @@ private List<ex_result> QueryData(sys_hospitalconfig config, per_allot allot, st
/// </summary>
/// <param name="allot"></param>
/// <param name="configs"></param>
public void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
private void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
{
Dictionary<string, object> pairs = new Dictionary<string, object>
{
......@@ -559,6 +535,55 @@ public void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
}
}
private List<NewExtractDto> StandData(IEnumerable<ex_result> results)
{
if (results == null || !results.Any()) return new List<NewExtractDto>();
var dict = personService.GetDepartments(Allot.HospitalId).ToList();
if (dict == null || !dict.Any())
return results.Select(t => new NewExtractDto { Department = t.Department, Category = t.Category, Value = (t.Fee ?? 0) == 0 ? null : t.Fee }).ToList();
dict.ForEach(t =>
{
t.HISDeptName = HasValue(t.HISDeptName, t.Department);
});
var data = results.GroupJoin(dict, outer => new { Department = outer.Department }, inner => new { Department = inner.HISDeptName }, (outer, inner) => new { outer, inner })
.Select(t =>
{
var dept = !string.IsNullOrEmpty(t.inner.FirstOrDefault()?.Department) ? t.inner.FirstOrDefault()?.Department : t.outer.Department;
return new NewExtractDto
{
SheetName = t.outer.Source,
Department = dept,
Category = t.outer.Category,
Value = t.outer.Fee ?? 0, //(t.outer.Fee ?? 0) == 0 ? null : t.outer.Fee
OutDoctorAccounting = t.inner.FirstOrDefault(l => l.Department == dept)?.OutDoctorAccounting?.AccountingUnit,
OutNurseAccounting = t.inner.FirstOrDefault(l => l.Department == dept)?.OutNurseAccounting?.AccountingUnit,
OutTechnicAccounting = t.inner.FirstOrDefault(l => l.Department == dept)?.OutTechnicAccounting?.AccountingUnit,
InpatDoctorAccounting = t.inner.FirstOrDefault(l => l.Department == dept)?.InpatDoctorAccounting?.AccountingUnit,
InpatNurseAccounting = t.inner.FirstOrDefault(l => l.Department == dept)?.InpatNurseAccounting?.AccountingUnit,
InpatTechnicAccounting = t.inner.FirstOrDefault(l => l.Department == dept)?.InpatTechnicAccounting?.AccountingUnit,
};
});
data = data.GroupBy(t => new { t.Department, t.Category, t.SheetName }).Select(t => new NewExtractDto
{
SheetName = t.Key.SheetName,
Department = t.Key.Department,
Category = t.Key.Category,
Value = t.Sum(group => group.Value) == 0 ? null : t.Sum(group => group.Value),
OutDoctorAccounting = t.First().OutDoctorAccounting,
OutNurseAccounting = t.First().OutNurseAccounting,
OutTechnicAccounting = t.First().OutTechnicAccounting,
InpatDoctorAccounting = t.First().InpatDoctorAccounting,
InpatNurseAccounting = t.First().InpatNurseAccounting,
InpatTechnicAccounting = t.First().InpatTechnicAccounting,
});
return data.ToList();
}
#endregion
#region Excel
......@@ -949,7 +974,7 @@ private void WriteAccountBasic(ISheet sheet, IPerSheetDataRead sheetRead, bool i
}
}
private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ex_module> modules, List<ex_item> items, List<ex_result> data, bool isNewTemp = true)
private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_module> modules, List<ex_item> items, List<NewExtractDto> data, bool isNewTemp = true)
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var module = modules.FirstOrDefault(t => t.SheetType == (int)SheetType.OtherIncome);
......@@ -962,21 +987,18 @@ private void WriteOtherIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Ac
logger.LogInformation($"{sheet.SheetName}开始写入列头系数.");
WriteHeaderAndFactor(sheet, sheetRead, itemList.ToList(), isNewTemp);
var extractdata = data.Where(t => t.AllotId == Allot.ID && t.Source == module.ModuleName);
var extractdata = data.Where(t => t.SheetName == module.ModuleName);
logger.LogInformation($"data有{extractdata?.Count() ?? 0}个.");
if (extractdata == null || !extractdata.Any())
return;
//查询数据
List<ExtractDto> allExtract = extractdata.Select(t => new ExtractDto { Department = t.Department, Category = t.Category, Value = t.Fee ?? 0 }).ToList();
logger.LogInformation($"{sheet.SheetName}开始写入数据.");
WriteSheetData(sheet, sheetRead, unitList, allExtract, itemList.Select(t => t.ItemName), isNewTemp);
WriteSheetData(sheet, sheetRead, extractdata.ToList(), itemList.Select(t => t.ItemName), isNewTemp);
logger.LogInformation($"{sheet.SheetName}写入结束.");
}
private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ex_module> modules, List<ex_item> items, List<ex_result> data, bool isNewTemp = true)
private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_module> modules, List<ex_item> items, List<NewExtractDto> data, bool isNewTemp = true)
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var module = modules.FirstOrDefault(t => t.ModuleName.Replace(" ", "") == sheet.SheetName.Replace(" ", ""));
......@@ -984,7 +1006,7 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
var itemList = items.Where(t => t.ModuleId == module.Id)?.ToList() ?? new List<ex_item>();
var extractdata = data.Where(t => t.AllotId == Allot.ID && t.Source == module.ModuleName);
var extractdata = data.Where(t => t.SheetName == module.ModuleName);
logger.LogInformation($"data有{extractdata?.Count() ?? 0}个.");
if (extractdata == null || !extractdata.Any())
{
......@@ -995,9 +1017,8 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
}
//查询数据
List<ExtractDto> allExtract = extractdata.Select(t => new ExtractDto { Department = t.Department, Category = t.Category, Value = t.Fee ?? 0 }).ToList();
var category = allExtract.Select(t => t.Category?.Trim()).Distinct().ToList();
var category = extractdata.Select(t => t.Category?.Trim()).Distinct().ToList();
var existHead = category.Except(itemList.Select(i => i.ItemName?.Trim()));
if (existHead != null && existHead.Any())
itemList.AddRange(existHead.Select(t => new ex_item { ItemName = t, FactorValue1 = 0, FactorValue2 = 0, FactorValue3 = 0 }));
......@@ -1006,11 +1027,11 @@ private void WriteIncome(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
WriteHeaderAndFactor(sheet, sheetRead, itemList, isNewTemp);
logger.LogInformation($"{sheet.SheetName}开始写入数据.");
WriteSheetData(sheet, sheetRead, unitList, allExtract, itemList.Select(t => t.ItemName), isNewTemp, true);
WriteSheetData(sheet, sheetRead, extractdata.ToList(), itemList.Select(t => t.ItemName), isNewTemp, true);
logger.LogInformation($"{sheet.SheetName}写入结束.");
}
private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ex_module> modules, List<ex_item> items, List<ex_result> data, bool isNewTemp = true)
private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_module> modules, List<ex_item> items, List<NewExtractDto> data, bool isNewTemp = true)
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var module = modules.FirstOrDefault(t => t.SheetType == (int)SheetType.Expend);
......@@ -1023,20 +1044,17 @@ private void WriteExpend(ISheet sheet, IPerSheetDataRead sheetRead, List<Account
logger.LogInformation($"{sheet.SheetName}开始写入列头系数.");
WriteHeaderAndFactor(sheet, sheetRead, itemList.ToList(), isNewTemp);
var extractdata = data.Where(t => t.AllotId == Allot.ID && t.Source == module.ModuleName);
var extractdata = data.Where(t => t.SheetName == module.ModuleName);
logger.LogInformation($"data有{extractdata?.Count() ?? 0}个.");
if (extractdata == null || !extractdata.Any())
return;
//查询数据
List<ExtractDto> allExtract = extractdata.Select(t => new ExtractDto { Department = t.Department, Category = t.Category, Value = t.Fee ?? 0 }).ToList();
logger.LogInformation($"{sheet.SheetName}开始写入数据.");
WriteSheetData(sheet, sheetRead, unitList, allExtract, itemList.Select(t => t.ItemName), isNewTemp);
WriteSheetData(sheet, sheetRead, extractdata.ToList(), itemList.Select(t => t.ItemName), isNewTemp);
logger.LogInformation($"{sheet.SheetName}写入结束.");
}
private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ex_module> modules, List<ex_item> items, List<ex_result> data, bool isNewTemp = true)
private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_module> modules, List<ex_item> items, List<NewExtractDto> data, bool isNewTemp = true)
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var module = modules.FirstOrDefault(t => t.ModuleName.Replace(" ", "") == sheet.SheetName.Replace(" ", ""));
......@@ -1049,26 +1067,23 @@ private void WriteWorkload(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
logger.LogInformation($"{sheet.SheetName}开始写入列头系数.");
WriteWorkHeader(sheet, sheetRead, itemList.ToList(), isNewTemp);
var extractdata = data.Where(t => t.AllotId == Allot.ID && t.Source == module.ModuleName);
var extractdata = data.Where(t => t.SheetName == module.ModuleName);
logger.LogInformation($"data有{extractdata?.Count() ?? 0}个.");
if (extractdata == null || !extractdata.Any())
return;
//查询数据
List<ExtractDto> allExtract = extractdata.Select(t => new ExtractDto { Department = t.Department, Category = t.Category, Value = t.Fee ?? 0 }).ToList();
var specialHead = new List<string>();
var extractHead = allExtract?.Select(t => t.Category);
var extractHead = extractdata?.Select(t => t.Category);
if (extractHead != null && extractHead.Any())
specialHead = itemList.Select(t => t.ItemName).Intersect(extractHead.Distinct())?.ToList(); // 有数据的列添加样式
//写入数据
logger.LogInformation($"{sheet.SheetName}开始写入数据.");
WriteWorkData(sheet, sheetRead, unitList, allExtract, specialHead, isNewTemp);
WriteWorkData(sheet, sheetRead, extractdata.ToList(), specialHead, isNewTemp);
logger.LogInformation($"{sheet.SheetName}写入结束.");
}
private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_special> specials, List<ex_result> data, per_allot lastAllot = null, bool IsWriteHead = true)
private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_special> specials, List<NewExtractDto> data, per_allot lastAllot = null, bool IsWriteHead = true)
{
logger.LogInformation($"{sheet.SheetName}开始执行写入.");
var dictionary = new Dictionary<string, Func<ex_special, List<im_specialunit>, object>>
......@@ -1106,7 +1121,7 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
int mergedBegin = sheetRead.Point.DataFirstRowNum.Value;
int mergedEnd = sheetRead.Point.DataFirstRowNum.Value;
var extractdata = data.Where(t => t.AllotId == Allot.ID && t.Source == specialname).ToList();
var extractdata = data.Where(t => t.SheetName == specialname).ToList();
logger.LogInformation($"data有{extractdata?.Count ?? 0}个.");
logger.LogInformation($"{sheet.SheetName}开始写入数据.");
......@@ -1136,7 +1151,7 @@ private void WriteSpecialUnit(ISheet sheet, IPerSheetDataRead sheetRead, List<ex
}
if (cell.StringCellValue == "数量" && speaialList[i]?.TypeId > 0)
{
value = extractdata?.FirstOrDefault(t => t.Category == speaialList[i].Target)?.Fee;
value = extractdata?.FirstOrDefault(t => t.Category == speaialList[i].Target)?.Value;
}
if (!new List<string> { "量化指标", "数量", "量化指标绩效分值" }.Contains(cell.StringCellValue) && rowIndex == mergedBegin)
......@@ -1228,7 +1243,7 @@ private void WriteHeaderAndFactor(ISheet sheet, IPerSheetDataRead sheetRead, Lis
/// <param name="header">设定抽取的列头</param>
/// <param name="isNewTemp">是否为空白模板</param>
/// <param name="isIncom">是否是开单、执行收入</param>
private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ExtractDto> allExtract, IEnumerable<string> header, bool isNewTemp, bool isIncom = false)
private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewExtractDto> allExtract, IEnumerable<string> header, bool isNewTemp, bool isIncom = false)
{
logger.LogInformation($"提取绩效数据 填充数据 -- {sheet.SheetName}");
//写入数据
......@@ -1287,43 +1302,52 @@ private void WriteSheetData(ISheet sheet, IPerSheetDataRead sheetRead, List<Acco
{
var headName = head.GetCell(i).StringCellValue;
var newCell = row.CreateCell(i);
if (headName.Replace("\n", "") == "核算单元(医生组)")
{
var dept = unitList.FirstOrDefault(t => t.Department == department && t.UnitType == (int)UnitType.医生组)?.AccountingUnit;
newCell.SetCellValue(dept ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName.Replace("\n", "") == "核算单元(护理组)")
{
var dept = unitList.FirstOrDefault(t => t.Department == department && t.UnitType == (int)UnitType.护理组)?.AccountingUnit;
newCell.SetCellValue(dept ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName.Replace("\n", "") == "核算单元(医技组)")
{
var dept = unitList.FirstOrDefault(t => t.Department == department && t.UnitType == (int)UnitType.医技组)?.AccountingUnit;
newCell.SetCellValue(dept ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName == "科室名称")
var celldata = allExtract.FirstOrDefault(t => t.Department == department);
if (headName == "科室名称")
{
newCell.SetCellValue(department ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else
else if (celldata != null)
{
var value = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName)?.Value;
if (isIncom)
if (headName.Replace("\n", "") == "核算单元(医生组)")
{
var accounting = HasValue(celldata.OutDoctorAccounting, celldata.InpatDoctorAccounting);
if (sheet.SheetName.IndexOf("住院") > -1)
accounting = HasValue(celldata.InpatDoctorAccounting, celldata.OutDoctorAccounting);
newCell.SetCellValue(accounting ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName.Replace("\n", "") == "核算单元(护理组)")
{
var accounting = HasValue(celldata.OutNurseAccounting, celldata.InpatNurseAccounting);
if (sheet.SheetName.IndexOf("住院") > -1)
accounting = HasValue(celldata.InpatNurseAccounting, celldata.OutNurseAccounting);
newCell.SetCellValue(accounting ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName.Replace("\n", "") == "核算单元(医技组)")
{
value = value == 0 ? null : value;
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
var accounting = HasValue(celldata.OutTechnicAccounting, celldata.InpatTechnicAccounting);
if (sheet.SheetName.IndexOf("住院") > -1)
accounting = HasValue(celldata.InpatTechnicAccounting, celldata.OutTechnicAccounting);
newCell.SetCellValue(accounting ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (header != null && header.Contains(headName))
else
{
value = value == 0 ? null : value;
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
celldata = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName);
if (isIncom)
{
OutToExcelCell(newCell, celldata?.Value);
newCell.CellStyle = style;
}
else if (header != null && header.Contains(headName))
{
OutToExcelCell(newCell, celldata?.Value);
newCell.CellStyle = style;
}
}
}
}
......@@ -1388,7 +1412,7 @@ private void WriteWorkHeader(ISheet sheet, IPerSheetDataRead sheetRead, List<ex_
/// <param name="allExtract"></param>
/// <param name="header"></param>
/// <param name="isNewTemp"></param>
private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<AccountUnitEntity> unitList, List<ExtractDto> allExtract, IEnumerable<string> header, bool isNewTemp)
private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<NewExtractDto> allExtract, IEnumerable<string> header, bool isNewTemp)
{
var head = GetOrCreate(sheet, sheetRead.Point.HeaderFirstRowNum.Value + 0);
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 2;
......@@ -1429,7 +1453,7 @@ private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
if (allExtract == null || !allExtract.Any()) return;
var unit = sheet.SheetName.IndexOf("医生") > -1 ? new int[] { (int)UnitType.医生组, (int)UnitType.医技组 } : new int[] { (int)UnitType.护理组 };
//var unit = sheet.SheetName.IndexOf("医生") > -1 ? new int[] { (int)UnitType.医生组, (int)UnitType.医技组 } : new int[] { (int)UnitType.护理组 };
#region 补充新的科室及数据
var lastrowIndex = isNewTemp ? rowIndex : sheet.LastRowNum + 1;
......@@ -1440,31 +1464,42 @@ private void WriteWorkData(ISheet sheet, IPerSheetDataRead sheetRead, List<Accou
{
var headName = head.GetCell(i).StringCellValue;
var newCell = row.CreateCell(i);
if (headName == "核算单元")
var celldata = allExtract.FirstOrDefault(t => t.Department == department);
if (headName == "科室名称")
{
var dept = unitList.FirstOrDefault(t => unit.Contains(t.UnitType) && t.Department == department)?.AccountingUnit
?? unitList.FirstOrDefault(t => t.Department == department)?.AccountingUnit;
newCell.SetCellValue(dept ?? "");
newCell.SetCellValue(department);
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else if (headName == "科室名称")
else if (celldata != null)
{
newCell.SetCellValue(department ?? "");
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else
{
var extract = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName);
var value = extract?.Value == 0 ? null : extract?.Value;
OutToExcelCell(newCell, value);
if (header != null && header.Contains(headName))
newCell.CellStyle = style;
if (headName == "核算单元")
{
var accounting = sheet.SheetName.IndexOf("医生") > -1
? HasValue(celldata.OutDoctorAccounting, celldata.InpatDoctorAccounting, celldata.OutTechnicAccounting, celldata.InpatTechnicAccounting)
: (celldata.OutNurseAccounting ?? celldata.InpatNurseAccounting);
newCell.SetCellValue(accounting);
newCell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.默认);
}
else
{
var extract = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName);
OutToExcelCell(newCell, extract?.Value);
if (header != null && header.Contains(headName))
newCell.CellStyle = style;
}
}
}
lastrowIndex++;
}
#endregion
}
private string HasValue(params string[] list)
{
if (list == null || !list.Any()) return null;
return list.FirstOrDefault(t => !string.IsNullOrEmpty(t));
}
#endregion
#endregion
......@@ -1621,4 +1656,16 @@ public class AccountBasic
public decimal? PermanentStaff { get; set; }
public int IsDelete { get; set; }
}
public class NewExtractDto : ExtractDto
{
public string SheetName { get; set; }
public string OutDoctorAccounting { get; set; }
public string OutNurseAccounting { get; set; }
public string OutTechnicAccounting { get; set; }
public string InpatDoctorAccounting { get; set; }
public string InpatNurseAccounting { get; set; }
public string InpatTechnicAccounting { get; set; }
public new decimal? Value { get; set; }
}
}
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