zhoushihao
2024-10-11 d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?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="racks_number" property="racksNumber"/>
        <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 COALESCE(max(sequence) + 1, 1) as sequence
        FROM down_glass_info
        WHERE flow_card_id = #{flowCardId}
          AND layer = #{layer}
    </select>
 
    <select id="queryWorkStationIsIn" resultMap="downGlassInfo">
        SELECT
        T.FLOW_CARD_ID,
        T.LAYER,
        T.RACKS_NUMBER
        <if test="!isDownload">
            ,T1.*
        </if>
        FROM
        DOWN_WORKSTATION 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>
            t.workstation_id in
            <foreach collection="workList" item="item" open='(' close=')' separator=','>
                #{item}
            </foreach>
            <if test="!isDownload">
                AND T2.GLASS_ID IS NULL
            </if>
            <if test="isDownload">
                AND T2.GLASS_ID IS not NULL
            </if>
 
        </where>
        ORDER BY
        T.RACKS_NUMBER DESC,
        T1.TEMPERING_LAYOUT_ID,
        T1.TEMPERING_FEED_SEQUENCE DESC
    </select>
    <select id="queryWorkStationFlowCard" resultMap="downGlassInfo">
        SELECT
        T.FLOW_CARD_ID,
        T.LAYER,
        T.RACKS_NUMBER
        FROM
        DOWN_WORKSTATION T
        where
        (t.flow_card_id is not null and t.flow_card_id != '')
        and t.workstation_id in
        <foreach collection="workList" item="item" open='(' close=')' separator=','>
            #{item}
        </foreach>
        ORDER BY T.RACKS_NUMBER DESC
    </select>
 
    <select id="selectFlowCard" resultType="java.util.Map">
        select fc.order_number,
               concat(round(ogd.child_width), "*", round(ogd.child_height))   as child_width,
               od.quantity,
               round(ogd.total_area, 2)                                       as total_area,
               od.perimeter,
               od.bend_radius,
               concat(IFNULL(od.processing_note, ''), IFNULL(od.remarks, '')) as remarks,
               od.other_columns,
               round(ogd.child_width)                                         as width,
               round(ogd.child_height)                                        as height,
               pd.separation,
               fc.technology_number
        from pp.flow_card as fc
                 left join sd.order_glass_detail as ogd
                           on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
                              fc.technology_number = ogd.technology_number
                 left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
                 left join sd.product_detail as pd
                           on pd.prod_id = od.product_id and pd.glass_sort = ogd.technology_number
        where fc.process_id = #{processId}
          and position(fc.technology_number in #{technologyNumber})
        group by fc.process_id, fc.order_number, fc.technology_number
        order by IF(sort != NULL || sort != '', sort, fc.order_number)
 
    </select>
 
    <select id="selectProject" resultType="java.util.Map">
        select o.customer_name,
               o.project,
               (select process
                from sd.order_glass_detail
                where order_id = fc.order_id
                  and order_number = fc.order_number
                  and technology_number = fc.technology_number) as process,
               od.edging_type,
               (select glass_child
                from sd.order_glass_detail
                where order_id = fc.order_id
                  and order_number = fc.order_number
                  and technology_number = fc.technology_number) as glass_child,
               od.product_name,
               o.processing_note,
               fc.process_id,
               SUM(od.quantity)                                 as quantity,
               round(SUM(ogd.total_area), 2)                    as gross_area,
               sum(od.weight)                                   as weight,
               1                                                as technologyNumber,
               concat(fc.process_id, '/', 1)                    as processIdNumber,
               concat('对应我司单号', o.batch)                        AS otherRemarks
        from pp.flow_card as fc
                 left join sd.order_glass_detail as ogd
                           on fc.order_id = ogd.order_id and fc.order_number = ogd.order_number and
                              fc.technology_number = ogd.technology_number
                 left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
                 left join sd.`order` as o on o.order_id = fc.order_id
                 left join sd.product as p on p.id = od.product_id
                 left join (select ogd.order_id,
                                   ogd.order_number,
                                   ogd.technology_number,
                                   ogd.glass_child,
                                   GROUP_CONCAT(glass_child SEPARATOR ' ') AS concatenated_glass_child
                            from sd.order_glass_detail as ogd
                            where ogd.order_id = left (#{processId}
                                , 10)
                              and position (ogd.technology_number in #{technologyNumber})
                            GROUP BY order_id, order_number) as ogdc
                           on ogdc.order_id = ogd.order_id and ogdc.order_number = ogd.order_number and
                              ogdc.technology_number = ogd.technology_number
        where fc.process_id = #{processId}
          and position(fc.technology_number in #{technologyNumber})
        group by fc.process_id
    </select>
 
    <select id="downGlassLabelPrint" resultType="java.util.Map">
        select a.flow_card_id,
               a.layer,
               a.width,
               a.height,
               a.filmsid,
               a.thickness,
               a.glass_type,
               COUNT(*) AS quantity,
               b.tempering_layout_id,
               b.tempering_feed_sequence
        from down_glass_info a
                 inner join glass_info b on a.glass_id = b.glass_id
        where a.flow_card_id = #{processId}
          and a.layer = #{technologyNumber}
        group by a.flow_card_id, a.layer, a.width, a.height, a.filmsid, a.thickness, a.glass_type, a.id
        order by a.id
    </select>
 
 
</mapper>