puzhibing
2023-02-15 2811bab657aab4145b65a45a824fb63e93b58e30
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
45
46
47
48
49
50
51
<?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.stylefeng.guns.modular.system.dao.DriverWorkMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.DriverWork">
        <id column="id" property="id" />
        <result column="driverId" property="driverId" />
        <result column="startTime" property="startTime" />
        <result column="endTime" property="endTime" />
        <result column="type" property="type" />
        <result column="state" property="state" />
    </resultMap>
 
 
    <select id="queryNewWork" resultType="DriverWork">
        select
        id as id,
        driverId as driverId,
        startTime as startTime,
        endTime as endTime,
        `type` as `type`,
        state as state
        from t_driver_work where 1 = 1
        <if test="null != driverId">
            and driverId = #{driverId}
        </if>
        <if test="null != type">
            and type like CONCAT('%', #{type}, '%')
        </if>
        <if test="null != state">
            and state = #{state}
        </if>
        order by startTime desc limit 0,1
    </select>
 
 
 
    <select id="query" resultType="DriverWork">
        select
        id as id,
        driverId as driverId,
        startTime as startTime,
        endTime as endTime,
        `type` as `type`,
        state as state
        from t_driver_work where `type` like CONCAT('%', #{type}, '%')
        and (unix_timestamp(if(endTime is null , now(), endTime))) -
        unix_timestamp(IF((DATE_FORMAT(now(), '%Y-%m-%d') != DATE_FORMAT(startTime, '%Y-%m-%d')), STR_TO_DATE(CONCAT(DATE_FORMAT(now(), '%Y-%m-%d'),' ','00:00:00'), '%Y-%m-%d %H:%i:%s'), startTime)) > (#{time} * 60 * 60)
    </select>
</mapper>