| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  | using EmitMapper; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public static class APIDoorServerService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存 出入记录 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="projectId">项目ID</param> | 
					
						
							|  |  |  |  |         /// <param name="idCard">身份证号码</param> | 
					
						
							|  |  |  |  |         /// <param name="isIn">1进0出</param> | 
					
						
							|  |  |  |  |         /// <param name="changeTime">进出时间</param> | 
					
						
							|  |  |  |  |         /// <param name="changeTime">进出方式</param> | 
					
						
							|  |  |  |  |         public static void SaveDoorInOutRecord(string projectId, string idCard, int isIn, DateTime changeTime, string Intype) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |             Model.SitePerson_Person getPerson = new Model.SitePerson_Person(); | 
					
						
							|  |  |  |  |             int maxId = 0; | 
					
						
							|  |  |  |  |             string name = string.Empty; | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2022-09-26 18:41:24 +08:00
										 |  |  |  |                 getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == idCard && x.ProjectId == projectId); | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |                 if (getPerson != null) | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |                     name = getPerson.PersonName; | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-12-07 16:34:32 +08:00
										 |  |  |  |                 else | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2022-09-26 18:41:24 +08:00
										 |  |  |  |                     getPerson = db.SitePerson_Person.Where(x => x.IdentityCard == idCard).OrderByDescending(x => x.InTime).FirstOrDefault(); | 
					
						
							| 
									
										
										
										
											2021-12-07 16:34:32 +08:00
										 |  |  |  |                     if (getPerson != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         name = getPerson.PersonName; | 
					
						
							| 
									
										
										
										
											2022-09-26 18:41:24 +08:00
										 |  |  |  |                         projectId = getPerson.ProjectId; | 
					
						
							| 
									
										
										
										
											2021-12-07 16:34:32 +08:00
										 |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-07 16:34:32 +08:00
										 |  |  |  |                 var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == Intype).Select(x => x.ID); | 
					
						
							|  |  |  |  |                 if (getmax.Count() > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     maxId = getmax.Max() + 1; | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord() | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     NewID = SQLHelper.GetNewID(), | 
					
						
							|  |  |  |  |                     ProjectId = projectId, | 
					
						
							|  |  |  |  |                     ID = maxId + 1, | 
					
						
							|  |  |  |  |                     EmployName = name, | 
					
						
							|  |  |  |  |                     EmployNO = idCard, | 
					
						
							|  |  |  |  |                     RoleID = Intype, | 
					
						
							|  |  |  |  |                     DateTimeRecord = changeTime, | 
					
						
							|  |  |  |  |                     RecordDes = Intype, | 
					
						
							|  |  |  |  |                     InOrOut = (isIn == 1 ? "进门" : "出门"), | 
					
						
							|  |  |  |  |                 }; | 
					
						
							|  |  |  |  |                 db.T_d_facerecord.InsertOnSubmit(newFacerecord); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-12-07 16:34:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  |             if (getPerson != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |                 ///// 根据出入记录 写入考勤记录 | 
					
						
							|  |  |  |  |                 Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ID = maxId + 1, | 
					
						
							|  |  |  |  |                     EmployName = name, | 
					
						
							|  |  |  |  |                     IDCardNo = idCard, | 
					
						
							|  |  |  |  |                     EmployNO = idCard, | 
					
						
							|  |  |  |  |                     ProjectId = projectId, | 
					
						
							|  |  |  |  |                     RoleID = Intype, | 
					
						
							|  |  |  |  |                     DateTimeRecord = changeTime, | 
					
						
							|  |  |  |  |                     RecordDes = Intype, | 
					
						
							|  |  |  |  |                     InOrOut = (isIn == 1 ? "进门" : "出门"), | 
					
						
							|  |  |  |  |                 }; | 
					
						
							| 
									
										
										
										
											2022-06-16 17:34:24 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 DoorServerService.InsertEmployInOutRecord(facerecord, getPerson); | 
					
						
							|  |  |  |  |                 APIPersonService.getPersonInOut(getPerson, isIn, changeTime); | 
					
						
							| 
									
										
										
										
											2021-07-20 16:02:27 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |