diff --git a/SGGL/BLL/API/APIPersonService.cs b/SGGL/BLL/API/APIPersonService.cs index d8a342be..946fe329 100644 --- a/SGGL/BLL/API/APIPersonService.cs +++ b/SGGL/BLL/API/APIPersonService.cs @@ -648,6 +648,88 @@ namespace BLL } } } + + public static List getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string trainTypeId, string name) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + + var getPersons = from x in db.View_SitePerson_Person + where x.ProjectId == projectId && x.States == Const.ProjectPersonStates_1 + select new Model.PersonItem + { + SitePersonId = x.SitePersonId, + PersonId = x.PersonId, + CardNo = x.CardNo, + PersonName = x.PersonName, + SexName = x.SexName, + IdentityCard = x.IdentityCard, + Address = x.Address, + ProjectId = x.ProjectId, + ProjectCode = x.ProjectCode, + ProjectName = x.ProjectName, + UnitId = x.UnitId, + UnitCode = x.UnitCode, + UnitName = x.UnitName, + TeamGroupId = x.TeamGroupId, + TeamGroupName = x.TeamGroupName, + WorkPostId = x.WorkPostId, + WorkPostName = x.WorkPostName, + InTime = string.Format("{0:yyyy-MM-dd}", x.InTime), + OutTime = string.Format("{0:yyyy-MM-dd}", x.OutTime), + OutResult = x.OutResult, + Telephone = x.Telephone, + PhotoUrl = x.PhotoUrl, + DepartName = x.DepartName, + }; + if (!string.IsNullOrEmpty(unitIds)) + { + List unitIdList = Funs.GetStrListByStr(unitIds, ','); + getPersons = getPersons.Where(x => unitIdList.Contains(x.UnitId)); + } + + if (!string.IsNullOrEmpty(workPostIds)) + { + List workPostIdList = Funs.GetStrListByStr(workPostIds, ','); + getPersons = getPersons.Where(x => workPostIdList.Contains(x.WorkPostId)); + } + + if (!string.IsNullOrEmpty(name)) + { + getPersons = getPersons.Where(x => x.PersonName.Contains(name)); + } + + List getTrainPersonList = new List(); + var getTrainType = TrainTypeService.GetTrainTypeById(trainTypeId); + if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false)) + { + foreach (var item in getPersons) + { + var getTrainPersonIdList1 = (from x in db.EduTrain_TrainRecordDetail + join y in db.EduTrain_TrainRecord on x.TrainingId equals y.TrainingId + where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && x.CheckResult == true && x.PersonId == item.PersonId + select x).FirstOrDefault(); + if (getTrainPersonIdList1 == null) + { + var getTrainPersonIdList2 = (from x in db.Training_Task + join y in db.Training_Plan on x.PlanId equals y.PlanId + where y.ProjectId == projectId && y.TrainTypeId == trainTypeId && y.States != "3" && x.UserId == item.PersonId + select x).FirstOrDefault(); + if (getTrainPersonIdList2 == null) + { + getTrainPersonList.Add(item); + } + } + } + return getTrainPersonList; + } + else + { + return getPersons.ToList(); + } + } + } + #endregion #region 人员信息保存方法 diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index 5971df32..d98a37e8 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -17019,7 +17019,7 @@ - + diff --git a/SGGL/WebAPI/Controllers/PersonController.cs b/SGGL/WebAPI/Controllers/PersonController.cs index 44b8e4ea..d692597a 100644 --- a/SGGL/WebAPI/Controllers/PersonController.cs +++ b/SGGL/WebAPI/Controllers/PersonController.cs @@ -404,6 +404,28 @@ namespace WebAPI.Controllers return responeData; } + 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, null).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; + } + + /// /// ///