586 lines
22 KiB
XML
Raw Normal View History

2021-08-07 17:29:45 +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.order.mapper.XhpcRealTimeOrderMapper">
<resultMap type="com.xhpc.order.domain.XhpcRealTimeOrder" id="XhpcRealTimeOrderMap">
<result column="real_time_order_id" property="realTimeOrderId"/>
<result column="charging_order_id" property="chargingOrderId"/>
<result column="transaction_number" property="transactionNumber"/>
<result column="pile_number" property="pileNumber"/>
<result column="gun_number" property="gunNumber"/>
<result column="pile_gun_status" property="pileGunStatus"/>
<result column="vehicle_gun_status" property="vehicleGunStatus"/>
<result column="voltage" property="voltage"/>
<result column="electric_current" property="electricCurrent"/>
<result column="gun_line_temperature" property="gunLineTemperature"/>
<result column="gun_line_number" property="gunLineNumber"/>
<result column="soc" property="soc"/>
<result column="max_temperature" property="maxTemperature"/>
<result column="charging_time" property="chargingTime"/>
2021-08-26 19:35:19 +08:00
<result column="charging_time_number" property="chargingTimeNumber"/>
2021-08-07 17:29:45 +08:00
<result column="remaining_time" property="remainingTime"/>
<result column="charging_degree" property="chargingDegree"/>
<result column="loss_charging_degree" property="lossChargingDegree"/>
<result column="amount_charged" property="amountCharged"/>
<result column="hardware_fault" property="hardwareFault"/>
<result column="status" property="status"/>
<result column="create_time" property="createTime"/>
<result column="create_by" property="createBy"/>
<result column="update_time" property="updateTime"/>
<result column="update_by" property="updateBy"/>
<result column="remark" property="remark"/>
<result column="user_id" property="userId"/>
<result column="charging_station_id" property="chargingStationId"/>
</resultMap>
<insert id="addXhpcRealTimeOrder" parameterType="com.xhpc.order.domain.XhpcRealTimeOrder" useGeneratedKeys="true"
keyProperty="realTimeOrderId">
insert into xhpc_real_time_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargingOrderId ">
charging_order_id,
</if>
<if test="null != transactionNumber ">
transaction_number,
</if>
<if test="null != pileNumber ">
pile_number,
</if>
<if test="null != gunNumber ">
gun_number,
</if>
<if test="null != pileGunStatus ">
pile_gun_status,
</if>
<if test="null != vehicleGunStatus ">
vehicle_gun_status,
</if>
<if test="null != voltage ">
voltage,
</if>
<if test="null != electricCurrent ">
electric_current,
</if>
<if test="null != gunLineTemperature ">
gun_line_temperature,
</if>
<if test="null != gunLineNumber ">
gun_line_number,
</if>
<if test="null != soc ">
soc,
</if>
<if test="null != maxTemperature ">
max_temperature,
</if>
<if test="null != chargingTime ">
charging_time,
</if>
<if test="null != remainingTime ">
remaining_time,
</if>
<if test="null != chargingDegree ">
charging_degree,
</if>
<if test="null != lossChargingDegree ">
loss_charging_degree,
</if>
<if test="null != amountCharged ">
amount_charged,
</if>
<if test="null != hardwareFault ">
hardware_fault,
</if>
<if test="null != status ">
status,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy ">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy ">
update_by,
</if>
<if test="null != remark ">
remark,
</if>
<if test="null != userId ">
user_id,
</if>
<if test="null != chargingStationId ">
2021-08-26 19:35:19 +08:00
charging_station_id,
</if>
<if test="null != chargingTimeNumber ">
charging_time_number
2021-08-07 17:29:45 +08:00
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargingOrderId ">
#{chargingOrderId},
</if>
<if test="null != transactionNumber ">
#{transactionNumber},
</if>
<if test="null != pileNumber ">
#{pileNumber},
</if>
<if test="null != gunNumber ">
#{gunNumber},
</if>
<if test="null != pileGunStatus ">
#{pileGunStatus},
</if>
<if test="null != vehicleGunStatus ">
#{vehicleGunStatus},
</if>
<if test="null != voltage ">
#{voltage},
</if>
<if test="null != electricCurrent ">
#{electricCurrent},
</if>
<if test="null != gunLineTemperature ">
#{gunLineTemperature},
</if>
<if test="null != gunLineNumber ">
#{gunLineNumber},
</if>
<if test="null != soc ">
#{soc},
</if>
<if test="null != maxTemperature ">
#{maxTemperature},
</if>
<if test="null != chargingTime ">
#{chargingTime},
</if>
<if test="null != remainingTime ">
#{remainingTime},
</if>
<if test="null != chargingDegree ">
#{chargingDegree},
</if>
<if test="null != lossChargingDegree ">
#{lossChargingDegree},
</if>
<if test="null != amountCharged ">
#{amountCharged},
</if>
<if test="null != hardwareFault ">
#{hardwareFault},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy ">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy ">
#{updateBy},
</if>
<if test="null != remark ">
#{remark},
</if>
<if test="null != userId ">
#{userId},
</if>
<if test="null != chargingStationId ">
2021-08-26 19:35:19 +08:00
#{chargingStationId},
</if>
<if test="null != chargingTimeNumber ">
#{chargingTimeNumber}
2021-08-07 17:29:45 +08:00
</if>
</trim>
2021-08-10 13:46:33 +08:00
</insert>
2021-08-07 17:29:45 +08:00
2021-08-12 18:05:12 +08:00
<insert id="addSOC" parameterType="com.xhpc.order.domain.XhpcChargeOrderSoc" useGeneratedKeys="true"
2021-08-12 15:54:28 +08:00
keyProperty="chargeOrderSocId">
insert into xhpc_charge_order_soc
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargeOrderId ">
charge_order_id,
</if>
<if test="null != soc ">
soc,
</if>
<if test="null != status ">
status,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy ">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy ">
update_by,
</if>
<if test="null != remark ">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargeOrderId ">
#{chargeOrderId},
</if>
<if test="null != soc ">
#{soc},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy ">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy ">
#{updateBy},
</if>
<if test="null != remark ">
#{remark}
</if>
</trim>
</insert>
2021-08-12 18:05:12 +08:00
<insert id="addCurrent" parameterType="com.xhpc.order.domain.XhpcChargeOrderCurrent" useGeneratedKeys="true"
keyProperty="chargeOrderCurrentId">
insert into xhpc_charge_order_current
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargeOrderId ">
charge_order_id,
</if>
<if test="null != current ">
current,
</if>
<if test="null != status ">
status,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy ">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy ">
update_by,
</if>
<if test="null != remark ">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargeOrderId ">
#{chargeOrderId},
</if>
<if test="null != current ">
#{current},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy ">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy ">
#{updateBy},
</if>
<if test="null != remark ">
#{remark}
</if>
</trim>
</insert>
2021-08-12 15:54:28 +08:00
2021-08-12 18:05:12 +08:00
<insert id="addVoltage" parameterType="com.xhpc.order.domain.XhpcChargeOrderVoltage" useGeneratedKeys="true"
keyProperty="chargeOrderVoltageId">
insert into xhpc_charge_order_voltage
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != chargeOrderId ">
charge_order_id,
</if>
<if test="null != voltage ">
voltage,
</if>
<if test="null != status ">
status,
</if>
<if test="null != createTime ">
create_time,
</if>
<if test="null != createBy ">
create_by,
</if>
<if test="null != updateTime ">
update_time,
</if>
<if test="null != updateBy ">
update_by,
</if>
<if test="null != remark ">
remark
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != chargeOrderId ">
#{chargeOrderId},
</if>
<if test="null != voltage ">
#{voltage},
</if>
<if test="null != status ">
#{status},
</if>
<if test="null != createTime ">
#{createTime},
</if>
<if test="null != createBy ">
#{createBy},
</if>
<if test="null != updateTime ">
#{updateTime},
</if>
<if test="null != updateBy ">
#{updateBy},
</if>
<if test="null != remark ">
#{remark}
</if>
</trim>
</insert>
2021-08-07 17:29:45 +08:00
2021-08-10 13:46:33 +08:00
<select id="list" resultType="map">
2021-08-10 18:52:50 +08:00
select
2021-08-15 22:09:54 +08:00
co.charge_order_id as chargeOrderId,
2021-08-11 16:25:10 +08:00
co.serial_number as serialNumber,
ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber,
ter.name as terminalName,
op.operator_id as operatorId,
op.name as operatorName,
cp.power as power,
cp.type as type,
co.status as status,
co.erro_remark as erroRemark,
2021-08-11 16:25:10 +08:00
co.create_time as createTime,
co.start_time as startTime,
2021-08-15 22:09:54 +08:00
(select real_time_order_id from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) realTimeOrderId,
(select soc from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) soc,
(select charging_degree from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) chargingDegree,
(select charging_time from xhpc_real_time_order where transaction_number =co.serial_number order by create_time desc limit 1) chargingTime,
2021-08-11 16:25:10 +08:00
co.source as source,
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone
2021-08-10 18:52:50 +08:00
from xhpc_charge_order co
2021-08-15 22:09:54 +08:00
left join xhpc_charging_station as ct on ct.charging_station_id = co.charging_station_id
2021-08-10 18:52:50 +08:00
left join xhpc_operator as op on op.operator_id = ct.operator_id
2021-08-15 22:09:54 +08:00
left join xhpc_terminal as ter on ter.terminal_id = co.terminal_id
2021-08-10 18:52:50 +08:00
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
2021-08-15 22:09:54 +08:00
where co.status=#{status} and co.del_flag=0
2021-08-10 18:52:50 +08:00
<if test="startTime !=null and startTime !=''">
and co.start_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and co.start_time &lt;= #{startTime}
</if>
<if test="transactionNumber !=null and transactionNumber !=''">
and co.serial_number like concat('%', #{transactionNumber}, '%')
</if>
<if test="chargingStationName !=null and chargingStationName !=''">
and co.serial_number like concat('%', #{transactionNumber}, '%')
</if>
<if test="terminalName !=null and terminalName !=''">
and ter.name like concat('%', #{terminalName}, '%')
</if>
<if test="operatorId !=null">
and op.operator_id =#{operatorId}
</if>
<if test="number==1">
2021-08-11 16:25:10 +08:00
and co.user_id in (SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%')) or
2021-08-10 18:52:50 +08:00
co.user_id in (SELECT internet_user_id from xhpc_internet_user where phone like concat('%', #{phone}, '%'))
</if>
<if test="number==2">
2021-08-10 18:52:50 +08:00
<if test="source !=null and source ==0">
2021-08-11 16:25:10 +08:00
and co.user_id in (SELECT app_user_id FROM xhpc_app_user)
2021-08-10 18:52:50 +08:00
</if>
<if test="source !=null and source ==1">
2021-08-11 16:25:10 +08:00
and co.user_id in (SELECT internet_user_id from xhpc_internet_user)
2021-08-10 18:52:50 +08:00
</if>
</if>
<if test="number==3">
2021-08-10 18:52:50 +08:00
<if test="source !=null and source ==0">
2021-08-11 16:25:10 +08:00
and co.user_id in (SELECT app_user_id FROM xhpc_app_user where phone like concat('%', #{phone}, '%'))
2021-08-10 18:52:50 +08:00
</if>
<if test="source !=null and source ==1">
2021-08-11 16:25:10 +08:00
and co.user_id in (SELECT internet_user_id from xhpc_internet_user where phone like concat('%',
#{phone}, '%'))
2021-08-10 18:52:50 +08:00
</if>
</if>
<if test="type==2">
and co.source =0
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="type==3">
and co.source =1
and co.user_id=#{userId}
</if>
2021-08-10 18:52:50 +08:00
order by co.create_time desc
2021-08-10 13:46:33 +08:00
</select>
2021-08-11 16:25:10 +08:00
<select id="getMessage" resultType="map">
select
ro.real_time_order_id as realTimeOrderId,
2021-08-30 15:49:42 +08:00
co.charge_order_id as chargeOrderId,
2021-08-11 16:25:10 +08:00
co.serial_number as serialNumber,
ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber,
ter.name as terminalName,
op.operator_id as operatorId,
op.name as operatorName,
2021-08-26 19:35:19 +08:00
cp.serial_number as pileSerialNumber,
2021-08-11 16:25:10 +08:00
cp.power as power,
cp.type as type,
ro.soc as soc,
co.status as status,
co.create_time as createTime,
ro.charging_degree as chargingDegree,
ro.charging_time as chargingTime,
co.source as source,
co.internet_serial_number as internetSerialNumber,
2021-08-26 19:35:19 +08:00
co.erro_remark as erroRemark,
ro.amount_charged as amountCharged,
2021-08-11 16:25:10 +08:00
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone
from xhpc_real_time_order ro
Left join xhpc_charge_order co on co.serial_number = ro.transaction_number
Left join xhpc_charging_station as ct on ct.charging_station_id = ro.charging_station_id
left join xhpc_operator as op on op.operator_id = ct.operator_id
2021-08-26 19:35:19 +08:00
left join xhpc_terminal as ter on ter.terminal_id = co.terminal_id
2021-08-11 16:25:10 +08:00
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
where ro.real_time_order_id=#{realTimeOrderId}
</select>
<select id="timeList" resultType="map">
select
create_time as createTime,
voltage,
electric_current as electricCurrent,
soc,
charging_degree as chargingDegree,
loss_charging_degree as lossChargingDegree,
gun_line_temperature as gunLineTemperature,
charging_time as chargingTime,
remaining_time as remainingTime,
2021-08-15 22:09:54 +08:00
vehicle_gun_status as vehicleGunStatus,
status
2021-08-11 16:25:10 +08:00
from xhpc_real_time_order
where charging_order_id=#{chargingOrderId}
order by create_time desc
</select>
<select id="timeChartSOCList" resultType="map">
select
group_concat(soc) as soc,
group_concat(DATE_FORMAT(create_time,'%H:%i:%s')) createTime
from xhpc_charge_order_soc
where charge_order_id=#{chargingOrderId}
</select>
<select id="timeChartVoltageList" resultType="map">
select
group_concat(voltage) as voltage,
group_concat(DATE_FORMAT(create_time,'%H:%i:%s')) createTime
from xhpc_charge_order_voltage
where charge_order_id=#{chargingOrderId}
</select>
<select id="timeChartCurrentList" resultType="map">
select
group_concat(current) as current,
group_concat(DATE_FORMAT(create_time,'%H:%i:%s')) createTime
from xhpc_charge_order_current
where charge_order_id=#{chargingOrderId}
</select>
2021-08-18 15:35:11 +08:00
<delete id="deleteRealTimeOrder">
delete from xhpc_real_time_order where charging_order_id=#{chargingOrderId}
</delete>
<delete id="deleteChargeVoltage">
2021-08-23 11:58:30 +08:00
delete from xhpc_charge_order_current where charge_order_id=#{chargingOrderId}
2021-08-18 15:35:11 +08:00
</delete>
<delete id="deleteChargeOrderSoc">
2021-08-23 11:58:30 +08:00
delete from xhpc_charge_order_soc where charge_order_id=#{chargingOrderId}
2021-08-18 15:35:11 +08:00
</delete>
<delete id="deleteChargeOrderCurrent">
2021-08-23 11:58:30 +08:00
delete from xhpc_charge_order_voltage where charge_order_id=#{chargingOrderId}
2021-08-18 15:35:11 +08:00
</delete>
2021-08-26 19:35:19 +08:00
<select id="getChargingOrderId" resultMap="XhpcRealTimeOrderMap">
select * from xhpc_real_time_order where charging_order_id=#{chargingOrderId} order by create_time desc limit 1
</select>
2021-08-30 15:49:42 +08:00
<select id="getChargeOrderById" resultType="map">
select
co.serial_number as serialNumber,
ct.name as chargingStationName,
ter.pile_serial_number as pileSerialNumber,
ter.name as terminalName,
op.operator_id as operatorId,
op.name as operatorName,
cp.serial_number as pileSerialNumber,
cp.power as power,
cp.type as type,
ro.soc as soc,
co.status as status,
co.create_time as createTime,
ro.charging_degree as chargingDegree,
ro.charging_time as chargingTime,
co.source as source,
co.internet_serial_number as internetSerialNumber,
co.erro_remark as erroRemark,
ro.amount_charged as amountCharged,
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone
from xhpc_charge_order as co
Left join xhpc_real_time_order ro on co.serial_number = ro.transaction_number
Left join xhpc_charging_station as ct on ct.charging_station_id = ro.charging_station_id
left join xhpc_operator as op on op.operator_id = ct.operator_id
left join xhpc_terminal as ter on ter.terminal_id = co.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
where ro.real_time_order_id=#{realTimeOrderId}
</select>
2021-08-07 17:29:45 +08:00
</mapper>