550 lines
		
	
	
		
			26 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			550 lines
		
	
	
		
			26 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Configuration; | |||
|  | using System.Data; | |||
|  | using System.IO; | |||
|  | using System.Linq; | |||
|  | using System.Net; | |||
|  | using System.Net.Http; | |||
|  | using System.Web; | |||
|  | using System.Web.Http; | |||
|  | using BLL; | |||
|  | using Model; | |||
|  | using WebAPI.Filter; | |||
|  | 
 | |||
|  | namespace WebAPI.Controllers | |||
|  | { | |||
|  |     /// <summary> | |||
|  |     ///  | |||
|  |     /// </summary> | |||
|  |     public class DoorServiceController : ApiController | |||
|  |     { | |||
|  |         #region 项目出入记录接口 | |||
|  |         /// <summary> | |||
|  |         /// 保存出入记录信息 | |||
|  |         /// </summary> | |||
|  |         /// <param name="records">出入记录信息</param> | |||
|  |         /// <returns></returns> | |||
|  |         [HttpPost] | |||
|  |         public Model.ResponeData postPersonInOuts([FromBody] Model.attendanceItems records) | |||
|  |         { | |||
|  |             var responeData = new Model.ResponeData(); | |||
|  |             try | |||
|  |             { | |||
|  |                 if (records != null && records.records.Count() > 0) | |||
|  |                 { | |||
|  |                     List<Model.attendanceItem> attendanceItems = records.records; | |||
|  |                     var getprojectCode = attendanceItems.FirstOrDefault(x => x.ProjectCode != null || x.ProjectId != null); | |||
|  |                     if (getprojectCode != null) | |||
|  |                     { | |||
|  |                         string projectId = getprojectCode.ProjectId; | |||
|  |                         if (string.IsNullOrEmpty(projectId)) | |||
|  |                         { | |||
|  |                             var getProject = ProjectService.GetProjectByProjectCode(getprojectCode.ProjectCode); | |||
|  |                             if (getProject != null) | |||
|  |                             { | |||
|  |                                 projectId = getProject.ProjectId; | |||
|  |                             }                            | |||
|  |                         } | |||
|  |                         if (!string.IsNullOrEmpty(projectId)) | |||
|  |                         { | |||
|  |                             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | |||
|  |                             { | |||
|  |                                 int maxId = 0; | |||
|  |                                 var getmax = db.T_d_facerecord.Where(x => x.ProjectId == projectId && x.RoleID == "白名单").Select(x => x.ID); | |||
|  |                                 if (getmax.Count() > 0) | |||
|  |                                 { | |||
|  |                                     maxId = getmax.Max(); | |||
|  |                                 } | |||
|  |                                 foreach (var item in attendanceItems) | |||
|  |                                 { | |||
|  |                                     maxId = maxId + 1; | |||
|  |                                     string name = string.Empty; | |||
|  |                                     string cardNo = string.Empty; | |||
|  |                                     var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == item.idCardNumber); | |||
|  |                                     if (getPerson != null) | |||
|  |                                     { | |||
|  |                                         name = getPerson.PersonName; | |||
|  |                                         cardNo = getPerson.CardNo; | |||
|  |                                     } | |||
|  | 
 | |||
|  |                                     Model.T_d_facerecord newFacerecord = new Model.T_d_facerecord() | |||
|  |                                     { | |||
|  |                                         NewID = SQLHelper.GetNewID(), | |||
|  |                                         ProjectId = projectId, | |||
|  |                                         ID = maxId, | |||
|  |                                         EmployName = name, | |||
|  |                                         EmployNO = item.idCardNumber, | |||
|  |                                         RoleID = "白名单", | |||
|  |                                         DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime), | |||
|  |                                         RecordDes = "白名单:允许通行", | |||
|  |                                         InOrOut = (item.attendanceType == 1 ? "进门" : "出门"), | |||
|  |                                     }; | |||
|  | 
 | |||
|  |                                     db.T_d_facerecord.InsertOnSubmit(newFacerecord); | |||
|  |                                     db.SubmitChanges(); | |||
|  |                                     ///// 根据出入记录 写入考勤记录 | |||
|  |                                     Model.t_d_facerecordItem facerecord = new Model.t_d_facerecordItem | |||
|  |                                     { | |||
|  |                                         ID = maxId, | |||
|  |                                         EmployName = name, | |||
|  |                                         IDCardNo = item.idCardNumber, | |||
|  |                                         EmployNO = item.idCardNumber, | |||
|  |                                         ProjectId = projectId, | |||
|  |                                         RoleID = "白名单", | |||
|  |                                         DateTimeRecord = Funs.GetNewDateTime(item.attendanceTime), | |||
|  |                                         RecordDes = "白名单:允许通行", | |||
|  |                                         InOrOut = (item.attendanceType == 1 ? "进门" : "出门"), | |||
|  |                                     };                                | |||
|  |                                     if (facerecord.DateTimeRecord.HasValue) | |||
|  |                                     { | |||
|  |                                         int isIn = 0; | |||
|  |                                         if (facerecord.InOrOut == "进门") | |||
|  |                                         { | |||
|  |                                             isIn = 1; | |||
|  |                                         } | |||
|  |                                         APIPersonService.getPersonInOut(facerecord.ProjectId, facerecord.EmployNO, isIn, facerecord.DateTimeRecord.Value); | |||
|  |                                     }                                    | |||
|  |                                 } | |||
|  |                                 responeData.message = "插入成功!"; | |||
|  |                             } | |||
|  |                         } | |||
|  |                         else | |||
|  |                         { | |||
|  |                             responeData.code = 0; | |||
|  |                             responeData.message = "项目号异常!"; | |||
|  |                         } | |||
|  |                     } | |||
|  |                     else | |||
|  |                     { | |||
|  |                         responeData.code = 0; | |||
|  |                         responeData.message = "项目号为空!"; | |||
|  |                     } | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     responeData.code = 0; | |||
|  |                     responeData.message = "数据为空!"; | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 responeData.code = 0; | |||
|  |                 responeData.message = ex.Message; | |||
|  |             } | |||
|  | 
 | |||
|  |             return responeData; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 项目出入人员信息 | |||
|  |         /// <summary> | |||
|  |         /// 保存人员信息 | |||
|  |         /// </summary> | |||
|  |         /// <param name="person">人员信息</param> | |||
|  |         /// <returns></returns> | |||
|  |         [HttpPost] | |||
|  |         public Model.ResponeData postPersons([FromBody] Model.PersonItem person) | |||
|  |         { | |||
|  |             var responeData = new Model.ResponeData(); | |||
|  |             try | |||
|  |             { | |||
|  |                 if (person != null) | |||
|  |                 { | |||
|  |                     using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | |||
|  |                     { | |||
|  |                         var getProject = ProjectService.GetProjectByProjectCode(person.ProjectCode); | |||
|  |                         if (getProject != null) | |||
|  |                         { | |||
|  |                             var getUnit = UnitService.getUnitByCollCropCodeUnitName(person.CollCropCode, person.UnitName); | |||
|  |                             if (getUnit != null) | |||
|  |                             { | |||
|  |                                 Model.SitePerson_Person newPerson = new Model.SitePerson_Person | |||
|  |                                 { | |||
|  |                                     PersonId = SQLHelper.GetNewID(), | |||
|  |                                     ProjectId = getProject.ProjectId, | |||
|  |                                     UnitId = getUnit.UnitId, | |||
|  |                                     PersonName = person.PersonName, | |||
|  |                                     IdentityCard = person.IdentityCard, | |||
|  |                                     IdcardType = "SHENFEN_ZHENGJIAN", | |||
|  |                                     IdcardAddress = person.IdcardAddress, | |||
|  |                                     IdcardForever = "N", | |||
|  |                                     IdcardStartDate = Funs.GetNewDateTime(person.IdcardStartDate), | |||
|  |                                     IdcardEndDate = Funs.GetNewDateTime(person.IdcardEndDate), | |||
|  |                                     Sex = (person.Sex == "女" || person.Sex == "2") ? "2" : "1", | |||
|  |                                     Address = person.Address, | |||
|  |                                     OutResult = person.OutResult, | |||
|  |                                     Birthday = person.Birthday, | |||
|  |                                     Telephone = person.Telephone, | |||
|  |                                     IsUsed = (person.IsUsed == false ? false : true), | |||
|  |                                     InTime = Funs.GetNewDateTimeOrNow(person.InTime), | |||
|  |                                     Password = BLL.PersonService.GetPersonPassWord(person.IdentityCard), | |||
|  |                                     Isprint = "0", | |||
|  |                                 }; | |||
|  |                                 if (!string.IsNullOrEmpty(person.TeamGroupName) && !string.IsNullOrEmpty(newPerson.UnitId)) | |||
|  |                                 { | |||
|  |                                     var getTeamGroup = TeamGroupService.getTeamGroupByTeamGroupName(getProject.ProjectId, newPerson.UnitId, person.TeamGroupName); | |||
|  |                                     if (getTeamGroup != null) | |||
|  |                                     { | |||
|  |                                         newPerson.TeamGroupId = getTeamGroup.TeamGroupId; | |||
|  |                                     } | |||
|  |                                     else | |||
|  |                                     { | |||
|  |                                         Model.ProjectData_TeamGroup newTeamGroup = new Model.ProjectData_TeamGroup | |||
|  |                                         { | |||
|  |                                             TeamGroupId = SQLHelper.GetNewID(), | |||
|  |                                             ProjectId = getProject.ProjectId, | |||
|  |                                             UnitId = newPerson.UnitId, | |||
|  |                                             TeamGroupName = person.TeamGroupName, | |||
|  |                                             Remark = "来源:门禁对接数据", | |||
|  |                                             TeamTypeId = "CANJIAN_TEAM", | |||
|  |                                             EntryTime = System.DateTime.Now, | |||
|  |                                             RealNamePushTime = null, | |||
|  |                                         }; | |||
|  |                                         db.ProjectData_TeamGroup.InsertOnSubmit(newTeamGroup); | |||
|  |                                         db.SubmitChanges(); | |||
|  |                                         newPerson.TeamGroupId = newTeamGroup.TeamGroupId; | |||
|  |                                     } | |||
|  |                                 } | |||
|  |                                 var getWorkArea = UnitWorkService.GetUnitWorkByUnitWorkName(getProject.ProjectId, person.WorkAreaName); | |||
|  |                                 if (getWorkArea != null) | |||
|  |                                 { | |||
|  |                                     newPerson.WorkAreaId = getWorkArea.UnitWorkId; | |||
|  |                                 } | |||
|  |                                 var getWorkPost = WorkPostService.GetWorkPostByName(person.WorkPostName); | |||
|  |                                 if (getWorkPost != null) | |||
|  |                                 { | |||
|  |                                     newPerson.WorkPostId = getWorkPost.WorkPostId; | |||
|  |                                 } | |||
|  |                                 var getHsseMan = ProjectService.getHSSEManager(getProject.ProjectId); | |||
|  |                                 if (getHsseMan != null) | |||
|  |                                 { | |||
|  |                                     newPerson.AuditorId = getHsseMan.UserId; | |||
|  |                                     newPerson.AuditorDate = DateTime.Now; | |||
|  |                                 } | |||
|  |                                 newPerson.OutTime = Funs.GetNewDateTime(person.OutTime); | |||
|  |                                 if (person.headImage != null) | |||
|  |                                 { | |||
|  |                                     var image = Convert.FromBase64String(person.headImage); | |||
|  |                                     newPerson.HeadImage = image; | |||
|  |                                     string rootPath = ConfigurationManager.AppSettings["localRoot"]; | |||
|  |                                     string path = "FileUpLoad/PersonBaseInfo/" + DateTime.Now.ToString("yyyy-MM") + "/"; | |||
|  |                                     string fileUrl = (rootPath + path).Replace('/', '\\'); | |||
|  |                                     string flieName = Funs.GetNewFileName() + "~" + person.PersonName + ".jpg"; | |||
|  |                                     if (!Directory.Exists(fileUrl)) | |||
|  |                                     { | |||
|  |                                         Directory.CreateDirectory(fileUrl); | |||
|  |                                     } | |||
|  |                                     newPerson.PhotoUrl = path + flieName; | |||
|  |                                     File.WriteAllBytes((fileUrl + flieName), image); | |||
|  |                                     //AttachFileService.Base64ToImage(person.headImage, path, person.PersonName); | |||
|  |                                 } | |||
|  | 
 | |||
|  |                                 var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.ProjectId == getProject.ProjectId && e.IdentityCard == person.IdentityCard); | |||
|  |                                 if (getPerson == null) | |||
|  |                                 { | |||
|  |                                     PersonService.AddPerson(newPerson); | |||
|  |                                     responeData.message = "新增人员成功!"; | |||
|  |                                 } | |||
|  |                                 else | |||
|  |                                 { | |||
|  |                                     if (!string.IsNullOrEmpty(person.OutTime)) | |||
|  |                                     { | |||
|  |                                         var outTime = Funs.GetNewDateTimeOrNow(person.OutTime); | |||
|  |                                         PersonService.PersonOut(getPerson.PersonId, outTime); | |||
|  |                                         responeData.message = "更新出场时间"; | |||
|  |                                     } | |||
|  |                                     else | |||
|  |                                     { | |||
|  |                                         getPerson.PersonName = newPerson.PersonName; | |||
|  |                                         getPerson.IdcardAddress = newPerson.IdcardAddress; | |||
|  |                                         getPerson.IdcardStartDate = newPerson.IdcardStartDate; | |||
|  |                                         getPerson.IdcardEndDate = newPerson.IdcardEndDate; | |||
|  |                                         getPerson.Sex = newPerson.Sex; | |||
|  |                                         getPerson.Address = newPerson.Address; | |||
|  |                                         getPerson.OutResult = newPerson.OutResult; | |||
|  |                                         getPerson.Birthday = newPerson.Birthday; | |||
|  |                                         getPerson.Telephone = newPerson.Telephone; | |||
|  |                                         getPerson.IsUsed = true; | |||
|  |                                         getPerson.InTime = newPerson.InTime; | |||
|  |                                         if (!string.IsNullOrEmpty(newPerson.PhotoUrl)) | |||
|  |                                         { | |||
|  |                                             getPerson.PhotoUrl = newPerson.PhotoUrl; | |||
|  |                                         } | |||
|  |                                         db.SubmitChanges(); | |||
|  |                                         responeData.message = getPerson.PersonName+ ":信息更新成功!"; | |||
|  |                                     } | |||
|  |                                 } | |||
|  |                             } | |||
|  |                             else | |||
|  |                             { | |||
|  |                                 responeData.code = 0; | |||
|  |                                 responeData.message = "单位:" + person.UnitName + "施工平台不存在!"; | |||
|  |                             } | |||
|  |                         } | |||
|  |                         else | |||
|  |                         { | |||
|  |                             responeData.code = 0; | |||
|  |                             responeData.message = "项目号:" + person.ProjectCode + "施工平台不存在!"; | |||
|  |                         } | |||
|  |                     } | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     responeData.code = 0; | |||
|  |                     responeData.message = "数据为空!"; | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 responeData.code = 0; | |||
|  |                 responeData.message = ex.Message; | |||
|  |             } | |||
|  | 
 | |||
|  |             return responeData; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 获取在岗人员 -照片不空 | |||
|  |         /// <summary> | |||
|  |         /// 获取在岗人员 | |||
|  |         /// </summary> | |||
|  |         /// <param name="projectCode"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public Model.ResponeData getPersons(string projectCode) | |||
|  |         { | |||
|  |             var responeData = new Model.ResponeData(); | |||
|  |             try | |||
|  |             { | |||
|  |                 var getProject = Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectCode == projectCode); | |||
|  |                 if (getProject != null) | |||
|  |                 { | |||
|  |                     responeData.data = from x in Funs.DB.SitePerson_Person | |||
|  |                                        join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId | |||
|  |                                        join T in Funs.DB.ProjectData_TeamGroup on x.TeamGroupId equals T.TeamGroupId | |||
|  |                                        join w in Funs.DB.Base_WorkPost on x.WorkPostId equals w.WorkPostId | |||
|  |                                        where x.ProjectId == getProject.ProjectId && !x.ExchangeTime.HasValue | |||
|  |                                        && (!x.OutTime.HasValue || x.OutTime > DateTime.Now) | |||
|  |                                        && x.InTime.HasValue && x.InTime < DateTime.Now | |||
|  |                                        && x.IsUsed == true  | |||
|  |                                        && x.PhotoUrl != null | |||
|  |                                        select new | |||
|  |                                        { | |||
|  |                                            x.PersonId, | |||
|  |                                            x.PersonName, | |||
|  |                                            x.CardNo, | |||
|  |                                            x.IdentityCard, | |||
|  |                                            x.UnitId, | |||
|  |                                            y.UnitCode, | |||
|  |                                            y.UnitName, | |||
|  |                                            y.ShortUnitName, | |||
|  |                                            T.TeamGroupName, | |||
|  |                                            x.Sex, | |||
|  |                                            w.WorkPostName, | |||
|  |                                            x.Telephone, | |||
|  |                                            x.Address, | |||
|  |                                            x.InTime, | |||
|  |                                            x.AuditorDate, | |||
|  |                                            x.ExchangeTime, | |||
|  |                                            x.ExchangeTime2, | |||
|  |                                            x.PhotoUrl, | |||
|  |                                        }; | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     responeData.code = 0; | |||
|  |                     responeData.message = "数据为空!"; | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 responeData.code = 0; | |||
|  |                 responeData.message = ex.Message; | |||
|  |                 ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "DoorServiceController.getPersons"); | |||
|  |             } | |||
|  |             return responeData; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 更新人员数据交换时间 | |||
|  |         /// <summary> | |||
|  |         /// 更新人员数据交换时间 | |||
|  |         /// </summary> | |||
|  |         /// <param name="projectCode"></param> | |||
|  |         /// <param name="idCard"></param> | |||
|  |         /// <param name="type"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public Model.ResponeData getUpdatePersonExchangeTime(string projectCode, string idCard, string type) | |||
|  |         { | |||
|  |             var responeData = new Model.ResponeData(); | |||
|  |             try | |||
|  |             { | |||
|  |                 using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | |||
|  |                 { | |||
|  |                     var getProject = db.Base_Project.FirstOrDefault(e => e.ProjectCode == projectCode); | |||
|  |                     if (getProject != null) | |||
|  |                     { | |||
|  |                         var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.ProjectId == getProject.ProjectId && e.IdentityCard == idCard); | |||
|  |                         if (getPerson != null && !string.IsNullOrEmpty(type)) | |||
|  |                         { | |||
|  |                             if (type == "1") | |||
|  |                             { | |||
|  |                                 getPerson.ExchangeTime2 = DateTime.Now; | |||
|  |                                 if (!getPerson.ExchangeTime.HasValue) | |||
|  |                                 { | |||
|  |                                     getPerson.ExchangeTime = DateTime.Now; | |||
|  |                                 } | |||
|  |                             } | |||
|  |                             else | |||
|  |                             { | |||
|  |                                 getPerson.ExchangeTime = DateTime.Now; | |||
|  |                             } | |||
|  |                             db.SubmitChanges(); | |||
|  |                         } | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 responeData.code = 0; | |||
|  |                 responeData.message = ex.Message; | |||
|  |                 ErrLogInfo.WriteLog(ex, "WX接口-更新人员数据交换时间", "PersonController.getUpdatePersonExchangeTime"); | |||
|  |             } | |||
|  |             return responeData; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 获取离场人员 | |||
|  |         /// <summary> | |||
|  |         /// 获取离场人员 | |||
|  |         /// </summary> | |||
|  |         /// <param name="projectCode"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public Model.ResponeData getOutWorkPersons(string projectCode) | |||
|  |         { | |||
|  |             var responeData = new Model.ResponeData(); | |||
|  |             try | |||
|  |             { | |||
|  |                 using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | |||
|  |                 { | |||
|  |                     var getProject = db.Base_Project.FirstOrDefault(e => e.ProjectCode == projectCode); | |||
|  |                     if (getProject != null) | |||
|  |                     { | |||
|  |                         responeData.data = (from x in db.SitePerson_Person | |||
|  |                                             where x.ProjectId == getProject.ProjectId | |||
|  |                                               && x.OutTime.HasValue | |||
|  |                                               && !x.ExchangeTime2.HasValue && x.ExchangeTime.HasValue | |||
|  |                                             select new | |||
|  |                                             { | |||
|  |                                                 x.PersonId, | |||
|  |                                                 x.PersonName, | |||
|  |                                                 x.CardNo, | |||
|  |                                                 x.IdentityCard, | |||
|  |                                                 OutTime = x.OutTime == null ? DateTime.Now.AddYears(10) : x.OutTime, | |||
|  |                                             }).Take(200).ToList(); | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 responeData.code = 0; | |||
|  |                 responeData.message = ex.Message; | |||
|  |             } | |||
|  |             return responeData; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 插入人员出入场记录 | |||
|  |         /// <summary> | |||
|  |         /// 获取人员出入场记录 | |||
|  |         /// </summary> | |||
|  |         /// <param name="projectCode"></param> | |||
|  |         /// <param name="idCard"></param> | |||
|  |         /// <param name="isIn"></param> | |||
|  |         /// <param name="changeTime"></param> | |||
|  |         /// <returns></returns> | |||
|  |         public Model.ResponeData getPersonInOut(string projectCode, string idCard, int isIn, DateTime changeTime) | |||
|  |         { | |||
|  |             var responeData = new Model.ResponeData(); | |||
|  |             try | |||
|  |             { | |||
|  |                 var getProject = ProjectService.GetProjectByProjectCode(projectCode); | |||
|  |                 if (getProject != null) | |||
|  |                 { | |||
|  |                     Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut | |||
|  |                     { | |||
|  |                         ProjectId = getProject.ProjectId, | |||
|  |                         IdentityCard = idCard, | |||
|  |                         IsIn = isIn == 1 ? true : false, | |||
|  |                         ChangeTime = changeTime, | |||
|  |                         InOutWay = Const.InOutWay_1, | |||
|  |                     }; | |||
|  | 
 | |||
|  |                     PersonInOutService.AddPersonInOut(newInOut); | |||
|  |                 } | |||
|  |             } | |||
|  |             catch (Exception ex) | |||
|  |             { | |||
|  |                 responeData.code = 0; | |||
|  |                 responeData.message = ex.Message; | |||
|  |                 ErrLogInfo.WriteLog(ex, "WX接口-插入人员出入场记录", "PersonController.getPersonInOut"); | |||
|  |             } | |||
|  |             return responeData; | |||
|  |         } | |||
|  | 		#endregion | |||
|  | 
 | |||
|  | 
 | |||
|  | 		/// <summary> | |||
|  | 		/// 获取人员考勤接口 | |||
|  | 		/// </summary> | |||
|  | 		/// <param name="projectId"></param> | |||
|  | 		/// <param name="dateA"></param> | |||
|  | 		/// <param name="dateZ"></param> | |||
|  | 		/// <returns></returns> | |||
|  | 		public Model.ResponeData getAttendance(string projectId, string dateA, string dateZ) | |||
|  | 		{ | |||
|  | 			var responeData = new Model.ResponeData(); | |||
|  | 			try | |||
|  | 			{ | |||
|  | 				string unitId = null; | |||
|  | 				string PostId = null; | |||
|  | 				var getData = Funs.DB.spInOutManHoursReport(projectId, unitId, PostId, Funs.GetNewDateTimeOrNow(dateA), Funs.GetNewDateTimeOrNow(dateZ)); | |||
|  | 				Dictionary<string, int> res = new Dictionary<string, int>(); | |||
|  | 				foreach (InOutstatisticsItem row in getData ) | |||
|  | 				{ | |||
|  | 					if (res.ContainsKey(row.UnitName + "$" + row.PostName)) | |||
|  | 					{ | |||
|  | 						res[row.UnitName + "$" + row.PostName]+= row.PersonCountSum.Value; | |||
|  | 
 | |||
|  | 					} | |||
|  | 					else | |||
|  | 					{ | |||
|  | 						res.Add(row.UnitName + "$" + row.PostName,row.PersonCountSum.Value); | |||
|  | 					} | |||
|  | 				} | |||
|  | 				DataTable dt = new DataTable(); | |||
|  | 				dt.Columns.Add("unit"); | |||
|  | 				dt.Columns.Add("post"); | |||
|  | 				dt.Columns.Add("count"); | |||
|  | 
 | |||
|  | 				foreach (string key in res.Keys) | |||
|  | 				{ | |||
|  | 					var row = dt.NewRow(); | |||
|  | 					row["unit"] = key.Split('$')[0]; | |||
|  | 					row["post"] = key.Split('$')[1]; | |||
|  | 					row["count"] = res[key]; | |||
|  | 					dt.Rows.Add(row); | |||
|  | 				} | |||
|  | 				responeData.data = dt; | |||
|  | 			} | |||
|  | 			catch (Exception ex) | |||
|  | 			{ | |||
|  | 				responeData.code = 0; | |||
|  | 				responeData.message = ex.Message; | |||
|  | 				ErrLogInfo.WriteLog(ex, "WX接口-插入人员出入场记录", "PersonController.getPersonInOut"); | |||
|  | 			} | |||
|  | 			return responeData; | |||
|  | 		} | |||
|  | 	} | |||
|  | } |