| 
														
															@@ -1,6 +1,7 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 package com.sysu.admin.controller.crop; 
														 | 
														
														 | 
														
															 package com.sysu.admin.controller.crop; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.mysql.jdbc.StringUtils; 
														 | 
														
														 | 
														
															 import com.mysql.jdbc.StringUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.sysu.admin.controller.city.*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.sysu.admin.controller.crop.images.CropImage; 
														 | 
														
														 | 
														
															 import com.sysu.admin.controller.crop.images.CropImage; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.sysu.admin.controller.crop.images.CropImageService; 
														 | 
														
														 | 
														
															 import com.sysu.admin.controller.crop.images.CropImageService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.sysu.admin.controller.crop.images.ImageType; 
														 | 
														
														 | 
														
															 import com.sysu.admin.controller.crop.images.ImageType; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -8,9 +9,14 @@ import com.sysu.admin.controller.geo.land.LandTaskStatus; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.sysu.admin.support.base.BaseService; 
														 | 
														
														 | 
														
															 import com.sysu.admin.support.base.BaseService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.sysu.admin.support.system.config.ConfigContext; 
														 | 
														
														 | 
														
															 import com.sysu.admin.support.system.config.ConfigContext; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.sysu.admin.utils.file.FileUtil; 
														 | 
														
														 | 
														
															 import com.sysu.admin.utils.file.FileUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.sysu.admin.utils.shape.GeoCastUtil; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.xiesx.fastboot.base.result.BaseResult; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.xiesx.fastboot.core.jpa.JpaPlusRepository; 
														 | 
														
														 | 
														
															 import com.xiesx.fastboot.core.jpa.JpaPlusRepository; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.apache.commons.codec.binary.Base64; 
														 | 
														
														 | 
														
															 import org.apache.commons.codec.binary.Base64; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.apache.commons.lang3.ObjectUtils; 
														 | 
														
														 | 
														
															 import org.apache.commons.lang3.ObjectUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.geolatte.geom.crs.CoordinateReferenceSystems; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.locationtech.jts.geom.Geometry; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.locationtech.jts.geom.Point; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
														
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
														
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -29,10 +35,18 @@ public class CropLandService extends BaseService<CropLand, Long> { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     CropImageService cropImageService; 
														 | 
														
														 | 
														
															     CropImageService cropImageService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Autowired 
														 | 
														
														 | 
														
															     @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ConfigContext configContext; 
														 | 
														
														 | 
														
															     ConfigContext configContext; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ProvinceRepository provinceRepository; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    CityRepository cityRepository; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    DistrictRepository districtRepository; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public List<CropPoint> findByBuffer(Double[] point, Integer meter){ 
														 | 
														
														 | 
														
															     public List<CropPoint> findByBuffer(Double[] point, Integer meter){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         double degree = meter / (2 * Math.PI * 6371004) * 360; 
														 | 
														
														 | 
														
															         double degree = meter / (2 * Math.PI * 6371004) * 360; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return mCropPointRepository.findByBuffer("Point("+point[0]+" "+point[1]+")",degree); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return mCropPointRepository.findByBufferAndStatus("Point("+point[0]+" "+point[1]+")",degree, new Integer[]{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                LandTaskStatus.published.ordinal(),LandTaskStatus.receive.ordinal() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        }); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public List<CropLand> findByExecutor(Long executor){ 
														 | 
														
														 | 
														
															     public List<CropLand> findByExecutor(Long executor){ 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -65,6 +79,22 @@ public class CropLandService extends BaseService<CropLand, Long> { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return  mCropLandRepository.updateCenterPoint(id); 
														 | 
														
														 | 
														
															         return  mCropLandRepository.updateCenterPoint(id); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public Point getCenterPoint(Long id){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return (Point)GeoCastUtil.wktToGeom(mCropLandRepository.getCenterPoint(id)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public Point getCenterPoint(Geometry geometry){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        geometry.setSRID(4326); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return (Point)GeoCastUtil.wktToGeom(mCropLandRepository.getCenterPoint(geometry)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public void setCity(CropLand bean, District district){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        bean.setProvince(((int)(district.getCode() / 10000)) * 10000); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        bean.setCity(((int)(district.getCode() / 100)) * 100); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        bean.setDistrict(district.getCode()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Transactional 
														 | 
														
														 | 
														
															     @Transactional 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public void saveCropAndImages(CropLand bean){ 
														 | 
														
														 | 
														
															     public void saveCropAndImages(CropLand bean){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         CropImage fay = bean.getFay(); 
														 | 
														
														 | 
														
															         CropImage fay = bean.getFay(); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -119,6 +149,23 @@ public class CropLandService extends BaseService<CropLand, Long> { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return newFileName; 
														 | 
														
														 | 
														
															         return newFileName; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Transactional 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public void saveCityAll(){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        QCropLand qCropLand = QCropLand.cropLand; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        List<CropLand> landList = findAll(qCropLand.district.isNull()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("landList load finnish"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        int size = landList.size(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for(CropLand bean : landList){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            bean.getCenterPoint().setSRID(4326); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            District district = districtRepository.findByPoint(bean.getCenterPoint()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if(district != null){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                setCity(bean, district); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                System.out.println("剩余:" + (--size)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        saveAll(landList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Override 
														 | 
														
														 | 
														
															     @Override 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public JpaPlusRepository<CropLand, Long> r() { 
														 | 
														
														 | 
														
															     public JpaPlusRepository<CropLand, Long> r() { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return mCropLandRepository; 
														 | 
														
														 | 
														
															         return mCropLandRepository; 
														 |