Example #1
0
        public int getResidentInfoSearchResidentCount(ResidentInfoSearchViewModel residentInfoSearchViewModel)
        {
            var predicate = SearchResidentInfoWhere(residentInfoSearchViewModel);

            var result = DbSet.Include(a => a.InfoRelationShips).ThenInclude(b => b.HouseInfo)
                         .Include(a => a.ResidentRelationShips).ThenInclude(b => b.ResidentIdentity)
                         .Where(predicate)


                         //.FromSql("", addIdentitySearchResidentViewModel.IdentityName)
                         .Select(
                p => new ResidentInfoSearchMiddle()
            {
                Id         = p.Id,
                Name       = p.Name,
                Phone      = p.Phone,
                Area       = p.InfoRelationShips.HouseInfo.Area,
                BuildingNo = p.InfoRelationShips.HouseInfo.BuildingNo,
                UnitNo     = p.InfoRelationShips.HouseInfo.UnitNo,
                HouseNo    = p.InfoRelationShips.HouseInfo.HouseNo
            }
                )

                         .ToList().Count();

            return(result);
        }
Example #2
0
        /// <summary>
        /// 居民信息查询时  查询的信息
        /// </summary>
        /// <param name="addIdentitySearchResidentViewModel"></param>
        /// <returns></returns>
        #region
        public List <ResidentInfoSearchMiddle> getResidentInfoSearchResident(ResidentInfoSearchViewModel residentInfoSearchViewModel)
        {
            int SkipNum   = residentInfoSearchViewModel.pageViewModel.CurrentPageNum * residentInfoSearchViewModel.pageViewModel.PageSize;
            var predicate = SearchResidentInfoWhere(residentInfoSearchViewModel);

            var result = DbSet.Include(a => a.InfoRelationShips).ThenInclude(b => b.HouseInfo)
                         .Include(a => a.ResidentRelationShips).ThenInclude(b => b.ResidentIdentity)
                         .Where(predicate)
                         .OrderBy(a => a.AddTime)

                         //.FromSql("", addIdentitySearchResidentViewModel.IdentityName)
                         .Select(
                p => new ResidentInfoSearchMiddle()
            {
                Id         = p.Id,
                Name       = p.Name,
                Phone      = p.Phone,
                Area       = p.InfoRelationShips.HouseInfo.Area,
                BuildingNo = p.InfoRelationShips.HouseInfo.BuildingNo,
                UnitNo     = p.InfoRelationShips.HouseInfo.UnitNo,
                HouseNo    = p.InfoRelationShips.HouseInfo.HouseNo
            }
                )

                         .ToList();
            //.GroupBy(a => a.Id).Select(a => a.First());//根据居民id去重

            //将结果放入内存中
            var aaaa = result
                       .Skip(SkipNum)
                       .Take(residentInfoSearchViewModel.pageViewModel.PageSize).ToList();


            return(aaaa);
        }
Example #3
0
        private Expression <Func <ResidentInfo, bool> > SearchResidentInfoWhere(ResidentInfoSearchViewModel residentInfoSearchViewModel)
        {
            var predicate = WhereExtension.True <ResidentInfo>();//初始化where表达式

            //姓名
            if (residentInfoSearchViewModel.Name != "")
            {
                predicate = predicate.And(p => p.Name.Contains(residentInfoSearchViewModel.Name));
            }
            //身份证号
            if (residentInfoSearchViewModel.IdNumber != "")
            {
                predicate = predicate.And(p => p.IdNumber.Equals(residentInfoSearchViewModel.IdNumber));
            }
            //性别
            if (residentInfoSearchViewModel.Gender != "")
            {
                predicate = predicate.And(p => p.Gender.Equals(residentInfoSearchViewModel.Gender));
            }
            //文化程度
            if (residentInfoSearchViewModel.Education != "")
            {
                predicate = predicate.And(p => p.Education.Equals(residentInfoSearchViewModel.Education));
            }
            //小区
            if (residentInfoSearchViewModel.Area != "")
            {
                predicate = predicate.And(p => p.InfoRelationShips.HouseInfo.Area.Equals(residentInfoSearchViewModel.Area));
            }
            //楼号
            if (residentInfoSearchViewModel.BuildingNo != 0)
            {
                predicate = predicate.And(p => p.InfoRelationShips.HouseInfo.BuildingNo.Equals(residentInfoSearchViewModel.BuildingNo));
            }
            //单元号
            if (residentInfoSearchViewModel.UnitNo != 0)
            {
                predicate = predicate.And(p => p.InfoRelationShips.HouseInfo.UnitNo.Equals(residentInfoSearchViewModel.UnitNo));
            }
            //门牌号
            if (residentInfoSearchViewModel.HouseNo != "")
            {
                predicate = predicate.And(p => p.InfoRelationShips.HouseInfo.HouseNo.Equals(residentInfoSearchViewModel.HouseNo));
            }
            //起始年龄
            if (residentInfoSearchViewModel.StartAge != 0)
            {
                predicate = predicate.And(p => Convert.ToInt32(DateTime.Now.Year.ToString()) - Convert.ToInt32(p.IdNumber.Substring(6, 4)) >= (residentInfoSearchViewModel.StartAge));
            }
            //结束年龄
            if (residentInfoSearchViewModel.EndAge != 0)
            {
                predicate = predicate.And(p => Convert.ToInt32(DateTime.Now.Year.ToString()) - Convert.ToInt32(p.IdNumber.Substring(6, 4)) <= (residentInfoSearchViewModel.EndAge));
            }
            //身份
            if (residentInfoSearchViewModel.IdentityName != "")
            {
                predicate = predicate.And(p => p.ResidentRelationShips.ResidentIdentity.IdentityName.Contains(residentInfoSearchViewModel.IdentityName));
            }
            //政治面貌
            if (residentInfoSearchViewModel.Politics != "")
            {
                predicate = predicate.And(p => p.Politics.Contains(residentInfoSearchViewModel.Politics));
            }

            if (residentInfoSearchViewModel.RelationWithHousehold == "租户")
            {
                predicate = predicate.And(p => p.InfoRelationShips.RelationWithHousehold == "租户");
            }
            if (residentInfoSearchViewModel.RelationWithHousehold == "居民")
            {
                predicate = predicate.And(p => p.InfoRelationShips.RelationWithHousehold != "租户");
            }

            return(predicate);
        }
        public int getResidentInfoSearchResidentCount(ResidentInfoSearchViewModel residentInfoSearchViewModel)
        {
            return _baseInfoInhabitantsRepository.getResidentInfoSearchResidentCount(residentInfoSearchViewModel);

        }
 /// <summary>
 /// 居民信息查询时  查询的信息
 /// </summary>
 /// <param name="addIdentitySearchResidentViewModel"></param>
 /// <returns></returns>
 public List<ResidentInfoSearchMiddle> getResidentInfoSearchResident(ResidentInfoSearchViewModel residentInfoSearchViewModel)
 {
     return _baseInfoInhabitantsRepository.getResidentInfoSearchResident(residentInfoSearchViewModel);
 }
        public ActionResult <ResidentInfoSearchResViewModel> residentInfoSearch_OpinionInfo_Search(ResidentInfoSearchViewModel residentInfoSearchViewModel)
        {
            var SearchResult = _baseInfoInhabitantsService.getResidentInfoSearchResident(residentInfoSearchViewModel);
            int total        = _baseInfoInhabitantsService.getResidentInfoSearchResidentCount(residentInfoSearchViewModel);
            var Actionresult = _inhabitantFactory.GetResidentInfoSearchResViewModel();

            Actionresult.baseViewModel.IsSuccess = true;
            Actionresult.Data                       = SearchResult;
            Actionresult.TotalCount                 = total;
            Actionresult.baseViewModel.Message      = "查询信息成功";
            Actionresult.baseViewModel.ResponseCode = 200;
            _ILogger.Information("查询信息成功");

            return(Ok(Actionresult));
        }