Commit b71df7c9 by 李承祥

列头、特殊科室

parent ca1235ce
...@@ -233,7 +233,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r ...@@ -233,7 +233,7 @@ public ApiResponse NewExtractData([CustomizeValidator, FromBody]ExtractRequest r
} }
else else
{ {
return new ApiResponse(ResponseType.Fail, "该功能暂未实现!");
} }
return new ApiResponse(ResponseType.Error, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!"); return new ApiResponse(ResponseType.Error, "HIS绩效数据提取任务正在执行,稍后我们将以邮件的通知您!");
} }
......
...@@ -50,13 +50,19 @@ public static ICellStyle CreateCellStyle(IWorkbook wb, StyleType type = StyleTyp ...@@ -50,13 +50,19 @@ public static ICellStyle CreateCellStyle(IWorkbook wb, StyleType type = StyleTyp
cellStyle.SetFont(font); cellStyle.SetFont(font);
//居中
cellStyle.Alignment = HorizontalAlignment.Center;//水平居中
cellStyle.VerticalAlignment = VerticalAlignment.Center;//垂直居中
switch (type) switch (type)
{ {
case StyleType.列头: case StyleType.列头:
cellStyle.FillForegroundColor = HSSFColor.Orange.Index; cellStyle.FillForegroundColor = HSSFColor.Gold.Index;
cellStyle.FillPattern = FillPattern.SolidForeground;
break; break;
case StyleType.系数: case StyleType.系数:
cellStyle.FillForegroundColor = HSSFColor.Green.Index; cellStyle.FillForegroundColor = HSSFColor.Green.Index;
cellStyle.FillPattern = FillPattern.SolidForeground;
break; break;
case StyleType.默认: case StyleType.默认:
cellStyle.SetFont(font); cellStyle.SetFont(font);
......
...@@ -43,6 +43,7 @@ public class NewExtractService : IAutoInjection ...@@ -43,6 +43,7 @@ public class NewExtractService : IAutoInjection
private readonly PerforImspecialunitRepository perforImspecialunitRepository; private readonly PerforImspecialunitRepository perforImspecialunitRepository;
private readonly PerforImdataRepository perforImdataRepository; private readonly PerforImdataRepository perforImdataRepository;
private IWorkbook workbook = null;
private ICellStyle style; private ICellStyle style;
public NewExtractService(ILogger<ExtractService> logger, public NewExtractService(ILogger<ExtractService> logger,
...@@ -102,8 +103,6 @@ public string ExtractData(int allotId, string email, int hospitalId) ...@@ -102,8 +103,6 @@ public string ExtractData(int allotId, string email, int hospitalId)
var extractList = perforModextractRepository.GetEntities(t => extractIdList.Contains(t.Id)); var extractList = perforModextractRepository.GetEntities(t => extractIdList.Contains(t.Id));
IWorkbook workbook = null;
try try
{ {
var (tempPath, newPath) = CopyOriginalFile(hospitalId); var (tempPath, newPath) = CopyOriginalFile(hospitalId);
...@@ -115,7 +114,8 @@ public string ExtractData(int allotId, string email, int hospitalId) ...@@ -115,7 +114,8 @@ public string ExtractData(int allotId, string email, int hospitalId)
style = workbook.CreateCellStyle(); style = workbook.CreateCellStyle();
//字体 //字体
IFont titleFont = workbook.CreateFont(); IFont titleFont = workbook.CreateFont();
titleFont.FontHeightInPoints = 12;//设置字体大小 titleFont.FontHeightInPoints = 11;
titleFont.FontName = "微软雅黑";//设置字体大小
titleFont.Color = HSSFColor.Black.Index;//设置字体颜色 titleFont.Color = HSSFColor.Black.Index;//设置字体颜色
style.SetFont(titleFont); style.SetFont(titleFont);
...@@ -186,7 +186,7 @@ public string ExtractData(int allotId, string email, int hospitalId) ...@@ -186,7 +186,7 @@ public string ExtractData(int allotId, string email, int hospitalId)
} }
finally finally
{ {
allot.IsExtracting = 3; allot.IsExtracting = null;
perforPerallotRepository.Update(allot); perforPerallotRepository.Update(allot);
workbook.Close(); workbook.Close();
GC.Collect(); GC.Collect();
...@@ -238,10 +238,21 @@ private void WriteOtherIncome(ISheet sheet, int hospitalId, IPerSheetDataRead sh ...@@ -238,10 +238,21 @@ private void WriteOtherIncome(ISheet sheet, int hospitalId, IPerSheetDataRead sh
//写入列头信息 //写入列头信息
foreach (var item in itemList) foreach (var item in itemList)
{ {
head.GetCell(cellStartIndex).SetCellValue(item.ItemName); var headcell = head.GetCell(cellStartIndex);
doctorFactor.GetCell(cellStartIndex).SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0); headcell.SetCellValue(item.ItemName);
nurseFactor.GetCell(cellStartIndex).SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0); headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
technicianFactor.GetCell(cellStartIndex).SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
var doctorcell = doctorFactor.GetCell(cellStartIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var nursecell = nurseFactor.GetCell(cellStartIndex);
nursecell.SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0);
nursecell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var techniciancell = technicianFactor.GetCell(cellStartIndex);
techniciancell.SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
techniciancell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
cellStartIndex++; cellStartIndex++;
} }
} }
...@@ -263,10 +274,21 @@ private void WriteIncome(ISheet sheet, int hospitalId, List<AccountUnitEntity> u ...@@ -263,10 +274,21 @@ private void WriteIncome(ISheet sheet, int hospitalId, List<AccountUnitEntity> u
int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 4; int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 4;
foreach (var item in itemList) foreach (var item in itemList)
{ {
GetOrCreate(head, cellStartIndex).SetCellValue(item.ItemName); var headcell = GetOrCreate(head, cellStartIndex);
GetOrCreate(doctorFactor, cellStartIndex).SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0); headcell.SetCellValue(item.ItemName);
GetOrCreate(nurseFactor, cellStartIndex).SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0); headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
GetOrCreate(technicianFactor, cellStartIndex).SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
var doctorcell = GetOrCreate(doctorFactor, cellStartIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var nursecell = GetOrCreate(nurseFactor, cellStartIndex);
nursecell.SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0);
nursecell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var techniciancell = GetOrCreate(technicianFactor, cellStartIndex);
techniciancell.SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
techniciancell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
cellStartIndex++; cellStartIndex++;
} }
//查询数据 //查询数据
...@@ -367,8 +389,13 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity> ...@@ -367,8 +389,13 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 2; int cellStartIndex = sheetRead.Point.HeaderFirstCellNum.Value + 2;
foreach (var item in itemList) foreach (var item in itemList)
{ {
GetOrCreate(head, cellStartIndex).SetCellValue(item.ItemName); var headcell = GetOrCreate(head, cellStartIndex);
GetOrCreate(factor, cellStartIndex).SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0); headcell.SetCellValue(item.ItemName);
headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
var doctorcell = GetOrCreate(factor, cellStartIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
cellStartIndex++; cellStartIndex++;
} }
//查询数据 //查询数据
...@@ -388,6 +415,13 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity> ...@@ -388,6 +415,13 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
allExtract.AddRange(result); allExtract.AddRange(result);
} }
} }
var specialHead = new List<string>();
var extractHead = allExtract?.Select(t => t.Category);
if (extractHead != null && extractHead.Any())
{
specialHead = itemList.Select(t => t.ItemName).Intersect(extractHead.Distinct())?.ToList();
}
//写入数据 //写入数据
var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 2; var rowIndex = sheetRead.Point.HeaderFirstRowNum.Value + 2;
foreach (var department in allExtract.Select(t => t.Department).Distinct()) foreach (var department in allExtract.Select(t => t.Department).Distinct())
...@@ -408,11 +442,11 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity> ...@@ -408,11 +442,11 @@ private void WriteWorkload(ISheet sheet, int hospitalId, List<AccountUnitEntity>
} }
else else
{ {
var value = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName)?.Value; var extract = allExtract.FirstOrDefault(t => t.Department == department && t.Category == headName);
value = value == 0 ? null : value; var value = extract?.Value == 0 ? null : extract?.Value;
OutToExcelCell(newCell, value); OutToExcelCell(newCell, value);
//newCell.SetCellValue(value == null || value == 0 ? "" : value.ToString()); //newCell.SetCellValue(value == null || value == 0 ? "" : value.ToString());
if (itemList.Select(t => t.ItemName).Contains(headName)) if (specialHead != null && specialHead.Contains(headName))
newCell.CellStyle = style; newCell.CellStyle = style;
} }
} }
...@@ -453,9 +487,6 @@ private void WriteExpend(ISheet sheet, int hospitalId, IPerSheetDataRead sheetRe ...@@ -453,9 +487,6 @@ private void WriteExpend(ISheet sheet, int hospitalId, IPerSheetDataRead sheetRe
var itemList = perforModitemRepository.GetEntities(t => t.ModuleId == module.Id); var itemList = perforModitemRepository.GetEntities(t => t.ModuleId == module.Id);
if (itemList == null || !itemList.Any()) return; if (itemList == null || !itemList.Any()) return;
//var head = sheet.GetRow(sheetRead.Point.HeaderFirstRowNum.Value + 1);
//var nurseFactor = sheet.GetRow(sheetRead.Point.HeaderFirstRowNum.Value + 2);
//var doctorFactor = sheet.GetRow(sheetRead.Point.HeaderFirstRowNum.Value + 3);
var nurseFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "护理组").FactorRow.Value); var nurseFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "护理组").FactorRow.Value);
var doctorFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "医生组").FactorRow.Value); var doctorFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "医生组").FactorRow.Value);
var technicianFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "医技组").FactorRow.Value); var technicianFactor = sheet.GetRow(sheetRead.Point.AccountingUnit.First(t => t.UnitType == "医技组").FactorRow.Value);
...@@ -465,10 +496,21 @@ private void WriteExpend(ISheet sheet, int hospitalId, IPerSheetDataRead sheetRe ...@@ -465,10 +496,21 @@ private void WriteExpend(ISheet sheet, int hospitalId, IPerSheetDataRead sheetRe
//写入列头信息 //写入列头信息
foreach (var item in itemList) foreach (var item in itemList)
{ {
GetOrCreate(head, cellStartIndex).SetCellValue(item.ItemName); var headcell = GetOrCreate(head, cellStartIndex);
GetOrCreate(doctorFactor, cellStartIndex).SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0); headcell.SetCellValue(item.ItemName);
GetOrCreate(nurseFactor, cellStartIndex).SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0); headcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.列头);
GetOrCreate(technicianFactor, cellStartIndex).SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
var doctorcell = GetOrCreate(doctorFactor, cellStartIndex);
doctorcell.SetCellValue(item.FactorValue1 != null ? (double)item.FactorValue1 : 0);
doctorcell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var nursecell = GetOrCreate(nurseFactor, cellStartIndex);
nursecell.SetCellValue(item.FactorValue2 != null ? (double)item.FactorValue2 : 0);
nursecell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
var techniciancell = GetOrCreate(technicianFactor, cellStartIndex);
techniciancell.SetCellValue(item.FactorValue3 != null ? (double)item.FactorValue3 : 0);
techniciancell.CellStyle = CellStyle.CreateCellStyle(workbook, StyleType.系数, CellFormat.百分比);
cellStartIndex++; cellStartIndex++;
} }
} }
...@@ -531,7 +573,7 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast, ...@@ -531,7 +573,7 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast,
{ "人数", (special,lastAllot) => lastAllot.Where(t=>special.Department == t.Department).Sum(t=>t.Number) }, { "人数", (special,lastAllot) => lastAllot.Where(t=>special.Department == t.Department).Sum(t=>t.Number) },
{ "量化指标", (special,lastAllot) => special.Target}, { "量化指标", (special,lastAllot) => special.Target},
{ "量化指标绩效分值",(special,lastAllot) => special.TargetFactor }, { "量化指标绩效分值",(special,lastAllot) => special.TargetFactor },
{ "调节系数", (special,lastAllot) => lastAllot.Where(t=>special.Department == t.Department).Max(t=>t.Adjust) }, { "调节系数", (special,lastAllot) => special.AdjustFactor },
}; };
var modDataList = perforModspecialRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.Department).ToList(); var modDataList = perforModspecialRepository.GetEntities(t => t.HospitalId == hospitalId)?.OrderBy(t => t.Department).ToList();
...@@ -571,44 +613,31 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast, ...@@ -571,44 +613,31 @@ private void WriteSpecialUnit(ISheet sheet, int hospitalId, per_allot allotLast,
foreach (var cell in cellList) foreach (var cell in cellList)
{ {
object value = null;
if (dictionary.ContainsKey(cell.StringCellValue)) if (dictionary.ContainsKey(cell.StringCellValue))
{ {
var item = dictionary.First(t => t.Key == cell.StringCellValue); var item = dictionary.First(t => t.Key == cell.StringCellValue);
var value = item.Value.Invoke(modDataList[i], allotDataList) ?? ""; value = item.Value.Invoke(modDataList[i], allotDataList) ?? "";
if (!new List<string> { "量化指标", "数量", "量化指标绩效分值" }.Contains(cell.StringCellValue) && rowIndex == mergedBegin) if (item.Key == "科室" && rowIndex == mergedBegin)
{
if (item.Key == "科室")
{ {
var count = modDataGroup.First(t => t.Department.ToString() == value.ToString()).Count; var count = modDataGroup.First(t => t.Department.ToString() == value.ToString()).Count;
mergedEnd = mergedBegin + count - 1; mergedEnd = mergedBegin + count - 1;
} }
CellRangeAddress region = new CellRangeAddress(mergedBegin, mergedEnd, cellIndex, cellIndex);
sheet.AddMergedRegion(region); //合并单元格
var newCell = importRow.CreateCell(cellIndex);
//newCell.SetCellValue(Verify(value));
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
} }
else
{
var newCell = importRow.CreateCell(cell.ColumnIndex);
//newCell.SetCellValue(Verify(value));
OutToExcelCell(newCell, value);
newCell.CellStyle = style;
}
}
else
{
if (!new List<string> { "量化指标", "数量", "量化指标绩效分值" }.Contains(cell.StringCellValue) && rowIndex == mergedBegin) if (!new List<string> { "量化指标", "数量", "量化指标绩效分值" }.Contains(cell.StringCellValue) && rowIndex == mergedBegin)
{ {
CellRangeAddress region = new CellRangeAddress(mergedBegin, mergedEnd, cellIndex, cellIndex); CellRangeAddress region = new CellRangeAddress(mergedBegin, mergedEnd, cellIndex, cellIndex);
sheet.AddMergedRegion(region); //合并单元格 sheet.AddMergedRegion(region); //合并单元格
}
var newCell = importRow.CreateCell(cellIndex); var newCell = importRow.CreateCell(cellIndex);
newCell.SetCellValue(""); //newCell.SetCellValue(Verify(value));
OutToExcelCell(newCell, value);
if (dictionary.ContainsKey(cell.StringCellValue))
newCell.CellStyle = style; newCell.CellStyle = style;
}
}
cellIndex++; cellIndex++;
} }
mergedBegin = mergedEnd + 1; mergedBegin = mergedEnd + 1;
......
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