| 
					
				 | 
			
			
				@@ -6,9 +6,13 @@ import com.querydsl.core.types.QBean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.querydsl.core.types.QList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.querydsl.jpa.impl.JPAQuery; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.city.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.controller.crop.executor_table.ExecutorTable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.controller.crop.executor_table.ExecutorTableService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.controller.crop.executor_table.PKRP; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.crop.images.CropImage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.crop.images.CropImageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.crop.images.ImageType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sysu.admin.controller.crop.interceptor.DynamicTableNames; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.crop.range.AutoTableNameInterceptor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.crop.range.LandRangeIndexService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.sysu.admin.controller.geo.land.LandTaskStatus; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -53,37 +57,37 @@ public class CropLandService extends BaseService<CropLand, Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     DistrictRepository districtRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     LandRangeIndexService landRangeIndexService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ExecutorTableService executorTableService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "aLong") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public CropLand findOne(Long aLong) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        AutoTableNameInterceptor.myTable.set(landRangeIndexService.getTableName(aLong)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         CropLand bean = super.findOne(aLong); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return bean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "entity") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public <S extends CropLand> S save(S entity) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        AutoTableNameInterceptor.myTable.set(landRangeIndexService.getTableName(entity.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return super.save(entity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "point") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<CropPoint> findByBuffer(Double[] point, Integer meter){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        AutoTableNameInterceptor.myTable.set(landRangeIndexService.getTableName(point)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         double degree = meter / (2 * Math.PI * 6371004) * 360; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return mCropPointRepository.findByBufferAndStatus("Point("+point[0]+" "+point[1]+")",degree, new Integer[]{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 LandTaskStatus.published.ordinal(),LandTaskStatus.receive.ordinal() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(executor = "executor") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<CropLand> findIdAndNameByExecutor(Long executor){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        QCropLand qCropLand = QCropLand.cropLand; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        QBean<CropLand> selectBean = Projections.fields(qCropLand, qCropLand.id, qCropLand.name, qCropLand.updateDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        JPAQuery<CropLand> jpaQuery = mJPAQueryFactory.select(selectBean) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .from(qCropLand) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .where(qCropLand.executor.eq(executor)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return jpaQuery.fetch(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Query query =mEntityManager.createQuery("select c.id,c.name,c.updateDate from CropLand c where c.executor = " + executor); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return query.getResultList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "point") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public CropLand findByPoint(Double[] point){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         CropLand cityLand = mCropLandRepository.findByPoint("Point("+point[0]+" "+point[1]+")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return cityLand; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -94,15 +98,16 @@ public class CropLandService extends BaseService<CropLand, Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return mCropPointRepository.getBuffer("Point("+point[0]+" "+point[1]+")", degree); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "tableNames") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<CropPoint> findCropLandNoGeomByTableNamesAndBBox(String tableNames, Double x1, Double y1, Double x2, Double y2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String wkt = bboxToWkt(x1, y1 , x2, y2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        AutoTableNameInterceptor.myTable.set(tableNames); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String sql = " select  "+ CropPoint.selectColumns; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         sql += " from p_crop  where ST_Intersects(geom,st_geomfromtext('"+wkt+"',4326)) "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<CropPoint> cropPointList = mEntityManager.createNativeQuery(sql, CropPoint.class).getResultList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return cropPointList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void updateStatus(Long id, Integer status, Long updateUserId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         CropLand bean = mCropLandRepository.findOne(id); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -111,17 +116,9 @@ public class CropLandService extends BaseService<CropLand, Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             bean.setReceiveDate(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             bean.setReceiver(updateUserId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        mCropLandRepository.save(bean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mCropLandRepository.saveAndFlush(bean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public int updateCenterPoint(Long 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)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -135,6 +132,7 @@ public class CropLandService extends BaseService<CropLand, Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         bean.setDistrict(district.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @DynamicTableNames(value = "bean") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void saveCropAndImages(CropLand bean){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         CropImage fay = bean.getFay(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -143,7 +141,10 @@ public class CropLandService extends BaseService<CropLand, Long> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         saveImage(fay, bean.getId(), ImageType.fay, bean.getExecutor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         saveImage(center, bean.getId(), ImageType.center, bean.getExecutor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         saveImage(near, bean.getId(), ImageType.near, bean.getExecutor()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        mCropLandRepository.save(bean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String tableName = AutoTableNameInterceptor.myTable.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ExecutorTable executorTable = new ExecutorTable().setPk(new PKRP().tableName(tableName).executor(bean.getExecutor())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        mCropLandRepository.saveAndFlush(bean); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        executorTableService.save(executorTable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private void saveImage(CropImage image, Long cropId, ImageType type, Long userId){ 
			 |