Administrator 2 년 전
부모
커밋
3ade6a21a6

+ 2 - 0
src/main/java/com/sysu/admin/api/crop/ApiLandController.java

@@ -3,6 +3,7 @@ package com.sysu.admin.api.crop;
 import com.alibaba.fastjson.JSON;
 import com.sysu.admin.controller.aland.CropAreaStat;
 import com.sysu.admin.controller.aland.Land;
+import com.sysu.admin.controller.aland.LandAreaStat;
 import com.sysu.admin.controller.aland.LandService;
 import com.sysu.admin.controller.crop.CropLand;
 import com.sysu.admin.controller.crop.images.CropImage;
@@ -45,6 +46,7 @@ public class ApiLandController extends BaseComponent {
         PaginationResult result  = landService.list(commonVo.getDistrict(),commonVo.getTown(), paginationVo, commonVo.getCrop_type());
         ((List<Land>)result.data()).stream().forEach(land -> {
             land.setCropTypeName(CropAreaStat.castName(land.getCrop_type()));
+            land.setParcelTypeName(LandAreaStat.castName(land.getParcelType()));
             land.setGeojson(GeoCastUtil.gjson.toString(land.getGeom()));
         });
         return result;

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

@@ -33,6 +33,8 @@ cropTypeName -- 作物类别名称
 number --编号
 perimeter -- 周长
 elevation -- 高程
+parcelTypeName -- 地块类型名称
+parcelType -- 地块类型
 id_card——身份证
 name——姓名
 aspect——坡向
@@ -124,6 +126,8 @@ Area——面积(平方米)
     private Integer majority;
     @Column
     private Integer parcelType;
+    @Transient
+    private String parcelTypeName;
 
     @JSONField(serialize = false)
     @Column(columnDefinition = "geom")

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

@@ -22,13 +22,13 @@ public interface LandRepository extends JpaPlusRepository<Land, Long> {
 
     @Query(value = "select count(1) from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326))",nativeQuery = true)
     int findCountByWkt(String wkt);
-    @Query(value = "select * from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) limit ?2",nativeQuery = true)
-    List<Land> findListByWkt(String wkt,Integer limit);
+    @Query(value = "select * from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) limit ?2 OFFSET ?3",nativeQuery = true)
+    List<Land> findListByWkt(String wkt, Integer limit, Integer start);
 
     @Query(value = "select count(1) from  leizhou_land where St_within(geom,st_geomfromtext(?1,4326)) and crop_type = ?2",nativeQuery = true)
     int findCountByWktAndCropType(String wkt, String cropType);
-    @Query(value = "select * from  leizhou_land where  St_within(geom,st_geomfromtext(?1,4326)) and crop_type = ?2 limit ?3",nativeQuery = true)
-    List<Land> findListByWktAndCropType(String wkt, String cropType, Integer limit);
+    @Query(value = "select * from  leizhou_land where  St_within(geom,st_geomfromtext(?1,4326)) and crop_type = ?2 limit ?3 OFFSET ?4",nativeQuery = true)
+    List<Land> findListByWktAndCropType(String wkt, String cropType, Integer limit, Integer start);
 
     @Query(value = "select new Land(geom) from Land")
     List<Land> findAllGeom();

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

@@ -195,12 +195,13 @@ public class LandService extends BaseService<Land,Long> {
             return PaginationHelper.create(pageData.getContent(), pageData.getTotalPages(), pageData.getPageable().getPageNumber());
         }else{
             List<Land> data = null;
-            int count = 0;
+            int count;
+            int start = page.getLimit() * (page.getPage() - 1);
             if(StringUtils.isNotBlank(cropType)){
-                data = landRepository.findListByWktAndCropType(wkt, cropType, page.getLimit());
+                data = landRepository.findListByWktAndCropType(wkt, cropType, page.getLimit(), start);
                 count = landRepository.findCountByWktAndCropType(wkt, cropType);
             }else{
-                data = landRepository.findListByWkt(wkt, page.getLimit());
+                data = landRepository.findListByWkt(wkt, page.getLimit(), start);
                 count = landRepository.findCountByWkt(wkt);
             }
             return PaginationHelper.create(data, count, page.getPage());

+ 6 - 3
src/test/java/com/sysu/admin/utils/shape/postgis/Main.java

@@ -1,8 +1,12 @@
 package com.sysu.admin.utils.shape.postgis;
 
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicInteger;
+
 public class Main {
     public static void main(String[] args) {
-        PostGisUtilTest postGisUtilTest = new PostGisUtilTest();
+//        PostGisUtilTest postGisUtilTest = new PostGisUtilTest();
 //        postGisUtilTest.testInsertShp();
 //        try {
 //            postGisUtilTest.createTable();
@@ -15,7 +19,6 @@ public class Main {
 //        postGisUtilTest.updateSrid();
 //        postGisUtilTest.ST_Extent();
 //        postGisUtilTest.createIndex();
-        postGisUtilTest.createCOLUMN();
-
+//        postGisUtilTest.createCOLUMN();
     }
 }