244 lines
13 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xhpc.charging.station.mapper.XhpcChargingStationMapper">
<resultMap id="BaseResultMap" type="com.xhpc.charging.station.domain.XhpcChargingStation">
<result property="chargingStationId" column="charging_station_id" />
<result property="name" column="name" />
<result property="operatorId" column="operator_id" />
<result property="type" column="type" />
<result property="constructionSite" column="construction_site" />
<result property="serviceFacilities" column="service_facilities" />
<result property="peripheryFacilities" column="periphery_facilities" />
<result property="areaCode" column="area_code" />
<result property="address" column="address" />
<result property="detailedAddress" column="detailed_address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="parkingInstructions" column="parking_instructions" />
<result property="serialNumber" column="serial_number" />
<result property="clientVisible" column="client_visible" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="remark" column="remark" />
<result property="rateModelId" column="rate_model_id" />
<result property="imgId" column="img_id" />
<result property="pbusinessInstructions" column="business_instructions" />
<result property="reminderInstructions" column="reminder_instructions" />
</resultMap>
<sql id="selectXhpcChargingStationVo">
select charging_station_id, name, operator_id, type, construction_site, service_facilities, periphery_facilities, area_code, address, detailed_address, longitude, latitude, parking_instructions, serial_number, client_visible, status, del_flag, create_time, create_by, update_time, update_by, remark, rate_model_id from xhpc_charging_station
</sql>
<select id="selectXhpcChargingStationList" resultType="map">
select
cs.charging_station_id as chargingStationId,
cs.name as name,
ope.name as operatorName,
cs.address as address,
(select url from xhpc_img where img_id = cs.img_id and del_flag =0 limit 1) as url,
cs.client_visible as clientVisible,
cs.status as status
from xhpc_charging_station as cs
left join xhpc_operator as ope on cs.operator_id = ope.operator_id
where cs.del_flag =0
<if test="name !=null and name !=''">
and cs.name like CONCAT('%',#{name},'%')
</if>
<if test="operatorName !=null and operatorName !=''">
and ope.name like CONCAT('%',#{operatorName},'%')
</if>
</select>
<select id="selectXhpcChargingStationById" resultMap="BaseResultMap">
<include refid="selectXhpcChargingStationVo"/>
where charging_station_id = #{chargingStationId}
</select>
<insert id="insertXhpcChargingStation" parameterType="com.xhpc.charging.station.domain.XhpcChargingStation">
insert into xhpc_charging_station
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="chargingStationId != null">charging_station_id,</if>
<if test="name != null">name,</if>
<if test="operatorId != null">operator_id,</if>
<if test="type != null">type,</if>
<if test="constructionSite != null">construction_site,</if>
<if test="serviceFacilities != null">service_facilities,</if>
<if test="peripheryFacilities != null">periphery_facilities,</if>
<if test="areaCode != null">area_code,</if>
<if test="address != null">address,</if>
<if test="detailedAddress != null">detailed_address,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="parkingInstructions != null">parking_instructions,</if>
<if test="serialNumber != null">serial_number,</if>
<if test="clientVisible != null">client_visible,</if>
<if test="status != null">status,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="remark != null">remark,</if>
<if test="rateModelId != null">rate_model_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="chargingStationId != null">#{chargingStationId},</if>
<if test="name != null">#{name},</if>
<if test="operatorId != null">#{operatorId},</if>
<if test="type != null">#{type},</if>
<if test="constructionSite != null">#{constructionSite},</if>
<if test="serviceFacilities != null">#{serviceFacilities},</if>
<if test="peripheryFacilities != null">#{peripheryFacilities},</if>
<if test="areaCode != null">#{areaCode},</if>
<if test="address != null">#{address},</if>
<if test="detailedAddress != null">#{detailedAddress},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="parkingInstructions != null">#{parkingInstructions},</if>
<if test="serialNumber != null">#{serialNumber},</if>
<if test="clientVisible != null">#{clientVisible},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="remark != null">#{remark},</if>
<if test="rateModelId != null">#{rateModelId},</if>
</trim>
</insert>
<update id="updateXhpcChargingStation" parameterType="com.xhpc.charging.station.domain.XhpcChargingStation">
update xhpc_charging_station
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="type != null">type = #{type},</if>
<if test="constructionSite != null">construction_site = #{constructionSite},</if>
<if test="serviceFacilities != null">service_facilities = #{serviceFacilities},</if>
<if test="peripheryFacilities != null">periphery_facilities = #{peripheryFacilities},</if>
<if test="areaCode != null">area_code = #{areaCode},</if>
<if test="address != null">address = #{address},</if>
<if test="detailedAddress != null">detailed_address = #{detailedAddress},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="parkingInstructions != null">parking_instructions = #{parkingInstructions},</if>
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
<if test="clientVisible != null">client_visible = #{clientVisible},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="rateModelId != null">rate_model_id = #{rateModelId},</if>
</trim>
where charging_station_id = #{chargingStationId}
</update>
<update id="updateXhpcChargingStationById" parameterType="Long">
update xhpc_charging_station set del_flag =1 where charging_station_id = #{chargingStationId}
</update>
<update id="updateXhpcChargingStationByIds" parameterType="String">
update xhpc_charging_station set del_flag =1 where charging_station_id in
<foreach item="chargingStationId" collection="array" open="(" separator="," close=")">
#{chargingStationId}
</foreach>
</update>
<update id="status">
update xhpc_charging_station set status =#{status} where charging_station_id = #{chargingStationId} and del_flag =0
</update>
<update id="clientVisible">
update xhpc_charging_station set client_visible =#{clientVisible} where charging_station_id = #{chargingStationId} and del_flag =0
</update>
<select id="stationInternetBlackList" resultType="map">
select name from xhpc_internet_user where del_flag=0 and internet_user_id not in (select internet_user_id from xhpc_station_internet_blacklist where charging_station_id=#{chargingStationId})
</select>
<select id="wxList" resultType="map">
select
charging_station_id as chargingStationId,
name as name,
parking_instructions as parkingInstructions,
detailed_address as detailedAddress,
service_facilities as serviceFacilities,
ROUND(ACOS(SIN((#{latitude} * 3.141593) / 180 ) *SIN((latitude * 3.141593) / 180 ) +
COS((#{latitude} * 3.141593) / 180 ) * COS((latitude * 3.141593) / 180 ) *
COS((#{longitude} * 3.141593) / 180 - (longitude * 3.141593) / 180 ) ) * 6370.9968,4)AS distance
from xhpc_charging_station
where del_flag =0 and status =0
and FIND_IN_SET(#{clientVisible},client_visible)>0
<if test="name !=null and name !=''">
and name like CONCAT('%',#{name},'%')
</if>
<if test="serviceFacilities !=null and serviceFacilities.size()>0 ">
and
<foreach collection="serviceFacilities" item="item" index="index" open="(" close=")" separator="or">
service_facilities like CONCAT('%',#{item},'%')
</foreach>
</if>
<if test="code !=null and code !=''">
and area_code=#{code}
</if>
ORDER BY distance asc
</select>
<select id="getCode" resultType="map">
select code, dict_key, dict_value
from xhpc_dict_biz
where code = #{code} and parent_id > 0 and del_flag = 0
<if test="serviceFacilities !=null and serviceFacilities.size()>0 ">
and
<foreach collection="serviceFacilities" item="item" index="index" open="(" close=")" separator="or">
dict_biz_id like CONCAT('%',#{item},'%')
</foreach>
</if>
</select>
<select id="getXhpcChargingStationMassage" resultType="map">
select
charging_station_id as chargingStationId,
(select type from xhpc_charging_pile where charging_station_id = charging_station_id and del_flag=0 and status=0) as type,
name as name,
reminder_instructions as reminderInstructions,
detailed_address as detailedAddress,
parking_instructions as parkingInstructions,
business_instructions as businessInstructions,
service_facilities as serviceFacilities,
img_id as imgId,
remark as remark,
ROUND(ACOS(SIN((#{latitude} * 3.141593) / 180 ) *SIN((latitude * 3.141593) / 180 ) +
COS((#{latitude} * 3.141593) / 180 ) * COS((latitude * 3.141593) / 180 ) *
COS((#{longitude} * 3.141593) / 180 - (longitude * 3.141593) / 180 ) ) * 6370.9968,4)AS distance
from xhpc_charging_station
where charging_station_id=#{chargingStationId} and del_flag=0 and status=0
</select>
<select id="getImageList" resultType="map">
select
img_id as imgId,
url as url
from xhpc_img where del_flag=0 and status=0
<if test="imgIds !=null and imgIds.size()>0 ">
img_id in
<foreach collection="imgIds" item="chargingStationId" open="(" separator="," close=")">
#{chargingStationId}
</foreach>
</if>
</select>
</mapper>