| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							| 
									
										
										
										
											2022-06-01 14:27:42 +08:00
										 |  |  |  | using FineUIPro; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public class SitePerson_CheckingService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         public static Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-01 14:27:42 +08:00
										 |  |  |  |         #region 现场考勤列表 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 记录数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public static int count | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get; | 
					
						
							|  |  |  |  |             set; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 定义变量 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private static IQueryable<Model.SitePerson_Checking> getDataLists = from x in db.SitePerson_Checking | 
					
						
							|  |  |  |  |                                                                              select x; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         ///  数据列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitId"></param> | 
					
						
							|  |  |  |  |         /// <param name="Grid1"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static IEnumerable getListData(string projectId, string unitId, string personName, string startDate, string endDate, Grid Grid1) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             IQueryable<Model.SitePerson_Checking> getDataList = getDataLists.Where(x => x.ProjectId == projectId);             | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 getDataList = getDataList.Where(x => x.UnitId == unitId); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(personName)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 getDataList = getDataList.Where(x => x.PersonName.Contains(personName)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(startDate)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DateTime? startDateD = Funs.GetNewDateTime(startDate); | 
					
						
							|  |  |  |  |                 if (startDateD.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getDataList = getDataList.Where(x => x.IntoOutTime >= startDateD.Value); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(endDate)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DateTime? endDateD = Funs.GetNewDateTime(endDate); | 
					
						
							|  |  |  |  |                 if (endDateD.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getDataList = getDataList.Where(x => x.IntoOutTime < endDateD.Value); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             count = getDataList.Count(); | 
					
						
							|  |  |  |  |             if (count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return null; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); | 
					
						
							|  |  |  |  |             return from x in getDataList | 
					
						
							|  |  |  |  |                    select new | 
					
						
							|  |  |  |  |                    { | 
					
						
							|  |  |  |  |                        x.CheckingId, x.ProjectId, x.UnitId, x.UnitName, x.PersonId, | 
					
						
							|  |  |  |  |                        x.PersonName, x.CardNo, x.IdentityCard, x.WorkAreaId, x.WorkAreaName, | 
					
						
							|  |  |  |  |                        x.IntoOut, x.IntoOutTime, x.Address, | 
					
						
							|  |  |  |  |                    }; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据人员考勤主键获取人员考勤管理信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="checkingId">人员考勤主键</param> | 
					
						
							|  |  |  |  |         /// <returns>人员考勤管理信息</returns> | 
					
						
							|  |  |  |  |         public static Model.SitePerson_Checking GetPersonInfoByCheckingId(string checkingId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return Funs.DB.SitePerson_Checking.FirstOrDefault(x=> x.CheckingId == checkingId); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 增加人员考勤管理信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="personInfo">人员考勤管理实体</param> | 
					
						
							|  |  |  |  |         public static void AddPersonInfo(Model.SitePerson_Checking personInfo) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |                 Model.SitePerson_Checking newPersonInfo = new Model.SitePerson_Checking | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     CheckingId = personInfo.CheckingId, | 
					
						
							|  |  |  |  |                     ProjectId = personInfo.ProjectId, | 
					
						
							|  |  |  |  |                     UnitId = personInfo.UnitId, | 
					
						
							|  |  |  |  |                     UnitName = personInfo.UnitName, | 
					
						
							|  |  |  |  |                     PersonId = personInfo.PersonId, | 
					
						
							|  |  |  |  |                     PersonName = personInfo.PersonName, | 
					
						
							|  |  |  |  |                     IdentityCard = personInfo.IdentityCard, | 
					
						
							|  |  |  |  |                     CardNo = personInfo.CardNo, | 
					
						
							|  |  |  |  |                     WorkAreaId = personInfo.WorkAreaId, | 
					
						
							|  |  |  |  |                     WorkAreaName = personInfo.WorkAreaName, | 
					
						
							|  |  |  |  |                     IntoOutTime = personInfo.IntoOutTime, | 
					
						
							|  |  |  |  |                     IntoOut = personInfo.IntoOut, | 
					
						
							|  |  |  |  |                     Address = personInfo.Address, | 
					
						
							|  |  |  |  |                     States = BLL.Const.State_2 | 
					
						
							|  |  |  |  |                 }; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |                 db.SitePerson_Checking.InsertOnSubmit(newPersonInfo); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!string.IsNullOrEmpty(personInfo.ProjectId) && !string.IsNullOrEmpty(personInfo.IdentityCard) && personInfo.IntoOutTime.HasValue) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 int inOut = personInfo.IntoOut == "1" ? 1 : 0; | 
					
						
							|  |  |  |  |                 APIDoorServerService.SaveDoorInOutRecord(personInfo.ProjectId, personInfo.IdentityCard, inOut, personInfo.IntoOutTime.Value, "手动"); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 修改人员考勤管理信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="personInfo">人员考勤管理实体</param> | 
					
						
							|  |  |  |  |         public static void UpdatePersonInfo(Model.SitePerson_Checking personInfo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |             Model.SitePerson_Checking newPersonInfo = db.SitePerson_Checking.FirstOrDefault(e => e.CheckingId == personInfo.CheckingId); | 
					
						
							|  |  |  |  |             if (newPersonInfo != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-06-01 14:27:42 +08:00
										 |  |  |  |                 newPersonInfo.UnitId = personInfo.UnitId; | 
					
						
							|  |  |  |  |                 newPersonInfo.UnitName = personInfo.UnitName; | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 newPersonInfo.PersonId = personInfo.PersonId; | 
					
						
							| 
									
										
										
										
											2022-06-01 14:27:42 +08:00
										 |  |  |  |                 newPersonInfo.PersonName = personInfo.PersonName; | 
					
						
							|  |  |  |  |                 newPersonInfo.CardNo = personInfo.CardNo; | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 newPersonInfo.IdentityCard = personInfo.IdentityCard; | 
					
						
							| 
									
										
										
										
											2022-06-01 14:27:42 +08:00
										 |  |  |  |                 newPersonInfo.WorkAreaId = personInfo.WorkAreaId; | 
					
						
							|  |  |  |  |                 newPersonInfo.WorkAreaName = personInfo.WorkAreaName;         | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 newPersonInfo.IntoOutTime = personInfo.IntoOutTime; | 
					
						
							|  |  |  |  |                 newPersonInfo.IntoOut = personInfo.IntoOut; | 
					
						
							|  |  |  |  |                 newPersonInfo.Address = personInfo.Address; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据卡号和时间查询人员考勤信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="cardNo">卡号</param> | 
					
						
							|  |  |  |  |         /// <returns>人员实体</returns> | 
					
						
							|  |  |  |  |         public static Model.SitePerson_Checking GetPersonCheckByCardNo(string projectId, string cardNo, DateTime? intoOutTime) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return Funs.DB.SitePerson_Checking.FirstOrDefault(e => e.ProjectId == projectId && e.CardNo == cardNo && e.IntoOutTime == intoOutTime); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据人员考勤主键删除一个人员考勤管理信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="checkingId">人员考勤主键</param> | 
					
						
							|  |  |  |  |         public static void DeletePersonInfoByCheckingId(string checkingId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.SitePerson_Checking personInfo = db.SitePerson_Checking.FirstOrDefault(e => e.CheckingId == checkingId); | 
					
						
							|  |  |  |  |             if (personInfo != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 db.SitePerson_Checking.DeleteOnSubmit(personInfo); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据作业区域Id查询所有人员考勤信息数量 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="workAreaId">作业区域Id</param> | 
					
						
							|  |  |  |  |         /// <returns>人员考勤信息数量</returns> | 
					
						
							|  |  |  |  |         public static int GetCheckingCountByWorkAreaId(string workAreaId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.SitePerson_Checking where x.WorkAreaId == workAreaId select x).ToList().Count(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据人员考勤主键删除一个人员考勤管理信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="checkingId">人员考勤主键</param> | 
					
						
							|  |  |  |  |         public static void DeletePersonInOutByCheckingId(string PersonInOutId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.SitePerson_PersonInOut personInOut = db.SitePerson_PersonInOut.FirstOrDefault(e => e.PersonInOutId == PersonInOutId); | 
					
						
							|  |  |  |  |             if (personInOut != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 db.SitePerson_PersonInOut.DeleteOnSubmit(personInOut); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |