CarParkRepository.java 4.29 KB
package com.bsth.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.bsth.entity.CarPark;

@Repository
public interface CarParkRepository extends BaseRepository<CarPark, Integer>{
	
	// 查询最大ID
	@Query(value = "SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_car_park) k"
			, nativeQuery=true)
	public long carParkMaxId();
	
	@Transactional
    @Modifying
    @Query(value="INSERT INTO bsth_c_car_park (" +
    			 " area , company , park_code , park_name , branche_company , " +
    		
    			 "create_by , create_date , descriptions , destroy, update_by, " +
    			 
    			 "update_date , versions , b_center_point , b_park_point ,db_type, " +
    			 
    			 "g_center_point, g_park_point, radius, shapes_type) " +
    			 
    			 " VALUES(" +
    			 "?1 , ?2 , ?3 , ?4 , ?5," +
    			 
    			 "?6 ,  str_to_date(?7,'%Y-%m-%d %H:%i:%s') , ?8 , ?9 , ?10," +
    			 
    			 "str_to_date(?11,'%Y-%m-%d %H:%i:%s'), ?12 ,?13,ST_GeomFromText(?14), ?15, " +
    			 
    			 "?16, ST_GeomFromText(?17), ?18,?19)", nativeQuery=true)
	public void carParkSave(Double area,String company,String parkCode,String parkName,
			
							String brancheCompany,Integer createBy,String createDate,String descriptions,Integer destroy,
							
							Integer updateBy,String updateDate,Integer versions,String bCenterPoint,String bParkPoint,
							
							String dbType,String gCenterPoint,String gParkPoint,Integer radius,String shapesType);
	
	
	/**
	 * @Description :TODO(查询路段信息)
	 * 
	 * @param map <id:路段路由ID>
	 * 
	 * @return List<Object[]>
	 */
	@Query(value ="SELECT   k.id AS carParkId," +
							"k.area AS carParkArea," +
							"k.company AS carParkCompany," +
							"k.park_code AS carParkCode," +
							"k.park_name AS carParkName," +
							"k.branche_company AS carParkBrancheCompany," +
							"k.create_by AS carParkCreateBy," +
							"k.create_date AS carParkCreateDate," +
							"k.descriptions AS carParkDescriptions," +
							"k.destroy AS carParkDestroy," +
							"k.update_by AS carParkUpdate," +
							"k.update_date AS carParkUpdateDate," +
							"k.versions AS carParkVersions," +
							"k.b_center_point AS carParkBcenterPoint," +
							"ST_AsText(k.b_park_point) AS carParkBparkPoint," +
							"k.g_center_point AS carParkGcenterPoint," +
							"ST_AsText(k.g_park_point) AS carParkGparkPoint, " +
							"k.db_type AS carParkDBtype," +
							"k.radius AS carParkRadius," +
							"k.shapes_type AS carParkShapesType FROM bsth_c_car_park k where k.id = ?1", nativeQuery=true)
	List<Object[]> findCarParkInfoFormId(int id);
	
	@Transactional
    @Modifying
    @Query(value="UPDATE bsth_c_car_park SET " +
    		"area =  ?1 , " +
    		"company = ?2  , " +
    		"park_code = ?3  , " +
    		"park_name = ?4  , " +
    		"branche_company =  ?5  , " +
    		"create_by =  ?6  , " +
    		"create_date =  str_to_date(?7,'%Y-%m-%d %H:%i:%s')  , " +
    		"descriptions =  ?8  , " +
    		"destroy = ?9  , " +
    		"update_by = ?10  , " +
    		"update_date =str_to_date(?11,'%Y-%m-%d %H:%i:%s')  , " +
    		"versions = ?12  , " +
    		"b_center_point = ?13  , " +
    		"g_center_point = ?14 , " +
    		"b_park_point = ST_GeomFromText(?15)  , " +
    		"g_park_point = ST_GeomFromText(?16)  , " +
    		"db_type = ?17  , " +
    		"radius = ?18  , " +
    		"shapes_type = ?19  " +
    		" WHERE id = ?20   ", nativeQuery=true)
	public void carParkUpdate(double area,String company,String parkCode,String parkName,String brancheCompany,
			
							  Integer createBy ,String createDate,String descriptions,Integer destroy,Integer updateBy,
							  
							  String updateDate,Integer versions,String bCenterPoint,String gCenterPoint,String bParkPoint,
							  
							  String gParkPoint,String dbType,Integer radius,String shapesType,Integer id );

	@Query(value = "select st_astext(g_park_point), shapes_type, g_center_point, radius,park_code,park_name  from bsth_c_car_park where park_code=?1", nativeQuery = true)
	public Object[][] bufferAera(String parkCode);
}