Exemple #1
0
        //获取二级分类数据
        public ActionResult getSecCate([FromQuery] string village)
        {
            List <LandSpaceDto> LandSpaceDtoList = new List <LandSpaceDto>();
            SecCateService      secCateService   = new SecCateService();

            if (!string.IsNullOrEmpty(village))
            {
                landSpaces = landSpaces.FindAll(item => item.QSDWMC == village);
            }
            foreach (var item in landSpaces)//根据二级分类代码将图斑分开
            {
                var          code         = item.ZRZYFLBM.Substring(0, 4);
                var          secCate      = secCateService.GetNameByCode(code.Trim());//获取二级类名称
                LandSpaceDto landSpaceDto = new LandSpaceDto()
                {
                    landSpace = item, code = code, name = secCate.name, Area = item.SHAPE_Area
                };
                LandSpaceDtoList.Add(landSpaceDto);//
            }
            var thirdLevelCate = landSpaces.GroupBy(item => new { item.ZRZYFLMC, item.ZRZYFLBM }).Select(x => new LandSpaceDto
            {
                code = x.Key.ZRZYFLBM,
                name = x.Key.ZRZYFLMC,
                Area = x.Sum(t => t.SHAPE_Area)
            }).ToList();//根据三级分类代码将图斑分开
            var secLevelCate = LandSpaceDtoList.GroupBy(x => new { x.name, x.code }).Select(x => new LandSpaceDto
            {
                code = x.Key.code,
                name = x.Key.name,
                Area = x.Sum(t => t.landSpace.SHAPE_Area),
            }).ToList();//根据二级类分组获取到代码,名字,总和

            return(Ok(secLevelCate));
        }
Exemple #2
0
        public ActionResult getWholeStatic([FromQuery] string village)
        {
            if (!string.IsNullOrEmpty(village))
            {
                landSpaces = landSpaces.FindAll(item => item.QSDWMC == village);
            }
            SecCateService secCateService = new SecCateService();
            var            res            = landSpaces.GroupBy(x => new { x.ZRZYFLMC, x.ZRZYFLBM }).Select(x => new cateArea
            {
                cateName = x.Key.ZRZYFLMC,
                area     = x.Sum(t => t.SHAPE_Area),
                cateCode = x.Key.ZRZYFLBM,
            }).ToList();

            var res1 = res.GroupBy(x => x.cateCode.Substring(0, 4)).ToList();//29类分成12类
            // var res3 = res.GroupBy(x => x.cateCode.Substring(0, 4)).Select(item =>new {item.Key,item.ToList() }).ToList() ;//29类分成12类
            List <SecCateDto> secCateDtosList = new List <SecCateDto>();

            foreach (var item in res1)//遍历12个二级类
            {
                SecCateDto secCateDto = new SecCateDto();
                secCateDto.secLevelCode = item.Key;

                var key   = item.Key;
                var areas = item.Sum(item => item.area);//某类的总面积
                var res2  = item.Select(x => new { x.cateCode, x.cateName, areas }).ToList();
            }
            return(Ok(res1));
        }