Commit 237dfe08 by lcx

4.1数据写入

parent 8bb620c0
......@@ -203,11 +203,7 @@ public static string GetDecodeEscapes(this ICell cell)
if (cell == null) return "";
cell.SetCellType(CellType.String);
string value = cell.StringCellValue;
if (!string.IsNullOrEmpty(value))
value = value.Replace("\n", "").Replace("\r", "").Replace(" ", "").Trim();
return value;
return cell.StringCellValue.NoBlank();
}
catch
{
......
......@@ -136,7 +136,7 @@ private void WriteDataToFile(IWorkbook workbook, int allotId, Dictionary<ExDataD
logger.LogInformation($"allotId: {allotId}: 总金额 - {extractDto?.Sum(s => s.Value ?? 0)}");
WriteDataFactory factory = new WriteDataFactory();
var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload };
var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload, SheetType.AccountBasic };
decimal ratio = 60m;
for (int sheetIndex = 0; sheetIndex < workbook.NumberOfSheets; sheetIndex++)
{
......@@ -182,9 +182,11 @@ private object GetDataBySheetType(SheetType sheetType, List<ExtractTransDto> ext
{
case SheetType.Employee:
case SheetType.ClinicEmployee:
case SheetType.AccountBasic:
return employeeDict;
case SheetType.AccountBasic:
return new List<im_accountbasic>();
default:
return extractDto;
}
......
......@@ -3,20 +3,55 @@
using Performance.EntityModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Performance.Services.ExtractExcelService.SheetDataWrite
{
class AccountBasicDataWrite : ISheetDataWrite
internal class AccountBasicDataWrite : ISheetDataWrite
{
public void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType sheetType, ExcelStyle style, List<collect_data> collects)
{
if (collects == null || !collects.Any(t => !string.IsNullOrEmpty(t.TypeName))) return;
var headerRow = sheet.GetRow(point.HeaderFirstRowNum ?? 1);
var columns = headerRow.GetCellValues();
if (columns == null || !columns.Any()) return;
collects.ForEach(t =>
{
t.UnitType = t.UnitType.NoBlank();
t.AccountingUnitDoctor = t.AccountingUnitDoctor.NoBlank();
t.TypeName = t.TypeName.NoBlank();
});
var rownumbers = collects.Select(t => t.RowNumber).Distinct().OrderBy(t => t).ToList();
for (int i = point.DataFirstRowNum.Value; i < sheet.LastRowNum + 1; i++)
{
var row = sheet.GetRow(i);
if (row != null)
{
string unittype = row.GetCell(point.DataFirstCellNum.Value - 2).GetDecodeEscapes();
string accountingunit = row.GetCell(point.DataFirstCellNum.Value - 1).GetDecodeEscapes();
int cellIndex = point.DataFirstCellNum.Value;
foreach (var column in columns)
{
var data = collects.FirstOrDefault(t => t.UnitType == unittype && t.AccountingUnitDoctor == accountingunit && t.TypeName == column);
if (data != null)
{
var cell = row.GetCell(cellIndex);
if (cell != null) cell.SetCellValue<decimal>(data.CellValue);
collects.Remove(data);
}
cellIndex++;
}
}
}
}
public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetType, ExcelStyle style, object data, Dictionary<ExDataDict, object> exdict = null)
{
}
}
}
......@@ -36,9 +36,9 @@ public ISheetDataWrite GetWriteData(SheetType sheetType, ILogger logger)
factory = new WorkloadDataWrite(logger);
break;
//case SheetType.AccountBasic:
// factory = new AccountBasicDataWrite();
// break;
case SheetType.AccountBasic:
factory = new AccountBasicDataWrite();
break;
case SheetType.SpecialUnit:
factory = new SpecialUnitDataWrite(logger);
......
......@@ -19,6 +19,7 @@ public class PerSheetDataReadDeptAccounting : IPerSheetDataRead
HeaderLastRowNum = 1,
HeaderFirstCellNum = 0,
DataFirstRowNum = 2,
DataFirstCellNum = 2,
};
public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
......
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