StatisticsDriveMapper.xml 1.51 KB
<?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.schedulerjob.task.mapper.StatisticsDriveMapper">

    <resultMap id="BaseResultMap" type="cn.com.glsx.schedulerjob.task.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.schedulerjob.task.entity.StatisticsDrive">
        select sn,
        sum(case when percent >= 80 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>

    <select id="getMaxDriveTime" resultType="java.lang.String">
        select max(drive_time) from t_statistics_fence_drive;
    </select>
</mapper>