164 lines
6.9 KiB
XML
Raw Normal View History

2022-08-30 17:48:44 +08:00
<?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.XhpcPileEditionMapper">
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcPileEdition">
<result property="pileEditionId" column="pile_edition_id"/>
<result property="chargingStationId" column="charging_station_id"/>
<result property="chargingPileIds" column="charging_pile_ids"/>
<result property="directNumber" column="direct_number"/>
<result property="communicationNumber" column="communication_number"/>
<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="tenantId" column="tenant_id"/>
</resultMap>
<select id="list" resultType="map">
select
xcs.name as chargingStationName,
xpe.pile_edition_id as pileEditionId,
xpe.direct_number as directNumber,
xpe.communication_number as communicationNumber,
xpe.status as status,
<if test="chargingPileIds !=null and chargingPileIds !=''">
(SELECT concat(replace(group_concat(name),',','号桩,'),'号桩') FROM xhpc_charging_pile where find_in_set(charging_pile_id,#{chargingPileIds})) as chargingPileName
</if>
<if test="chargingPileIds==null">
concat('--') as chargingPileName
</if>
from xhpc_pile_edition as xpe
left join xhpc_charging_station xcs on xpe.charging_station_id = xcs.charging_station_id
where xpe.del_flag=0
<if test="chargingStationId !=null">
and xpe.charging_station_id = #{chargingStationId}
</if>
<if test="chargingPileIds !=null and chargingPileIds !=''">
and find_in_set(xpe.charging_pile_ids, #{chargingPileIds})
</if>
<if test="type ==1">
and xpe.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test="type ==2">
and xpe.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
<if test="tenantId !=null and tenantId !=''">
and xpe.tenant_id=#{tenantId}
</if>
</select>
<select id="getXhpcPileEditions" resultType="int">
select
count(xpe.pile_edition_id) number
from xhpc_pile_edition xpe
where find_in_set(xpe.charging_pile_ids, #{chargingPileIds}) and xpe.del_flag=0 and xpe.status =0
<if test="type ==1">
and xpe.pile_edition_id != #{pileEditionId}
</if>
</select>
<insert id="insertXhpcPileEdition">
insert into xhpc_pile_edition
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargingStationId ">
charging_station_id,
</if>
<if test="null != chargingPileIds and chargingPileIds !=''">
charging_pile_ids,
</if>
<if test="null != directNumber and directNumber !=''">
direct_number,
</if>
<if test="null != communicationNumber and communicationNumber !=''">
communication_number,
</if>
<if test="null != status ">
status,
</if>
<if test="null != delFlag ">
del_flag,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy and '' != createBy">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy and '' != updateBy">
update_by,
</if>
<if test="null != remark and '' != remark">
remark,
</if>
<if test="null != tenantId and '' != tenantId">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargingStationId ">
#{chargingStationId},
</if>
<if test="null != chargingPileIds and chargingPileIds !=''">
#{chargingPileIds},
</if>
<if test="null != directNumber and directNumber !=''">
#{directNumber},
</if>
<if test="null != communicationNumber and communicationNumber !=''">
#{communicationNumber},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != delFlag ">
#{delFlag},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy and '' != createBy">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy and '' != updateBy">
#{updateBy},
</if>
<if test="null != remark and '' != remark">
#{remark},
</if>
<if test="null != tenantId and '' != tenantId">
#{tenantId},
</if>
</trim>
</insert>
<update id="updatePileEdition">
update xhpc_pile_edition
<trim prefix="SET" suffixOverrides=",">
<if test="chargingStationId != null">charging_station_id = #{chargingStationId},</if>
<if test="chargingPileIds != null and chargingPileIds !=''">charging_pile_ids = #{chargingPileIds},</if>
<if test="directNumber != null and directNumber!=''">direct_number = #{directNumber},</if>
<if test="communicationNumber != null and communicationNumber !=''">communication_number = #{communicationNumber},</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="tenantId != null and tenantId!=''">tenant_id=#{tenantId},</if>
</trim>
where pile_edition_id = #{pileEditionId}
</update>
</mapper>