2024-08-14 09:22:39 +08:00

207 lines
8.4 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.XhpcTimingChargingPowerMapper">
<resultMap id="BaseResultMap" type="com.xhpc.common.domain.XhpcTimingChargingPowerModel">
<result property="timingChargingPowerId" column="timing_charging_power_id"/>
<result property="reason" column="reason"/>
<result property="chargingStationId" column="charging_station_id"/>
<result property="timingTime" column="timing_time"/>
<result property="errorReason" column="error_reason"/>
<result property="number" column="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"/>
<result property="phone" column="phone"/>
<result property="powerNumber" column="power_number"/>
<result property="pileIds" column="pile_ids"/>
</resultMap>
<select id="list" resultType="map">
select
tcm.timing_charging_power_id as timingChargingPowerId,
tcm.reason as reason,
cs.name as chargingStationName,
tcm.timing_time as timingTime,
tcm.status as status,
tcm.power_number as powerNumber,
tcm.create_time as createTime
from xhpc_timing_charging_power as tcm
left join xhpc_charging_station as cs on cs.charging_station_id = tcm.charging_station_id
where tcm.del_flag =0
<if test="operatorId !=null">
and cs.operator_id = #{operatorId}
</if>
<if test="chargingStationId !=null">
and tcm.charging_station_id = #{chargingStationId}
</if>
<if test="reason !=null and ''!=reason">
and tcm.reason like concat('%', #{reason}, '%')
</if>
<if test="status !=null">
and tcm.status = #{status}
</if>
<if test="startTime !=null and '' !=startTime">
and tcm.timing_time &gt;=#{startTime}
</if>
<if test="endTime !=null and '' !=endTime">
and tcm.timing_time &lt;=#{endTime}
</if>
<if test="tenantId !=null and '' !=tenantId">
and tcm.tenant_id =#{tenantId}
</if>
<if test="type ==1">
and cs.charging_station_id in(select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test="type ==2">
and cs.charging_station_id in(select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
order by tcm.status asc, tcm.create_time desc
</select>
<insert id="insertXhpcTimingChargingPowerModel" parameterType="com.xhpc.common.domain.XhpcTimingChargingPowerModel" useGeneratedKeys="true" keyProperty="timingChargingPowerId">
insert into xhpc_timing_charging_power
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != reason and ''!=reason">
reason,
</if>
<if test="null != chargingStationId ">
charging_station_id,
</if>
<if test="null != timingTime ">
timing_time,
</if>
<if test="null != tenantId ">
tenant_id,
</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 != phone and '' != phone">
phone,
</if>
<if test="null != powerNumber ">
power_number,
</if>
<if test="null != pileIds and '' != pileIds">
pile_ids,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != reason and ''!=reason">
#{reason},
</if>
<if test="null != chargingStationId ">
#{chargingStationId},
</if>
<if test="null != timingTime ">
#{timingTime},
</if>
<if test="null != tenantId ">
#{tenantId},
</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 != phone and '' != phone">
#{phone},
</if>
<if test="null != powerNumber ">
#{powerNumber},
</if>
<if test="null != pileIds and '' != pileIds">
#{pileIds},
</if>
</trim>
</insert>
<select id="getXhpcTimingChargingPowerModelById" resultMap="BaseResultMap">
select xtcp.*,xcs.name as chargingStationName
from xhpc_timing_charging_power xtcp
left join xhpc_charging_station xcs on xtcp.charging_station_id = xcs.charging_station_id
where xtcp.timing_charging_power_id =#{timingChargingPowerId}
and xtcp.del_flag=0
<if test="tenantId !=null and ''!=tenantId">
and xtcp.tenant_id=#{tenantId}
</if>
</select>
<update id="updateXhpcTimingChargingPowerModel" parameterType="Integer">
update xhpc_timing_charging_power
<trim prefix="SET" suffixOverrides=",">
<if test="chargingStationId != null">charging_station_id = #{chargingStationId},</if>
<if test="reason != null and ''!=reason">reason = #{reason},</if>
<if test="timingTime != null">timing_time = #{timingTime},</if>
<if test="errorReason != null and ''!=errorReason">error_reason = #{errorReason},</if>
<if test="number != null">number = #{number},</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="phone != null">phone = #{phone},</if>
<if test="powerNumber != null">power_number = #{powerNumber},</if>
<if test="pileIds != null and ''!=pileIds">pile_ids = #{pileIds},</if>
</trim>
where timing_charging_power_id =#{timingChargingPowerId}
</update>
<select id="getXhpcTimingChargingPowerModelCron" resultMap="BaseResultMap">
select * from xhpc_timing_charging_power where status =0 and del_flag=0
</select>
<select id="getXhpcChargingPile" resultType="String">
select serialNumber from xhpc_charging_pile where charging_pile_id=#{chargingPileId} and del_flag =0 and charging_station_id=#{chargingStationId}
</select>
<update id="updateXhpcChargingPile">
update xhpc_charging_pile set power_number =#{powerNumber} where charging_pile_id =#{chargingPileId}
</update>
</mapper>