1255 lines
52 KiB
XML
Raw Normal View History

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"/>
<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-01 11:00:18 +08:00
format(sum(act_price), 2) actPrice,
format(sum(act_power_price), 2) actPowerPrice,
format(sum(act_service_price), 2) actServicePrice,
format(sum(act_service_price + act_power_price), 2) actTotalPrice,
2022-04-01 11:00:18 +08:00
format(sum(charging_degree), 2) chargingDegree,
format(sum(charging_time), 2) chargingTime,
format(sum(charging_number), 2) chargingNumber,
format(sum(power_price), 2) powerPrice,
format(sum(service_price), 2) servicePrice,
format(sum(total_price), 2) totalPrice,
format(sum(promotion_discount), 2) promotionDiscount,
format(sum(internet_commission), 2) internetCommission,
format(sum(internet_svc_commission), 2) internetSvcCommission,
format(sum(internet_degree_commission), 2) internetDegreeCommission,
format(sum(platform_commission), 2) platformCommission,
format(sum(platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(operation_commission), 2) operationCommission,
format(sum(operation_svc_commission), 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
where del_flag=0 and total_price &gt;=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>
<if test="startTime !=null and startTime !=''">
and create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and create_time &lt;= #{endTime}
2021-09-01 19:21:44 +08:00
</if>
<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>
<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-01 19:21:44 +08:00
group by status
order by status
</select>
<select id="getDateIntervalPage" resultType="map">
select
2022-04-01 11:00:18 +08:00
format(sum(charging_degree), 2) chargingDegree,
format(sum(charging_time), 2) chargingTime,
format(sum(charging_number), 2) chargingNumber,
format(sum(power_price), 2) powerPrice,
format(sum(service_price), 2) servicePrice,
format(sum(total_price), 2) totalPrice,
format(sum(act_price), 2) actPrice,
format(sum(act_power_price), 2) actPowerPrice,
format(sum(act_service_price), 2) actServicePrice,
format(sum(promotion_discount), 2) promotionDiscount,
format(sum(internet_commission), 2) internetCommission,
format(sum(internet_svc_commission), 2) internetSvcCommission,
format(sum(internet_degree_commission), 2) internetDegreeCommission,
format(sum(platform_commission), 2) platformCommission,
format(sum(platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(operation_commission), 2) operationCommission,
format(sum(operation_svc_commission), 2) operationSvcCommission,
format(sum(act_power_price + act_service_price), 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
where del_flag=0 and type=1 and total_price &gt;=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>
<if test="startTime !=null and startTime !=''">
and create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and create_time &lt;= #{endTime}
2021-09-01 19:21:44 +08:00
</if>
<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>
<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})
</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
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-04-01 11:00:18 +08:00
format(sum(ss.charging_degree), 2) chargingDegree,
format(sum(ss.charging_time), 2) chargingTime,
format(sum(ss.charging_number), 2) chargingNumber,
format(sum(ss.power_price), 2) powerPrice,
format(sum(ss.service_price), 2) servicePrice,
format(sum(ss.total_price), 2) totalPrice,
format(sum(ss.act_price), 2) actPrice,
format(sum(ss.act_power_price), 2) actPowerPrice,
format(sum(ss.act_service_price), 2) actServicePrice,
format(sum(ss.act_service_price + ss.act_power_price), 2) actTotalPrice,
2022-04-01 11:00:18 +08:00
format(sum(ss.promotion_discount), 2) promotionDiscount,
format(sum(ss.internet_commission), 2) internetCommission,
format(sum(ss.internet_svc_commission), 2) internetSvcCommission,
format(sum(ss.internet_degree_commission), 2) internetDegreeCommission,
format(sum(ss.platform_commission), 2) platformCommission,
format(sum(ss.platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(ss.operation_commission), 2) operationCommission,
format(sum(ss.operation_svc_commission), 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
where ss.del_flag=0 and ss.type=2 and ss.total_price &gt;=0
<if test="startTime !=null and startTime !=''">
and ss.create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{endTime}
2021-09-01 19:21:44 +08:00
</if>
<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>
<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">
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">
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-01-12 16:24:45 +08:00
<if test="tenantId !=null and tenantId !=''">
and ss.tenant_id = #{tenantId}
</if>
2021-09-01 19:21:44 +08:00
group by ss.charging_station_id
</select>
<select id="getOperatorIntervalPage" resultType="map">
select
2022-04-01 11:00:18 +08:00
format(sum(ss.charging_degree), 2) chargingDegree,
format(sum(ss.charging_time), 2) chargingTime,
format(sum(ss.charging_number), 2) chargingNumber,
format(sum(ss.power_price), 2) powerPrice,
format(sum(ss.service_price), 2) servicePrice,
format(sum(ss.total_price), 2) totalPrice,
format(sum(ss.act_price), 2) actPrice,
format(sum(ss.act_power_price), 2) actPowerPrice,
format(sum(ss.act_service_price), 2) actServicePrice,
format(sum(ss.act_service_price + ss.act_power_price), 2) actTotalPrice,
2022-04-01 11:00:18 +08:00
format(sum(ss.promotion_discount), 2) promotionDiscount,
format(sum(ss.internet_commission), 2) internetCommission,
format(sum(ss.internet_svc_commission), 2) internetSvcCommission,
format(sum(ss.internet_degree_commission), 2) internetDegreeCommission,
format(sum(ss.platform_commission), 2) platformCommission,
format(sum(ss.platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(ss.operation_commission), 2) operationCommission,
format(sum(ss.operation_svc_commission), 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
where ss.del_flag=0 and ss.type=2 and ss.total_price &gt;=0
<if test="startTime !=null and startTime !=''">
and ss.create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{endTime}
2021-09-01 19:21:44 +08:00
</if>
<if test="operatorUserId !=null and operatorUserId.size()>0">
and ss.operator_id in
<foreach collection="operatorUserId" open="(" item="operatorIds" separator="," close=")" >
#{operatorIds}
</foreach>
</if>
<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>
<if test="type==2">
and ss.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 ss.tenant_id = #{tenantId}
</if>
2021-09-01 19:21:44 +08:00
group by ss.operator_id
</select>
<select id="getInternetUserIntervalPage" resultType="map">
select
2022-04-01 11:00:18 +08:00
format(sum(ss.charging_degree), 2) chargingDegree,
format(sum(ss.charging_time), 2) chargingTime,
format(sum(ss.charging_number), 2) chargingNumber,
format(sum(ss.power_price), 2) powerPrice,
format(sum(ss.service_price), 2) servicePrice,
format(sum(ss.total_price), 2) totalPrice,
format(sum(ss.act_price), 2) actPrice,
format(sum(ss.act_power_price), 2) actPowerPrice,
format(sum(ss.act_service_price), 2) actServicePrice,
format(sum(ss.promotion_discount), 2) promotionDiscount,
format(sum(ss.internet_commission), 2) internetCommission,
format(sum(ss.internet_svc_commission), 2) internetSvcCommission,
format(sum(ss.internet_degree_commission), 2) internetDegreeCommission,
format(sum(ss.platform_commission), 2) platformCommission,
format(sum(ss.platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(ss.operation_commission), 2) operationCommission,
format(sum(ss.operation_svc_commission), 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
where ss.del_flag=0 and ss.type=2 and ss.internet_user_id is not null and ss.total_price &gt;=0
<if test="startTime !=null and startTime !=''">
and ss.create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{endTime}
2021-09-01 19:21:44 +08:00
</if>
<if test="internetIds !=null and internetIds.size()>0">
and ss.internet_user_id in
<foreach collection="internetIds" open="(" item="internetId" separator="," close=")" >
#{internetId}
</foreach>
2021-09-01 19:21:44 +08:00
</if>
<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>
2021-09-01 19:21:44 +08:00
group by ss.internet_user_id
</select>
<select id="getTerminalIntervalPage" resultType="map">
select
2022-04-01 11:00:18 +08:00
format(sum(ss.charging_degree), 2) chargingDegree,
format(sum(ss.charging_time), 2) chargingTime,
format(sum(ss.charging_number), 2) chargingNumber,
format(sum(ss.power_price), 2) powerPrice,
format(sum(ss.service_price), 2) servicePrice,
format(sum(ss.total_price), 2) totalPrice,
format(sum(ss.act_price), 2) actPrice,
format(sum(ss.act_power_price), 2) actPowerPrice,
format(sum(ss.act_service_price), 2) actServicePrice,
format(sum(ss.act_service_price + ss.act_power_price), 2) actTotalPrice,
2022-04-01 11:00:18 +08:00
format(sum(ss.promotion_discount), 2) promotionDiscount,
format(sum(ss.internet_commission), 2) internetCommission,
format(sum(ss.internet_svc_commission), 2) internetSvcCommission,
format(sum(ss.internet_degree_commission), 2) internetDegreeCommission,
format(sum(ss.platform_commission), 2) platformCommission,
format(sum(ss.platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(ss.operation_commission), 2) operationCommission,
format(sum(ss.operation_svc_commission), 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
where ss.del_flag=0 and ss.type=3 and ss.total_price &gt;=0
<if test="startTime !=null and startTime !=''">
and ss.create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{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>
<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})
</if>
2022-01-12 16:24:45 +08:00
<if test="tenantId !=null and tenantId !=''">
and ss.tenant_id = #{tenantId}
</if>
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
where 1=1
<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>
<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>
<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
where 1=1
<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
where 1=1
<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>
<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}))
</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="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
where del_flag =0
<if test="chargingStationId!=null">
and charging_station_id=#{chargingStationId}
</if>
<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>
<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>
<select id="getMechanismPage" resultType="map">
select
2022-04-01 11:00:18 +08:00
format(sum(charging_degree), 2) chargingDegree,
format(sum(charging_time), 2) chargingTime,
format(sum(charging_number), 2) chargingNumber,
format(sum(power_price), 2) powerPrice,
format(sum(service_price), 2) servicePrice,
format(sum(total_price), 2) totalPrice,
format(sum(act_price), 2) actPrice,
format(sum(act_power_price), 2) actPowerPrice,
format(sum(act_service_price), 2) actServicePrice,
format(sum(act_service_price + act_power_price), 2) actTotalPrice,
2022-04-01 11:00:18 +08:00
format(sum(promotion_discount), 2) promotionDiscount,
format(sum(internet_commission), 2) internetCommission,
format(sum(internet_svc_commission), 2) internetSvcCommission,
format(sum(internet_degree_commission), 2) internetDegreeCommission,
format(sum(platform_commission), 2) platformCommission,
format(sum(platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(operation_commission) , 2)operationCommission,
format(sum(operation_svc_commission), 2) operationSvcCommission,
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
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
<if test="source !=null and source !=-1">
and source=#{source}
</if>
<if test="source ==null">
and source in (2,3)
</if>
<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 &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and create_time &lt;= #{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-02-08 18:15:28 +08:00
group by source
</select>
<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 ">
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 ">
internet_degree_commission
</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>
<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 ">
#{internetDegreeCommission}
</if>
</trim>
</insert>
<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 ">
history_order_id,
</if>
<if test="chargingMode != null">
charging_mode,
</if>
2021-12-15 15:14:59 +08:00
<if test="null != internetDegreeCommission ">
internet_degree_commission,
</if>
<if test="null != source ">
source,
2021-12-15 15:14:59 +08:00
</if>
</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 ">
#{historyOrderId},
</if>
<if test="chargingMode != null">
#{chargingMode},
</if>
2021-12-15 15:14:59 +08:00
<if test="null != internetDegreeCommission ">
#{internetDegreeCommission},
</if>
<if test="null != source ">
#{source},
</if>
</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-04-01 11:00:18 +08:00
format(sum(ss.charging_degree), 2) chargingDegree,
format(sum(ss.charging_time), 2) chargingTime,
format(sum(ss.charging_number), 2) chargingNumber,
format(sum(ss.power_price), 2) powerPrice,
format(sum(ss.service_price), 2) servicePrice,
format(sum(ss.total_price), 2) totalPrice,
format(sum(ss.act_price), 2) actPrice,
format(sum(ss.act_power_price), 2) actPowerPrice,
format(sum(ss.act_service_price), 2) actServicePrice,
format(sum(ss.act_service_price + ss.act_power_price), 2) actTotalPrice,
2022-04-01 11:00:18 +08:00
format(sum(ss.promotion_discount), 2) promotionDiscount,
format(sum(ss.internet_commission), 2) internetCommission,
format(sum(ss.internet_svc_commission), 2) internetSvcCommission,
format(sum(ss.internet_degree_commission), 2) internetDegreeCommission,
format(sum(ss.platform_commission), 2) platformCommission,
format(sum(ss.platform_svc_commisssion), 2) platformSvcCommisssion,
format(sum(ss.operation_commission), 2) operationCommission,
format(sum(ss.operation_svc_commission), 2) operationSvcCommission,
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 !=''">
and ss.create_time &gt;= #{startTime}
</if>
<if test="endTime !=null and endTime !=''">
and ss.create_time &lt;= #{endTime}
</if>
<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>
<if test="number==1">
and ss.charging_station_id in (select charging_station_id from xhpc_charging_station where operator_id=#{userId})
</if>
<if test="number==2">
and ss.charging_station_id in (select charging_station_id from xhpc_user_privilege where user_id=#{userId})
</if>
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
<select id="getTodayStatusNumber" resultType="map">
2022-03-17 12:03:41 +08:00
SELECT
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 &gt;=#{beginOfDay} and create_time &lt;= #{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
<select id="getTodayOrderNumber" resultType="int">
SELECT
COUNT(charge_order_id) number
FROM
xhpc_charge_order
WHERE
create_time &gt;=#{beginOfDay} and create_time &lt;= #{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
COUNT(charge_order_id) number
2022-03-17 12:03:41 +08:00
FROM
xhpc_charge_order
WHERE
create_time &gt;=#{beginOfDay} and create_time &lt;= #{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
IFNULL(sum(total_power),0) number
2022-03-17 12:03:41 +08:00
FROM
xhpc_history_order
2022-03-17 12:03:41 +08:00
WHERE
end_time &gt;=#{beginOfDay} and end_time &lt;= #{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
IFNULL(sum(total_price),0) number
2022-03-17 12:03:41 +08:00
FROM
xhpc_history_order
2022-03-17 12:03:41 +08:00
WHERE
end_time &gt;=#{beginOfDay} and end_time &lt;= #{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="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
sum(total_power) totalPower,
sum(total_price) totalPrice,
sum(power_price_total) powerPriceTotal,
sum(service_price_total) servicePriceTotal,
<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 &gt;=#{beginOfDay} and end_time &lt;= #{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">
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
IFNULL(sum(total_power),0) totalPower
2022-03-22 15:15:37 +08:00
from xhpc_history_order
where end_time &gt;=#{beginOfDay} and end_time &lt;= #{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">
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,
<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 &gt;=#{beginOfDay} and end_time &lt;= #{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">
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 &gt;=#{beginOfDay} and end_time &lt;= #{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">
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>
2021-09-01 19:21:44 +08:00
</mapper>