Commit 551d51f3 by lcx

报表数据导入删除历史数据方法调整,dbset添加his_script

parent 8adb1960
......@@ -109,6 +109,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
/// <summary> </summary>
public virtual DbSet<his_importdata> his_importdata { get; set; }
/// <summary> </summary>
public virtual DbSet<his_script> his_script { get; set; }
/// <summary> </summary>
public virtual DbSet<hos_personfee> hos_personfee { get; set; }
/// <summary> 科室核算导入信息 </summary>
public virtual DbSet<im_accountbasic> im_accountbasic { get; set; }
......
......@@ -266,11 +266,10 @@ private void ImportBasicData(ISheet sheet, List<string> columns, int hospitalId,
t.CreateTime = dateTime;
});
var yearMonths = data.Select(t => $"{t.Year}-{t.Month}").Distinct();
var entities = hisimportdataRepository.GetEntities(t => t.HospitalId == hospitalId && yearMonths.Contains($"{t.Year}-{t.Month}") && t.Category == sheetName);
if (entities != null && entities.Any())
hisimportdataRepository.BulkDelete(entities);
foreach (var item in data.Select(t => new { t.Year, t.Month }).Distinct())
{
hisimportdataRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Category == sheetName && t.Year == item.Year && t.Month == item.Month);
}
hisimportdataRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
}
......@@ -302,11 +301,10 @@ private void ImporSummaryData(ISheet sheet, List<string> columns, int hospitalId
t.CreateTime = dateTime;
});
var yearMonths = data.Select(t => $"{t.Year}-{t.Month}").Distinct();
var entities = hisimportsummaryRepository.GetEntities(t => t.HospitalId == hospitalId && yearMonths.Contains($"{t.Year}-{t.Month}"));
if (entities != null && entities.Any())
hisimportsummaryRepository.BulkDelete(entities);
foreach (var item in data.Select(t => new { t.Year, t.Month }).Distinct())
{
hisimportsummaryRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportsummaryRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
}
......@@ -340,11 +338,10 @@ private void ImporAccountData(ISheet sheet, List<string> columns, int hospitalId
t.CreateTime = dateTime;
});
var yearMonths = data.Select(t => $"{t.Year}-{t.Month}").Distinct();
var entities = hisimportaccountRepository.GetEntities(t => t.HospitalId == hospitalId && yearMonths.Contains($"{t.Year}-{t.Month}"));
if (entities != null && entities.Any())
hisimportaccountRepository.BulkDelete(entities);
foreach (var item in data.Select(t => new { t.Year, t.Month }).Distinct())
{
hisimportaccountRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportaccountRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
}
......@@ -415,11 +412,10 @@ private void ImporClinicData(ISheet sheet, List<string> columns, int hospitalId,
t.CreateTime = dateTime;
});
var yearMonths = data.Select(t => $"{t.Year}-{t.Month}").Distinct();
var entities = hisimportclinicRepository.GetEntities(t => t.HospitalId == hospitalId && yearMonths.Contains($"{t.Year}-{t.Month}"));
if (entities != null && entities.Any())
hisimportclinicRepository.BulkDelete(entities);
foreach (var item in data.Select(t => new { t.Year, t.Month }).Distinct())
{
hisimportclinicRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportclinicRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
}
......@@ -489,11 +485,10 @@ private void ImporBasicnormData(ISheet sheet, List<string> columns, int hospital
t.CreateTime = dateTime;
});
var yearMonths = data.Select(t => $"{t.Year}-{t.Month}").Distinct();
var entities = hisimportbaiscnormRepository.GetEntities(t => t.HospitalId == hospitalId && yearMonths.Contains($"{t.Year}-{t.Month}"));
if (entities != null && entities.Any())
hisimportbaiscnormRepository.BulkDelete(entities);
foreach (var item in data.Select(t => new { t.Year, t.Month }).Distinct())
{
hisimportbaiscnormRepository.DeleteFromQuery(t => t.HospitalId == hospitalId && t.Year == item.Year && t.Month == item.Month);
}
hisimportbaiscnormRepository.BulkInsert(data.Where(t => t.Year != 0 && t.Month != 0));
}
......
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