Commit 84bbf135 by lcx

特殊科室抽取完成、取消测试时注释的代码

parent 0ee51efa
...@@ -45,8 +45,7 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue ...@@ -45,8 +45,7 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue
try try
{ {
var type = defaultValue.GetType(); switch (typeof(T).ToString())
switch (type.ToString())
{ {
#region SetValue #region SetValue
...@@ -69,9 +68,7 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue ...@@ -69,9 +68,7 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue
case "System.Double": case "System.Double":
cell.SetCellValue(ConvertHelper.To<double>(value)); cell.SetCellValue(ConvertHelper.To<double>(value));
break; break;
case "System.DBNull"://空值处理 case "System.DBNull"://空值处理
cell.SetCellValue("");
break;
default: default:
cell.SetCellValue(""); cell.SetCellValue("");
break; break;
......
...@@ -76,27 +76,27 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, ref Dictionary<E ...@@ -76,27 +76,27 @@ public List<ex_result> Handler(int hospitalId, per_allot allot, ref Dictionary<E
ClearHistoryData(allot.ID); ClearHistoryData(allot.ID);
var data = new List<ex_result>(); var data = new List<ex_result>();
//var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId)); var scripts = exscriptRepository.GetEntities(t => extypeIds.Contains(t.TypeId));
//if (scripts != null && scripts.Any()) if (scripts != null && scripts.Any())
//{ {
// var allmodules = dict[ExDataDict.ExModule] as List<ex_module>; var allmodules = dict[ExDataDict.ExModule] as List<ex_module>;
// foreach (var pair in dict) foreach (var pair in dict)
// { {
// switch (pair.Key) switch (pair.Key)
// { {
// case ExDataDict.ExModule: case ExDataDict.ExModule:
// data.AddRange(ExtractModuleData(allot, scripts, configs, pair.Value)); data.AddRange(ExtractModuleData(allot, scripts, configs, pair.Value));
// break; break;
// case ExDataDict.ExItem: case ExDataDict.ExItem:
// data.AddRange(ExtractItemData(allot, scripts, configs, allmodules, pair.Value)); data.AddRange(ExtractItemData(allot, scripts, configs, allmodules, pair.Value));
// break; break;
// case ExDataDict.ExSpecial: case ExDataDict.ExSpecial:
// data.AddRange(ExtractSpecialData(allot, scripts, configs, pair.Value)); data.AddRange(ExtractSpecialData(allot, scripts, configs, pair.Value));
// break; break;
// } }
// } }
//} }
return data; return data;
} }
catch (Exception ex) catch (Exception ex)
...@@ -181,7 +181,7 @@ private List<ex_result> ExtractModuleData(per_allot allot, List<ex_script> scrip ...@@ -181,7 +181,7 @@ private List<ex_result> ExtractModuleData(per_allot allot, List<ex_script> scrip
{ {
foreach (var script in scripts.Where(t => t.TypeId == typeId)) foreach (var script in scripts.Where(t => t.TypeId == typeId))
{ {
var config = configs.FirstOrDefault(t => t.Id == script.ConfigId); var config = configs.FirstOrDefault(t => t.Id == script.ConfigId) ?? configs.FirstOrDefault(t => t.DataBaseType == script.DatabaseType);
if (config == null) continue; if (config == null) continue;
var querydata = QueryData(config, allot, script.ExecScript); var querydata = QueryData(config, allot, script.ExecScript);
......
...@@ -48,8 +48,8 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp ...@@ -48,8 +48,8 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
}).ToList(); }).ToList();
SupplySpecialQuantity(sheet, style, specials, needMergedRegions, columns, ref dataFirstRowNum); SupplySpecialQuantity(sheet, style, specials, needMergedRegions, columns, ref dataFirstRowNum);
//AddNewSpecialConfig(sheet, style, specials, needMergedRegions, columns, dataFirstRowNum); AddNewSpecialConfig(sheet, style, specials, needMergedRegions, columns, dataFirstRowNum);
//AddMergedRegion(sheet, needMergedRegions, columns); AddMergedRegion(sheet, needMergedRegions, columns);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -57,6 +57,13 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp ...@@ -57,6 +57,13 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
} }
} }
/// <summary>
/// 清除特殊科室数据(数量)
/// </summary>
/// <param name="sheet"></param>
/// <param name="columns"></param>
/// <param name="dataFirstRowNum"></param>
/// <param name="clear"></param>
private void ClearSheetPartialData(ISheet sheet, List<string> columns, int dataFirstRowNum, params string[] clear) private void ClearSheetPartialData(ISheet sheet, List<string> columns, int dataFirstRowNum, params string[] clear)
{ {
if (sheet == null) return; if (sheet == null) return;
...@@ -79,6 +86,11 @@ private void ClearSheetPartialData(ISheet sheet, List<string> columns, int dataF ...@@ -79,6 +86,11 @@ private void ClearSheetPartialData(ISheet sheet, List<string> columns, int dataF
} }
} }
/// <summary>
/// 取消合并单元格
/// </summary>
/// <param name="sheet"></param>
/// <param name="mergedRegions"></param>
private void RemoveMergedRegion(ISheet sheet, ref List<SpecialCellRange> mergedRegions) private void RemoveMergedRegion(ISheet sheet, ref List<SpecialCellRange> mergedRegions)
{ {
if (sheet.NumMergedRegions > 0) if (sheet.NumMergedRegions > 0)
...@@ -94,6 +106,12 @@ private void RemoveMergedRegion(ISheet sheet, ref List<SpecialCellRange> mergedR ...@@ -94,6 +106,12 @@ private void RemoveMergedRegion(ISheet sheet, ref List<SpecialCellRange> mergedR
} }
} }
/// <summary>
/// 补充取消单元格后的剩余单元格数据
/// </summary>
/// <param name="sheet"></param>
/// <param name="style"></param>
/// <param name="mergedRegions"></param>
private void SupplyMergedRegionData(ISheet sheet, ExcelStyle style, List<SpecialCellRange> mergedRegions) private void SupplyMergedRegionData(ISheet sheet, ExcelStyle style, List<SpecialCellRange> mergedRegions)
{ {
if (mergedRegions == null || !mergedRegions.Any(t => t.FirstRow > 1)) return; if (mergedRegions == null || !mergedRegions.Any(t => t.FirstRow > 1)) return;
...@@ -128,10 +146,20 @@ private void SupplyMergedRegionData(ISheet sheet, ExcelStyle style, List<Special ...@@ -128,10 +146,20 @@ private void SupplyMergedRegionData(ISheet sheet, ExcelStyle style, List<Special
} }
} }
/// <summary>
/// 补充已存在数据的抽取数据
/// </summary>
/// <param name="sheet"></param>
/// <param name="style"></param>
/// <param name="specials"></param>
/// <param name="ranges"></param>
/// <param name="columns"></param>
/// <param name="dataFirstRowNum"></param>
private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialDto> specials, List<SpecialCellRange> ranges, List<string> columns, ref int dataFirstRowNum) private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialDto> specials, List<SpecialCellRange> ranges, List<string> columns, ref int dataFirstRowNum)
{ {
if (sheet == null) return; if (sheet == null) return;
var rowStyle = style.GetCellStyle();
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据); var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
var quantityIndex = columns.IndexOf(SpecialUnitColumns.Quantity); var quantityIndex = columns.IndexOf(SpecialUnitColumns.Quantity);
...@@ -147,18 +175,11 @@ private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialD ...@@ -147,18 +175,11 @@ private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialD
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++) for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++)
{ {
var row = sheet.GetOrCreate(rowIndex); var row = sheet.GetOrCreate(rowIndex);
var target = row.GetCell(dict[SpecialUnitColumns.Target]).GetDecodeEscapes();
bool hasValue = false; if (!string.IsNullOrEmpty(target))
foreach (var item in row.GetCellValues())
if (!string.IsNullOrEmpty(item))
{
hasValue = true; break;
}
if (hasValue)
{ {
row.SetRowStyle(rowStyle);
var department = row.GetCell(dict[SpecialUnitColumns.Department]).GetDecodeEscapes(); var department = row.GetCell(dict[SpecialUnitColumns.Department]).GetDecodeEscapes();
var target = row.GetCell(dict[SpecialUnitColumns.Target]).GetDecodeEscapes();
CheckMergedRegions(rowIndex, department, ranges); CheckMergedRegions(rowIndex, department, ranges);
...@@ -171,12 +192,17 @@ private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialD ...@@ -171,12 +192,17 @@ private void SupplySpecialQuantity(ISheet sheet, ExcelStyle style, List<SpecialD
specials.Remove(special); specials.Remove(special);
} }
dataFirstRowNum = rowIndex + 1; dataFirstRowNum = rowIndex + 1;
} }
} }
} }
/// <summary>
/// 获取需要合并的单元格
/// </summary>
/// <param name="rowIndex"></param>
/// <param name="department"></param>
/// <param name="ranges"></param>
private void CheckMergedRegions(int rowIndex, string department, List<SpecialCellRange> ranges) private void CheckMergedRegions(int rowIndex, string department, List<SpecialCellRange> ranges)
{ {
var range = ranges.FirstOrDefault(t => t.FirstRow <= rowIndex && t.LastRow >= rowIndex); var range = ranges.FirstOrDefault(t => t.FirstRow <= rowIndex && t.LastRow >= rowIndex);
...@@ -199,6 +225,15 @@ private void CheckMergedRegions(int rowIndex, string department, List<SpecialCel ...@@ -199,6 +225,15 @@ private void CheckMergedRegions(int rowIndex, string department, List<SpecialCel
} }
} }
/// <summary>
/// 添加新的特殊科室配置
/// </summary>
/// <param name="sheet"></param>
/// <param name="style"></param>
/// <param name="specials"></param>
/// <param name="ranges"></param>
/// <param name="columns"></param>
/// <param name="dataFirstRowNum"></param>
private void AddNewSpecialConfig(ISheet sheet, ExcelStyle style, List<SpecialDto> specials, List<SpecialCellRange> ranges, List<string> columns, int dataFirstRowNum) private void AddNewSpecialConfig(ISheet sheet, ExcelStyle style, List<SpecialDto> specials, List<SpecialCellRange> ranges, List<string> columns, int dataFirstRowNum)
{ {
if (specials == null || !specials.Any()) return; if (specials == null || !specials.Any()) return;
...@@ -262,6 +297,12 @@ private void WriteSpecialData(IRow row, ICellStyle style, SpecialDto special, Li ...@@ -262,6 +297,12 @@ private void WriteSpecialData(IRow row, ICellStyle style, SpecialDto special, Li
} }
} }
/// <summary>
/// 合并单元格
/// </summary>
/// <param name="sheet"></param>
/// <param name="ranges"></param>
/// <param name="columns"></param>
private void AddMergedRegion(ISheet sheet, List<SpecialCellRange> ranges, List<string> columns) private void AddMergedRegion(ISheet sheet, List<SpecialCellRange> ranges, List<string> columns)
{ {
if (columns == null || !columns.Any()) return; if (columns == null || !columns.Any()) return;
......
...@@ -19,16 +19,16 @@ public ISheetDataWrite GetWriteData(SheetType sheetType) ...@@ -19,16 +19,16 @@ public ISheetDataWrite GetWriteData(SheetType sheetType)
//case SheetType.ClinicEmployee: //case SheetType.ClinicEmployee:
// factory = new ClinicEmployeeDataWrite(); // factory = new ClinicEmployeeDataWrite();
// break; // break;
//case SheetType.OtherIncome: case SheetType.OtherIncome:
//case SheetType.Expend: case SheetType.Expend:
// factory = new OtherIncomeDataWrite(); factory = new OtherIncomeDataWrite();
// break; break;
//case SheetType.Income: case SheetType.Income:
// factory = new IncomeDataWrite(); factory = new IncomeDataWrite();
// break; break;
//case SheetType.Workload: case SheetType.Workload:
// factory = new WorkloadDataWrite(); factory = new WorkloadDataWrite();
// break; break;
//case SheetType.AccountBasic: //case SheetType.AccountBasic:
// factory = new AccountBasicDataWrite(); // factory = new AccountBasicDataWrite();
// break; // break;
......
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