StatisticsDriveMapper.xml
1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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="cn.com.glsx.stdinterface.modules.mapper.StatisticsDriveMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.entity.StatisticsDrive">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="driveNum" column="drive_num" jdbcType="INTEGER"/>
<result property="driveTotal" column="drive_total" jdbcType="INTEGER"/>
<result property="driveTime" column="drive_time" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,sn,drive_num,
drive_time,created_time,updated_time
</sql>
<select id="statisticsDriveDataEveryDay" resultType="cn.com.glsx.stdinterface.dto.StatisticsDriveDto">
select sn,
sum(case when percent >= 50 then 1 else 0 end) as driveNum,
count(1) as driveTotal,
left(journey_time,10) as driveTime
from t_electric_fence_drive
where left(journey_time,10) = #{yesterDayFormat}
GROUP BY sn
</select>
<insert id="statisticsAndInsertDriveDataEveryDay">
INSERT t_statistics_fence_drive (sn ,drive_num ,drive_total ,drive_time ,vd_id ,created_time)
select sn ,
sum(case when percent >= 50 then 1 else 0 end) as driveNum ,
count(1) as driveTotal ,
left(journey_time,10) as driveTime ,
vd_id ,
NOW()
from t_electric_fence_drive
where left(journey_time,10) = #{yesterDayFormat}
GROUP BY sn;
</insert>
</mapper>