重复判定
parent
f7d348a8cd
commit
5b309e55f9
|
|
@ -106,13 +106,20 @@ public class InsAiShpApp : SqlSugarBaseApp<InsAishp, SugarDbContext>
|
|||
public async Task<Response<bool>> Insert(List<InsAiShpInsert> req)
|
||||
{
|
||||
var aiShpList = req.MapToList<InsAishp>();
|
||||
var removeList = new List<InsAishp>();
|
||||
foreach (var shp in aiShpList)
|
||||
{
|
||||
shp.Id = Guid.NewGuid().ToString();
|
||||
shp.CreateTime = DateTime.Now;
|
||||
shp.UpdateTime = DateTime.Now;
|
||||
// 重复判定
|
||||
if (await Repository.CountAsync(a => a.ShpPath == shp.ShpPath) > 0)
|
||||
{
|
||||
removeList.Add(shp);
|
||||
}
|
||||
}
|
||||
|
||||
aiShpList.RemoveAll(a => removeList.Contains(a));
|
||||
await Repository.InsertRangeAsync(aiShpList);
|
||||
return new Response<bool>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,12 +74,19 @@ public class InsTifApp : SqlSugarBaseApp<InsTif, SugarDbContext>
|
|||
public async Task<Response<bool>> Insert(IEnumerable<InsTifInsert> req)
|
||||
{
|
||||
var tifList = req.MapToList<InsTif>();
|
||||
var removeList = new List<InsTif>();
|
||||
foreach (var tif in tifList)
|
||||
{
|
||||
if (await Repository.CountAsync(a => a.TifPath == tif.TifPath) > 0)
|
||||
{
|
||||
removeList.Add(tif);
|
||||
}
|
||||
|
||||
tif.Id = Guid.NewGuid().ToString();
|
||||
tif.CreateTime = DateTime.Now;
|
||||
tif.UpdateTime = DateTime.Now;
|
||||
}
|
||||
tifList.RemoveAll(a => removeList.Contains(a));
|
||||
await Repository.InsertRangeAsync(tifList);
|
||||
return new Response<bool>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue