zhoushihao
2024-06-26 79cddf75458ebc5d8855f66ea9bf9ef073327b03
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?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.downglassinfo.mapper.DownGlassInfoMapper">
 
    <resultMap id="downGlassInfoDTO" type="com.mes.downworkstation.entity.dto.DownGlassInfoDTO">
        <result column="flow_card_id" property="flowCardId"/>
        <result column="layer" property="layer"/>
        <result column="count" property="count"/>
    </resultMap>
    <resultMap id="downGlassInfo" type="com.mes.downworkstation.entity.dto.DownGlassInfoDTO">
        <result column="flow_card_id" property="flowCardId"/>
        <result column="layer" property="layer"/>
        <result column="count" property="count"/>
        <collection property="glassInfoList" ofType="com.mes.glassinfo.entity.GlassInfo">
            <id column="id" property="id"/>
            <result column="flow_card_id" property="flowCardId"/>
            <result column="glass_type" property="glassType"/>
            <result column="width" property="width"/>
            <result column="height" property="height"/>
            <result column="thickness" property="thickness"/>
            <result column="filmsid" property="filmsid"/>
            <result column="total_layer" property="totalLayer"/>
            <result column="layer" property="layer"/>
        </collection>
    </resultMap>
 
    <select id="queryDownGlassMaxLayer" resultMap="downGlassInfoDTO">
        SELECT flow_card_id,
               layer,
               COUNT(layer) AS count
        FROM
            down_glass_info
        WHERE
            flow_card_id = #{flowCardId}
        GROUP BY
            flow_card_id,
            layer
        order by count desc limit 1
    </select>
    <select id="queryMaxSequence" resultType="java.lang.Integer">
        SELECT max(sequence) + 1 as sequence
        FROM down_glass_info
        WHERE flow_card_id = #{flowCardId}
          AND layer = #{layer}
    </select>
 
    <select id="queryWorkStationIsIn" resultMap="downGlassInfo">
        SELECT T.*
        <if test="isDownload == null and isDownload == true ">
            ,T1.*
        </if>
        FROM (
        SELECT T.FLOW_CARD_ID,
        T.LAYER,
        COUNT(T.LAYER) AS COUNT
        FROM
        DOWN_GLASS_INFO T
        INNER JOIN DOWN_WORKSTATION T1
        ON T.FLOW_CARD_ID = T1.FLOW_CARD_ID
        AND T.LAYER = T1.LAYER
        GROUP BY
        T.FLOW_CARD_ID,
        T.LAYER
        ) T
        INNER JOIN GLASS_INFO T1 ON T.FLOW_CARD_ID = T1.FLOW_CARD_ID
        AND T.LAYER = T1.LAYER
        LEFT JOIN DOWN_GLASS_INFO T2 ON T1.GLASS_ID = T2.GLASS_ID
        <where>
            <if test="isDownload == null or isDownload == false">
                AND T2.GLASS_ID IS NULL
            </if>
            <if test="isDownload == true">
                AND T2.GLASS_ID IS not NULL
            </if>
        </where>
        order by t.count desc
    </select>
</mapper>