zhoushihao
2024-06-24 6acde3b011f5f1b843c6f097baf64fbd9b574b23
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
<?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="queryWorkStationNotIn" resultMap="downGlassInfo">
        SELECT T.*,
               T1.*
        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 T2.GLASS_ID IS NULL
        order by t.count desc
    </select>
</mapper>