CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/DoorServer/InOutService.cs

144 lines
5.2 KiB
C#
Raw Normal View History

2021-06-18 20:37:07 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 考勤
/// </summary>
public static class InOutService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 记录数
/// </summary>
public static int count
{
get;
set;
}
/// <summary>
/// 定义变量
/// </summary>
private static IQueryable<Model.T_d_facerecord> qq = from x in db.T_d_facerecord
2021-06-21 14:10:40 +08:00
orderby x.DateTimeRecord descending
2021-06-18 20:37:07 +08:00
select x;
2021-06-21 14:10:40 +08:00
private static IQueryable<Model.T_d_validcardevent> qq1= from x in db.T_d_validcardevent
orderby x.RecordDateTime descending
select x;
2021-06-18 20:37:07 +08:00
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="PageIndex">页码</param>
/// <param name="PageSize">每页数量</param>
/// <returns></returns>
public static IEnumerable getListData(string projectId, string type, string unitId, string name, string startDate, string endDate, int PageIndex, int PageSize)
{
if (type == "1")
{
IQueryable<Model.T_d_validcardevent> q1 = qq1.Where(x => x.ProjectId == projectId);
2021-06-21 14:10:40 +08:00
2021-06-18 20:37:07 +08:00
if (!string.IsNullOrEmpty(startDate))
{
q1 = q1.Where(e => e.RecordDateTime >= Funs.GetNewDateTime(startDate));
}
if (!string.IsNullOrEmpty(endDate))
{
q1 = q1.Where(e => e.RecordDateTime <= Funs.GetNewDateTime(endDate));
}
if (!string.IsNullOrEmpty(unitId))
{
q1 = from x in q1
join y in db.SitePerson_Person on x.IDCardNo equals y.IdentityCard
2021-06-21 14:10:40 +08:00
where y.UnitId == unitId
select x;
2021-06-18 20:37:07 +08:00
}
if (!string.IsNullOrEmpty(name))
{
q1 = q1.Where(e => e.EmployName.Contains(name));
}
count = q1.Count();
if (count == 0)
{
return null;
}
return from x in q1.Skip(PageSize * PageIndex).Take(PageSize)
select new
{
x.NewID,
x.ProjectId,
x.EmployName,
x.DepartmentID,
2021-06-21 14:10:40 +08:00
DepartName=x.DepartmentName,
2021-06-18 20:37:07 +08:00
x.AreaID,
x.AreaName,
x.EmployNO,
2021-06-21 14:10:40 +08:00
CardID=x.CardNO,
DateTimeRecord=x.RecordDateTime,
RecordDes=x.RecordAll,
InOrOut=(x.InOrOut ==2? "出门" : "进门"),
2021-06-18 20:37:07 +08:00
};
}
else
{
IQueryable<Model.T_d_facerecord> q = qq.Where(x => x.ProjectId == projectId);
if (type == "2")
{
q = q.Where(e => e.RoleID == "微信端");
}
else
{
q = q.Where(e => e.RoleID != "微信端");
}
if (!string.IsNullOrEmpty(startDate))
{
q = q.Where(e => e.DateTimeRecord >= Funs.GetNewDateTime(startDate));
}
if (!string.IsNullOrEmpty(endDate))
{
q = q.Where(e => e.DateTimeRecord <= Funs.GetNewDateTime(endDate));
}
if (!string.IsNullOrEmpty(unitId))
{
q = from x in q
2021-06-21 14:10:40 +08:00
join y in db.SitePerson_Person on x.EmployNO equals y.IdentityCard
where y.UnitId == unitId
select x;
2021-06-18 20:37:07 +08:00
}
if (!string.IsNullOrEmpty(name))
{
q = q.Where(e => e.EmployName.Contains(name));
}
count = q.Count();
if (count == 0)
{
return null;
}
return from x in q.Skip(PageSize * PageIndex).Take(PageSize)
select new
{
x.NewID,
x.ProjectId,
x.EmployName,
x.DepartmentID,
x.DepartName,
x.AreaID,
x.AreaName,
x.EmployNO,
x.CardID,
x.DateTimeRecord,
x.RecordDes,
2021-06-21 14:10:40 +08:00
x.InOrOut,
2021-06-18 20:37:07 +08:00
};
}
}
}
}