20220301 考勤导入优化

This commit is contained in:
2022-03-01 10:38:44 +08:00
parent d2562d6ae0
commit 5dd16e8bf7
3 changed files with 31 additions and 33 deletions
@@ -15,12 +15,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// 上传预设的虚拟路径
/// </summary>
private string initPath = Const.ExcelUrl;
/// <summary>
/// 人员考勤集合
/// </summary>
public static List<Model.View_SitePerson_Checking> viewCheckings = new List<Model.View_SitePerson_Checking>();
/// <summary>
/// 错误集合
/// </summary>
@@ -54,11 +49,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
{
this.hdFileName.Text = string.Empty;
this.hdCheckResult.Text = string.Empty;
this.ProjectId = this.CurrUser.LoginProjectId;
if (viewCheckings != null)
{
viewCheckings.Clear();
}
this.ProjectId = this.CurrUser.LoginProjectId;
errorInfos = string.Empty;
}
}
@@ -84,11 +75,7 @@ namespace FineUIPro.Web.HSSE.SitePerson
{
ShowNotify("只可以选择Excel文件!", MessageBoxIcon.Warning);
return;
}
if (viewCheckings!=null)
{
viewCheckings.Clear();
}
}
if (!string.IsNullOrEmpty(errorInfos))
{
errorInfos = string.Empty;
@@ -171,8 +158,8 @@ namespace FineUIPro.Web.HSSE.SitePerson
{
var units = from x in Funs.DB.Base_Unit select x;
var sitePersons = from x in Funs.DB.SitePerson_Person
where x.ProjectId == this.ProjectId select x;
where x.ProjectId == this.ProjectId
select x;
for (int i = 0; i < ir; i++)
{
string col0 = pds.Rows[i][0].ToString().Trim();
@@ -205,6 +192,12 @@ namespace FineUIPro.Web.HSSE.SitePerson
{
result += "第" + (i + 2).ToString() + "行," + "姓名" + "," + "[" + col1 + "]不在人员信息表中!" + "|";
}
var personOut = sitePersons.FirstOrDefault(e => e.PersonName == col1 && e.OutTime.HasValue && e.OutTime < DateTime.Now);
if (personOut != null)
{
result += "第" + (i + 2).ToString() + "行," + "姓名" + "," + "[" + col1 + "]已离岗!" + "|";
}
}
if (!string.IsNullOrEmpty(col2))
{
@@ -335,6 +328,10 @@ namespace FineUIPro.Web.HSSE.SitePerson
}
}
#endregion
/// <summary>
/// 人员考勤集合
/// </summary>
public static List<Model.View_SitePerson_Checking> viewCheckings = new List<Model.View_SitePerson_Checking>();
#region Dataset的数据导入数据库
/// <summary>
@@ -345,13 +342,13 @@ namespace FineUIPro.Web.HSSE.SitePerson
/// <returns></returns>
private bool AddDatasetToSQL2(DataTable pds)
{
viewCheckings.Clear();
viewCheckings.Clear();
int ir = pds.Rows.Count;
if (pds != null && ir > 0)
{
var units = from x in Funs.DB.Base_Unit select x;
var sitePersons = from x in Funs.DB.SitePerson_Person where x.ProjectId == this.ProjectId select x;
{
var sitePersons = from x in Funs.DB.SitePerson_Person
where x.ProjectId == this.ProjectId && !x.OutTime.HasValue
select x;
for (int i = 0; i < ir; i++)
{
string col0 = pds.Rows[i][0].ToString().Trim();
@@ -369,14 +366,14 @@ namespace FineUIPro.Web.HSSE.SitePerson
IntoOut = col3 == "进" ? "1" : "0",
IntoOutTime = Convert.ToDateTime(col4)
};
var person = BLL.PersonService.GetPersonByIdentityCard( this.ProjectId, checking.IdentityCard);
var person = sitePersons.FirstOrDefault(x => x.IdentityCard == checking.IdentityCard);
if (person != null)
{
checking.PersonId = person.PersonId;
checking.ProjectId = person.ProjectId;
}
checking.CheckingId = SQLHelper.GetNewID();
viewCheckings.Add(checking);
checking.CheckingId = SQLHelper.GetNewID();
viewCheckings.Add(checking);
}
}
}
if (viewCheckings.Count > 0)