#
lsh
2024-01-16 d9131e43a1fa8fe4d5e086d02d4037997cb13bde
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?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.zy.asrs.mapper.WrkMastMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.WrkMast">
        <id column="wrk_no" property="wrkNo" />
        <result column="inv_wh" property="invWh" />
        <result column="ymd" property="ymd" />
        <result column="mk" property="mk" />
        <result column="whs_type" property="whsType" />
        <result column="wrk_sts" property="wrkSts" />
        <result column="io_type" property="ioType" />
        <result column="crn_no" property="crnNo" />
        <result column="rgv_no" property="rgvNo" />
        <result column="sheet_no" property="sheetNo" />
        <result column="io_pri" property="ioPri" />
        <result column="wrk_date" property="wrkDate" />
        <result column="loc_no" property="locNo" />
        <result column="sta_no" property="staNo" />
        <result column="source_sta_no" property="sourceStaNo" />
        <result column="source_loc_no" property="sourceLocNo" />
        <result column="rgv_ssta_no" property="rgvSstaNo" />
        <result column="rgv_dsta_no" property="rgvDstaNo" />
        <result column="loc_sts" property="locSts" />
        <result column="picking" property="picking" />
        <result column="link_mis" property="linkMis" />
        <result column="online_yn" property="onlineYn" />
        <result column="upd_mk" property="updMk" />
        <result column="exit_mk" property="exitMk" />
        <result column="plt_type" property="pltType" />
        <result column="empty_mk" property="emptyMk" />
        <result column="io_time" property="ioTime" />
        <result column="ctn_type" property="ctnType" />
        <result column="packed" property="packed" />
        <result column="ove_mk" property="oveMk" />
        <result column="mtn_type" property="mtnType" />
        <result column="user_no" property="userNo" />
        <result column="crn_str_time" property="crnStrTime" />
        <result column="crn_end_time" property="crnEndTime" />
        <result column="plc_str_time" property="plcStrTime" />
        <result column="crn_pos_time" property="crnPosTime" />
        <result column="load_time" property="loadTime" />
        <result column="exp_time" property="expTime" />
        <result column="ref_wrkno" property="refWrkno" />
        <result column="ref_iotime" property="refIotime" />
        <result column="modi_user" property="modiUser" />
        <result column="modi_time" property="modiTime" />
        <result column="appe_user" property="appeUser" />
        <result column="appe_time" property="appeTime" />
        <result column="pause_mk" property="pauseMk" />
        <result column="error_time" property="errorTime" />
        <result column="error_memo" property="errorMemo" />
        <result column="ctn_kind" property="ctnKind" />
        <result column="manu_type" property="manuType" />
        <result column="memo" property="memo" />
        <result column="sc_weight" property="scWeight" />
        <result column="log_mk" property="logMk" />
        <result column="log_err_time" property="logErrTime" />
        <result column="log_err_memo" property="logErrMemo" />
        <result column="barcode" property="barcode" />
<!--        <result column="Pdc_type" property="PdcType" />-->
        <result column="ctn_no" property="ctnNo" />
        <result column="full_plt" property="fullPlt" />
 
    </resultMap>
 
    <select id="selectByLocNo"  resultMap="BaseResultMap">
        select top 1 * from asr_wrk_mast where source_loc_no = #{sourceLocNo} and  (ctn_no is null or ctn_no != 'Y')
    </select>
 
    <select id="selectByLocNo1"  resultMap="BaseResultMap">
        select top 1 * from asr_wrk_mast where source_loc_no = #{sourceLocNo} or loc_no = #{sourceLocNo}
    </select>
 
    <select id="selectToBeCompleteData" resultMap="BaseResultMap">
        select * from asr_wrk_mast where ((wrk_sts = 4 Or wrk_sts = 14 ) and io_type != 103 and io_type != 104 and io_type != 107 ) or (wrk_sts = 2 and io_type=6) order by upd_mk,io_time,wrk_no
    </select>
 
    <select id="selectToBeHistoryData" resultMap="BaseResultMap">
        select * from asr_wrk_mast
        where wrk_sts=5
        or (wrk_sts=15 and ove_mk='Y' and wrk_no not in (select wrk_no from asr_bas_devp))
        or (wrk_sts=15 and dateadd(mi,15,crn_end_time) &lt;= getdate() and wrk_no not in (select wrk_no from asr_bas_devp))
        or (wrk_sts=15 and crn_end_time is null and wrk_no not in (select wrk_no from asr_bas_devp))
        order by io_time,wrk_no asc
    </select>
 
    <select id="selectPakInStep1" resultMap="BaseResultMap">
        select top 1 * from asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=2 and barcode=#{barcode} and (io_type=1 or io_type=10) order by io_pri desc,io_time,wrk_no ASC
    </select>
 
    <select id="selectPakInStep11" resultMap="BaseResultMap">
        select top 1 * from asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=1 and (io_type=1 or io_type=10) order by io_pri desc,io_time,wrk_no ASC
    </select>
 
    <select id="selectPakInStep2" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where wrk_sts=2 and crn_no=#{crnNo} and wrk_no=#{workNo} and sta_no=#{staNo} and (io_type=1 or io_type=10 or io_type=53 or io_type=54 or io_type=57) order by io_pri desc,io_time,wrk_no ASC
    </select>
 
    <select id="selectPakInStep12" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where wrk_sts=2 and crn_no=#{crnNo} and (io_type=1 or io_type=10 or io_type=53 or io_type=54 or io_type=57) order by io_pri desc,io_time,wrk_no ASC
    </select>
 
    <select id="selectPakInStep3" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where wrk_no=#{workNo}
    </select>
 
    <select id="selectPakInStep4" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where sta_no=#{staNo} and wrk_sts = 14 and io_type>100 and sheet_no=#{sheetNo}
    </select>
 
    <select id="selectPakInStep5" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where sta_no=#{staNo} and wrk_sts = 14 and io_type>100 and sheet_no!=#{sheetNo}
    </select>
 
    <select id="selectPickStep" resultMap="BaseResultMap">
        select top 1 * from asr_wrk_mast where barcode=#{barcode} and wrk_sts=14 and (io_type=103 or io_type=107 or io_type=104)
    </select>
 
    <select id="selectPakOutStep1" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where crn_no=#{crnNo} and source_sta_no=#{sourceStaNo} and wrk_sts=11 and io_type>100 order by io_pri desc,io_time,wrk_no asc
    </select>
 
    <select id="selectPakOutStep2" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=12 and io_type>100 order by io_pri desc,io_time desc,wrk_no ASC
    </select>
 
    <select id="selectPakOutStep3" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=2 and io_type=10
    </select>
 
    <select id="selectLocMove" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where wrk_sts=11 and io_type=11 and crn_no=#{crnNo} order by io_time,wrk_no
    </select>
 
    <select id="selectLocMoving" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where wrk_sts=12 and io_type=11 and crn_no=#{crnNo} order by io_time,wrk_no
    </select>
 
    <select id="selectWorking" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and (wrk_sts=3 or wrk_sts=12) and crn_no=#{crnNo} order by io_time,wrk_no
    </select>
 
<!--    &lt;!&ndash; 入库任务 &ndash;&gt;-->
<!--    <select id="selectWorkingPakin" resultMap="BaseResultMap">-->
<!--        select top 1 * from dbo.asr_wrk_mast where wrk_sts in (2,3,4) and io_type != 11 and source_sta_no = 180 order by io_time,wrk_no-->
<!--    </select>-->
 
<!--    &lt;!&ndash; 出库任务 &ndash;&gt;-->
<!--    <select id="selectWorkingPakout" resultMap="BaseResultMap">-->
<!--        select top 1 *-->
<!--        from dbo.asr_wrk_mast-->
<!--        where (wrk_sts in (11,12)-->
<!--        or (wrk_sts in (14,15) and wrk_no in-->
<!--        (-->
<!--        select wrk_no-->
<!--        from asr_bas_devp-->
<!--        where wrk_no > 0)-->
<!--        ))-->
<!--        and io_type != 11-->
<!--        and source_sta_no = 180-->
<!--        order by io_time,wrk_no-->
<!--    </select>-->
 
    <select id="selectCrnWorking" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and wrk_sts in (3,4,11,12) and crn_no=#{crnNo} order by io_time,wrk_no
    </select>
 
    <select id="selectDevWorking" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and wrk_sts=2 and crn_no=#{crnNo} order by io_time,wrk_no
    </select>
 
    <select id="selectPick" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where 1=1 and wrk_sts = 14 and io_type in (103,104,107)
    </select>
 
    <select id="selectPakOutStep11" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where crn_no=#{crnNo} and source_sta_no=#{sourceStaNo} and wrk_sts=11 and io_type>100 order by io_pri desc,io_time,wrk_no asc
    </select>
 
    <select id="selectPakOutStep12" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where crn_no=#{crnNo} and wrk_sts=11 and io_type>100 order by io_pri desc,io_time,wrk_no asc
    </select>
 
    <!--                                       入出库模式相关                                      -->
    <select id="selectWorkingPakin" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where wrk_sts in (2,3,4) and io_type != 11 and source_sta_no = #{sourceStaNo} order by io_time,wrk_no
    </select>
 
    <select id="selectWorkingPakout" resultMap="BaseResultMap">
        select top 1 *
        from dbo.asr_wrk_mast
        where (wrk_sts in (11,12)
        or (wrk_sts in (14,15) and wrk_no in
        (
        select wrk_no
        from asr_bas_devp
        where wrk_no > 0)
        ))
        and io_type != 11
        and source_sta_no = #{sourceStaNo}
        order by io_time,wrk_no
    </select>
    <select id="selectPakoutEmpty" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where  io_type = 110 and sta_no = #{staNo} order by io_time,wrk_no
    </select>
    <select id="selectExistInEmpty" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM dbo.asr_wrk_mast Where io_type = 10 and wrk_sts in (1,2,3)
    </select>
 
    <!--                                       RGV调度入出库相关                                      -->
    <select id="selectRgvInStep1" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast
        where rgv_no=#{rgvNo} and rgv_ssta_no in
            <foreach item="item" collection="staNos" index="index"  separator="," open="(" close=")">
                #{item}
            </foreach>
            and wrk_sts=2 and (io_type=1 or io_type=10 or io_type=53 or io_type=54 or io_type=57)
        order by io_pri desc,io_time,wrk_no asc
    </select>
 
    <select id="selectRgvInStep2" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where rgv_dsta_no=#{rgvInDStn} and wrk_sts=7 and (io_type=1 or io_type=10 or io_type=53 or io_type=54 or io_type=57) order by io_pri desc,io_time desc,wrk_no ASC
    </select>
 
    <select id="selectRgvInWorking" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where 1=1 and wrk_sts in (6,7) and rgv_no=#{rgvNo} order by io_time,wrk_no
    </select>
 
    <select id="selectRgvOutStep2" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where rgv_dsta_no=#{rgvOutDStn} and wrk_sts=17 and io_type > 100 order by io_pri desc,io_time desc,wrk_no ASC
    </select>
 
    <select id="selectRgvDestStep2" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where rgv_dsta_no=#{rgvDestStn} and wrk_sts in (7,17) order by io_pri desc,io_time desc,wrk_no ASC
    </select>
 
    <select id="selectRgvOutStep1" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast
        where rgv_no=#{rgvNo} and rgv_ssta_no in
        <foreach item="item" collection="staNos" index="index"  separator="," open="(" close=")">
            #{item}
        </foreach>
        and wrk_sts=14 and io_type>100 and online_yn='N'
        order by io_pri desc,io_time,wrk_no asc
    </select>
 
    <select id="selectRgvOutWorking" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast where 1=1 and wrk_sts in (16,17) and rgv_no=#{rgvNo} order by io_time,wrk_no
    </select>
    <!--                                       RGV调度入出库相关                                      -->
    <!-- ==============================================RGV任务绑定相关 ============================================== -->
 
    <select id="selectWaitBindRGV" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast
        where 1=1
        and wrk_sts in (2,14)
        and rgv_no is null
    </select>
 
    <select id="selectWaitBindRgvNo2" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast
        where 1=1
        and wrk_sts in (2,14)
        and (rgv_no IS NULL OR rgv_no = 0)
    </select>
 
    <select id="selectWaitBindRGVRgvNo" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast_rgv
        where 1=1
        and wrk_sts &lt; 110
        and rgv_no = #{rgvNo}
    </select>
 
    <select id="selectWaitBindRgvNoOneWrkNo" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast_rgv
        where 1=1
        and wrk_no = #{wrkNo}
    </select>
 
    <insert id="insertRgvMast">
        INSERT INTO dbo.asr_wrk_mast_rgv SELECT * FROM asr_wrk_mast WHERE wrk_no = #{wrkNo}
    </insert>
 
    <update id="updateRgvMast">
        update asr_wrk_mast_rgv
        set wrk_sts=100
        where 1=1
        and wrk_no = #{wrkNo}
    </update>
 
    <select id="selectRgvInSteWrkNo" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and wrk_sts =12 and wrk_no=#{wrkNo} and rgv_no is null
    </select>
 
    <select id="selectRgvOutSteWrkNo" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and wrk_sts =24 and wrk_no=#{wrkNo} and rgv_no is null
    </select>
 
    <select id="selectIoRgvNo" resultMap="BaseResultMap">
        select * from dbo.asr_wrk_mast
        where 1=1
        and wrk_sts in (2,4,23,25)
        and rgv_no = #{rgvNo}
        order by io_pri desc,io_time desc,wrk_no ASC
    </select>
 
    <select id="selectRgvInSteNo" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and wrk_sts =14 and rgv_no=#{rgvNo}
        <if test="rgvNo == 1">
            order by rgv_dsta_no
        </if>
        <if test="rgvNo == 2">
            order by rgv_dsta_no desc
        </if>
    </select>
 
    <select id="selectRgvOutSteNo" resultMap="BaseResultMap">
        select top 1 * from dbo.asr_wrk_mast where 1=1 and wrk_sts =24 and rgv_no=#{rgvNo}
        <if test="rgvNo == 1">
            order by rgv_dsta_no
        </if>
        <if test="rgvNo == 2">
            order by rgv_dsta_no desc
        </if>
    </select>
 
    <!-- ==============================================RGV任务绑定相关 ============================================== -->
    <!-- ==============================================自动补空板相关 ============================================== -->
<!--    <select id="selectDischargingMachineOutputTray" resultMap="BaseResultMap">-->
<!--        select * from dbo.asr_wrk_mast where 1=1 and io_type = 201-->
<!--    </select>-->
 
 
<!--    <select id="selectStackingCompletionDriveTray" resultMap="BaseResultMap">-->
<!--        select * from dbo.asr_wrk_mast where 1=1 and io_type = 201 and wrk_sts = 43-->
<!--    </select>-->
 
<!--    <select id="selectConfigCount10468N" resultType="java.lang.Integer">-->
<!--        SELECT COUNT(1) FROM dbo.sys_config Where 1=1 and id=10468 and value = 'N'-->
<!--    </select>-->
 
    <!-- ==============================================自动补空板相关 ============================================== -->
 
    <select id="selectWrkMastUnstackingOne202" resultMap="BaseResultMap">
        SELECT top 1 * FROM dbo.asr_wrk_mast Where 1=1 and io_type=202 and wrk_sts =51 and source_sta_no = #{sourceStaNo}
    </select>
 
    <select id="selectWrkMastLabelingOne54" resultMap="BaseResultMap">
        SELECT top 1 * FROM dbo.asr_wrk_mast Where 1=1 and io_type=202 and wrk_sts =54
    </select>
 
</mapper>