Commit 157f5009 by lcx

抽取测试修改

parent eea7bc11
......@@ -44,11 +44,14 @@ public static void SetCellOValue(this ICell cell, object value)
if (cell == null) return;
if (value == null || string.IsNullOrWhiteSpace(value.ToString()))
{
cell.SetCellValue("");
return;
}
try
{
string stringV = value.ToString();
string stringV = value.ToString().Trim();
var type = value.GetType();
switch (type.ToString())
{
......@@ -135,6 +138,13 @@ public static string GetDecodeEscapes(this ICell cell)
}
}
public static string NoBlank(this string @string)
{
if (string.IsNullOrEmpty(@string))
return "";
return @string.Replace("\n", "").Replace(" ", "").Trim();
}
public static IWorkbook GetWorkbook(string filePath)
{
IWorkbook workbook = null;
......
......@@ -23,9 +23,9 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
var columns = headers.Select(t => t).ToList();
// 收入支出系数
var nurseFactor = sheet.GetOrCreate(point.AccountingUnit.First(t => t.UnitType == UnitType.护理组.ToString()).FactorRow.Value);
var doctorFactor = sheet.GetRow(point.AccountingUnit.First(t => t.UnitType == UnitType.医生组.ToString()).FactorRow.Value);
var technicianFactor = sheet.GetRow(point.AccountingUnit.First(t => t.UnitType == UnitType.医技组.ToString()).FactorRow.Value);
var nurseFactor = sheet.GetOrCreate(point.AccountingUnit.FirstOrDefault(t => t.UnitType == UnitType.护理组.ToString())?.FactorRow.Value ?? 0);
var doctorFactor = sheet.GetOrCreate(point.AccountingUnit.FirstOrDefault(t => t.UnitType == UnitType.医生组.ToString())?.FactorRow.Value ?? 0);
var technicianFactor = sheet.GetOrCreate(point.AccountingUnit.FirstOrDefault(t => t.UnitType == UnitType.医技组.ToString())?.FactorRow.Value ?? 0);
// 费用类型
var columnHeader = sheet.GetOrCreate(point.HeaderFirstRowNum.Value);
// 工作量系数
......@@ -152,7 +152,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var row = sheet.GetOrCreate(dataFirstRowNum);
for (int cellIndex = point.HeaderFirstCellNum.Value; cellIndex < columnHeader.LastCellNum; cellIndex++)
{
var column = row.GetCell(cellIndex).GetDecodeEscapes();
var column = columnHeader.GetCell(cellIndex).GetDecodeEscapes();
var cell = row.CreateCell(cellIndex);
if (filed.ContainsKey(column))
......
......@@ -74,7 +74,7 @@ public string Main(int allotId, int hospitalId, string email, string groupName =
var templateFilePath = ExtractHelper.GetExtractFile(hospitalId, ref extractFilePath, filePath);
WriteDataToFile(templateFilePath, extractFilePath, dict);
WriteDataToFile(templateFilePath, extractFilePath, dict, standData);
return templateFilePath;
}
......@@ -90,9 +90,9 @@ public string Main(int allotId, int hospitalId, string email, string groupName =
return extractFilePath;
}
private void WriteDataToFile(string templateFile, string extractFile, Dictionary<ExDataDict, object> exdict)
private void WriteDataToFile(string templateFile, string extractFile, Dictionary<ExDataDict, object> exdict, List<ExtractTransDto> extractDto)
{
if (!FileHelper.IsExistFile(templateFile) || !FileHelper.IsExistFile(extractFile))
if (!FileHelper.IsExistFile(templateFile))
throw new PerformanceException("");
var workbook = ExcelHelper.GetWorkbook(templateFile);
......@@ -111,7 +111,11 @@ private void WriteDataToFile(string templateFile, string extractFile, Dictionary
var point = PerSheetDataFactory.GetDataRead(sheetType)?.Point;
var customer = factory.GetWriteData(sheetType);
customer.WriteSheetData(sheet, point, sheetType, exdict);
if (customer != null)
{
var data = extractDto.Where(t => t.SheetName.NoBlank() == sheet.SheetName.NoBlank())?.ToList();
customer.WriteSheetData(sheet, point, sheetType, data, exdict);
}
}
using (FileStream file = new FileStream(extractFile, FileMode.OpenOrCreate))
......@@ -139,7 +143,7 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re
PersonnelNumber = t.PersonnelNumber,
Department = t.Department,
Category = t.Category,
Value = (t.Fee ?? 0) == 0 ? null : t.Fee
Value = t.Fee ?? 0
}).ToList();
dict.ForEach(t =>
......
......@@ -65,7 +65,12 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, ref Dictionary<E
var configs = hosconfigRepository.GetEntities(t => t.HospitalId == hospitalId);
if (configs == null || !configs.Any()) throw new Exception("医院未配置绩效抽取信息");
dict = new Dictionary<ExDataDict, object>();
dict = new Dictionary<ExDataDict, object>
{
{ ExDataDict.ExModule, new List<ex_module>() },
{ ExDataDict.ExItem, new List<ex_item>() },
{ ExDataDict.ExSpecial, new List<ex_script>() }
};
var extypeIds = GetQueryScriptIds(hospitalId, ref dict);
ClearHistoryData(allot.ID);
......@@ -74,8 +79,7 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, ref Dictionary<E
var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
if (scripts != null && scripts.Any())
{
var allmodules = new List<ex_module>();
if (dict.ContainsKey(ExDataDict.ExModule)) allmodules = dict[ExDataDict.ExModule] as List<ex_module>;
var allmodules = dict[ExDataDict.ExModule] as List<ex_module>;
foreach (var pair in dict)
{
......@@ -116,13 +120,13 @@ private List<int> GetQueryScriptIds(int hospitalId, ref Dictionary<ExDataDict, o
var items = new List<ex_item>();
if (modules != null && modules.Any())
{
dict.Add(ExDataDict.ExModule, modules);
dict[ExDataDict.ExModule] = modules;
extypeIds.AddRange(modules.Select(t => t.TypeId ?? 0));
items = exitemRepository.GetEntities(t => t.ModuleId.HasValue && modules.Select(m => m.Id).Contains(t.ModuleId.Value));
if (items != null && items.Any(t => t.TypeId.HasValue))
{
dict.Add(ExDataDict.ExItem, items);
dict[ExDataDict.ExItem] = items;
extypeIds.AddRange(items.Select(t => t.TypeId ?? 0));
}
}
......@@ -130,7 +134,7 @@ private List<int> GetQueryScriptIds(int hospitalId, ref Dictionary<ExDataDict, o
var specials = exspecialRepository.GetEntities(t => t.HospitalId == hospitalId);
if (specials != null && specials.Any())
{
dict.Add(ExDataDict.ExSpecial, specials);
dict[ExDataDict.ExSpecial] = specials;
extypeIds.AddRange(specials.Select(t => t.TypeId ?? 0));
}
......
......@@ -13,7 +13,7 @@ public class IncomeDataWrite : ISheetDataWrite
public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, object data, Dictionary<ExDataDict, object> exdict = null)
{
var modules = exdict[ExDataDict.ExModule] as List<ex_module>;
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType);
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.NoBlank() == sheet.SheetName.NoBlank());
if (module == null) return;
var items = exdict[ExDataDict.ExItem] as List<ex_item>;
......
......@@ -13,7 +13,7 @@ public class OtherIncomeDataWrite : ISheetDataWrite
public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, object data, Dictionary<ExDataDict, object> exdict = null)
{
var modules = exdict[ExDataDict.ExModule] as List<ex_module>;
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType);
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.NoBlank() == sheet.SheetName.NoBlank());
if (module == null) return;
var items = exdict[ExDataDict.ExItem] as List<ex_item>;
......
......@@ -13,7 +13,7 @@ public class WorkloadDataWrite : ISheetDataWrite
public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, object data, Dictionary<ExDataDict, object> exdict = null)
{
var modules = exdict[ExDataDict.ExModule] as List<ex_module>;
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType);
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.NoBlank() == sheet.SheetName.NoBlank());
if (module == null) return;
var items = exdict[ExDataDict.ExItem] as List<ex_item>;
......
......@@ -13,12 +13,12 @@ public ISheetDataWrite GetWriteData(SheetType sheetType)
ISheetDataWrite factory;
switch (sheetType)
{
case SheetType.Employee:
factory = new EmployeeDataWrite();
break;
case SheetType.ClinicEmployee:
factory = new ClinicEmployeeDataWrite();
break;
//case SheetType.Employee:
// factory = new EmployeeDataWrite();
// break;
//case SheetType.ClinicEmployee:
// factory = new ClinicEmployeeDataWrite();
// break;
case SheetType.OtherIncome:
case SheetType.Expend:
factory = new OtherIncomeDataWrite();
......@@ -29,12 +29,12 @@ public ISheetDataWrite GetWriteData(SheetType sheetType)
case SheetType.Workload:
factory = new WorkloadDataWrite();
break;
case SheetType.AccountBasic:
factory = new AccountBasicDataWrite();
break;
case SheetType.SpecialUnit:
factory = new SpecialUnitDataWrite();
break;
//case SheetType.AccountBasic:
// factory = new AccountBasicDataWrite();
// break;
//case SheetType.SpecialUnit:
// factory = new SpecialUnitDataWrite();
// break;
default:
return null;
}
......
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