2022-03-17 16:20:47 +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">
|
|
|
|
|
<!--suppress ALL -->
|
2022-04-21 10:04:20 +08:00
|
|
|
<mapper namespace="com.xhpc.card.mapper.XhpcRateTimeMapper">
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.xhpc.card.pojo.XhpcRateTime">
|
2022-03-17 16:20:47 +08:00
|
|
|
<id column="rate_time_id" jdbcType="BIGINT" property="rateTimeId"/>
|
|
|
|
|
<result column="charging_station_id" jdbcType="BIGINT" property="chargingStationId"/>
|
|
|
|
|
<result column="rate_id" jdbcType="BIGINT" property="rateId"/>
|
|
|
|
|
<result column="start_time" jdbcType="TIME" property="startTime"/>
|
|
|
|
|
<result column="end_time" jdbcType="TIME" property="endTime"/>
|
|
|
|
|
<result column="status" jdbcType="INTEGER" property="status"/>
|
|
|
|
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
|
|
|
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
|
|
|
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
|
|
|
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
|
|
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
|
|
|
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
|
|
|
|
<result column="rate_model_id" jdbcType="BIGINT" property="rateModelId"/>
|
|
|
|
|
<result column="sort" jdbcType="INTEGER" property="sort"/>
|
|
|
|
|
<result column="type" jdbcType="INTEGER" property="type"/>
|
|
|
|
|
<result column="rate_value" jdbcType="VARCHAR" property="rateValue"/>
|
|
|
|
|
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
rate_time_id
|
|
|
|
|
, charging_station_id, rate_id, start_time, end_time, `status`, del_flag,
|
|
|
|
|
create_time, create_by, update_time, update_by, remark, rate_model_id, sort, `type`,
|
|
|
|
|
rate_value, tenant_id
|
|
|
|
|
</sql>
|
|
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List"/>
|
|
|
|
|
from xhpc_rate_time
|
|
|
|
|
where rate_time_id = #{rateTimeId,jdbcType=BIGINT}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectByTenantIdsAndCharingStationIds" resultType="Map">
|
|
|
|
|
select
|
2022-05-16 16:49:50 +08:00
|
|
|
ROUND(ro.charging_degree,2) as chargingDegree,
|
|
|
|
|
DATE_FORMAT(co.start_time,"%H:%i") as startTime,
|
|
|
|
|
ro.amount_charged amountCharged,
|
|
|
|
|
ro.electric_current electricCurrent,
|
|
|
|
|
ro.real_time_order_id as realTimeOrderId,
|
|
|
|
|
ro.voltage as voltage,
|
|
|
|
|
ro.soc as soc,
|
|
|
|
|
ro.charging_time chargingTime,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN co.charging_mode = "新电途" THEN
|
|
|
|
|
"新电途用户"
|
|
|
|
|
WHEN co.charging_mode = "快电" THEN
|
|
|
|
|
"快电用户"
|
|
|
|
|
WHEN co.charging_mode = "恒大" THEN
|
|
|
|
|
"恒大用户"
|
|
|
|
|
WHEN co.charging_mode = "小桔" THEN
|
|
|
|
|
"小桔用户"
|
|
|
|
|
ELSE
|
2022-03-17 16:20:47 +08:00
|
|
|
"C端用户"
|
2022-05-16 16:49:50 +08:00
|
|
|
END chargingMode
|
|
|
|
|
from xhpc_charge_order co
|
|
|
|
|
left join xhpc_internet_user as inu on inu.internet_user_id = co.user_id and co.source =1
|
|
|
|
|
left join xhpc_app_user as apu on apu.app_user_id = co.user_id and co.source =0
|
|
|
|
|
left join xhpc_community_personnel as cop on cop.community_personnel_id = co.user_id and co.source =2
|
|
|
|
|
left join xhpc_customers_personnel as cup on cup.customers_personnel_id = co.user_id and co.source =3
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT charging_order_id,real_time_order_id,soc,charging_degree,charging_time,amount_charged,electric_current,voltage FROM xhpc_real_time_order
|
|
|
|
|
WHERE real_time_order_id IN ( SELECT max( real_time_order_id ) FROM xhpc_real_time_order GROUP BY charging_order_id )
|
|
|
|
|
) ro ON ro.charging_order_id = co.charge_order_id
|
|
|
|
|
where co.status=0 and co.del_flag=0
|
2022-05-09 17:14:58 +08:00
|
|
|
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
|
2022-05-16 16:49:50 +08:00
|
|
|
and find_in_set(co.tenant_id, #{tenantIdsStr})
|
2022-03-17 16:20:47 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="xhpcChargingStationList!=null and xhpcChargingStationList.size()!=0">
|
2022-05-16 16:49:50 +08:00
|
|
|
and co.charging_station_id in
|
2022-03-17 16:20:47 +08:00
|
|
|
<foreach collection="xhpcChargingStationList" open="(" close=")" separator="," item="chargingStationId">
|
|
|
|
|
#{chargingStationId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
2022-05-16 16:49:50 +08:00
|
|
|
order by co.create_time desc
|
2022-03-17 16:20:47 +08:00
|
|
|
</select>
|
|
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
|
|
|
|
delete
|
|
|
|
|
from xhpc_rate_time
|
|
|
|
|
where rate_time_id = #{rateTimeId,jdbcType=BIGINT}
|
|
|
|
|
</delete>
|
|
|
|
|
<insert id="insert" keyColumn="rate_time_id" keyProperty="rateTimeId"
|
2022-04-21 10:04:20 +08:00
|
|
|
parameterType="com.xhpc.card.pojo.XhpcRateTime" useGeneratedKeys="true">
|
2022-03-17 16:20:47 +08:00
|
|
|
insert into xhpc_rate_time (charging_station_id, rate_id, start_time,
|
|
|
|
|
end_time, `status`, del_flag,
|
|
|
|
|
create_time, create_by, update_time,
|
|
|
|
|
update_by, remark, rate_model_id,
|
|
|
|
|
sort, `type`, rate_value,
|
|
|
|
|
tenant_id)
|
|
|
|
|
values (#{chargingStationId,jdbcType=BIGINT}, #{rateId,jdbcType=BIGINT}, #{startTime,jdbcType=TIME},
|
|
|
|
|
#{endTime,jdbcType=TIME}, #{status,jdbcType=INTEGER}, #{delFlag,jdbcType=INTEGER},
|
|
|
|
|
#{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
|
|
|
|
|
#{updateBy,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{rateModelId,jdbcType=BIGINT},
|
|
|
|
|
#{sort,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{rateValue,jdbcType=VARCHAR},
|
|
|
|
|
#{tenantId,jdbcType=VARCHAR})
|
|
|
|
|
</insert>
|
|
|
|
|
<insert id="insertSelective" keyColumn="rate_time_id" keyProperty="rateTimeId"
|
2022-04-21 10:04:20 +08:00
|
|
|
parameterType="com.xhpc.card.pojo.XhpcRateTime" useGeneratedKeys="true">
|
2022-03-17 16:20:47 +08:00
|
|
|
insert into xhpc_rate_time
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="chargingStationId != null">
|
|
|
|
|
charging_station_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateId != null">
|
|
|
|
|
rate_id,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null">
|
|
|
|
|
start_time,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endTime != null">
|
|
|
|
|
end_time,
|
|
|
|
|
</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>
|
|
|
|
|
<if test="sort != null">
|
|
|
|
|
sort,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="type != null">
|
|
|
|
|
`type`,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateValue != null">
|
|
|
|
|
rate_value,
|
|
|
|
|
</if>
|
|
|
|
|
<if test="tenantId != null">
|
|
|
|
|
tenant_id,
|
|
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
<if test="chargingStationId != null">
|
|
|
|
|
#{chargingStationId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateId != null">
|
|
|
|
|
#{rateId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null">
|
|
|
|
|
#{startTime,jdbcType=TIME},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endTime != null">
|
|
|
|
|
#{endTime,jdbcType=TIME},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status != null">
|
|
|
|
|
#{status,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="delFlag != null">
|
|
|
|
|
#{delFlag,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createTime != null">
|
|
|
|
|
#{createTime,jdbcType=TIMESTAMP},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createBy != null">
|
|
|
|
|
#{createBy,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateTime != null">
|
|
|
|
|
#{updateTime,jdbcType=TIMESTAMP},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateBy != null">
|
|
|
|
|
#{updateBy,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="remark != null">
|
|
|
|
|
#{remark,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateModelId != null">
|
|
|
|
|
#{rateModelId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="sort != null">
|
|
|
|
|
#{sort,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="type != null">
|
|
|
|
|
#{type,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateValue != null">
|
|
|
|
|
#{rateValue,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="tenantId != null">
|
|
|
|
|
#{tenantId,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
</trim>
|
|
|
|
|
</insert>
|
2022-04-21 10:04:20 +08:00
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.XhpcRateTime">
|
2022-03-17 16:20:47 +08:00
|
|
|
update xhpc_rate_time
|
|
|
|
|
<set>
|
|
|
|
|
<if test="chargingStationId != null">
|
|
|
|
|
charging_station_id = #{chargingStationId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateId != null">
|
|
|
|
|
rate_id = #{rateId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null">
|
|
|
|
|
start_time = #{startTime,jdbcType=TIME},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endTime != null">
|
|
|
|
|
end_time = #{endTime,jdbcType=TIME},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status != null">
|
|
|
|
|
`status` = #{status,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="delFlag != null">
|
|
|
|
|
del_flag = #{delFlag,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createTime != null">
|
|
|
|
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="createBy != null">
|
|
|
|
|
create_by = #{createBy,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateTime != null">
|
|
|
|
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateBy != null">
|
|
|
|
|
update_by = #{updateBy,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="remark != null">
|
|
|
|
|
remark = #{remark,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateModelId != null">
|
|
|
|
|
rate_model_id = #{rateModelId,jdbcType=BIGINT},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="sort != null">
|
|
|
|
|
sort = #{sort,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="type != null">
|
|
|
|
|
`type` = #{type,jdbcType=INTEGER},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="rateValue != null">
|
|
|
|
|
rate_value = #{rateValue,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="tenantId != null">
|
|
|
|
|
tenant_id = #{tenantId,jdbcType=VARCHAR},
|
|
|
|
|
</if>
|
|
|
|
|
</set>
|
|
|
|
|
where rate_time_id = #{rateTimeId,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
2022-04-21 10:04:20 +08:00
|
|
|
<update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.XhpcRateTime">
|
2022-03-17 16:20:47 +08:00
|
|
|
update xhpc_rate_time
|
|
|
|
|
set charging_station_id = #{chargingStationId,jdbcType=BIGINT},
|
|
|
|
|
rate_id = #{rateId,jdbcType=BIGINT},
|
|
|
|
|
start_time = #{startTime,jdbcType=TIME},
|
|
|
|
|
end_time = #{endTime,jdbcType=TIME},
|
|
|
|
|
`status` = #{status,jdbcType=INTEGER},
|
|
|
|
|
del_flag = #{delFlag,jdbcType=INTEGER},
|
|
|
|
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
|
|
|
create_by = #{createBy,jdbcType=VARCHAR},
|
|
|
|
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
|
|
|
|
update_by = #{updateBy,jdbcType=VARCHAR},
|
|
|
|
|
remark = #{remark,jdbcType=VARCHAR},
|
|
|
|
|
rate_model_id = #{rateModelId,jdbcType=BIGINT},
|
|
|
|
|
sort = #{sort,jdbcType=INTEGER},
|
|
|
|
|
`type` = #{type,jdbcType=INTEGER},
|
|
|
|
|
rate_value = #{rateValue,jdbcType=VARCHAR},
|
|
|
|
|
tenant_id = #{tenantId,jdbcType=VARCHAR}
|
|
|
|
|
where rate_time_id = #{rateTimeId,jdbcType=BIGINT}
|
|
|
|
|
</update>
|
|
|
|
|
</mapper>
|