CarParkRepository.java 3.94 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 (" +
    			 "id , 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 , ?7 , str_to_date(?8,'%Y-%m-%d %H:%i:%s') , ?9 , ?10," +
    			 "?11,str_to_date(?12,'%Y-%m-%d %H:%i:%s') ,?13, ?14, GeomFromText(?15), " +
    			 "?16, ?17,GeomFromText(?18),?19,?20)", nativeQuery=true)
	public void carParkSave(Integer id,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," +
							"AsText(k.b_park_point) AS carParkBparkPoint," +
							"k.g_center_point AS carParkGcenterPoint," +
							"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 =  ?7  , " +
    		"descriptions =  ?8  , " +
    		"destroy = ?9  , " +
    		"update_by = ?10  , " +
    		"update_date = ?11  , " +
    		"versions = ?12  , " +
    		"b_center_point = ?13  , " +
    		"g_center_point = ?14 , " +
    		"b_park_point = GeomFromText(?15)  , " +
    		"g_park_point = 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 );
	
}