Commit adefae09 by 钟博

提取数据时,5.x~6.x的核算单元和4.1中保持一致

parent b0b2d449
......@@ -30,6 +30,7 @@ public class CollectService : IAutoInjection
private readonly PerforCollectpermissionRepository perforcollectpermissionRepository;
private readonly PerforUserroleRepository userroleRepository;
private readonly PerforImaccountbasicRepository perforImaccountbasicRepository;
private readonly PerforPerdeptdicRepository perforPerdeptdicRepository;
private readonly SheetSevice sheetSevice;
private readonly Application options;
......@@ -46,6 +47,7 @@ public class CollectService : IAutoInjection
PerforCollectpermissionRepository perforcollectpermissionRepository,
PerforUserroleRepository userroleRepository,
PerforImaccountbasicRepository perforImaccountbasicRepository,
PerforPerdeptdicRepository perforPerdeptdicRepository,
SheetSevice sheetSevice,
IOptions<Application> options)
{
......@@ -61,6 +63,7 @@ public class CollectService : IAutoInjection
this.perforcollectpermissionRepository = perforcollectpermissionRepository;
this.userroleRepository = userroleRepository;
this.perforImaccountbasicRepository = perforImaccountbasicRepository;
this.perforPerdeptdicRepository = perforPerdeptdicRepository;
this.sheetSevice = sheetSevice;
this.options = options.Value;
}
......@@ -368,11 +371,27 @@ public HandsonTable GetCollectData(int userId, int allotId, string sheetName)
else if (sheet.SheetType == (int)SheetType.LogisticsEmployee)
rowDatas = GetLogisticsEmployee(sheet);
else if (sheet.SheetType == (int)SheetType.AccountBasic)
rowDatas = GetAccountBasic(sheet);
{
List<HandsonCellData> cells = new List<HandsonCellData>();
var dept = perforPerdeptdicRepository.GetAccountBasicAccountingUnit(allot.HospitalId);
rowDatas = GetAccountBasic(sheet, dept, cells);
}
else
rowDatas = GetCommonData(sheet);
}
//补全核算单元和类型
var sTypes = new[] { (int)SheetType.AccountExtra, (int)SheetType.PersonExtra, (int)SheetType.AccountDrugAssess, (int)SheetType.AccountMaterialsAssess };
var sTypeName = new[] { "6.1目标考核", "6.6 科室预算比例" };
if (sTypes.Contains((int)sheet.SheetType) || sTypeName.Contains(sheet.SheetName))
{
List<HandsonCellData> cells = new List<HandsonCellData>();
var perSheet = perforPersheetRepository.GetEntity(t=>t.AllotID==allotId && t.SheetName=="4.1 临床科室医护绩效测算表");
var dept = perforPerdeptdicRepository.GetAccountBasicAccountingUnit(allot.HospitalId);
GetAccountBasic(perSheet, dept, cells);
UnitFit(rowDatas, cells, sheet);
}
if (rowDatas == null || !rowDatas.Any())
rowDatas = GetAccountExtra(allot, sheet.SheetType.Value);
......@@ -514,10 +533,11 @@ private HandsonRowData CreateRowData(int row, ColumnInfo[] columns, SortedDictio
return xx;
}
private List<HandsonRowData> GetAccountBasic(per_sheet sheet)
private List<HandsonRowData> GetAccountBasic(per_sheet sheet, IEnumerable<per_dept_dic> dept, List<HandsonCellData> cells)
{
//var accounts = sheetSevice.SheetExport(sheet.ID);
var result = new List<HandsonRowData>();
var groupAccount = perforImdataRepository.GetEntities(t => t.SheetID == sheet.ID); //.OrderBy(c=>c.RowNumber).GroupBy(c => c.RowNumber);
if (groupAccount != null && groupAccount.Any())
{
......@@ -551,14 +571,28 @@ private List<HandsonRowData> GetAccountBasic(per_sheet sheet)
break;
}
var rowData = new HandsonRowData(rowNumber.Value, data);
result.Add(rowData);
string unit = ""; string type = "";
foreach (var cell in data)
{
if (cell.Name == "核算单元")
{
unit = cell.Value.ToString();
}
else if (cell.Name == "核算单元类型")
{
type = cell.Value.ToString();
}
}
cells.Add(new HandsonCellData(unit, type));
}
//var temps = accounts.Row.Select(item => new { row = item.Rownumber, dic = JsonHelper.Deserialize(item) });
//return new List<HandsonRowData>(temps.Select(temp => CreateRowData(temp.row, ExcelReadConfig.AccountBaisc, temp.dic)));
}
UnitFit(result, dept, cells);
return result;
}
......@@ -669,6 +703,110 @@ public void SaveCollectData(int allotId, SaveCollectData request)
return result;
}
private void UnitFit(List<HandsonRowData> rowDatas, IEnumerable<per_dept_dic> dept, List<HandsonCellData> cellDatas)
{
var rowCount = rowDatas.Count;
List<HandsonRowData> suppRowDatas = new List<HandsonRowData>();
foreach (var dic in dept)
{
bool exists = false;
bool exists2 = false;
foreach (var rowData in rowDatas)
{
foreach (var cellData in rowData.CellData)
{
//var cell = rowData.CellData.Where(c => c.Value == dic.AccountingUnit).ToList();
if (cellData.Value?.ToString() == dic.AccountingUnit)
{
exists = true;
}
if (exists && cellData.Value?.ToString() == dic.UnitType)
{
exists2 = true;
}
}
}
if ((exists == false && exists2 == false) || exists2 == false)
{
cellDatas.Add(new HandsonCellData(dic.AccountingUnit, dic.UnitType));
var cells = new List<HandsonCellData>();
cells.Add(new HandsonCellData("核算单元", dic.AccountingUnit));
cells.Add(new HandsonCellData("核算单元类型", dic.UnitType));
suppRowDatas.Add(new HandsonRowData(rowCount++, cells));
}
}
cellDatas.Distinct().ToList();
rowDatas.AddRange(suppRowDatas);
}
private void UnitFit(List<HandsonRowData> rowDatas, List<HandsonCellData> cellDatas, per_sheet sheet)
{
var rowCount = rowDatas.Count;
List<HandsonRowData> suppRowDatas = new List<HandsonRowData>();
foreach (var cell in cellDatas)
{
bool exists = false;
bool exists2 = false;
var cells = new List<HandsonCellData>();
if (cell.Name == "总务科")
{
var ss = 1;
}
foreach (var rowData in rowDatas)
{
foreach (var cellData in rowData.CellData)
{
//var cell = rowData.CellData.Where(c => c.Value == dic.AccountingUnit).ToList();
if (cellData.Value?.ToString() == cell.Name)
{
exists = true;
}
if (cellData.Name == "核算单元分类" && cellData.Value?.ToString() == cell.Value)
{
exists2 = true;
}
else if (cellData.Name == "核算组别" && cellData.Value?.ToString() == cell.Value)
{
exists2 = true;
}
else if (cellData.Name == "核算单元类型" && cellData.Value?.ToString() == cell.Value)
{
exists2 = true;
}
else
{
exists2 = true;
}
}
}
if (exists == false || (exists == false && exists2 == false) || exists2 == false)
{
cells.Add(new HandsonCellData("核算单元", cell.Name));
if (sheet.SheetName == "5.2业务中层行政中高层医院奖罚")
{
cells.Add(new HandsonCellData("核算单元分类", cell.Value));
}
else if (sheet.SheetName == "5.1 科室绩效医院奖罚")
{
cells.Add(new HandsonCellData("核算组别", cell.Value));
}
else
{
cells.Add(new HandsonCellData("核算单元类型", cell.Value));
}
suppRowDatas.Add(new HandsonRowData(++rowCount, cells));
}
}
rowDatas.AddRange(suppRowDatas);
}
}
public class CollectDataConfig
......
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