|
|
@@ -640,4 +640,85 @@
|
|
|
LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
+ <!-- 搜索充电站结果映射 -->
|
|
|
+ <resultMap id="AppletStationSearchResultMap" type="com.zsElectric.boot.business.model.vo.applet.AppletStationSearchVO">
|
|
|
+ <result property="stationId" column="station_id"/>
|
|
|
+ <result property="stationName" column="station_name"/>
|
|
|
+ <result property="address" column="address"/>
|
|
|
+ <result property="distance" column="distance"/>
|
|
|
+ <result property="fastIdleCount" column="fast_idle_count"/>
|
|
|
+ <result property="fastTotalCount" column="fast_total_count"/>
|
|
|
+ <result property="slowIdleCount" column="slow_idle_count"/>
|
|
|
+ <result property="slowTotalCount" column="slow_total_count"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 搜索充电站(根据站点名称和地址模糊查询) -->
|
|
|
+ <select id="searchStations" resultMap="AppletStationSearchResultMap">
|
|
|
+ SELECT
|
|
|
+ tpsi.id AS station_id,
|
|
|
+ tpsi.station_name,
|
|
|
+ tpsi.address,
|
|
|
+ <if test="longitude != null and latitude != null">
|
|
|
+ ROUND(
|
|
|
+ ST_Distance_Sphere(
|
|
|
+ point(tpsi.station_lng, tpsi.station_lat),
|
|
|
+ point(#{longitude}, #{latitude})
|
|
|
+ ) / 1000,
|
|
|
+ 2
|
|
|
+ ) AS distance,
|
|
|
+ </if>
|
|
|
+ <if test="longitude == null or latitude == null">
|
|
|
+ NULL AS distance,
|
|
|
+ </if>
|
|
|
+ <!-- 快充空闲数 -->
|
|
|
+ IFNULL((
|
|
|
+ SELECT COUNT(1)
|
|
|
+ FROM third_party_connector_info tpci
|
|
|
+ WHERE tpci.station_id = tpsi.station_id
|
|
|
+ AND tpci.connector_type = 1
|
|
|
+ AND tpci.connector_status = 1
|
|
|
+ AND tpci.is_deleted = 0
|
|
|
+ ), 0) AS fast_idle_count,
|
|
|
+ <!-- 快充总数 -->
|
|
|
+ IFNULL((
|
|
|
+ SELECT COUNT(1)
|
|
|
+ FROM third_party_connector_info tpci
|
|
|
+ WHERE tpci.station_id = tpsi.station_id
|
|
|
+ AND tpci.connector_type = 1
|
|
|
+ AND tpci.is_deleted = 0
|
|
|
+ ), 0) AS fast_total_count,
|
|
|
+ <!-- 慢充空闲数 -->
|
|
|
+ IFNULL((
|
|
|
+ SELECT COUNT(1)
|
|
|
+ FROM third_party_connector_info tpci
|
|
|
+ WHERE tpci.station_id = tpsi.station_id
|
|
|
+ AND tpci.connector_type = 2
|
|
|
+ AND tpci.connector_status = 1
|
|
|
+ AND tpci.is_deleted = 0
|
|
|
+ ), 0) AS slow_idle_count,
|
|
|
+ <!-- 慢充总数 -->
|
|
|
+ IFNULL((
|
|
|
+ SELECT COUNT(1)
|
|
|
+ FROM third_party_connector_info tpci
|
|
|
+ WHERE tpci.station_id = tpsi.station_id
|
|
|
+ AND tpci.connector_type = 2
|
|
|
+ AND tpci.is_deleted = 0
|
|
|
+ ), 0) AS slow_total_count
|
|
|
+ FROM third_party_station_info tpsi
|
|
|
+ WHERE tpsi.is_deleted = 0
|
|
|
+ AND tpsi.equipment_owner_id = 'MA6DP6BE7'
|
|
|
+ AND tpsi.policy_configured = 1
|
|
|
+ AND (
|
|
|
+ tpsi.station_name LIKE CONCAT('%', #{keyword}, '%')
|
|
|
+ OR tpsi.address LIKE CONCAT('%', #{keyword}, '%')
|
|
|
+ )
|
|
|
+ <if test="longitude != null and latitude != null">
|
|
|
+ ORDER BY distance ASC
|
|
|
+ </if>
|
|
|
+ <if test="longitude == null or latitude == null">
|
|
|
+ ORDER BY tpsi.id DESC
|
|
|
+ </if>
|
|
|
+ LIMIT 50
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|