148 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			148 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			C#
		
	
	
	
| 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
 | |
|                                                              orderby x.DateTimeRecord descending
 | |
|                                                              select x;
 | |
|         private static IQueryable<Model.T_d_validcardevent> qq1 = from x in db.T_d_validcardevent
 | |
|                                                                   orderby x.RecordDateTime descending
 | |
|                                                                   select x;
 | |
| 
 | |
|         /// <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);
 | |
| 
 | |
|                 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
 | |
|                          where y.UnitId == unitId
 | |
|                          select x;
 | |
|                 }
 | |
|                 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,
 | |
|                            DepartName = x.DepartmentName,
 | |
|                            x.AreaID,
 | |
|                            x.AreaName,
 | |
|                            x.EmployNO,
 | |
|                            CardID = x.CardNO,
 | |
|                            DateTimeRecord = x.RecordDateTime,
 | |
|                            RecordDes = x.RecordAll,
 | |
|                            InOrOut = (x.InOrOut == 2 ? "出门" : "进门"),
 | |
|                        };
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 IQueryable<Model.T_d_facerecord> q = qq.Where(x => x.ProjectId == projectId);
 | |
|                 if (type == "2")
 | |
|                 {
 | |
|                     q = q.Where(e => e.RoleID == "微信端");
 | |
|                 }
 | |
|                 else if (type == "3")
 | |
|                 {
 | |
|                     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
 | |
|                         join y in db.SitePerson_Person on x.EmployNO equals y.IdentityCard
 | |
|                         where y.UnitId == unitId
 | |
|                         select x;
 | |
|                 }
 | |
|                 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,
 | |
|                            x.InOrOut,
 | |
|                        };
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |