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
<?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.mes.hollowqueue.mapper.HollowGlassQueueInfoMapper">
 
    <select id="queryNeedInCarGlass" resultType="java.lang.String">
        WITH queue_temp AS (
        SELECT
        slot,
        glass_id,
        LEAST( width, height ) AS height,
        relation_id,
        is_pair,
        ROW_NUMBER() OVER ( PARTITION BY cell ORDER BY hollow_sequence ) AS rn
        FROM
        hollow_glass_queue_info
        WHERE
        state = - 1
        ),
        task_temp AS (
        SELECT
        t.*
        FROM
        queue_temp t
        INNER JOIN hollow_glass_out_relation_info t1 ON t.relation_id = t1.id
        WHERE
        t1.state = 1
        and t.slot BETWEEN 500 and 900
        AND (
        t.is_pair = 1
        OR ( t.is_pair = 0 AND t1.is_force = 1 )) )SELECT
        glass_id
        FROM
        task_temp
        ORDER BY
        rn
    </select>
</mapper>