xuhy
2025-02-21 0e416914d19635d62f4ef7b5be74c1ed6b7ea24e
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
52
53
54
<?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.TOrderTapeMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TOrderTape">
        <id column="id" property="id" />
        <result column="orderId" property="orderId" />
        <result column="orderType" property="orderType" />
        <result column="fileLink" property="fileLink" />
        <result column="fileName" property="fileName" />
        <result column="fileFormat" property="fileFormat" />
        <result column="fileSize" property="fileSize" />
        <result column="afterTime" property="afterTime" />
        <result column="insertTime" property="insertTime" />
        <result column="isDelete" property="isDelete" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,orderId,orderType,fileLink,fileName,fileFormat,fileSize,afterTime,insertTime,isDelete
    </sql>
    <select id="getOrderTapeList" resultType="java.util.Map">
        SELECT tot.id,tot.orderId,tot.orderType,tot.fileLink,tot.fileName,tot.fileFormat,tot.fileSize,tot.afterTime,tot.insertTime,tot.isDelete,o.orderNum,
            (case when tot.afterTime &lt;= now() then 2 when tot.afterTime &gt;= now() then 1 end) as state
        from t_order_tape tot
        LEFT JOIN
        (
        SELECT id,orderNum,isDelete,1 as orderType from t_order_private_car
        UNION ALL
        SELECT id,orderNum,isDelete,3 as orderType from t_order_cross_city
        UNION ALL
        SELECT id,orderNum,isDelete,7 as orderType from t_order_transfer
        ) o
        on tot.orderId = o.id
        where tot.isDelete = 1 and o.isDelete = 1 and tot.orderType = o.orderType
        <if test="beginTime != null and endTime != null">
            and tot.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
        </if>
        <if test="fileName != null and fileName != ''">
            and tot.fileName like concat('%',#{fileName},'%')
        </if>
        <if test="orderNum != null and orderNum != ''">
            and o.orderNum like concat('%',#{orderNum},'%')
        </if>
        <if test="state != null and state == 1">
            and tot.afterTime &gt;= now()
        </if>
        <if test="state != null and state == 2">
            and tot.afterTime &lt;= now()
        </if>
    </select>
 
</mapper>