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>
2022-01-04 18:48:54 +08:00
<insert id= "insertXhpcRealTimeOrder" parameterType= "com.xhpc.order.domain.XhpcRealTimeOrder" useGeneratedKeys= "true"
2021-08-07 17:29:45 +08:00
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 " >
2022-02-25 10:17:23 +08:00
charging_time_number,
</if>
<if test= "null != source " >
source
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 " >
2022-02-25 10:17:23 +08:00
#{chargingTimeNumber},
</if>
<if test= "null != source " >
#{source}
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
2022-09-01 14:07:52 +08:00
<insert id= "insertRealTimeOrderBms" >
insert into xhpc_real_time_order_bms
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != orderNo and orderNo !=''" >
order_no,
</if>
<if test= "null != pileNo and pileNo!=''" >
pile_no,
</if>
<if test= "null != gunId and gunId!='' " >
gun_id,
</if>
<if test= "null != bmsVoltageRequest " >
bms_voltage_request,
</if>
<if test= "null != bmsCurrentRequest " >
bms_current_request,
</if>
<if test= "null != bmsChargingMod " >
bms_charging_mod,
</if>
<if test= "null != bmsChargingVolt " >
bms_charging_volt,
</if>
<if test= "null != bmsChargingCurrent " >
bms_charging_current,
</if>
2022-10-20 11:27:48 +08:00
<if test= "null != monoBatteryVolt " >
mono_battery_volt,
</if>
2022-09-01 14:07:52 +08:00
<if test= "null != soc " >
soc,
</if>
<if test= "null != bmsEstRemainingTime and bmsEstRemainingTime !=''" >
bms_est_remaining_time,
</if>
<if test= "null != pileVoltageOutput " >
pile_voltage_output,
</if>
<if test= "null != pileCurrentOutput " >
pile_current_output,
</if>
<if test= "null != chargingTimeSummary and chargingTimeSummary !=''" >
charging_time_summary,
</if>
<if test= "null != monoBatteryVoltGroupId " >
mono_battery_volt_groupId,
</if>
<if test= "null != chargingOrderId " >
charging_order_id,
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != orderNo and orderNo !=''" >
#{orderNo},
</if>
<if test= "null != pileNo and pileNo!=''" >
#{pileNo},
</if>
<if test= "null != gunId and gunId!='' " >
#{gunId},
</if>
<if test= "null != bmsVoltageRequest " >
#{bmsVoltageRequest},
</if>
<if test= "null != bmsCurrentRequest " >
#{bmsCurrentRequest},
</if>
<if test= "null != bmsChargingMod " >
#{bmsChargingMod},
</if>
<if test= "null != monoBatteryVolt " >
#{monoBatteryVolt},
</if>
<if test= "null != bmsChargingCurrent " >
#{bmsChargingCurrent},
</if>
2022-10-20 11:27:48 +08:00
<if test= "null != monoBatteryVolt " >
#{monoBatteryVolt},
</if>
2022-09-01 14:07:52 +08:00
<if test= "null != soc " >
#{soc},
</if>
<if test= "null != bmsEstRemainingTime and bmsEstRemainingTime!=''" >
#{bmsEstRemainingTime},
</if>
<if test= "null != pileVoltageOutput " >
#{pileVoltageOutput},
</if>
<if test= "null != pileCurrentOutput " >
#{pileCurrentOutput},
</if>
<if test= "null != chargingTimeSummary and chargingTimeSummary!=''" >
#{chargingTimeSummary},
</if>
<if test= "null != monoBatteryVoltGroupId " >
#{monoBatteryVoltGroupId},
</if>
<if test= "null != chargingOrderId " >
#{chargingOrderId},
</if>
</trim>
</insert>
2022-01-04 18:48:54 +08:00
<insert id= "insertSOC" 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>
2022-01-04 18:48:54 +08:00
<insert id= "insertCurrent" parameterType= "com.xhpc.order.domain.XhpcChargeOrderCurrent" useGeneratedKeys= "true"
2021-08-12 18:05:12 +08:00
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
2022-01-04 18:48:54 +08:00
<insert id= "insertVoltage" parameterType= "com.xhpc.order.domain.XhpcChargeOrderVoltage" useGeneratedKeys= "true"
2021-08-12 18:05:12 +08:00
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,
2021-08-23 19:59:57 +08:00
co.erro_remark as erroRemark,
2021-08-11 16:25:10 +08:00
co.create_time as createTime,
2021-08-23 19:59:57 +08:00
co.start_time as startTime,
2021-11-30 18:21:02 +08:00
ro.real_time_order_id as realTimeOrderId,
ro.soc as soc,
ro.charging_degree as chargingDegree,
ro.charging_time as chargingTime,
2021-08-11 16:25:10 +08:00
co.source as source,
2021-11-30 18:21:02 +08:00
co.internet_serial_number as internetSerialNumber,
2021-11-22 18:53:46 +08:00
co.Plate_num as plateNum,
2021-11-30 18:21:02 +08:00
inu.name as internetName,
inu.phone as internetUserPhone,
2022-01-28 15:39:25 +08:00
cup.name as customersName,
cup.account as customersAccount,
cop.name as communityName,
cop.account as communityAccount,
2021-11-30 18:21:02 +08:00
apu.phone as appUserPhone
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-11-30 18:21:02 +08:00
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
2022-01-28 15:39:25 +08:00
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
2021-12-02 17:15:40 +08:00
LEFT JOIN (
2021-12-27 15:45:06 +08:00
SELECT charging_order_id,real_time_order_id,soc,charging_degree,charging_time 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 )
2021-12-02 17:15:40 +08:00
) ro ON ro.charging_order_id = co.charge_order_id
2021-12-27 15:45:06 +08:00
<if test= "number==1" >
inner join (
2022-01-28 15:39:25 +08:00
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_app_user as xau on xau.app_user_id = xco.user_id where xco.source=0 and xau.phone LIKE concat('%',#{phone}, '%')
2021-12-27 15:45:06 +08:00
union
2022-01-28 15:39:25 +08:00
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = xco.user_id where xco.source=1 and xiu.phone LIKE concat('%',#{phone}, '%')
union
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_community_personnel as xcp on xcp.community_personnel_id = xco.user_id where xco.source=2 and xcp.account LIKE concat('%',#{phone}, '%')
union
select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_customers_personnel as xcup on xcup.customers_personnel_id = xco.user_id where xco.source=3 and xcup.account LIKE concat('%',#{phone}, '%')
) ut on ut.charge_order_id = co.charge_order_id
2021-12-27 15:45:06 +08:00
</if>
2021-08-15 22:09:54 +08:00
where co.status=#{status} and co.del_flag=0
2021-11-30 18:21:02 +08:00
<if test= "internetId !=null" >
and co.source =1
and inu.internet_user_id=#{internetId}
</if>
2022-05-07 18:22:47 +08:00
<if test= "chargingStationId!=null" >
and co.charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId!=null" >
and co.terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id =#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId!=null" >
and co.terminal_id=#{terminalId}
</if>
2021-11-30 18:21:02 +08:00
<if test= "internetSerialNumber !=null and internetSerialNumber !=''" >
and co.source =1
and inu.name like concat('%', #{internetSerialNumber}, '%')
</if>
<if test= "plateNum !=null and plateNum !=''" >
and co.Plate_num like concat('%', #{plateNum}, '%')
</if>
2022-03-01 16:42:08 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and co.tenant_id =#{tenantId}
</if>
2021-11-22 18:53:46 +08:00
<if test= "source !=null" >
and co.source =#{source}
</if>
2021-08-10 18:52:50 +08:00
<if test= "startTime !=null and startTime !=''" >
and co.start_time > = #{startTime}
</if>
<if test= "endTime !=null and endTime !=''" >
2021-10-22 14:37:29 +08:00
and co.start_time < = #{endTime}
2021-08-10 18:52:50 +08:00
</if>
<if test= "transactionNumber !=null and transactionNumber !=''" >
and co.serial_number like concat('%', #{transactionNumber}, '%')
</if>
<if test= "chargingStationName !=null and chargingStationName !=''" >
2021-11-24 17:22:49 +08:00
and ct.name like concat('%', #{chargingStationName}, '%')
2021-08-10 18:52:50 +08:00
</if>
<if test= "terminalName !=null and terminalName !=''" >
and ter.name like concat('%', #{terminalName}, '%')
</if>
<if test= "operatorId !=null" >
and op.operator_id =#{operatorId}
</if>
2021-08-23 19:59:57 +08:00
<if test= "number==2" >
2021-08-10 18:52:50 +08:00
<if test= "source !=null and source ==0" >
2022-01-28 15:39:25 +08:00
and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_app_user as xau on xau.app_user_id = xco.user_id where xco.source=0 and xau.phone LIKE concat('%',#{phone}, '%'))
2021-08-10 18:52:50 +08:00
</if>
<if test= "source !=null and source ==1" >
2022-01-28 15:39:25 +08:00
and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = xco.user_id where xco.source=1 and xiu.phone LIKE concat('%',#{phone}, '%'))
2021-08-10 18:52:50 +08:00
</if>
</if>
2021-08-23 19:59:57 +08:00
<if test= "number==3" >
2021-08-10 18:52:50 +08:00
<if test= "source !=null and source ==0" >
2022-01-28 15:39:25 +08:00
and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_app_user as xau on xau.app_user_id = xco.user_id where xco.source=0 and xau.phone LIKE concat('%',#{phone}, '%'))
2021-08-10 18:52:50 +08:00
</if>
<if test= "source !=null and source ==1" >
2022-01-28 15:39:25 +08:00
a and co.charge_order_id in (select xco.charge_order_id as charge_order_id from xhpc_charge_order as xco INNER JOIN xhpc_internet_user as xiu on xiu.internet_user_id = xco.user_id where xco.source=1 and xiu.phone LIKE concat('%',#{phone}, '%'))
2021-08-10 18:52:50 +08:00
</if>
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
2021-08-23 19:59:57 +08:00
and co.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and co.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-08-23 19:59:57 +08:00
</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,
2021-10-22 14:37:29 +08:00
ro.voltage as voltage,
ro.electric_current as electricCurrent,
2021-08-11 16:25:10 +08:00
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-11-22 18:53:46 +08:00
co.Plate_num as plateNum,
2022-07-20 17:43:27 +08:00
co.start_time as startTime,
co.end_time as endTime,
2021-08-11 16:25:10 +08:00
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
2021-11-22 18:53:46 +08:00
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone,
2022-01-28 15:39:25 +08:00
(SELECT name from xhpc_internet_user where internet_user_id = co.user_id and co.source=1) as internetName,
(SELECT account from xhpc_community_personnel where community_personnel_id = co.user_id and co.source=2) as communityAccount,
(SELECT account from xhpc_customers_personnel where customers_personnel_id = co.user_id and co.source=3) as customersAccount
2021-08-11 16:25:10 +08:00
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>
2022-04-02 16:29:52 +08:00
2022-08-26 15:01:23 +08:00
<select id= "getXhpcChargingStationById" resultType= "map" >
select
charging_station_id chargingStationId,
rate_model_id as rateModelId
from xhpc_charging_station where charging_station_id=#{chargingStationId}
</select>
2022-04-02 16:29:52 +08:00
<select id= "getMessageChargeOrderId" resultType= "map" >
select
co.charge_order_id as chargeOrderId,
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,
concat(0) as soc,
concat(0) as voltage,
concat(0) as electricCurrent,
co.status as status,
co.create_time as createTime,
2022-07-20 17:43:27 +08:00
co.start_time as startTime,
co.end_time as endTime,
co.charging_degree as chargingDegree,
2022-04-02 16:29:52 +08:00
concat(0) as chargingTime,
co.source as source,
co.internet_serial_number as internetSerialNumber,
co.erro_remark as erroRemark,
concat(0) as amountCharged,
co.Plate_num as plateNum,
(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,
(SELECT name from xhpc_internet_user where internet_user_id = co.user_id and co.source=1) as internetName,
(SELECT account from xhpc_community_personnel where community_personnel_id = co.user_id and co.source=2) as communityAccount,
(SELECT account from xhpc_customers_personnel where customers_personnel_id = co.user_id and co.source=3) as customersAccount
from xhpc_charge_order co
2022-04-06 14:30:57 +08:00
Left join xhpc_charging_station as ct on ct.charging_station_id = co.charging_station_id
2022-04-02 16:29:52 +08:00
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
2022-04-06 14:30:57 +08:00
where co.charge_order_id=#{chargeOrderId}
2022-04-02 16:29:52 +08:00
</select>
2021-08-11 16:25:10 +08:00
<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>
2022-09-01 14:07:52 +08:00
<select id= "timeBmsList" resultType= "map" >
select
order_no as orderNo,
pile_no as pileNo,
gun_id as gunId,
bms_voltage_request as bmsVoltageRequest,
bms_current_request as bmsCurrentRequest,
bms_charging_mod as bmsChargingMod,
bms_charging_volt as bmsChargingVolt,
2022-10-20 11:27:48 +08:00
bms_charging_current as bmsChargingCurrent,
2022-09-01 14:07:52 +08:00
mono_battery_volt as monoBatteryVolt,
soc as soc,
bms_est_remaining_time as bmsEstRemainingTime,
2022-10-20 11:27:48 +08:00
pile_voltage_output as pileVoltageOutput,
2022-09-01 14:07:52 +08:00
pile_current_output as pileCurrentOutput,
charging_time_summary as chargingTimeSummary,
mono_battery_volt_groupId as monoBatteryVoltGroupId,
create_time as createTime
from xhpc_real_time_order_bms
where charging_order_id=#{chargingOrderId}
order by create_time desc
</select>
2021-08-11 16:25:10 +08:00
<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" >
2022-03-29 13:43:49 +08:00
select
*
from xhpc_real_time_order
where charging_order_id=#{chargingOrderId}
and soc>0 and charging_degree>0
<if test= "type ==1" >
2021-11-22 18:53:46 +08:00
order by create_time asc
</if>
<if test= "type==2" >
order by create_time desc
</if>
limit 1
2021-08-26 19:35:19 +08:00
</select>
2022-04-21 16:10:35 +08:00
<select id= "getRealTimeOrderTime" resultType= "double" >
select IFNULL((
(SELECT
max(charging_degree)
FROM
xhpc_real_time_order
WHERE
charging_order_id =#{chargingOrderId}
and create_time < =#{endTime} )-(SELECT
min(charging_degree)
FROM
xhpc_real_time_order
WHERE
charging_order_id =#{chargingOrderId}
and create_time > =#{startTime})),0) number from xhpc_real_time_order WHERE
charging_order_id =#{chargingOrderId}
limit 1
</select>
<select id= "getDifferenceTime" resultType= "int" >
SELECT IFNULL(TIMESTAMPDIFF(SECOND,
(SELECT
max(create_time)
FROM
xhpc_real_time_order
WHERE
charging_order_id =#{chargingOrderId}
and create_time < =#{time} ),
#{time}
),0) time from xhpc_real_time_order WHERE charging_order_id =#{chargingOrderId} limit 1
</select>
<select id= "getChargingDegreeTime" resultType= "double" >
SELECT IFNULL((SELECT
min(charging_degree)
FROM
xhpc_real_time_order
WHERE
charging_order_id =#{chargingOrderId}
and create_time > =#{time} )-
(SELECT
max(charging_degree)
FROM
xhpc_real_time_order
WHERE
charging_order_id =#{chargingOrderId}
and create_time < =#{time} ),0)time from xhpc_real_time_order WHERE charging_order_id =#{chargingOrderId} 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-11-05 14:55:03 +08:00
<select id= "getOperatorIdEvcs" resultType= "map" >
select
2021-12-01 09:41:37 +08:00
internet_user_id as internetUserId,
2021-11-05 14:55:03 +08:00
operator_id_evcs as operatorIdEvcs,
commission_type as commissionType,
commission_rate as commissionRate
from xhpc_internet_user
where del_flag =0 and operator_id_evcs=#{operatorIdEvcs} limit 1
</select>
2022-04-21 16:10:35 +08:00
<select id= "getActivityFormulaTime" resultType= "com.xhpc.order.dto.XhpcActivityFormulaDomainDto" >
select
activity_formula_id as activityFormulaId,
activity_id as activityId,
start_time as startTime,
end_time as endTime,
service_price as servicePrice,
power_price as powerPrice,
compute_formula as computeFormula
from xhpc_activity_formula
where
activity_id = #{activityId}
2022-05-05 14:12:56 +08:00
and activity_formula_id in (SELECT activity_formula_id FROM xhpc_activity_formula WHERE start_time < = #{startTime} AND end_time > = #{startTime} and activity_id = #{activityId})
or activity_formula_id in (SELECT activity_formula_id FROM xhpc_activity_formula WHERE start_time < = #{endTime} AND end_time > = #{endTime} and activity_id = #{activityId})
2022-04-21 16:10:35 +08:00
order by activity_formula_id
</select>
<select id= "getActivityStationTime" resultType= "com.xhpc.order.dto.XhpcActivityInternetDomainDto" >
select
activity_id as activityId,
activity_name as activityName,
internet_name as internetName,
compute_type as computeType,
service_price as servicePrice,
compute_formula as computeFormula,
start_time as startTime,
end_time as endTime,
station_list as stationList,
tenant_id as tenantId,
`status`,
del_flag as delFlag
from xhpc_activity_internet
where tenant_id =#{tenantId}
and find_in_set(#{chargingStationId}, station_list)
and internet_name = (select name from xhpc_internet_user where internet_user_id =#{internetUserId} and del_flag =0)
and status =3 and del_flag=0
2022-05-05 14:12:56 +08:00
and start_time < = #{startTime} AND end_time > = #{startTime}
2022-04-21 16:10:35 +08:00
order by end_time
</select>
<select id= "getActivityDiscountTime" resultType= "com.xhpc.order.dto.XhpcActivityDiscountDto" >
select
xad.activity_id as activityId,
xad.activity_name as activityName,
xad.template_id as templateId,
xad.app_user_list as appUserList,
xad.com_user_list as comUserList,
xad.cus_user_list as cusUserList,
xad.station_list as stationList,
xad.tenant_id as tenantId,
xad.start_time as startTime,
xad.end_time as endTime,
xad.status as status,
xad.del_flag as delFlag,
xad.create_by as createBy,
xad.create_time as createTime,
xad.update_by as updateBy,
xad.update_time as updateTime,
xad.check_by as checkBy,
xad.check_time as checkTime,
xat.discount_type discountType,
xat.discount_rate discountRate
from xhpc_activity_discount as xad
join xhpc_activity_template as xat on xat.activity_template_id = xad.template_id and xat.del_flag =0 and xat.status=1
where xad.tenant_id=#{tenantId} and xad.status=3 and xad.del_flag =0
and find_in_set(#{chargingStationId}, xad.station_list)
<if test= "userType ==0" >
and (find_in_set(#{internetUserId}, xad.app_user_list) or xad.app_user_list='-1')
</if>
<if test= "userType ==2" >
2022-04-27 11:22:57 +08:00
and (find_in_set(#{internetUserId}, xad.com_user_list) or xad.com_user_list='-1')
2022-04-21 16:10:35 +08:00
</if>
<if test= "userType ==3" >
2022-04-27 11:22:57 +08:00
and (find_in_set(#{internetUserId}, xad.cus_user_list) or xad.cus_user_list='-1')
2022-04-21 16:10:35 +08:00
</if>
and xad.start_time < =#{startTime} and xad.end_time > #{startTime}
order by xad.start_time asc
</select>
2022-05-16 16:49:50 +08:00
<select id= "getActivityFormulaById" resultType= "com.xhpc.order.dto.XhpcActivityFormulaDomainDto" >
select
activity_formula_id as activityFormulaId,
activity_id as activityId,
start_time as startTime,
end_time as endTime,
service_price as servicePrice,
power_price as powerPrice,
compute_formula as computeFormula
from xhpc_activity_formula
where activity_id = #{activityId}
</select>
<select id= "getRateTimeList" resultType= "com.xhpc.order.dto.RateTime" >
select
start_time as startTime,
replace(end_time, '00:00:00', '24:00:00') as endTime,
power_fee as powerPrice,
service_fee as servicePrice
from xhpc_rate_time as xrt
left join xhpc_rate as xr on xrt.rate_id = xr.rate_id
where xrt.charging_station_id=#{chargingStationId} and xrt.rate_model_id=#{rateModelId} and xrt.del_flag=0
<if test= "rateValue !=null and rateValue !=''" >
and xrt.rate_value =#{rateValue}
</if>
</select>
<select id= "getActivityFormulaTimeById" resultType= "com.xhpc.order.dto.XhpcActivityFormulaDomainDto" >
select
activity_formula_id as activityFormulaId,
activity_id as activityId,
start_time as startTime,
end_time as endTime,
service_price as servicePrice,
power_price as powerPrice,
compute_formula as computeFormula
from xhpc_activity_formula
where activity_id = #{activityId}
and start_time > = #{startTime} AND end_time < = #{endTime}
</select>
2021-08-07 17:29:45 +08:00
</mapper>