284 lines
13 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_pile_id" property="chargingPileId"/>
<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-01 19:21:44 +08:00
</resultMap>
<select id="getTimeIntervalPage" resultType="map">
select
sum(charging_degree) chargingDegree,
sum(charging_time) chargingTime,
sum(charging_number) chargingNumber,
sum(power_price) powerPrice,
sum(service_price) servicePrice,
sum(total_price) totalPrice,
sum(promotion_discount) promotionDiscount,
sum(internet_commission) internetCommission,
sum(internet_svc_commission) internetSvcCommission,
sum(platform_commission) platformCommission,
sum(platform_svc_commisssion) platformSvcCommisssion,
sum(operation_commission) operationCommission,
sum(operation_svc_commission) operationSvcCommission,
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
<if test="chargingPileIds !=null and chargingPileIds.size()>0">
and charging_pile_id in
<foreach collection="chargingPileIds" open="(" item="chargingPileId" separator="," close=")" >
#{chargingPileId}
</foreach>
</if>
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
and #{startTime} &lt;=create_time
and create_time &lt;=#{endTime}
</if>
<if test="type==2">
and operator_id=#{operatorId}
</if>
<if test="type==3">
and internet_user_id=#{internetUserId}
</if>
group by status
order by status
</select>
<select id="getDateIntervalPage" resultType="map">
select
sum(charging_degree) chargingDegree,
sum(charging_time) chargingTime,
sum(charging_number) chargingNumber,
sum(power_price) powerPrice,
sum(service_price) servicePrice,
sum(total_price) totalPrice,
sum(promotion_discount) promotionDiscount,
sum(internet_commission) internetCommission,
sum(internet_svc_commission) internetSvcCommission,
sum(platform_commission) platformCommission,
sum(platform_svc_commisssion) platformSvcCommisssion,
sum(operation_commission) operationCommission,
sum(operation_svc_commission) operationSvcCommission,
DATE_FORMAT(create_time,'%Y-%m-%d') createTime
2021-09-02 11:18:14 +08:00
from xhpc_statistics_station
2021-09-01 19:21:44 +08:00
where del_flag=0 and type=1
<if test="chargingPileIds !=null and chargingPileIds.size()>0">
and charging_pile_id in
<foreach collection="chargingPileIds" open="(" item="chargingPileId" separator="," close=")" >
#{chargingPileId}
</foreach>
</if>
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
and #{startTime} &lt;=create_time
and create_time &lt;=#{endTime}
</if>
<if test="type==2">
and operator_id=#{operatorId}
</if>
<if test="type==3">
and internet_user_id=#{internetUserId}
</if>
group by create_time
order by create_time desc
</select>
<select id="getStationIntervalPage" resultType="map">
select
sum(ss.charging_degree) chargingDegree,
sum(ss.charging_time) chargingTime,
sum(ss.charging_number) chargingNumber,
sum(ss.power_price) powerPrice,
sum(ss.service_price) servicePrice,
sum(ss.total_price) totalPrice,
sum(ss.promotion_discount) promotionDiscount,
sum(ss.internet_commission) internetCommission,
sum(ss.internet_svc_commission) internetSvcCommission,
sum(ss.platform_commission) platformCommission,
sum(ss.platform_svc_commisssion) platformSvcCommisssion,
sum(ss.operation_commission) operationCommission,
sum(ss.operation_svc_commission) operationSvcCommission,
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
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
and #{startTime} &lt;=ss.create_time
and ss.create_time &lt;=#{endTime}
</if>
<if test="type==2">
and ss.operator_id=#{operatorId}
</if>
<if test="type==3">
and ss.internet_user_id=#{internetUserId}
</if>
<if test="stationName !=null and stationName !=''">
and cs.name like concat('%', #{stationName}, '%')
</if>
<if test="operatorName !=null and operatorName !=''">
and op.name like concat('%', #{operatorName}, '%')
</if>
group by ss.charging_station_id
</select>
<select id="getOperatorIntervalPage" resultType="map">
select
sum(ss.charging_degree) chargingDegree,
sum(ss.charging_time) chargingTime,
sum(ss.charging_number) chargingNumber,
sum(ss.power_price) powerPrice,
sum(ss.service_price) servicePrice,
sum(ss.total_price) totalPrice,
sum(ss.promotion_discount) promotionDiscount,
sum(ss.internet_commission) internetCommission,
sum(ss.internet_svc_commission) internetSvcCommission,
sum(ss.platform_commission) platformCommission,
sum(ss.platform_svc_commisssion) platformSvcCommisssion,
sum(ss.operation_commission) operationCommission,
sum(ss.operation_svc_commission) operationSvcCommission,
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
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
and #{startTime} &lt;=ss.create_time
and ss.create_time &lt;=#{endTime}
</if>
<if test="type==2">
and ss.operator_id=#{operatorId}
</if>
<if test="type==3">
and ss.internet_user_id=#{internetUserId}
</if>
<if test="operatorName !=null and operatorName !=''">
and op.name like concat('%', #{operatorName}, '%')
</if>
group by ss.operator_id
</select>
<select id="getInternetUserIntervalPage" resultType="map">
select
sum(ss.charging_degree) chargingDegree,
sum(ss.charging_time) chargingTime,
sum(ss.charging_number) chargingNumber,
sum(ss.power_price) powerPrice,
sum(ss.service_price) servicePrice,
sum(ss.total_price) totalPrice,
sum(ss.promotion_discount) promotionDiscount,
sum(ss.internet_commission) internetCommission,
sum(ss.internet_svc_commission) internetSvcCommission,
sum(ss.platform_commission) platformCommission,
sum(ss.platform_svc_commisssion) platformSvcCommisssion,
sum(ss.operation_commission) operationCommission,
sum(ss.operation_svc_commission) operationSvcCommission,
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
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
and #{startTime} &lt;=ss.create_time
and ss.create_time &lt;=#{endTime}
</if>
<if test="type==3">
and ss.internet_user_id=#{internetUserId}
</if>
<if test="internetUserName !=null and internetUserName !=''">
and iu.name like concat('%', #{internetUserName}, '%')
</if>
group by ss.internet_user_id
</select>
<select id="getTerminalIntervalPage" resultType="map">
select
sum(ss.charging_degree) chargingDegree,
sum(ss.charging_time) chargingTime,
sum(ss.charging_number) chargingNumber,
sum(ss.power_price) powerPrice,
sum(ss.service_price) servicePrice,
sum(ss.total_price) totalPrice,
sum(ss.promotion_discount) promotionDiscount,
sum(ss.internet_commission) internetCommission,
sum(ss.internet_svc_commission) internetSvcCommission,
sum(ss.platform_commission) platformCommission,
sum(ss.platform_svc_commisssion) platformSvcCommisssion,
sum(ss.operation_commission) operationCommission,
sum(ss.operation_svc_commission) operationSvcCommission,
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
<if test="startTime !=null and startTime !='' and endTime !=null and endTime !=''">
and #{startTime} &lt;=ss.create_time
and ss.create_time &lt;=#{endTime}
</if>
<if test="type==2">
and ss.operator_id=#{operatorId}
</if>
<if test="chargingStationName !=null and chargingStationName !=''">
and cs.name like concat('%', #{chargingStationName}, '%')
</if>
<if test="terminalName !=null and terminalName !=''">
and te.name like concat('%', #{terminalName}, '%')
</if>
group by ss.terminal_id
</select>
</mapper>