using BLL; using Model; using System; using System.Linq; using System.Web.Http; namespace WebAPI.Controllers { /// /// 人员信息 /// public class PersonController : ApiController { #region 根据personid获取人员档案基本信息 /// /// 根据personid获取人员档案基本信息 /// /// /// public Model.ResponeData getPersonInfoByPersonId(string personId) { var responeData = new Model.ResponeData(); try { var personData = APIPersonService.getPersonByPersonId(personId); PersonInfoItem data = new PersonInfoItem(); data.PersonId = personData.PersonId; data.PersonName = personData.PersonName; data.SexName = personData.SexName; data.IdentityCard = personData.IdentityCard; data.Telephone = personData.Telephone; data.UnitName = personData.UnitName; data.TeamGroupName = personData.TeamGroupName; data.WorkPostName = personData.WorkPostName; data.InTime = personData.InTime; data.PhotoUrl = personData.PhotoUrl; //获取用户本年HSE分值、培训学时(待处理) data.HSEScore = 0; data.LearnHour = 0; responeData.data = data; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据personid获取人员信息 /// /// 根据personid获取人员信息 /// /// /// public Model.ResponeData getPersonByPersonId(string personId) { var responeData = new Model.ResponeData(); try { responeData.data = APIPersonService.getPersonByPersonId(personId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据identityCard获取人员信息 /// /// 根据identityCard获取人员信息 /// /// /// public Model.ResponeData getPersonByIdentityCard(string identityCard) { var responeData = new Model.ResponeData(); try { responeData.data = APIPersonService.getPersonByPersonId(identityCard); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId、identityCard获取人员信息 /// /// 根据projectId、identityCard获取人员信息 /// /// /// /// public Model.ResponeData getPersonByProjectIdIdentityCard(string projectId, string identityCard) { var responeData = new Model.ResponeData(); try { responeData.data = APIPersonService.getPersonByProjectIdIdentityCard(projectId, identityCard); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId、unitid获取人员信息 /// /// 根据projectId、unitid获取人员信息 /// /// /// /// /// public Model.ResponeData getPersonByProjectIdUnitId(string projectId, string unitId, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getPersonByProjectIdUnitId(projectId, unitId); int pageCount = getDataList.Count; if (pageCount > 0 && pageIndex > 0) { getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取在岗、离岗、待审人员数量 /// /// 获取在岗、离岗、待审人员列表 /// /// /// /// /// /// /// /// public Model.ResponeData getPersonStatesCount(string projectId, string unitId, string states, string strUnitId, string strWorkPostId, string strParam) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var getViews = from x in db.SitePerson_Person where x.ProjectId == projectId && (strUnitId == null || x.UnitId == strUnitId) && (strWorkPostId == null || x.WorkPostId == strWorkPostId) select x; if (unitId != Const.UnitId_TCC && !string.IsNullOrEmpty(unitId)) { getViews = getViews.Where(x => x.UnitId == unitId); } if (!string.IsNullOrEmpty(strParam)) { getViews = getViews.Where(x => x.PersonName.Contains(strParam) || x.IdentityCard.Contains(strParam)); } int tatalCount = getViews.Count(); //在审 int count0 = getViews.Where(x => x.IsUsed == false && !x.AuditorDate.HasValue).Count(); //在岗 int count1 = getViews.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now)).Count(); //离岗 int count2 = getViews.Where(x => x.IsUsed == true && x.OutTime <= DateTime.Now).Count(); //打回 int count3 = getViews.Where(x => x.IsUsed == false && x.AuditorDate.HasValue).Count(); responeData.data = new { tatalCount, count0, count1, count2, count3 }; } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取在岗、离岗、待审人员列表 /// /// 获取在岗、离岗、待审人员列表 /// /// /// 当前人单位ID /// 0待审1在岗2离岗 /// 查询单位 /// 查询岗位 /// 查询条件 /// /// public Model.ResponeData getPersonListByProjectIdStates(string projectId, string unitId, string states, string strUnitId, string strWorkPostId, string strParam, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getPersonListByProjectIdStates(projectId, unitId, states, strUnitId, strWorkPostId, strParam, pageIndex); int pageCount = APIPersonService.getPersonListCount; responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据identityCard获取人员培训考试信息 /// /// 根据identityCard获取人员培训考试信息 /// /// /// /// public Model.ResponeData getPersonTestRecoedByIdentityCard(string identityCard, string projectId = null) { var responeData = new Model.ResponeData(); try { responeData.data = APIPersonService.getPersonTestRecoedByIdentityCard(identityCard, projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据identityCard获取人员资质信息 /// /// 根据identityCard获取人员资质信息 /// /// /// /// public Model.ResponeData getPersonQualityByIdentityCard(string identityCard, string projectId = null) { var responeData = new Model.ResponeData(); try { responeData.data = APIPersonService.getPersonQualityByIdentityCard(identityCard, projectId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId、unitid获取特岗人员资质各状态数 /// /// 根据projectId、unitid获取特岗人员资质各状态数 /// /// 项目ID /// 单位ID /// 人员资质数量 public Model.ResponeData getPersonQualityCount(string projectId, string unitId) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var getDataList = db.View_QualityAudit_PersonQuality.Where(x => x.ProjectId == projectId && x.CertificateId != null); if (ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(projectId, unitId)) { getDataList = getDataList.Where(x => x.UnitId == unitId); } //总数 int tatalCount = getDataList.Count(); //过期 int count1 = getDataList.Where(x => x.LimitDate < DateTime.Now).Count(); //即将过期 int count2 = getDataList.Where(x => x.LimitDate >= DateTime.Now && x.LimitDate < DateTime.Now.AddMonths(1)).Count(); responeData.data = new { tatalCount, count1, count2 }; } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据projectId、unitid获取特岗人员资质信息 /// /// 根据projectId、unitid获取特岗人员资质信息 /// /// 项目ID /// 单位ID /// 数据类型0-已过期;1-即将过期;2-无证;3-待审核;4-已审核;-1打回 /// 页码 /// public Model.ResponeData getPersonQualityByProjectIdUnitId(string projectId, string unitId, string type, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getPersonQualityByProjectIdUnitId(projectId, unitId, type); int pageCount = getDataList.Count(); if (pageCount > 0 && pageIndex > 0) { getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 保存 人员资质信息 QualityAudit_PersonQuality /// /// 保存Meeting /// /// 人员资质信息 /// [HttpPost] public Model.ResponeData SavePersonQuality([FromBody] Model.PersonQualityItem personQuality) { var responeData = new Model.ResponeData(); try { APIPersonService.SavePersonQuality(personQuality); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据项目\单位\岗位\培训类型获取项目培训\考试人员信息 /// /// 根据项目\单位\岗位\培训类型获取项目培训\考试人员信息 /// /// 项目ID /// 培训单位ID /// 培训岗位ID(可为空) /// 培训类型ID(可为空) /// 分页 /// public Model.ResponeData getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string trainTypeId, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getTrainingPersonListByTrainTypeId(projectId, unitIds, workPostIds, trainTypeId).OrderBy(x => x.UnitName).ThenBy(x => x.ProjectName).ToList(); int pageCount = getDataList.Count; if (pageCount > 0 && pageIndex > 0) { getDataList = getDataList.OrderBy(u => u.UnitName).ThenBy(u => u.PersonName).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); ////200 ->Funs.PageSize } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 保存项目人员信息 /// /// 保存项目人员信息 /// /// 人员信息 /// [HttpPost] public Model.ResponeData SaveSitePerson([FromBody] Model.PersonItem person) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { if (person != null && !string.IsNullOrEmpty(person.IdentityCard)) { string photourl = person.PhotoUrl; var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.ProjectId == person.ProjectId); if (getPerson != null && getPerson.PersonId != person.PersonId && !string.IsNullOrEmpty(person.PersonId)) { responeData.code = -1; responeData.message = "该身份证号码已存在两条记录,请联系管理员处理!"; } else { if (getPerson != null) { person.PersonId = getPerson.PersonId; } if (!string.IsNullOrEmpty(person.UnitId)) { var unit = db.Base_Unit.FirstOrDefault(x => x.UnitCode == person.UnitId); if (unit != null) { person.UnitId = unit.UnitId; } } var getNewPerson = APIPersonService.SaveSitePerson(person); if (getNewPerson != null) { var getProject = ProjectService.GetProjectByProjectId(getNewPerson.ProjectId); if (!string.IsNullOrEmpty(getNewPerson.PhotoUrl) && getProject != null && getProject.IsFace == true) { responeData.message = APIPersonService.PersonFace(getNewPerson); if (!responeData.message.Contains("成功")) { responeData.code = 2; } } responeData.data = getNewPerson.PersonId; } } db.SubmitChanges(); } else { responeData.code = -1; responeData.message = "人员信息有误!"; } } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } [HttpPost] public Model.ResponeData SaveAndUpdateSitePerson([FromBody] Model.PersonItem person) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { if (person != null && !string.IsNullOrEmpty(person.IdentityCard)) { string photourl = person.PhotoUrl; var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.ProjectId == person.ProjectId); if (getPerson != null && getPerson.PersonId != person.PersonId && !string.IsNullOrEmpty(person.PersonId)) { getPerson.InTime = Funs.GetNewDateTime(person.InTime); getPerson.OutTime = Funs.GetNewDateTime(person.OutTime); if (!string.IsNullOrEmpty(person.TeamGroupId)) { getPerson.TeamGroupId = person.TeamGroupId; } else if (!string.IsNullOrEmpty(person.TeamGroupName)) { var group = db.ProjectData_TeamGroup.FirstOrDefault(x => x.ProjectId == person.ProjectId && x.TeamGroupName == person.TeamGroupName); if (group != null) { getPerson.TeamGroupId = group.TeamGroupId; } else { Model.ProjectData_TeamGroup teamGroup = new Model.ProjectData_TeamGroup(); teamGroup.TeamGroupId = Guid.NewGuid().ToString(); teamGroup.ProjectId = person.ProjectId; teamGroup.EntryTime = DateTime.Now; teamGroup.TeamGroupName = person.TeamGroupName; teamGroup.UnitId = person.UnitId; teamGroup.TeamTypeId = "CANJIAN_TEAM"; db.ProjectData_TeamGroup.InsertOnSubmit(teamGroup); db.SubmitChanges(); } } if (!string.IsNullOrEmpty(person.WorkPostId)) { getPerson.WorkPostId = person.WorkPostId; } else if (!string.IsNullOrEmpty(person.WorkPostName)) { var post = db.Base_WorkPost.FirstOrDefault(x => x.WorkPostName == person.WorkPostName); if (post != null) { getPerson.WorkPostId = post.WorkPostId; } } if (person.IsUsed == true) { getPerson.IsUsed = true; } else { getPerson.IsUsed = false; } db.SubmitChanges(); responeData.code = 1; responeData.message = "更新成功"; } else { if (getPerson != null) { person.PersonId = getPerson.PersonId; } if (!string.IsNullOrEmpty(person.UnitId)) { var unit = db.Base_Unit.FirstOrDefault(x => x.UnitCode == person.UnitId); if (unit != null) { person.UnitId = unit.UnitId; } } var getNewPerson = APIPersonService.SaveSitePerson(person); if (getNewPerson != null) { var getProject = ProjectService.GetProjectByProjectId(getNewPerson.ProjectId); if (!string.IsNullOrEmpty(getNewPerson.PhotoUrl) && getProject != null && getProject.IsFace == true) { responeData.message = APIPersonService.PersonFace(getNewPerson); if (!responeData.message.Contains("成功")) { responeData.code = 2; } } responeData.data = getNewPerson.PersonId; } } db.SubmitChanges(); } else { responeData.code = -1; responeData.message = "人员信息有误!"; } } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据personid人员打回 /// /// 根据personid人员打回 /// /// 人员ID /// 审核人id /// public Model.ResponeData getReUserPersonByPersonId(string personId, string userId) { var responeData = new Model.ResponeData(); try { APIPersonService.getReUserPersonByPersonId(personId, userId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 更新人员更新附件 /// /// 更新人员更新附件 /// /// 人员信息 /// [HttpPost] public Model.ResponeData SaveSitePersonAttachment([FromBody] Model.PersonItem person) { var responeData = new Model.ResponeData(); try { APIPersonService.SaveSitePersonAttachment(person); var getNewPerson = PersonService.GetPersonById(person.PersonId); if (getNewPerson != null) { var getProject = ProjectService.GetProjectByProjectId(getNewPerson.ProjectId); if (!string.IsNullOrEmpty(person.PhotoUrl) && getProject != null && getProject.IsFace == true) { responeData.message = APIPersonService.PersonFace(getNewPerson); if (!responeData.message.Contains("成功")) { responeData.code = 2; } } } else { responeData.code = 2; responeData.message = "人员附件信息有误!"; } } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 人员离场 /// /// 人员离场 /// /// /// public Model.ResponeData getPersonOut(string personId) { var responeData = new Model.ResponeData(); try { APIPersonService.getPersonOut(personId); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 人员离场 /// /// 人员离场 /// /// /// [HttpGet] public Model.ResponeData addToBlack(string personId, bool black, string reason = "") { var responeData = new Model.ResponeData(); try { APIPersonService.addToBlack(personId, black, reason); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取项目当日在场人员数据 /// /// 获取项目当日在场人员数据 /// /// /// [HttpGet] public Model.ResponeData getPersonPresenceData(string projectId, DateTime date) { var responeData = new Model.ResponeData(); try { responeData.data = APIPersonService.getPersonPresenceData(projectId, date); } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 插入人员出入场记录 /// /// 获取人员出入场记录 /// /// /// /// /// /// public Model.ResponeData getPersonInOut(string projectId, string idCard, int isIn, DateTime changeTime) { var responeData = new Model.ResponeData(); try { Model.SitePerson_PersonInOut newInOut = new Model.SitePerson_PersonInOut { ProjectId = 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 #region 获取发卡人员 /// /// 获取发卡人员 /// /// /// public Model.ResponeData getPersonDataExchange(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId where x.BlackList == null || x.BlackList == false where x.ProjectId == 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, Funs.DB.ProjectData_TeamGroup.First(z => z.TeamGroupId == x.TeamGroupId).TeamGroupName, x.Sex, Funs.DB.Base_WorkPost.First(z => z.WorkPostId == x.WorkPostId).WorkPostName, x.Telephone, x.Address, x.InTime, x.AuditorDate, x.ExchangeTime, x.ExchangeTime2, x.PhotoUrl, }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "PersonController.getPersonDataExchange"); } return responeData; } public Model.ResponeData getAllPersonDataExchange(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId where x.ProjectId == projectId && !x.ExchangeTime.HasValue && x.InTime.HasValue && x.InTime < DateTime.Now && x.PhotoUrl != null select new { x.PersonId, x.PersonName, x.CardNo, x.IdentityCard, x.UnitId, y.UnitCode, y.UnitName, y.ShortUnitName, Funs.DB.ProjectData_TeamGroup.First(z => z.TeamGroupId == x.TeamGroupId).TeamGroupName, x.Sex, Funs.DB.Base_WorkPost.First(z => z.WorkPostId == x.WorkPostId).WorkPostName, x.Telephone, x.Address, x.InTime, x.AuditorDate, x.ExchangeTime, x.ExchangeTime2, x.PhotoUrl, IsUsed = x.IsUsed ? 1 : 0, BlackList = x.BlackList.HasValue && x.BlackList.Value ? 1 : 0 }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "PersonController.getPersonDataExchange"); } return responeData; } public Model.ResponeData getPersonData(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId where x.BlackList == null || x.BlackList == false where x.ProjectId == projectId && (!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, Funs.DB.ProjectData_TeamGroup.First(z => z.TeamGroupId == x.TeamGroupId).TeamGroupName, x.Sex, Funs.DB.Base_WorkPost.First(z => z.WorkPostId == x.WorkPostId).WorkPostName, x.Telephone, x.Address, x.InTime, x.AuditorDate, x.ExchangeTime, x.ExchangeTime2, x.PhotoUrl, }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "PersonController.getPersonDataExchange"); } return responeData; } public Model.ResponeData getPersonAllData(string projectId) { var responeData = new Model.ResponeData(); try { responeData.data = from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId where x.ProjectId == projectId select new { x.PersonId, x.PersonName, x.CardNo, x.IdentityCard, x.UnitId, y.UnitCode, y.UnitName, y.ShortUnitName, Funs.DB.ProjectData_TeamGroup.First(z => z.TeamGroupId == x.TeamGroupId).TeamGroupName, x.Sex, Funs.DB.Base_WorkPost.First(z => z.WorkPostId == x.WorkPostId).WorkPostName, x.Telephone, x.Address, x.InTime, x.OutTime, x.IsUsed, x.AuditorDate, x.ExchangeTime, x.ExchangeTime2, x.PhotoUrl, x.BlackList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; ErrLogInfo.WriteLog(ex, "WX接口-获取人员下发门禁", "PersonController.getPersonDataExchange"); } return responeData; } #endregion #region 获取离场人员 /// /// 获取离场人员 /// /// /// public Model.ResponeData getPersonOutDataExchange(string projectId) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { responeData.data = (from x in db.SitePerson_Person_Bak where x.ProjectId == projectId && x.InTime.HasValue && x.InTime < DateTime.Now && ((x.IsUsed == true && !x.OutTime.HasValue) || 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 更新人员数据交换时间 /// /// 更新人员数据交换时间 /// /// 人员ID /// 交换类型 /// public Model.ResponeData getUpdatePersonExchangeTime(string personId, string type) { var responeData = new Model.ResponeData(); try { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId); 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 获取人员信息出入场记录 /// /// 获取人员信息出入场记录 /// /// /// 当前人单位ID /// /// /// 页码 /// public Model.ResponeData getPersonInOutList(string projectId, string unitId, string startTime, string endTime, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getPersonInOutList(projectId, unitId, startTime, endTime); int pageCount = getDataList.Count(); if (pageCount > 0 && pageIndex > 0) { getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; ErrLogInfo.WriteLog(ex, "WX接口-获取人员信息出入场记录", "PersonController.getPersonInOutList"); } return responeData; } #endregion #region 获取人员信息出入场记录-查询 /// /// 获取人员信息出入场记录 /// /// /// /// 当前人单位ID /// 岗位 /// 查询条件 /// /// /// 页码 /// public Model.ResponeData getPersonInOutList(string projectId, string userUnitId, string workPostId, string strParam, string startTime, string endTime, int pageIndex, string unitId = null) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getPersonInOutList(projectId, userUnitId, unitId, workPostId, strParam, startTime, endTime); int pageCount = getDataList.Count(); if (pageCount > 0 && pageIndex > 0) { getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 根据人员ID获取个人出入场记录 /// /// 根据人员ID获取个人出入场记录 /// /// /// /// /// 页码 /// public Model.ResponeData getPersonInOutListByPersonId(string personId, string startTime, string endTime, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getPersonInOutListByPersonId(personId, startTime, endTime); int pageCount = getDataList.Count(); if (pageCount > 0 && pageIndex > 0) { getDataList = getDataList.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList(); } responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; } return responeData; } #endregion #region 获取异常人员信息出入场记录 /// /// 获取异常人员信息出入场记录 /// /// /// 单位ID /// 开始时间 /// 结束时间 /// 入场异常 0 出场异常 1 /// 页码 /// public Model.ResponeData getAbnormalPersonInOutList(string projectId, string unitId, string startTime, string endTime, string inOut, int pageIndex) { var responeData = new Model.ResponeData(); try { var getDataList = APIPersonService.getAbnormalPersonInOutList(projectId, unitId, startTime, endTime, inOut, pageIndex); int pageCount = getDataList.Count(); responeData.data = new { pageCount, getDataList }; } catch (Exception ex) { responeData.code = 0; responeData.message = ex.Message; ErrLogInfo.WriteLog(ex, "WX接口-获取异常人员信息出入场记录", "PersonController.getAbnormalPersonInOutList"); } return responeData; } #endregion } }