<?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.ruoyi.chargingPile.mapper.TParkingRecordMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.chargingPile.api.model.TParkingRecord">
|
<id column="id" property="id" />
|
<result column="app_user_id" property="appUserId" />
|
<result column="license_plate" property="licensePlate" />
|
<result column="vehicle_color" property="vehicleColor" />
|
<result column="charging_order_id" property="chargingOrderId" />
|
<result column="parking_lot_id" property="parkingLotId" />
|
<result column="in_parking_time" property="inParkingTime" />
|
<result column="out_parking_time" property="outParkingTime" />
|
<result column="parking_duration" property="parkingDuration" />
|
<result column="order_amount" property="orderAmount" />
|
<result column="status" property="status" />
|
<result column="out_parking_type" property="outParkingType" />
|
<result column="create_time" property="createTime" />
|
<result column="code" property="code" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, app_user_id, license_plate, vehicle_color, charging_order_id, parking_lot_id, in_parking_time, out_parking_time, parking_duration, order_amount, status, out_parking_type, create_time
|
</sql>
|
<select id="getSum" resultType="java.math.BigDecimal">
|
select sum(timeout_amount) from t_parking_record where in_parking_time >= #{sixBefore}
|
</select>
|
<select id="pageList" resultType="com.ruoyi.chargingPile.api.vo.TParkingRecordVO">
|
select
|
tpr.id, tpr.app_user_id, tpr.license_plate, tpr.vehicle_color, tpr.charging_order_id, tpr.parking_lot_id, tpr.in_parking_time, tpr.out_parking_time,
|
tpr.parking_duration, tpr.order_amount, tpr.status, tpr.out_parking_type, tpr.create_time,(tpr.order_amount - tpr.timeout_amount) as parkingFee,
|
(tpr.parking_duration - tpr.free_duration) as feeDuration,ts.name as siteName
|
from t_parking_record tpr
|
left join t_parking_lot tpl on tpr.parking_lot_id = tpl.id
|
left join t_site ts on tpl.site_id = ts.id
|
<where>
|
<if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
|
AND tpr.create_time BETWEEN #{query.startTime} AND #{query.endTime}
|
</if>
|
<if test="query.code != null and query.code != ''">
|
AND tpr.code LIKE concat('%',#{query.code},'%')
|
</if>
|
<if test="query.licensePlate != null and query.licensePlate != ''">
|
AND tpr.licensePlate LIKE concat('%',#{query.licensePlate},'%')
|
</if>
|
<if test="query.lotIds != null and query.lotIds.size()>0">
|
AND tpr.parking_lot_id IN
|
<foreach collection="query.lotIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
AND tpr.status = 3
|
</where>
|
ORDER BY tpr.create_time DESC
|
</select>
|
<select id="getParkingRecordCount" resultType="com.ruoyi.chargingPile.api.vo.TParkingRecordPageInfoVO">
|
SELECT count(id) as orderCount,
|
sum(timeout_amount) as timeoutAmountSum,
|
sum(parking_duration - free_duration) as feeDurationSum,
|
sum(parking_duration) as parkingDurationSum
|
from t_parking_record
|
<where>
|
<if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
|
AND create_time BETWEEN #{query.startTime} AND #{query.endTime}
|
</if>
|
<if test="query.code != null and query.code != ''">
|
AND code LIKE concat('%',#{query.code},'%')
|
</if>
|
<if test="query.licensePlate != null and query.licensePlate != ''">
|
AND licensePlate LIKE concat('%',#{query.licensePlate},'%')
|
</if>
|
<if test="query.lotIds != null and query.lotIds.size()>0">
|
AND parking_lot_id IN
|
<foreach collection="query.lotIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
AND status = 3
|
</where>
|
group by create_time
|
ORDER BY create_time DESC
|
</select>
|
<select id="parkingData" resultType="java.util.Map">
|
SELECT
|
DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time,
|
count( 1 ) AS orders,
|
SUM( timeout_amount ) AS timeoutAmount
|
FROM
|
t_parking_record
|
where DATE(create_time ) = CURDATE()
|
<if test="parkingRecordQueryDto.parkingLotId !=null">
|
AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId}
|
</if>
|
GROUP BY
|
time
|
ORDER BY
|
time
|
</select>
|
<select id="parkingDataByDate" resultType="java.util.Map">
|
SELECT
|
DATE_FORMAT( create_time, '%Y-%m-%d' ) AS time,
|
count( 1 ) AS orders,
|
SUM( timeout_amount ) AS timeoutAmount
|
FROM
|
t_parking_record
|
<where>
|
<if test="parkingRecordQueryDto.parkingLotId !=null">
|
AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId}
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 2">
|
AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 3">
|
AND MONTH( create_time ) = MONTH(CURDATE())
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 4">
|
AND YEAR( create_time ) = YEAR(CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 5">
|
<if test="parkingRecordQueryDto.startTime != null">
|
AND create_time >= #{parkingRecordQueryDto.startTime}
|
</if>
|
<if test="parkingRecordQueryDto.endTime != null">
|
AND create_time <= #{parkingRecordQueryDto.endTime}
|
</if>
|
</if>
|
</where>
|
GROUP BY
|
time
|
ORDER BY
|
time
|
|
|
</select>
|
<select id="getCarColor" resultType="java.util.Map">
|
SELECT
|
vehicle_color,count(1) as counts
|
FROM
|
t_parking_record
|
<where>
|
<if test="parkingRecordQueryDto.parkingLotId !=null">
|
AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId}
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 1">
|
AND DATE( create_time ) = CURDATE()
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 2">
|
AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 3">
|
AND MONTH( create_time ) = MONTH(CURDATE())
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 4">
|
AND YEAR( create_time ) = YEAR(CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 5">
|
<if test="parkingRecordQueryDto.startTime != null">
|
AND create_time >= #{parkingRecordQueryDto.startTime}
|
</if>
|
<if test="parkingRecordQueryDto.endTime != null">
|
AND create_time <= #{parkingRecordQueryDto.endTime}
|
</if>
|
</if>
|
</where>
|
GROUP BY vehicle_color
|
|
</select>
|
<select id="getOutType" resultType="java.util.Map">
|
SELECT
|
out_parking_type,count(1) as counts
|
FROM
|
t_parking_record
|
<where>
|
<if test="parkingRecordQueryDto.parkingLotId !=null">
|
AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId}
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 1">
|
AND DATE( create_time ) = CURDATE()
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 2">
|
AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 3">
|
AND MONTH( create_time ) = MONTH(CURDATE())
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 4">
|
AND YEAR( create_time ) = YEAR(CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 5">
|
<if test="parkingRecordQueryDto.startTime != null">
|
AND create_time >= #{parkingRecordQueryDto.startTime}
|
</if>
|
<if test="parkingRecordQueryDto.endTime != null">
|
AND create_time <= #{parkingRecordQueryDto.endTime}
|
</if>
|
</if>
|
</where>
|
GROUP BY out_parking_type
|
</select>
|
<select id="getIsCharge" resultType="java.util.Map">
|
SELECT
|
CASE
|
WHEN charging_order_id IS NOT NULL THEN 'WithChargingOrder'
|
ELSE 'WithoutChargingOrder'
|
END AS order_status,
|
COUNT(*) AS counts
|
FROM
|
`t_parking_record`
|
<where>
|
<if test="parkingRecordQueryDto.parkingLotId !=null">
|
AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId}
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 1">
|
AND DATE( create_time ) = CURDATE()
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 2">
|
AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 3">
|
AND MONTH( create_time ) = MONTH(CURDATE())
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 4">
|
AND YEAR( create_time ) = YEAR(CURDATE() )
|
</if>
|
<if test="parkingRecordQueryDto.dayType == 5">
|
<if test="parkingRecordQueryDto.startTime != null">
|
AND create_time >= #{parkingRecordQueryDto.startTime}
|
</if>
|
<if test="parkingRecordQueryDto.endTime != null">
|
AND create_time <= #{parkingRecordQueryDto.endTime}
|
</if>
|
</if>
|
</where>
|
GROUP BY
|
order_status
|
</select>
|
<select id="income" resultType="java.util.Map">
|
SELECT sum(pr.order_amount) as amount,pl.name
|
from t_parking_record pr
|
LEFT JOIN t_parking_lot pl on pr.parking_lot_id = pl.id
|
<where>
|
<if test="parkingRecordQueryDto.parkingLotId !=null">
|
AND pr.parking_lot_id = #{parkingRecordQueryDto.parkingLotId}
|
</if>
|
|
AND DATE( pr.create_time ) between #{parkingRecordQueryDto.startTime} and #{parkingRecordQueryDto.endTime}
|
|
</where>
|
GROUP BY pl.name
|
</select>
|
|
</mapper>
|