2021-07-20 16:51:57 +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.XhpcTerminalMapper" >
2021-07-28 18:07:25 +08:00
<resultMap id= "BaseResultMap" type= "com.xhpc.common.domain.XhpcTerminal" >
<result property= "terminalId" column= "terminal_id" />
<result property= "chargingPileId" column= "charging_pile_id" />
<result property= "chargingStationId" column= "charging_station_id" />
<result property= "name" column= "name" />
<result property= "serialNumber" column= "serial_number" />
<result property= "pileSerialNumber" column= "pile_serial_number" />
<result property= "gunStatus" column= "gun_status" />
<result property= "workStatus" column= "work_status" />
<result property= "status" column= "status" />
<result property= "delFlag" column= "del_flag" />
2021-07-20 16:51:57 +08:00
<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" />
</resultMap>
2021-07-27 18:09:18 +08:00
<sql id= "selectXhpcTerminalVo" >
select terminal_id, charging_pile_id, charging_station_id, name, serial_number, pile_serial_number, gun_status, work_status, status, del_flag, create_time, create_by, update_time, update_by, remark from xhpc_terminal
</sql>
2021-07-20 16:51:57 +08:00
<select id= "countXhpcTerminalWorkStatus" resultType= "map" >
select
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag=0 and work_status=0 and charging_station_id=#{chargingStationId}) offLine,
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag=0 and work_status=1 and charging_station_id=#{chargingStationId}) fault,
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag=0 and work_status=2 and charging_station_id=#{chargingStationId}) freeTime,
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag=0 and work_status=3 and charging_station_id=#{chargingStationId}) charge
from xhpc_terminal LIMIT 1
</select>
2021-07-27 18:09:18 +08:00
<select id= "getXhpcTerminalList" resultType= "map" >
select
te.terminal_id as terminalId,
te.name as terminalName,
ct.name as chargingStationName,
te.pile_serial_number as pileSerialNumber,
cp.power as power,
cp.serial_number as serialNumber,
te.status as status,
te.work_status as workStatus
from xhpc_terminal as te
left join xhpc_charging_station as ct on ct.charging_station_id = te.charging_station_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = te.charging_pile_id
where te.del_flag=0
<if test= "chargingStationId !=null" >
and te.charging_station_id=#{chargingStationId}
</if>
<if test= "serialNumber !=null and serialNumber !=''" >
and te.serial_number like CONCAT('%',#{serialNumber},'%')
</if>
<if test= "type !=null " >
and cp.type=#{type}
</if>
<if test= "status !=null " >
and cp.status=#{status}
</if>
<if test= "workStatus !=null and workStatus !=''" >
and te.work_status=#{chargingStationId}
</if>
</select>
<select id= "selectXhpcTerminalById" resultMap= "BaseResultMap" >
<include refid= "selectXhpcTerminalVo" />
where terminal_id = #{terminalId}
</select>
2021-07-28 18:07:25 +08:00
<update id= "updateXhpcTerminal" parameterType= "com.xhpc.common.domain.XhpcTerminal" >
2021-07-27 18:09:18 +08:00
update xhpc_terminal
<trim prefix= "SET" suffixOverrides= "," >
<if test= "chargingPileId != null" > charging_pile_id = #{chargingPileId},</if>
<if test= "chargingStationId != null" > charging_station_id = #{chargingStationId},</if>
<if test= "name != null" > name = #{name},</if>
<if test= "serialNumber != null" > serial_number = #{serialNumber},</if>
<if test= "pileSerialNumber != null" > pile_serial_number = #{pileSerialNumber},</if>
<if test= "gunStatus != null" > gun_status = #{gunStatus},</if>
<if test= "workStatus != null" > work_status = #{workStatus},</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>
</trim>
where terminal_id = #{terminalId}
</update>
2021-07-28 18:07:25 +08:00
<insert id= "addXhpcTerminal" parameterType= "com.xhpc.common.domain.XhpcTerminal" useGeneratedKeys= "true"
keyProperty="terminalId">
2021-07-27 18:09:18 +08:00
insert into xhpc_terminal
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingPileId " >
charging_pile_id,
</if>
<if test= "null != chargingStationId " >
charging_station_id,
</if>
<if test= "null != name " >
name,
</if>
<if test= "null != serialNumber " >
serial_number,
</if>
<if test= "null != pileSerialNumber " >
pile_serial_number,
</if>
2021-08-03 19:59:27 +08:00
<if test= "null != gunStatus " >
2021-07-27 18:09:18 +08:00
gun_status,
</if>
<if test= "null != workStatus " >
work_status,
</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>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingPileId " >
#{chargingPileId},
</if>
<if test= "null != chargingStationId " >
#{chargingStationId},
</if>
<if test= "null != name " >
#{name},
</if>
<if test= "null != serialNumber " >
#{serialNumber},
</if>
<if test= "null != pileSerialNumber " >
#{pileSerialNumber},
</if>
2021-08-03 19:59:27 +08:00
<if test= "null != gunStatus " >
#{gunStatus},
2021-07-27 18:09:18 +08:00
</if>
<if test= "null != workStatus " >
#{workStatus},
</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>
</trim>
</insert>
<select id= "selectXhpcTerminalPileMessage" resultType= "map" >
select
ter.terminal_id as terminalId,
2021-08-03 19:59:27 +08:00
ter.charging_station_id as chargingStationId,
2021-07-27 18:09:18 +08:00
ter.name as name,
ter.serial_number as serialNumber,
ter.gun_status as gunStatus,
ter.work_status as workStatus,
ter.status as status,
ct.name as chargingStationName,
ter.create_time as createTime,
cp.serial_number as pileSerialNumber,
cp.type as type,
cp.national_standard as nationalStandard,
cp.power as power,
cp.auxiliary_power_supply as auxiliaryPowerSupply,
cp.input_voltage as inputVoltage,
cp.max_voltage as maxVoltage,
cp.min_voltage as minVoltage,
cp.max_electric_current as maxElectricCurrent,
cp.min_electric_current as minElectricCurrent,
cp.communication_operator as communicationOperator,
cp.sim_card as simCard
from xhpc_terminal as ter
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join xhpc_charging_station as ct on ct.charging_station_id = ter.charging_station_id
where ter.terminal_id =#{terminalId}
</select>
<select id= "getXhpcRateTimeTypeList" resultType= "map" >
<if test= "type ==1" >
select
rt.start_time as startTime,
replace(rt.end_time,'00:00:00','24:00:00') AS endTime,
rt.rate_id as rateId,
2021-08-05 11:18:32 +08:00
rt.rate_value as rateValue,
2021-07-27 18:09:18 +08:00
ra.name as rateName
from xhpc_rate_time as rt
left join xhpc_rate as ra on ra.rate_id =rt.rate_id
where rt.charging_station_id=#{chargingStationId} and rt.del_flag =0 and rt.type=1
</if>
<if test= "type ==2" >
select
rt.start_time as startTime,
replace(rt.end_time,'00:00:00','24:00:00') AS endTime,
rt.rate_id as rateId,
ra.name as rateName
from xhpc_rate_time as rt
left join xhpc_rate as ra on ra.rate_id =rt.rate_id
where rt.charging_station_id=#{chargingStationId} and rt.del_flag =0 and rt.type=2
group by type
</if>
</select>
<select id= "getXhpcRateTimeOrderStatistics" resultType= "map" >
select
2021-08-03 19:59:27 +08:00
IFNULL(sum(charging_degree),'0') AS chargingDegreeSum,
2021-07-27 18:09:18 +08:00
COUNT(real_time_order_id) as realTimeOrderIdCount,
COUNT(DISTINCT user_id) as userIdCount
from xhpc_real_time_order
where real_time_order_id in (
select max(real_time_order_id) from xhpc_real_time_order WHERE to_days(create_time) = to_days(now()) and charging_station_id=#{chargingStationId} and gun_number =#{gunNumber} group by charging_order_id )
</select>
2021-07-29 13:47:03 +08:00
<select id= "getWXpNumMessage" resultType= "map" >
select
ter.name as terminalName,
ter.serial_number as serialNumber,
cp.power as power,
2021-07-30 16:29:52 +08:00
cp.type as type,
2021-07-29 13:47:03 +08:00
cp.max_voltage as maxVoltage,
cp.auxiliary_power_supply as auxiliaryPowerSupply,
ct.parking_instructions as parkingInstructions,
2021-07-29 17:39:20 +08:00
ct.create_time as createTime,
2021-07-29 13:47:03 +08:00
ter.charging_station_id as chargingStationId
from xhpc_terminal as ter
left join xhpc_charging_pile as cp on cp.charging_pile_id=ter.charging_pile_id
left join xhpc_charging_station as ct on ct.charging_station_id =ter.charging_station_id
where ter.serial_number=#{pNum} and ter.del_flag = 0
</select>
2021-07-29 15:07:34 +08:00
<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 " >
and img_id in
<foreach collection= "imgIds" item= "chargingStationId" open= "(" separator= "," close= ")" >
#{chargingStationId}
</foreach>
</if>
</select>
2021-07-28 18:07:25 +08:00
</mapper>