lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
ÿþlocal function QueryEndLoc(strLuaDEID, str, end_roadway)
    -- ·ƒÖSg̑b—„vzz'MO
 
    local strCondition = "N_CURRENT_NUM = 0 AND S_AREA_CODE = 'LK' AND N_ROADWAY = " .. end_roadway
    strCondition = strCondition .. " AND N_LOCK_STATE = 0 AND C_ENABLE = 'Y' AND N_POS = 2  AND N_LAYER IN(" .. str ..
                       ")"
    local strOrder = "N_COL, N_LAYER" -- gя÷]SãS
    -- gY·ƒÖS 10 ag
    local nRet, strRetInfo = mobox.queryDataObjAttr3(strLuaDEID, "Location", strCondition, 10, strOrder)
    if (nRet ~= 0) then
        return 2, "·ƒÖS'MOáOo`•ï‹! " .. strRetInfo .. " SQLagöN: " .. strCondition
    end
    if (strRetInfo ~= '') then
        local loc
        local retObjs = json.decode(strRetInfo)
 
        nRet, loc = m3.ObjAttrStrToLuaObj("Location", lua.table2str(retObjs[1].attrs))
        if (nRet ~= 0) then
            return 2, "m3.ObjAttrStrToLuaObj(Location) 1Y%! " .. loc
        end
        return 0, loc.code
    end
 
    -- ·ƒÖSgYb—„vzz'MO
    strCondition = "N_CURRENT_NUM = 0 AND S_AREA_CODE = 'LK' AND N_ROADWAY = " .. end_roadway
    strCondition = strCondition .. " AND N_LOCK_STATE = 0 AND C_ENABLE = 'Y' AND N_POS = 1  AND N_LAYER IN(" .. str ..
                       ")"
    -- gY·ƒÖS 10 ag
    nRet, strRetInfo = mobox.queryDataObjAttr3(strLuaDEID, "Location", strCondition, 10, strOrder)
    if (nRet ~= 0) then
        return 2, "·ƒÖS'MOáOo`•ï‹! " .. strRetInfo .. " SQLagöN: " .. strCondition
    end
    if (strRetInfo ~= '') then
        local loc
        local retObjs = json.decode(strRetInfo)
        nRet, loc = m3.ObjAttrStrToLuaObj("Location", lua.table2str(retObjs[1].attrs))
        if (nRet ~= 0) then
            return 2, "m3.ObjAttrStrToLuaObj(Location) 1Y%! " .. loc
        end
        return 0, loc.code
    end
 
    return 2, "¡l    gzz'MO!"
end
--[[
   x: GT-122-31
    Tðy:
   \O€ÿ
   åegÿ2025-04-22
 
   ýQpeÿ ClickOk
   ŸRý€:  9hncLub— NÉbFh„v{|‹W /fcš[÷]Sûy“^؏/fcš['MOûy“^ ÿcš['MOûy“^Rôv¥cRú^¹pù[¹psOûN¡R ÿ
          cš[÷]Sûy“^R—‰·ƒÖS÷]Så‹ir™e0yb!k„v¹[hV ÿ6qTª_¯sRú^sOûN¡R
 
   ôf9e°‹U_:
    20240424 LZH V1.1 È~¹p—‰9hncir™e$R­e ÿ¢”N»S1~3B\ ÿö€™eOHQ4~12 ÿvQ!kMb/f1~3
 
--]]
 
json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require("oi_base_mobox")
wms = require("OILua_WMS")
require("GT-Base")
require("GT_InAndOutboundPolicies")
function ClickOk(strLuaDEID)
    local nRet, strRetInfo, strCondition
    -- ·ƒÖSpenc
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_TYPE", "S_ITEM_CODE", "S_BATCH_NO", "S_START_ROADWAY",
        "S_END_ROADWAY", "N_QTY", "S_START_LOC", "S_END_LOC")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo)
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local type = obj_attrs[1].value -- {|‹W
    if (type == 'cš[÷]Sûy“^') then
        local item_code = obj_attrs[2].value -- ir™e÷S
        if (item_code == nil or item_code == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "ir™e÷S Ný€:Nzz!")
        end
        local batch_no = obj_attrs[3].value -- yb!k÷S
        if (batch_no == nil or batch_no == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S Ný€:Nzz!")
        end
        local start_roadway = obj_attrs[4].value -- wËY÷]S
        if (start_roadway == nil or start_roadway == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "wËY÷]S Ný€:Nzz!")
        end
        local end_roadway = obj_attrs[5].value -- îv„v÷]S
        if (end_roadway == nil or end_roadway == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "îv„v÷]S Ný€:Nzz!")
        end
        local qty = lua.StrToNumber(obj_attrs[6].value) -- Xbpe
        if qty <= 0 or qty ~= math.floor(qty) then
            lua.Error(strLuaDEID, debug.getinfo(1), "Xbpe Ný€:N00\pebpe!")
        end
 
        -- ‚Yœg÷]Søv TRôv¥c¥b•úQ
        if (start_roadway == end_roadway) then
            lua.Error(strLuaDEID, debug.getinfo(1), "wËY÷]SŒTîv„v÷]S Ný€øv T!")
        end
 
        -- $R­e÷]S…Qå‹yb!k„vir™eXbpe/f&Tý€án³—‰úQ„vXbpe
        local strFromTabInfo = "TN_Loc_Container a LEFT JOIN TN_CG_Detail b ON a.S_CNTR_CODE = b.S_CNTR_CODE"
        strFromTabInfo = strFromTabInfo .. " LEFT JOIN TN_Location c ON a.S_LOC_CODE = c.S_CODE"
        strFromTabInfo = strFromTabInfo .. " LEFT JOIN TN_Container d ON a.S_CNTR_CODE = d.S_CODE"
        -- ågâ‹ÔÞV„vW[µk
        local strAttrInfo = " count(1) "
        -- ågâ‹agöN ir™exŒTyb!k÷Søv T ÿ¹[hV¡l    g
N• ÿ'MO:N…QñmMO
        local condition = "b.S_ITEM_CODE = '" .. item_code .. "' AND b.S_BATCH_NO = '" .. batch_no .. "'"
        condition = condition .. " AND d.N_LOCK_STATE = 0 AND c.N_LOCK_STATE = 0 AND c.N_ROADWAY = " .. start_roadway
        nRet, strRetInfo = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1000, condition)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. strRetInfo)
        end
        strRetInfo = json.decode(strRetInfo)
        lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
        if (lua.StrToNumber(strRetInfo[1][1]) < qty) then
            lua.Error(strLuaDEID, debug.getinfo(1), "“^X[ Nán³ûy“^„vXbpe!")
        end
 
        -- ª_¯sRú^sOûN¡R
        for i = 1, qty do
            -- step2 ·ƒÖS…QñmMOŒTYñmMO„vXbØvpeϑ ÿ‚Yœg…QñmMOpeϑYRHQúQ…QñmMO ‚Yœg…QñmMOŒTYñmMOpeϑøvI{ROHQúQYñmMO
            -- åg⋅QñmMO„vXbØvpeϑ
            local inside_num, outside_num, inside_info, outside_info
            -- ågâ‹ÔÞV„vW[µk
            strAttrInfo = " count(1) "
            -- ågâ‹agöN ir™exŒTyb!k÷Søv T ÿ¹[hV¡l    g
N• ÿ'MO:N…QñmMO
            strCondition = condition .. " AND c.N_POS = 2"
            nRet, inside_num = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. inside_num)
            end
            inside_num = json.decode(inside_num)
            inside_num = tonumber(inside_num[1][1])
            lua.Debug(strLuaDEID, debug.getinfo(1), '…QñmMOpeϑ', inside_num)
 
            -- ågâ‹agöN ir™exŒTyb!k÷Søv T ÿ¹[hV¡l    g
N• ÿ'MO:NYñmMO
            strCondition = condition .. " AND c.N_POS = 1"
            nRet, outside_num = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. outside_num)
            end
            outside_num = json.decode(outside_num)
            outside_num = tonumber(outside_num[1][1]) -- YñmMOpeϑ
            lua.Debug(strLuaDEID, debug.getinfo(1), 'YñmMOpeϑ', outside_num)
 
            -- $R­e …Q > Y peϑ,OHQúQY„v…QñmMO
            local start_loc, cntr_code
            if (tonumber(inside_num) > tonumber(outside_num)) then
                -- ·ƒÖSw¹pŒT¹[hV
                strCondition = condition .. " AND c.N_POS = 2"
                strAttrInfo = "a.S_LOC_CODE,a.S_CNTR_CODE,c.N_ROW_GROUP"
                nRet, inside_info = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. inside_info)
                end
                inside_info = json.decode(inside_info)
                lua.Debug(strLuaDEID, debug.getinfo(1), 'inside_info', inside_info)
 
                for j = 1, #inside_info do
                    local start_loc_code = inside_info[j][1]
                    cntr_code = inside_info[j][2]
                    local row_group = inside_info[j][3]
                    lua.Debug(strLuaDEID, debug.getinfo(1), 'row_group', row_group)
 
                    -- $R­eù[”^„vYñmMO/f&TX[(W'ÁTb€ck(WgbLˆ
                    local new_loc_code
                    nRet, new_loc_code = OuterDeepPosition(strLuaDEID, row_group, start_loc_code)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), new_loc_code)
                    end
                    lua.Debug(strLuaDEID, debug.getinfo(1), 'new_loc_code', new_loc_code)
 
                    -- $R­eYñmMO/f&TX[(W'ÁTv^N'MO*g
N•,X[(WRRú^ûy“^\ON, NX[(WRôv¥cԏÞV'MOx
                    strCondition = "S_CODE = '" .. new_loc_code .. "' AND N_LOCK_STATE = 0"
                    nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Location", strCondition)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
                    end
                    if (tonumber(strRetInfo) == 0) then
                        goto continue
                    end
 
                    strCondition = "S_CODE = '" .. new_loc_code .. "' AND N_CURRENT_NUM = 1"
                    nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Location", strCondition)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
                    end
                    if (tonumber(strRetInfo) == 0) then
                        -- ·ƒÖSw¹páOo`
                        nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. start_loc)
                        end
                        lua.Debug(strLuaDEID, debug.getinfo(1), 'w¹p'MOáOo`', start_loc)
                        start_loc = json.decode(start_loc)
                        break
                    else
                        -- YñmMO    gN‰Ræ‰ÑS«ˆ¨Rûy“^
                        -- ·ƒÖSw¹páOo`
                        local new_start_loc, new_end_loc
                        nRet, new_start_loc = wms_wh.GetLocInfo(new_loc_code)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo1Y%!' .. start_loc)
                        end
 
                        -- ·ƒÖS¹[hVáOo`
                        strCondition = "S_LOC_CODE = '" .. new_loc_code .. "'"
                        local new_cntr_loc
                        nRet, new_cntr_loc = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1),
                                "·ƒÖS0'MO¹[hV0áOo`1Y%! " .. new_cntr_loc)
                        end
 
                        -- ·ƒÖS'ÁTáOo`
                        strCondition = "S_CNTR_CODE = '" .. new_cntr_loc.cntr_code .. "'"
                        local new_cg_detail
                        nRet, new_cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1),
                                "·ƒÖS0¹[hV'ÁTfÆ~0áOo`1Y%! " .. new_cg_detail)
                        end
 
                        -- ·ƒÖSir™e{|‹W
                        local item_type, material
                        nRet, item_type, material = GT_Get_ItemType(strLuaDEID, new_cg_detail.item_code)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), item_type)
                        end
 
                        local layer = ''
                        if (item_type == '¢”N') then
                            layer = wms_base.Get_sConst(strLuaDEID, "sO-Ëz“^¢”N'MOB\")
                        else
                            layer = wms_base.Get_sConst(strLuaDEID, "sO-Ëz“^^—¢”N'MOB\")
                        end
 
                        -- ·ƒÖSÈ~¹páOo`
                        nRet, new_end_loc = GetEndLoc(strLuaDEID, new_start_loc.roadway, layer)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), new_end_loc)
                        end
 
                        -- Rú^sOûN¡R
                        local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
                        -- w¹páOo`
                        gt_task.start_wh_code = new_start_loc.wh_code
                        gt_task.start_area_code = new_start_loc.area_code
                        gt_task.start_loc_code = new_start_loc.code
                        -- È~¹páOo`
                        gt_task.end_wh_code = new_end_loc.wh_code
                        gt_task.end_area_code = new_end_loc.area_code
                        gt_task.end_loc_code = new_end_loc.code
                        gt_task.type = 3 -- 1 ‰|™eŒèb,dЏ 2 Øpö€,dЏ 3  T÷]Sûy“^
                        gt_task.priority = 2 -- 'Y„vOHQ
                        gt_task.cntr_code = new_cntr_loc.cntr_code
                        nRet, gt_task = m3.CreateDataObj(strLuaDEID, gt_task)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0sOûN¡R01Y%!' .. gt_task)
                        end
 
                        -- ·ƒÖSw¹páOo`
                        nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. start_loc)
                        end
                        lua.Debug(strLuaDEID, debug.getinfo(1), 'w¹p'MOáOo`', start_loc)
                        start_loc = json.decode(start_loc)
                        break
                    end
 
                    ::continue::
                end
                if (start_loc == nil) then
                    -- ·ƒÖSw¹pŒT¹[hV
                    strCondition = condition .. " AND c.N_POS = 1"
                    strAttrInfo = "a.S_LOC_CODE,a.S_CNTR_CODE"
                    nRet, outside_info = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. outside_info)
                    end
                    outside_info = json.decode(outside_info)
                    local start_loc_code = outside_info[1][1]
                    cntr_code = outside_info[1][2]
 
                    -- ·ƒÖSw¹páOo`
                    nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. start_loc)
                    end
                    lua.Debug(strLuaDEID, debug.getinfo(1), 'w¹p'MOáOo`', start_loc)
                    start_loc = json.decode(start_loc)
                end
            elseif (tonumber(inside_num) <= tonumber(outside_num)) then
                -- ·ƒÖSw¹pŒT¹[hV
                strCondition = condition .. " AND c.N_POS = 1"
                strAttrInfo = "a.S_LOC_CODE,a.S_CNTR_CODE"
                nRet, outside_info = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. outside_info)
                end
                outside_info = json.decode(outside_info)
                local start_loc_code = outside_info[1][1]
                cntr_code = outside_info[1][2]
 
                -- ·ƒÖSw¹páOo`
                nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. start_loc)
                end
                lua.Debug(strLuaDEID, debug.getinfo(1), 'w¹p'MOáOo`', start_loc)
                start_loc = json.decode(start_loc)
            end
 
            -- ·ƒÖSÈ~¹p
            -- ·ƒÖS¹[hV
N„vir™e
            local cg_detail
            strCondition = "S_CNTR_CODE ='" .. cntr_code .. "'"
            nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), cg_detail)
            end
            -- ·ƒÖSir™e{|‹W
            local item_type, material
            nRet, item_type, material = GT_Get_ItemType(strLuaDEID, cg_detail.item_code)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), item_type)
            end
            lua.Debug(strLuaDEID, debug.getinfo(1), 'ir™eáOo`', material)
            -- ¢”NêSý€eQcš[B\
            local str, end_loc_code
            if (item_type == '¢”N') then
                str = wms_base.Get_sConst(strLuaDEID, "sO-Ëz“^¢”N'MOB\")
                nRet, end_loc_code = QueryEndLoc(strLuaDEID, str, end_roadway)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), end_loc_code)
                end
                if (end_loc_code == nil or end_loc_code == '') then
                    lua.Error(strLuaDEID, debug.getinfo(1), "¡l    gïSûy“^'MO!")
                end
            else
                str = wms_base.Get_sConst(strLuaDEID, "sO-Ëz“^^—¢”N'MOB\")
                nRet, end_loc_code = QueryEndLoc(strLuaDEID, str, end_roadway)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), end_loc_code)
                end
                if (end_loc_code == nil or end_loc_code == '') then
                    str = wms_base.Get_sConst(strLuaDEID, "sO-Ëz“^¢”N'MOB\")
                    nRet, end_loc_code = QueryEndLoc(strLuaDEID, str, end_roadway)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), end_loc_code)
                    end
                    if (end_loc_code == nil or end_loc_code == '') then
                        lua.Error(strLuaDEID, debug.getinfo(1), "¡l    gïSûy“^'MO!")
                    end
                end
            end
 
            -- ·ƒÖSÈ~¹páOo`
            local end_loc
            nRet, end_loc = wms.wms_GetLocBaseInfo(end_loc_code)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. end_loc)
            end
            lua.Debug(strLuaDEID, debug.getinfo(1), 'È~¹p'MOáOo`', end_loc)
            end_loc = json.decode(end_loc)
            -- Rú^¹pù[¹pûy“^ûN¡R
            local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
            lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
            -- w¹páOo`
            gt_task.start_wh_code = start_loc.wh_code
            gt_task.start_area_code = start_loc.area_code
            gt_task.start_loc_code = start_loc.code
            -- È~¹páOo`
            gt_task.end_wh_code = end_loc.wh_code
            gt_task.end_area_code = end_loc.area_code
            gt_task.end_loc_code = end_loc.code
            gt_task.type = 3
            gt_task.cntr_code = cntr_code
            nRet, gt_task = m3.CreateDataObj(strLuaDEID, gt_task)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0sOûN¡R01Y%!' .. gt_task)
            end
            lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
 
            -- sOûN¡R„vw¹pÈ~¹p'MO
N•
            nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.start_loc_code,
                wms_base.Get_nConst(strLuaDEID, "•{|‹W-úQ“^•"), gt_task.code, gt_task.code,
                "cš[÷]Sûy“^•š['MO")
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo)
            end
            nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.end_loc_code,
                wms_base.Get_nConst(strLuaDEID, "•{|‹W-eQ“^•"), gt_task.code, gt_task.code,
                "cš[÷]Sûy“^•š['MO")
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo)
            end
        end
    else
        local start_loc_code = obj_attrs[7].value -- w¹p
        if (start_loc_code == nil or start_loc_code == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "w¹p Ný€:Nzz!")
        end
        local end_loc_code = obj_attrs[8].value -- È~¹p
        if (end_loc_code == nil or end_loc_code == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "È~¹p Ný€:Nzz!")
        end
 
        -- ·ƒÖSw¹páOo`
        local start_loc
        nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. start_loc)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'w¹p'MOáOo`', start_loc)
        start_loc = json.decode(start_loc)
 
        -- ·ƒÖSw¹pÑ~š[„v¹[hV
        local strCondition = "S_LOC_CODE = '" .. start_loc.code .. "'"
        nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), '9hncw¹p·ƒÖS0'MO¹[hV0áOo`1Y%!' .. strRetInfo)
        end
        local cntr_code = strRetInfo.cntr_code
 
        -- ·ƒÖSÈ~¹páOo`
        local end_loc
        nRet, end_loc = wms.wms_GetLocBaseInfo(end_loc_code)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MOúW,gáOo`1Y%!" .. end_loc)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'È~¹p'MOáOo`', end_loc)
        end_loc = json.decode(end_loc)
        -- Rú^¹pù[¹pûy“^ûN¡R
        local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
        lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
        -- w¹páOo`
        gt_task.start_wh_code = start_loc.wh_code
        gt_task.start_area_code = start_loc.area_code
        gt_task.start_loc_code = start_loc.code
        -- È~¹páOo`
        gt_task.end_wh_code = end_loc.wh_code
        gt_task.end_area_code = end_loc.area_code
        gt_task.end_loc_code = end_loc.code
        gt_task.type = 3
        gt_task.cntr_code = cntr_code
        nRet, gt_task = m3.CreateDataObj(strLuaDEID, gt_task)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0sOûN¡R01Y%!' .. gt_task)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
 
        -- sOûN¡R„vw¹pÈ~¹p'MO
N•
        nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.start_loc_code,
            wms_base.Get_nConst(strLuaDEID, "•{|‹W-úQ“^•"), gt_task.code, gt_task.code,
            "¹pù[¹pûy“^•š['MO")
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo)
        end
        nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.end_loc_code,
            wms_base.Get_nConst(strLuaDEID, "•{|‹W-eQ“^•"), gt_task.code, gt_task.code,
            "¹pù[¹pûy“^•š['MO")
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo)
        end
    end
end