This commit is contained in:
2021-07-14 19:57:50 +08:00
parent ff100e0b7b
commit 4f2057ccd3
5 changed files with 141 additions and 3 deletions
@@ -25,7 +25,10 @@ namespace FineUIPro.Web.ZHGL.RealName
this.drpProject.SelectedValue = this.CurrUser.LoginProjectId;
this.drpProject.Readonly = true;
}
if (this.CurrUser.UserId == Const.hfnbdId)
{
this.btnDataProcess.Hidden = false;
}
this.SetPage();
}
}
@@ -297,5 +300,50 @@ namespace FineUIPro.Web.ZHGL.RealName
}
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDataProcess_Click(object sender, EventArgs e)
{
var result = (from x in Funs.DB.RealName_PersonInOutNow
group x by new
{
x.ProjectId,
date = x.ChangeTime.Value.Date,
x.IdcardNumber,
x.IsIn
} into g
where g.Count() > 1
select new
{
g.First().ProjectId,
date = g.First().ChangeTime.Value.Date,
g.First().IdcardNumber,
g.First().IsIn
}).Distinct().Take(500);
foreach (var item in result)
{
var getDateRecords = from x in Funs.DB.RealName_PersonInOutNow
where x.ProjectId == item.ProjectId && x.ChangeTime.Value >= item.date.Date && x.ChangeTime.Value < item.date.Date.AddDays(1)
&& x.IdcardNumber == item.IdcardNumber
select x;
DateTime? minChangeTime = getDateRecords.Where(x => x.IsIn == true).Min(x=>x.ChangeTime);
DateTime? maxChangeTime = getDateRecords.Where(x => x.IsIn == false).Max(x => x.ChangeTime);
var getDeleteR = from x in getDateRecords
where (minChangeTime.HasValue && x.IsIn == true && x.ChangeTime != minChangeTime) ||
(maxChangeTime.HasValue && x.IsIn == false && x.ChangeTime != maxChangeTime)
select x;
if (getDeleteR.Count() > 0)
{
Funs.DB.RealName_PersonInOutNow.DeleteAllOnSubmit(getDeleteR);
Funs.DB.SubmitChanges();
}
}
Alert.ShowInTop("完成!", MessageBoxIcon.Success);
}
}
}