2021-09-01 19:21:44 +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.XhpcStatisticsServiceMapper" >
<resultMap type= "com.xhpc.order.domain.XhpcStatisticsTimeInterval" id= "StatisticsTimeIntervalResult" >
<result column= "statistics_time_interval_id" property= "statisticsTimeIntervalId" />
<result column= "status" property= "status" />
<result column= "charging_degree" property= "chargingDegree" />
<result column= "charging_time" property= "chargingTime" />
<result column= "charging_number" property= "chargingNumber" />
<result column= "power_price" property= "powerPrice" />
<result column= "service_price" property= "servicePrice" />
<result column= "total_price" property= "totalPrice" />
<result column= "promotion_discount" property= "promotionDiscount" />
<result column= "internet_commission" property= "internetCommission" />
<result column= "internet_svc_commission" property= "internetSvcCommission" />
<result column= "platform_commission" property= "platformCommission" />
<result column= "platform_svc_commisssion" property= "platformSvcCommisssion" />
<result column= "operation_commission" property= "operationCommission" />
<result column= "operation_svc_commission" property= "operationSvcCommission" />
<result column= "operator_id" property= "operatorId" />
<result column= "internet_user_id" property= "internetUserId" />
2021-09-07 10:00:04 +08:00
<result column= "charging_station_id" property= "chargingStationId" />
2021-09-01 19:21:44 +08:00
<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" />
2021-09-02 20:08:21 +08:00
<result property= "terminalId" column= "terminal_id" />
2021-09-27 09:49:43 +08:00
<result property= "startTimeEvcs" column= "start_time_evcs" />
<result property= "endTimeEvcs" column= "end_time_evcs" />
<result property= "elecPriceEvcs" column= "elec_price_evcs" />
<result property= "servicePriceEvcs" column= "service_price_evcs" />
2021-09-01 19:21:44 +08:00
</resultMap>
<select id= "getTimeIntervalPage" resultType= "map" >
select
2022-04-26 14:29:51 +08:00
format(ifnull(sum(act_price),0), 2) actPrice,
format(ifnull(sum(act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(act_service_price),0), 2) actServicePrice,
format(ifnull(sum(act_service_price + act_power_price),0), 2) actTotalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(activity_total_price),0), 2) activityTotalPrice,
2022-07-13 14:24:22 +08:00
format(ifnull(sum(charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(power_price),0), 2) powerPrice,
format(ifnull(sum(service_price),0), 2) servicePrice,
format(ifnull(sum(total_price),0), 2) totalPrice,
format(ifnull(sum(promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(internet_commission),0), 2) internetCommission,
format(ifnull(sum(internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(platform_commission),0), 2) platformCommission,
format(ifnull(sum(platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(operation_commission),0), 2) operationCommission,
format(ifnull(sum(operation_svc_commission),0), 2) operationSvcCommission,
2021-09-01 19:21:44 +08:00
status,
case when status=1 then "00:00-01:00"
when status=2 then "01:00-02:00"
when status=3 then "02:00-03:00"
when status=4 then "03:00-04:00"
when status=5 then "04:00-05:00"
when status=6 then "05:00-06:00"
when status=7 then "06:00-07:00"
when status=8 then "07:00-08:00"
when status=9 then "08:00-09:00"
when status=10 then "09:00-10:00"
when status=11 then "10:00-11:00"
when status=12 then "11:00-12:00"
when status=13 then "12:00-13:00"
when status=14 then "13:00-14:00"
when status=15 then "14:00-15:00"
when status=16 then "15:00-16:00"
when status=17 then "16:00-17:00"
when status=18 then "17:00-18:00"
when status=19 then "18:00-19:00"
when status=20 then "19:00-20:00"
when status=21 then "20:00-21:00"
when status=22 then "21:00-22:00"
when status=23 then "22:00-23:00"
when status=24 then "23:00-24:00"
end time
from xhpc_statistics_time_interval
2022-04-21 16:10:35 +08:00
where del_flag=0 and total_price > =0
2021-09-06 16:15:37 +08:00
<if test= "chargingStationIds !=null and chargingStationIds.size()>0" >
and charging_station_id in
<foreach collection= "chargingStationIds" open= "(" item= "chargingStationId" separator= "," close= ")" >
#{chargingStationId}
2021-09-01 19:21:44 +08:00
</foreach>
</if>
2022-05-09 17:14:58 +08:00
<if test= "chargingStationId !=null" >
and charging_station_id =#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId !=null" >
and terminal_id =#{terminalId}
</if>
2021-11-18 11:21:04 +08:00
<if test= "startTime !=null and startTime !=''" >
and create_time > = #{startTime}
</if>
<if test= "endTime !=null and endTime !=''" >
and create_time < = #{endTime}
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-11-01 10:52:56 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2022-06-09 15:46:35 +08:00
<if test= "operatorId !=null" >
and operator_id =#{operatorId}
</if>
2022-06-22 10:10:50 +08:00
and operator_id is not null
2021-09-01 19:21:44 +08:00
group by status
order by status
</select>
<select id= "getDateIntervalPage" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(power_price),0), 2) powerPrice,
format(ifnull(sum(service_price),0), 2) servicePrice,
format(ifnull(sum(total_price),0), 2) totalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(act_price),0), 2) actPrice,
format(ifnull(sum(act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(act_service_price),0), 2) actServicePrice,
format(ifnull(sum(promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(internet_commission),0), 2) internetCommission,
format(ifnull(sum(internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(platform_commission),0), 2) platformCommission,
format(ifnull(sum(platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(operation_commission),0), 2) operationCommission,
format(ifnull(sum(operation_svc_commission),0), 2) operationSvcCommission,
format(ifnull(sum(act_power_price + act_service_price),0), 2) actTotalPrice,
2021-09-01 19:21:44 +08:00
DATE_FORMAT(create_time,'%Y-%m-%d') createTime
2021-09-02 11:18:14 +08:00
from xhpc_statistics_station
2022-04-21 16:10:35 +08:00
where del_flag=0 and type=1 and total_price > =0
2021-09-06 16:15:37 +08:00
<if test= "chargingStationIds !=null and chargingStationIds.size()>0" >
and charging_station_id in
<foreach collection= "chargingStationIds" open= "(" item= "chargingStationId" separator= "," close= ")" >
#{chargingStationId}
2021-09-01 19:21:44 +08:00
</foreach>
</if>
2022-05-09 17:14:58 +08:00
<if test= "chargingStationId !=null" >
and charging_station_id =#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId !=null" >
and terminal_id =#{terminalId}
</if>
2021-11-18 11:21:04 +08:00
<if test= "startTime !=null and startTime !=''" >
and create_time > = #{startTime}
</if>
<if test= "endTime !=null and endTime !=''" >
and create_time < = #{endTime}
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
2021-11-23 17:10:02 +08:00
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-11-01 10:52:56 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2022-06-09 15:46:35 +08:00
<if test= "operatorId !=null" >
and operator_id =#{operatorId}
</if>
2022-06-22 10:10:50 +08:00
and operator_id is not null
2021-09-06 16:15:37 +08:00
group by DATE_FORMAT(create_time,'%Y-%m-%d')
order by DATE_FORMAT(create_time,'%Y-%m-%d') desc
2021-09-01 19:21:44 +08:00
</select>
<select id= "getStationIntervalPage" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(ss.charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(ss.charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(ss.activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(ss.activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(ss.activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.act_price),0), 2) actPrice,
format(ifnull(sum(ss.act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(ss.act_service_price),0), 2) actServicePrice,
2022-04-27 11:43:00 +08:00
format(ifnull(sum(ss.act_service_price + ss.act_power_price), 0), 2) actTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(ss.internet_commission),0), 2) internetCommission,
format(ifnull(sum(ss.internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(ss.internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(ss.platform_commission),0), 2) platformCommission,
format(ifnull(sum(ss.platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(ss.operation_commission),0), 2) operationCommission,
format(ifnull(sum(ss.operation_svc_commission),0), 2) operationSvcCommission,
2021-09-01 19:21:44 +08:00
cs.name chargingStationName,
op.name operatorName,
DATE_FORMAT(ss.create_time,'%Y-%m-%d') createTime
from xhpc_statistics_station as ss
left join xhpc_charging_station as cs on cs.charging_station_id = ss.charging_station_id
left join xhpc_operator as op on op.operator_id = ss.operator_id
2022-04-21 16:10:35 +08:00
where ss.del_flag=0 and ss.type=2 and ss.total_price > =0
2021-11-18 11:21:04 +08:00
<if test= "startTime !=null and startTime !=''" >
and ss.create_time > = #{startTime}
</if>
2022-05-09 17:14:58 +08:00
<if test= "chargingStationId !=null" >
and ss.charging_station_id =#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and ss.terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId !=null" >
and ss.terminal_id =#{terminalId}
</if>
2021-11-18 11:21:04 +08:00
<if test= "endTime !=null and endTime !=''" >
and ss.create_time < = #{endTime}
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-09-01 19:21:44 +08:00
</if>
2021-09-06 16:15:37 +08:00
<if test= "chargingStationIds !=null and chargingStationIds.size()>0" >
2021-09-07 10:00:04 +08:00
and ss.charging_station_id in
2021-09-06 16:15:37 +08:00
<foreach collection= "chargingStationIds" open= "(" item= "chargingStationId" separator= "," close= ")" >
#{chargingStationId}
</foreach>
</if>
<if test= "operatorUserId !=null and operatorUserId.size()>0" >
2021-09-07 10:00:04 +08:00
and ss.operator_id in
2021-09-06 16:15:37 +08:00
<foreach collection= "operatorUserId" open= "(" item= "operatorId" separator= "," close= ")" >
#{operatorId}
</foreach>
2021-09-01 19:21:44 +08:00
</if>
2022-06-09 15:46:35 +08:00
<if test= "operatorId !=null" >
and ss.operator_id =#{operatorId}
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and ss.tenant_id = #{tenantId}
</if>
2022-06-22 10:10:50 +08:00
and ss.operator_id is not null
2021-09-01 19:21:44 +08:00
group by ss.charging_station_id
</select>
<select id= "getOperatorIntervalPage" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(ss.charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(ss.charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(ss.activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(ss.activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(ss.activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.act_price),0), 2) actPrice,
format(ifnull(sum(ss.act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(ss.act_service_price),0), 2) actServicePrice,
format(ifnull(sum(ss.act_service_price + ss.act_power_price),0), 2) actTotalPrice,
format(ifnull(sum(ss.promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(ss.internet_commission),0), 2) internetCommission,
format(ifnull(sum(ss.internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(ss.internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(ss.platform_commission),0), 2) platformCommission,
format(ifnull(sum(ss.platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(ss.operation_commission),0), 2) operationCommission,
format(ifnull(sum(ss.operation_svc_commission),0), 2) operationSvcCommission,
2021-09-01 19:21:44 +08:00
op.name operatorName,
DATE_FORMAT(ss.create_time,'%Y-%m-%d') createTime
from xhpc_statistics_station as ss
left join xhpc_operator as op on op.operator_id = ss.operator_id
2022-04-21 16:10:35 +08:00
where ss.del_flag=0 and ss.type=2 and ss.total_price > =0
2021-11-18 11:21:04 +08:00
<if test= "startTime !=null and startTime !=''" >
and ss.create_time > = #{startTime}
</if>
2022-05-09 17:14:58 +08:00
<if test= "chargingStationId !=null" >
and ss.charging_station_id =#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and ss.terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId !=null" >
and ss.terminal_id =#{terminalId}
</if>
2021-11-18 11:21:04 +08:00
<if test= "endTime !=null and endTime !=''" >
and ss.create_time < = #{endTime}
2021-09-01 19:21:44 +08:00
</if>
2021-09-07 10:00:04 +08:00
<if test= "operatorUserId !=null and operatorUserId.size()>0" >
and ss.operator_id in
<foreach collection= "operatorUserId" open= "(" item= "operatorIds" separator= "," close= ")" >
#{operatorIds}
</foreach>
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-11-01 10:52:56 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and ss.tenant_id = #{tenantId}
</if>
2022-06-09 15:46:35 +08:00
<if test= "operatorId !=null" >
2022-06-22 10:10:50 +08:00
and ss.operator_id =#{operatorId}
2022-06-09 15:46:35 +08:00
</if>
2022-06-22 10:10:50 +08:00
and ss.operator_id is not null
2021-09-01 19:21:44 +08:00
group by ss.operator_id
</select>
<select id= "getInternetUserIntervalPage" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(ss.charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(ss.charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(ss.activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(ss.activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(ss.activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.act_price),0), 2) actPrice,
format(ifnull(sum(ss.act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(ss.act_service_price),0), 2) actServicePrice,
format(ifnull(sum(ss.promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(ss.internet_commission),0), 2) internetCommission,
format(ifnull(sum(ss.internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(ss.internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(ss.platform_commission),0), 2) platformCommission,
format(ifnull(sum(ss.platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(ss.operation_commission),0), 2) operationCommission,
format(ifnull(sum(ss.operation_svc_commission),0), 2) operationSvcCommission,
2021-09-01 19:21:44 +08:00
iu.name internetUserName,
DATE_FORMAT(ss.create_time,'%Y-%m-%d') createTime
from xhpc_statistics_station as ss
left join xhpc_internet_user as iu on iu.internet_user_id = ss.internet_user_id
2022-04-21 16:10:35 +08:00
where ss.del_flag=0 and ss.type=2 and ss.internet_user_id is not null and ss.total_price > =0
2021-11-18 11:21:04 +08:00
<if test= "startTime !=null and startTime !=''" >
and ss.create_time > = #{startTime}
</if>
<if test= "endTime !=null and endTime !=''" >
and ss.create_time < = #{endTime}
2021-09-01 19:21:44 +08:00
</if>
2021-09-07 10:00:04 +08:00
<if test= "internetIds !=null and internetIds.size()>0" >
2021-09-09 11:02:28 +08:00
and ss.internet_user_id in
2021-09-07 10:00:04 +08:00
<foreach collection= "internetIds" open= "(" item= "internetId" separator= "," close= ")" >
#{internetId}
</foreach>
2021-09-01 19:21:44 +08:00
</if>
2021-09-07 10:00:04 +08:00
<if test= "type==3" >
and ss.internet_user_id =#{internetUserId}
2021-09-01 19:21:44 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and ss.tenant_id = #{tenantId}
</if>
2022-06-09 15:46:35 +08:00
<if test= "operatorId !=null" >
2022-06-22 10:10:50 +08:00
and ss.operator_id =#{operatorId}
2022-06-09 15:46:35 +08:00
</if>
2022-06-22 10:10:50 +08:00
and ss.operator_id is not null
2021-09-01 19:21:44 +08:00
group by ss.internet_user_id
</select>
<select id= "getTerminalIntervalPage" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(ss.charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(ss.charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(ss.activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(ss.activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(ss.activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.act_price),0), 2) actPrice,
format(ifnull(sum(ss.act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(ss.act_service_price),0), 2) actServicePrice,
format(ifnull(sum(ss.act_service_price + ss.act_power_price),0), 2) actTotalPrice,
format(ifnull(sum(ss.promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(ss.internet_commission),0), 2) internetCommission,
format(ifnull(sum(ss.internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(ss.internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(ss.platform_commission),0), 2) platformCommission,
format(ifnull(sum(ss.platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(ss.operation_commission),0), 2) operationCommission,
format(ifnull(sum(ss.operation_svc_commission),0), 2) operationSvcCommission,
2021-09-01 19:21:44 +08:00
cs.name chargingStationName,
te.name terminalName,
DATE_FORMAT(ss.create_time,'%Y-%m-%d') createTime
from xhpc_statistics_station as ss
left join xhpc_charging_station as cs on cs.charging_station_id = ss.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ss.terminal_id
2022-04-21 16:10:35 +08:00
where ss.del_flag=0 and ss.type=3 and ss.total_price > =0
2021-11-18 11:21:04 +08:00
<if test= "startTime !=null and startTime !=''" >
and ss.create_time > = #{startTime}
</if>
<if test= "endTime !=null and endTime !=''" >
and ss.create_time < = #{endTime}
2021-09-01 19:21:44 +08:00
</if>
2021-11-25 13:26:08 +08:00
<if test= "chargingStationId !=null and chargingStationId !=''" >
2021-09-06 16:15:37 +08:00
and cs.charging_station_id=#{chargingStationId}
2021-09-01 19:21:44 +08:00
</if>
2021-11-25 13:26:08 +08:00
<if test= "terminalId !=null and terminalId !=''" >
2021-09-06 16:15:37 +08:00
and te.terminal_id=#{terminalId}
2021-09-01 19:21:44 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test= "type==2" >
and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-11-01 10:52:56 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and ss.tenant_id = #{tenantId}
</if>
2022-06-09 15:46:35 +08:00
<if test= "operatorId !=null" >
2022-06-22 10:10:50 +08:00
and ss.operator_id =#{operatorId}
2022-06-09 15:46:35 +08:00
</if>
2022-06-22 10:10:50 +08:00
and ss.operator_id is not null
2021-09-01 19:21:44 +08:00
group by ss.terminal_id
</select>
2021-09-06 16:15:37 +08:00
<select id= "getChargingStationList" resultType= "map" >
select
name as stationName,
charging_station_id as chargingStationId
from xhpc_charging_station
2022-05-07 18:22:47 +08:00
where del_flag =0
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
2021-09-06 16:15:37 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
2021-11-01 10:52:56 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2022-05-05 14:12:56 +08:00
<if test= "operatorId !=null" >
and operator_id =#{operatorId}
</if>
2021-09-06 16:15:37 +08:00
</select>
2022-04-21 16:10:35 +08:00
<select id= "getChargingPileList" resultType= "map" >
select
concat(cp.name,"号桩--",cs.name) as chargingPileName,
cp.charging_pile_id as chargingPileId
from xhpc_charging_pile as cp
left join xhpc_charging_station cs on cs.charging_station_id = cp.charging_station_id
2022-05-07 18:22:47 +08:00
where cp.del_flag =0
2022-04-21 16:10:35 +08:00
<if test= "type==1" >
and cp.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test= "type==2" >
and cp.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and cp.tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and cp.charging_station_id = #{chargingStationId}
</if>
order by cp.serial_number asc
</select>
2021-09-06 16:15:37 +08:00
<select id= "getOperatorList" resultType= "map" >
select
operator_id as operatorId,
name as operatorName
from xhpc_operator
2022-05-07 18:22:47 +08:00
where del_flag =0
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and operator_id in (select operator_id from xhpc_charging_station where operator_id=#{userId})
2021-09-06 16:15:37 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and operator_id in (select operator_id from xhpc_charging_station where charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}))
2021-11-01 10:52:56 +08:00
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2021-09-06 16:15:37 +08:00
</select>
2022-05-05 14:12:56 +08:00
<select id= "getTenantList" resultType= "map" >
select
xt.tenant_id as tenantId,
xt.tenant_name as tenantName
2022-05-06 11:38:58 +08:00
from xhpc_operator as xo
join xhpc_tenant as xt on xt.tenant_id = xo.tenant_id
2022-05-07 18:22:47 +08:00
where xt.is_deleted =0 and xo.del_flag =0
2022-05-05 14:12:56 +08:00
<if test= "type==1" >
2022-05-06 11:38:58 +08:00
and xo.operator_id=#{userId}
2022-05-05 14:12:56 +08:00
</if>
<if test= "type==2" >
2022-05-06 11:38:58 +08:00
and xo.operator_id in (select operator_id from xhpc_charging_station where charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId}))
2022-05-05 14:12:56 +08:00
</if>
group by xt.tenant_id
</select>
2021-09-06 16:15:37 +08:00
<select id= "getInternetUserIList" resultType= "map" >
select
internet_user_id as operinternetUserId,
name as operinternetUserName
from xhpc_internet_user
where 1=1
<if test= "type==2" >
and internet_user_id =#{internetUserId}
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2021-09-06 16:15:37 +08:00
</select>
<select id= "getTerminalList" resultType= "map" >
select
terminal_id as terminalId,
name as terminalName
from xhpc_terminal
2022-04-25 09:18:00 +08:00
where del_flag =0
2022-05-07 18:22:47 +08:00
2022-04-25 09:18:00 +08:00
<if test= "chargingStationId!=null" >
and charging_station_id=#{chargingStationId}
</if>
2022-05-07 18:22:47 +08:00
<if test= "chargingPileId!=null" >
and charging_pile_id=#{chargingPileId}
</if>
<if test= "operatorId !=null" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
2021-09-06 16:15:37 +08:00
</if>
2021-11-19 18:24:17 +08:00
<if test= "type==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2021-09-06 16:15:37 +08:00
</select>
2021-09-09 11:02:28 +08:00
2022-02-08 12:30:39 +08:00
<select id= "getMechanismPage" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(power_price),0), 2) powerPrice,
format(ifnull(sum(service_price),0), 2) servicePrice,
format(ifnull(sum(total_price),0), 2) totalPrice,
format(ifnull(sum(act_price),0), 2) actPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(act_service_price),0), 2) actServicePrice,
format(ifnull(sum(act_service_price + act_power_price),0), 2) actTotalPrice,
format(ifnull(sum(promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(internet_commission),0), 2) internetCommission,
format(ifnull(sum(internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(platform_commission),0), 2) platformCommission,
format(ifnull(sum(platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(operation_commission),0) , 2)operationCommission,
format(ifnull(sum(operation_svc_commission),0), 2) operationSvcCommission,
2022-02-08 12:30:39 +08:00
DATE_FORMAT(create_time,'%Y-%m-%d') createTime,
source as source,
CASE
WHEN source = 2 THEN
"社区用户"
WHEN source = 3 THEN
"B端用户"
ELSE
"未知用户"
2022-02-08 18:15:28 +08:00
END sourceName
2022-02-08 12:30:39 +08:00
from xhpc_statistics_station
2022-04-01 11:00:18 +08:00
where del_flag=0 and type=2 and source !=0 and source !=1
2022-02-10 10:33:55 +08:00
<if test= "source !=null and source !=-1" >
2022-02-08 12:30:39 +08:00
and source=#{source}
</if>
<if test= "source ==null" >
and source in (2,3)
</if>
2022-05-09 17:14:58 +08:00
<if test= "operatorId !=null" >
and operator_id =#{operatorId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id =#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId !=null" >
and terminal_id =#{terminalId}
</if>
2022-02-08 12:30:39 +08:00
<if test= "chargingStationIds !=null and chargingStationIds.size()>0" >
and charging_station_id in
<foreach collection= "chargingStationIds" open= "(" item= "chargingStationId" separator= "," close= ")" >
#{chargingStationId}
</foreach>
</if>
<if test= "startTime !=null and startTime !=''" >
and create_time > = #{startTime}
</if>
<if test= "endTime !=null and endTime !=''" >
and create_time < = #{endTime}
</if>
<if test= "type==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test= "type==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2022-06-22 10:10:50 +08:00
and operator_id is not null
2022-02-08 18:15:28 +08:00
group by source
2022-02-08 12:30:39 +08:00
</select>
2021-09-09 11:02:28 +08:00
<insert id= "addStatisticsTime" >
insert into xhpc_statistics_time_interval
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != status " >
status,
</if>
<if test= "null != chargingDegree " >
charging_degree,
</if>
<if test= "null != chargingTime " >
charging_time,
</if>
<if test= "null != chargingNumber " >
charging_number,
</if>
<if test= "null != powerPrice " >
power_price,
</if>
<if test= "null != servicePrice " >
service_price,
</if>
<if test= "null != totalPrice " >
total_price,
</if>
<if test= "null != promotionDiscount " >
promotion_discount,
</if>
<if test= "null != actPrice " >
act_price,
</if>
<if test= "null != actPowerPrice " >
act_power_price,
</if>
<if test= "null != actServicePrice " >
act_service_price,
</if>
<if test= "null != internetCommission " >
internet_commission,
</if>
<if test= "null != internetSvcCommission " >
internet_svc_commission,
</if>
<if test= "null != platformCommission " >
platform_commission,
</if>
<if test= "null != platformSvcCommisssion " >
platform_svc_commisssion,
</if>
<if test= "null != operationCommission " >
operation_commission,
</if>
<if test= "null != operationSvcCommission " >
operation_svc_commission,
</if>
<if test= "null != internetUserId " >
internet_user_id,
</if>
<if test= "null != operatorId " >
operator_id,
</if>
<if test= "null != chargingStationId " >
charging_station_id,
</if>
<if test= "null != delFlag " >
del_flag,
</if>
<if test= "null != createTime " >
create_time,
</if>
<if test= "null != remark " >
remark,
</if>
<if test= "null != terminalId " >
2021-09-10 15:35:39 +08:00
terminal_id,
</if>
<if test= "null != historyOrderId " >
2021-09-27 09:49:43 +08:00
history_order_id,
</if>
<if test= "null != startTimeEvcs " >
start_time_evcs,
</if>
<if test= "null != endTimeEvcs " >
end_time_evcs,
</if>
<if test= "null != elecPriceEvcs " >
elec_price_evcs,
</if>
<if test= "null != servicePriceEvcs " >
2021-12-15 15:14:59 +08:00
service_price_evcs,
</if>
<if test= "null != internetDegreeCommission " >
2022-04-27 11:22:57 +08:00
internet_degree_commission,
</if>
<if test= "null != activityPowerPriceTotal " >
activity_power_price_total,
</if>
<if test= "null != activityServicePriceTotal " >
activity_service_price_total,
</if>
<if test= "null != activityTotalPrice " >
activity_total_price,
2021-09-09 11:02:28 +08:00
</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != status " >
#{status},
</if>
<if test= "null != chargingDegree " >
#{chargingDegree},
</if>
<if test= "null != chargingTime " >
#{chargingTime},
</if>
<if test= "null != chargingNumber " >
#{chargingNumber},
</if>
<if test= "null != powerPrice " >
#{powerPrice},
</if>
<if test= "null != servicePrice " >
#{servicePrice},
</if>
<if test= "null != totalPrice " >
#{totalPrice},
</if>
<if test= "null != promotionDiscount " >
#{promotionDiscount},
</if>
<if test= "null != actPrice " >
#{actPrice},
</if>
<if test= "null != actPowerPrice " >
#{actPowerPrice},
</if>
<if test= "null != actServicePrice " >
#{actServicePrice},
</if>
<if test= "null != internetCommission " >
#{internetCommission},
</if>
<if test= "null != internetSvcCommission " >
#{internetSvcCommission},
</if>
<if test= "null != platformCommission " >
#{platformCommission},
</if>
<if test= "null != platformSvcCommisssion " >
#{platformSvcCommisssion},
</if>
<if test= "null != operationCommission " >
#{operationCommission},
</if>
<if test= "null != operationSvcCommission " >
#{operationSvcCommission},
</if>
<if test= "null != internetUserId " >
#{internetUserId},
</if>
<if test= "null != operatorId " >
#{operatorId},
</if>
<if test= "null != chargingStationId " >
#{chargingStationId},
</if>
<if test= "null != delFlag " >
#{delFlag},
</if>
<if test= "null != createTime " >
#{createTime},
</if>
<if test= "null != remark " >
#{remark},
</if>
<if test= "null != terminalId " >
#{terminalId},
</if>
2021-09-10 15:35:39 +08:00
<if test= "null != historyOrderId " >
2021-09-27 09:49:43 +08:00
#{historyOrderId},
</if>
<if test= "null != startTimeEvcs " >
#{startTimeEvcs},
</if>
<if test= "null != endTimeEvcs " >
#{endTimeEvcs},
</if>
<if test= "null != elecPriceEvcs " >
#{elecPriceEvcs},
</if>
<if test= "null != servicePriceEvcs " >
2021-12-15 15:14:59 +08:00
#{servicePriceEvcs},
</if>
<if test= "null != internetDegreeCommission " >
2022-04-27 11:22:57 +08:00
#{internetDegreeCommission},
</if>
<if test= "null != activityPowerPriceTotal " >
#{activityPowerPriceTotal},
</if>
<if test= "null != activityServicePriceTotal " >
#{activityServicePriceTotal},
</if>
<if test= "null != activityTotalPrice " >
#{activityTotalPrice},
2021-09-09 11:02:28 +08:00
</if>
</trim>
</insert>
2021-09-13 19:09:15 +08:00
<insert id= "addStatisticsStation" >
insert into xhpc_statistics_station
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingDegree " >
charging_degree,
</if>
<if test= "null != chargingTime " >
charging_time,
</if>
<if test= "null != chargingNumber " >
charging_number,
</if>
<if test= "null != powerPrice " >
power_price,
</if>
<if test= "null != servicePrice " >
service_price,
</if>
<if test= "null != totalPrice " >
total_price,
</if>
<if test= "null != promotionDiscount " >
promotion_discount,
</if>
<if test= "null != actPrice " >
act_price,
</if>
<if test= "null != actPowerPrice " >
act_power_price,
</if>
<if test= "null != actServicePrice " >
act_service_price,
</if>
<if test= "null != internetCommission " >
internet_commission,
</if>
<if test= "null != internetSvcCommission " >
internet_svc_commission,
</if>
<if test= "null != platformCommission " >
platform_commission,
</if>
<if test= "null != platformSvcCommisssion " >
platform_svc_commisssion,
</if>
<if test= "null != operationCommission " >
operation_commission,
</if>
<if test= "null != operationSvcCommission " >
operation_svc_commission,
</if>
<if test= "null != internetUserId " >
internet_user_id,
</if>
<if test= "null != operatorId " >
operator_id,
</if>
<if test= "null != chargingPileId " >
charging_pile_id,
</if>
<if test= "null != chargingStationId " >
charging_station_id,
</if>
<if test= "null != delFlag " >
del_flag,
</if>
<if test= "null != createTime " >
create_time,
</if>
<if test= "null != remark " >
remark,
</if>
<if test= "null != terminalId " >
terminal_id,
</if>
<if test= "null != type " >
type,
</if>
<if test= "null != historyOrderId " >
2021-12-01 16:27:30 +08:00
history_order_id,
</if>
<if test= "chargingMode != null" >
charging_mode,
2021-09-13 19:09:15 +08:00
</if>
2021-12-15 15:14:59 +08:00
<if test= "null != internetDegreeCommission " >
2022-02-08 12:30:39 +08:00
internet_degree_commission,
</if>
<if test= "null != source " >
source,
2021-12-15 15:14:59 +08:00
</if>
2022-04-27 11:22:57 +08:00
<if test= "null != activityPowerPriceTotal " >
activity_power_price_total,
</if>
<if test= "null != activityServicePriceTotal " >
activity_service_price_total,
</if>
<if test= "null != activityTotalPrice " >
activity_total_price,
</if>
2021-09-13 19:09:15 +08:00
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "null != chargingDegree " >
#{chargingDegree},
</if>
<if test= "null != chargingTime " >
#{chargingTime},
</if>
<if test= "null != chargingNumber " >
#{chargingNumber},
</if>
<if test= "null != powerPrice " >
#{powerPrice},
</if>
<if test= "null != servicePrice " >
#{servicePrice},
</if>
<if test= "null != totalPrice " >
#{totalPrice},
</if>
<if test= "null != promotionDiscount " >
#{promotionDiscount},
</if>
<if test= "null != actPrice " >
#{actPrice},
</if>
<if test= "null != actPowerPrice " >
#{actPowerPrice},
</if>
<if test= "null != actServicePrice " >
#{actServicePrice},
</if>
<if test= "null != internetCommission " >
#{internetCommission},
</if>
<if test= "null != internetSvcCommission " >
#{internetSvcCommission},
</if>
<if test= "null != platformCommission " >
#{platformCommission},
</if>
<if test= "null != platformSvcCommisssion " >
#{platformSvcCommisssion},
</if>
<if test= "null != operationCommission " >
#{operationCommission},
</if>
<if test= "null != operationSvcCommission " >
#{operationSvcCommission},
</if>
<if test= "null != internetUserId " >
#{internetUserId},
</if>
<if test= "null != operatorId " >
#{operatorId},
</if>
<if test= "null != chargingPileId " >
#{chargingPileId},
</if>
<if test= "null != chargingStationId " >
#{chargingStationId},
</if>
<if test= "null != delFlag " >
#{delFlag},
</if>
<if test= "null != createTime " >
#{createTime},
</if>
<if test= "null != remark " >
#{remark},
</if>
<if test= "null != terminalId " >
#{terminalId},
</if>
<if test= "null != type " >
#{type},
</if>
<if test= "null != historyOrderId " >
2021-12-01 16:27:30 +08:00
#{historyOrderId},
</if>
<if test= "chargingMode != null" >
#{chargingMode},
2021-09-13 19:09:15 +08:00
</if>
2021-12-15 15:14:59 +08:00
<if test= "null != internetDegreeCommission " >
#{internetDegreeCommission},
</if>
2022-02-08 12:30:39 +08:00
<if test= "null != source " >
#{source},
</if>
2022-04-27 11:22:57 +08:00
<if test= "null != activityPowerPriceTotal " >
#{activityPowerPriceTotal},
</if>
<if test= "null != activityServicePriceTotal " >
#{activityServicePriceTotal},
</if>
<if test= "null != activityTotalPrice " >
#{activityTotalPrice},
</if>
2021-09-13 19:09:15 +08:00
</trim>
</insert>
2021-11-30 18:21:02 +08:00
<select id= "getInternetList" resultType= "map" >
SELECT
internet_user_id as id,name
FROM
xhpc_internet_user
WHERE
del_flag = 0
<if test= "userId !=null" >
and internet_user_id=#{userId}
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
2021-11-30 18:21:02 +08:00
</select>
<select id= "getLandUser" resultType= "map" >
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
<select id= "getSumSourceList" resultType= "map" >
select
2022-07-13 14:24:22 +08:00
format(ifnull(sum(ss.charging_degree),0), 4) chargingDegree,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.charging_time),0), 2) chargingTime,
2022-05-05 14:12:56 +08:00
ifnull(sum(ss.charging_number),0) chargingNumber,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.power_price),0), 2) powerPrice,
format(ifnull(sum(ss.service_price),0), 2) servicePrice,
format(ifnull(sum(ss.total_price),0), 2) totalPrice,
2022-04-27 11:22:57 +08:00
format(ifnull(sum(ss.activity_power_price_total),0), 2) activityPowerPriceTotal,
format(ifnull(sum(ss.activity_service_price_total),0), 2) activityServicePriceTotal,
format(ifnull(sum(ss.activity_total_price),0), 2) activityTotalPrice,
2022-04-26 14:29:51 +08:00
format(ifnull(sum(ss.act_price),0), 2) actPrice,
format(ifnull(sum(ss.act_power_price),0), 2) actPowerPrice,
format(ifnull(sum(ss.act_service_price),0), 2) actServicePrice,
format(ifnull(sum(ss.act_service_price + ss.act_power_price),0), 2) actTotalPrice,
format(ifnull(sum(ss.promotion_discount),0), 2) promotionDiscount,
format(ifnull(sum(ss.internet_commission),0), 2) internetCommission,
format(ifnull(sum(ss.internet_svc_commission),0), 2) internetSvcCommission,
format(ifnull(sum(ss.internet_degree_commission),0), 2) internetDegreeCommission,
format(ifnull(sum(ss.platform_commission),0), 2) platformCommission,
format(ifnull(sum(ss.platform_svc_commisssion),0), 2) platformSvcCommisssion,
format(ifnull(sum(ss.operation_commission),0), 2) operationCommission,
format(ifnull(sum(ss.operation_svc_commission),0), 2) operationSvcCommission,
2022-04-01 11:00:18 +08:00
IF(iu.name IS NULL,ss.charging_mode, iu.name) as internetUserName,
2021-11-30 18:21:02 +08:00
DATE_FORMAT(ss.create_time,'%Y-%m-%d') createTime
from xhpc_statistics_station as ss
left join xhpc_internet_user as iu on iu.internet_user_id = ss.charging_mode
where ss.del_flag=0 and ss.type=2
<if test= "startTime !=null and startTime !=''" >
2022-05-13 09:54:53 +08:00
and ss.create_time > = #{startTime}
2021-11-30 18:21:02 +08:00
</if>
<if test= "endTime !=null and endTime !=''" >
and ss.create_time < = #{endTime}
</if>
2022-05-09 17:14:58 +08:00
<if test= "operatorId !=null" >
and ss.operator_id =#{operatorId}
</if>
<if test= "chargingStationId !=null" >
and ss.charging_station_id =#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and ss.terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId} and del_flag =0)
</if>
<if test= "terminalId !=null" >
and ss.terminal_id =#{terminalId}
</if>
2021-11-30 18:21:02 +08:00
<if test= "sourceIds !=null and sourceIds.size()>0" >
and ss.charging_mode in
<foreach collection= "sourceIds" open= "(" item= "sourceId" separator= "," close= ")" >
#{sourceId}
</foreach>
</if>
2021-12-15 15:14:59 +08:00
<if test= "chargingStationIdList !=null and chargingStationIdList.size()>0" >
and ss.charging_station_id in
<foreach collection= "chargingStationIdList" open= "(" item= "chargingStationId" separator= "," close= ")" >
#{chargingStationId}
</foreach>
</if>
2022-01-12 16:24:45 +08:00
<if test= "tenantId !=null and tenantId !=''" >
and ss.tenant_id = #{tenantId}
</if>
2022-04-21 16:10:35 +08:00
<if test= "number==1" >
2022-04-28 11:14:43 +08:00
and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{sysUserId})
2022-04-21 16:10:35 +08:00
</if>
<if test= "number==2" >
2022-04-28 11:14:43 +08:00
and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{sysUserId})
2022-04-21 16:10:35 +08:00
</if>
2022-06-22 10:10:50 +08:00
and ss.operator_id is not null
2022-04-12 09:46:31 +08:00
and ss.charging_mode is not null
2021-11-30 18:21:02 +08:00
group by ss.charging_mode
</select>
2022-03-08 10:40:04 +08:00
<select id= "getStatisticsTimeHistoryOrderId" resultType= "int" >
select count(statistics_time_interval_id) from xhpc_statistics_time_interval where history_order_id=#{historyOrderId}
</select>
<select id= "getStatisticsStationHistoryOrderId" resultType= "int" >
select count(statistics_station_id) from xhpc_statistics_station where history_order_id=#{historyOrderId} and type=#{type}
</select>
2022-03-10 15:49:07 +08:00
2022-04-21 16:10:35 +08:00
<select id= "getTodayStatusNumber" resultType= "map" >
2022-03-17 12:03:41 +08:00
SELECT
2022-03-22 10:57:37 +08:00
COUNT(status) value,
case when status=-1 then "无效订单"
when status=0 then "充电中订单"
when status=1 then "自动结算订单"
when status=2 then "异常订单"
when status=3 then "平台结算订单"
else "其他订单"
end name
2022-03-17 12:03:41 +08:00
FROM
xhpc_charge_order
WHERE
create_time > =#{beginOfDay} and create_time < = #{endOfDay}
<if test= "operatorId !=null" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
group by status
</select>
2022-03-10 15:49:07 +08:00
2022-04-21 16:10:35 +08:00
<select id= "getTodayOrderNumber" resultType= "int" >
SELECT
COUNT(charge_order_id) number
FROM
xhpc_charge_order
WHERE
create_time > =#{beginOfDay} and create_time < = #{endOfDay}
<if test= "operatorId !=null" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
</select>
2022-03-17 12:03:41 +08:00
<select id= "getTodayNUmber" resultType= "int" >
SELECT
2022-03-22 10:57:37 +08:00
COUNT(charge_order_id) number
2022-03-17 12:03:41 +08:00
FROM
xhpc_charge_order
WHERE
create_time > =#{beginOfDay} and create_time < = #{endOfDay}
<if test= "operatorId !=null" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
2022-03-10 15:49:07 +08:00
</select>
2022-03-17 12:03:41 +08:00
<select id= "getTodayDegreeNUmber" resultType= "int" >
SELECT
2022-04-21 16:10:35 +08:00
IFNULL(sum(total_power),0) number
2022-03-17 12:03:41 +08:00
FROM
2022-03-22 10:57:37 +08:00
xhpc_history_order
2022-03-17 12:03:41 +08:00
WHERE
2022-03-22 10:57:37 +08:00
end_time > =#{beginOfDay} and end_time < = #{endOfDay}
<if test= "operatorId !=null and operatorId !=''" >
2022-03-17 12:03:41 +08:00
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
</select>
<select id= "getTodayAmount" resultType= "double" >
SELECT
2022-03-22 10:57:37 +08:00
IFNULL(sum(total_price),0) number
2022-03-17 12:03:41 +08:00
FROM
2022-03-22 10:57:37 +08:00
xhpc_history_order
2022-03-17 12:03:41 +08:00
WHERE
2022-03-22 10:57:37 +08:00
end_time > =#{beginOfDay} and end_time < = #{endOfDay}
<if test= "operatorId !=null and ''!=operatorId" >
2022-03-17 12:03:41 +08:00
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
</select>
2022-03-22 10:57:37 +08:00
<select id= "getTerminal" resultType= "String" >
select serial_number as serialNumber
from xhpc_terminal
where del_flag = 0
<if test= "operatorId !=null and ''!=operatorId" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
and charging_pile_id=#{chargingPileId}
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
</select>
2022-03-22 15:15:37 +08:00
<select id= "getDateOrder" resultType= "map" >
select
2022-04-26 14:29:51 +08:00
ifnull(sum(total_power),0) totalPower,
ifnull(sum(total_price),0) totalPrice,
ifnull(sum(power_price_total),0) powerPriceTotal,
ifnull(sum(service_price_total),0)servicePriceTotal,
2022-07-27 16:30:38 +08:00
-- format(ifnull(sum(total_power),0)/ifnull(count(history_order_id),0),3) averageOrderPower,
2022-07-27 11:00:23 +08:00
<if test= "type!=null and type ==4" >
date_format(end_time, '%Y-%m') time
</if>
<if test= "type !=4" >
DATE_FORMAT(end_time, '%Y-%m-%d') time
</if>
2022-03-22 15:15:37 +08:00
from xhpc_history_order
where end_time > =#{beginOfDay} and end_time < = #{endOfDay}
<if test= "operatorId !=null and ''!=operatorId" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
2022-04-21 16:10:35 +08:00
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
2022-03-22 15:15:37 +08:00
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
GROUP BY time
order by end_time
</select>
<select id= "getDateOrderNUmber" resultType= "int" >
select
2022-04-21 16:10:35 +08:00
IFNULL(sum(total_power),0) totalPower
2022-03-22 15:15:37 +08:00
from xhpc_history_order
where end_time > =#{beginOfDay} and end_time < = #{endOfDay}
<if test= "operatorId !=null and ''!=operatorId" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
2022-04-21 16:10:35 +08:00
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
2022-03-22 15:15:37 +08:00
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
</select>
<select id= "getDateOrderCount" resultType= "map" >
select
count(history_order_id) number,
2022-07-27 16:30:38 +08:00
2022-03-22 15:15:37 +08:00
<if test= "type!=null and type ==4" >
date_format(end_time, '%Y-%m') time
</if>
<if test= "type !=4" >
DATE_FORMAT(end_time, '%Y-%m-%d') time
</if>
from xhpc_history_order
where end_time > =#{beginOfDay} and end_time < = #{endOfDay}
<if test= "operatorId !=null and ''!=operatorId" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
2022-04-21 16:10:35 +08:00
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
2022-03-22 15:15:37 +08:00
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
GROUP BY time
order by end_time
</select>
<select id= "getDateOrderCountNUmber" resultType= "int" >
select
count(history_order_id) number
from xhpc_history_order
where end_time > =#{beginOfDay} and end_time < = #{endOfDay}
<if test= "operatorId !=null and ''!=operatorId" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{operatorId})
</if>
<if test= "tenantId !=null and tenantId !=''" >
and tenant_id = #{tenantId}
</if>
<if test= "chargingStationId !=null" >
and charging_station_id=#{chargingStationId}
</if>
<if test= "chargingPileId !=null" >
2022-04-21 16:10:35 +08:00
and terminal_id in (select terminal_id from xhpc_terminal where charging_pile_id=#{chargingPileId})
2022-03-22 15:15:37 +08:00
</if>
<if test= "status==1" >
and charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
</select>
2022-09-06 16:27:06 +08:00
<select id= "getChargingStationEmptyOrder" resultType= "map" >
SELECT
COUNT(xh.history_order_id) totalOrder,
xcs.`name` name,
IFNULL(ut.empty,0) emptyorder,
concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),"%") orders
FROM `xhpc_history_order` as xh
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id =xh.charging_station_id
LEFT join (SELECT COUNT(xh.history_order_id) empty,xh.charging_station_id
FROM `xhpc_history_order` as xh
where xh.end_time > =#{beginOfDay} and xh.end_time < = #{endOfDay}
and xh.total_price=0
and xh.stop_reason_evcs !='40'
and xh.stop_reason_evcs !='41'
and xh.stop_reason_evcs !='6E'
and xh.tenant_id =#{tenantId}
<if test= "status==1" >
and xh.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and xh.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
GROUP BY xh.charging_station_id)ut on ut.charging_station_id = xh.charging_station_id
where xh.end_time > =#{beginOfDay} and xh.end_time < = #{endOfDay}
and xh.tenant_id =#{tenantId}
and xh.total_price is not null
<if test= "status==1" >
and xh.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and xh.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
GROUP BY xh.charging_station_id
</select>
<select id= "getTerminalEmptyOrder" resultType= "map" >
SELECT
COUNT(xh.history_order_id) totalOrder,
xt.`name` name,
IFNULL(ut.empty,0) emptyorder,
concat(format(ifnull(empty/COUNT(xh.history_order_id)*100,0), 2),"%") orders
FROM `xhpc_history_order` as xh
LEFT JOIN xhpc_charging_station xcs on xcs.charging_station_id =xh.charging_station_id
LEFT JOIN xhpc_terminal xt on xt.terminal_id =xh.terminal_id
LEFT join (SELECT COUNT(xh.history_order_id) empty,xh.terminal_id
FROM `xhpc_history_order` as xh
where xh.end_time > =#{beginOfDay} and xh.end_time < = #{endOfDay}
and xh.total_price=0
and xh.stop_reason_evcs !='40'
and xh.stop_reason_evcs !='41'
and xh.stop_reason_evcs !='6E'
and xh.charging_station_id =#{chargingStationId}
<if test= "status==1" >
and xh.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and xh.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
GROUP BY xh.terminal_id)ut on ut.terminal_id = xh.terminal_id
where xh.end_time > =#{beginOfDay} and xh.end_time < = #{endOfDay}
and xh.total_price is not null
and xh.charging_station_id =#{chargingStationId}
<if test= "status==1" >
and xh.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{logOperatorId})
</if>
<if test= "status==2" >
and xh.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{logOperatorId})
</if>
GROUP BY xh.terminal_id
</select>
2021-09-01 19:21:44 +08:00
</mapper>