Administrator 2 tahun lalu
induk
melakukan
3dfcafa064

+ 1 - 0
src/main/java/com/sysu/admin/controller/aland/CropAreaStat.java

@@ -7,6 +7,7 @@ public class CropAreaStat {
     private String name;
     private Double area;
     private String color;
+    private Integer count;
 
     static  String[] names = {"corn","rice","other"};
     static  String[] name2s = {"玉米","水稻","其他"};

+ 1 - 0
src/main/java/com/sysu/admin/controller/aland/LandAreaStat.java

@@ -8,6 +8,7 @@ public class LandAreaStat {
     private String name;
     private Double area;
     private String color;
+    private Integer count;
 
     /**
      * 0其它 1水田  2水浇地  3旱地  4果园

+ 4 - 4
src/main/java/com/sysu/admin/controller/aland/LandRepository.java

@@ -7,16 +7,16 @@ import java.util.List;
 
 public interface LandRepository extends JpaPlusRepository<Land, Long> {
 
-    @Query(value = "select crop_type,sum(area) from  leizhou_land  group by crop_type",nativeQuery = true)
+    @Query(value = "select crop_type,sum(area),count(id) from  leizhou_land  group by crop_type",nativeQuery = true)
     List<Object[]> statCropTypeAll();
 
-    @Query(value = "select crop_type,sum(area) from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) group by crop_type",nativeQuery = true)
+    @Query(value = "select crop_type,sum(area),count(id) from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) group by crop_type",nativeQuery = true)
     List<Object[]> statCropType(String wkt);
 
-    @Query(value = "select parcel_type,sum(area) from  leizhou_land  group by parcel_type",nativeQuery = true)
+    @Query(value = "select parcel_type,sum(area),count(id) from  leizhou_land  group by parcel_type",nativeQuery = true)
     List<Object[]> statParcelTypeAll();
 
-    @Query(value = "select parcel_type,sum(area) from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) group by parcel_type",nativeQuery = true)
+    @Query(value = "select parcel_type,sum(area),count(id) from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) group by parcel_type",nativeQuery = true)
     List<Object[]> statParcelType(String wkt);
 
     @Query(value = "select * from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) limit ?2",nativeQuery = true)

+ 8 - 6
src/main/java/com/sysu/admin/controller/aland/LandService.java

@@ -52,6 +52,7 @@ public class LandService extends BaseService<Land,Long> {
             bean.setName(LandAreaStat.castName(bean.getId()));
             bean.setArea((area + area / 2) / 1000);
             bean.setArea(bean.getArea() * percent);
+            bean.setCount(Integer.valueOf(o[2].toString()));
             list.add(bean);
         });
         return list;
@@ -83,12 +84,13 @@ public class LandService extends BaseService<Land,Long> {
         }
         res.stream().forEach(o -> {
             Double area = (Double)o[1];
-            CropAreaStat cropAreaStat = new CropAreaStat();
-            cropAreaStat.setName(CropAreaStat.castName(o[0].toString()));
-            cropAreaStat.setColor(CropAreaStat.castColor(o[0].toString()));
-            cropAreaStat.setArea((area + area / 2) / 1000);
-            cropAreaStat.setArea(cropAreaStat.getArea() * percent);
-            list.add(cropAreaStat);
+            CropAreaStat bean = new CropAreaStat();
+            bean.setName(CropAreaStat.castName(o[0].toString()));
+            bean.setColor(CropAreaStat.castColor(o[0].toString()));
+            bean.setArea((area + area / 2) / 1000);
+            bean.setArea(bean.getArea() * percent);
+            bean.setCount(Integer.valueOf(o[2].toString()));
+            list.add(bean);
         });
         return list;
     }

+ 0 - 4
src/main/java/com/sysu/admin/controller/crop/CropLandRepository.java

@@ -2,12 +2,8 @@ package com.sysu.admin.controller.crop;
 
 import com.xiesx.fastboot.core.jpa.JpaPlusRepository;
 import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.Point;
-import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
-import java.util.List;
-
 
 public interface CropLandRepository extends JpaPlusRepository<CropLand, Long> {