lzh
2025-06-19 3a6436e0c88042c6ce8dca2fe8adb0109f0ad9e4
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
local function QueryEndLoc(strLuaDEID, str, end_roadway)
    -- 获取最里面的空货位
 
    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" -- 最近巷道口
    -- 最多获取 10 条
    local nRet, strRetInfo = mobox.queryDataObjAttr3(strLuaDEID, "Location", strCondition, 10, strOrder)
    if (nRet ~= 0) then
        return 2, "获取货位信息错误! " .. strRetInfo .. " SQL条件: " .. 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) 失败! " .. loc
        end
        return 0, loc.code
    end
 
    -- 获取最外面的空货位
    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 ..
                       ")"
    -- 最多获取 10 条
    nRet, strRetInfo = mobox.queryDataObjAttr3(strLuaDEID, "Location", strCondition, 10, strOrder)
    if (nRet ~= 0) then
        return 2, "获取货位信息错误! " .. strRetInfo .. " SQL条件: " .. 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) 失败! " .. loc
        end
        return 0, loc.code
    end
 
    return 2, "没有空货位!"
end
--[[
   编码: GT-122-31
   名称:
   作者:
   日期:2025-04-22
 
   函数: ClickOk
   功能:  根据界面下拉框的类型 是指定巷道移库还是指定货位移库,指定货位移库则直接创建点对点佳通任务,
          指定巷道移库则需要获取巷道该物料、批次的容器,然后循环创建佳通任务
 
   更改记录:
    20240424 LZH V1.1 终点需要根据物料判断,钢丝去1~3层,胶料优先4~12,其次才是1~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
    -- 获取数据
    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), "获取当前编辑属性失败! " .. strRetInfo)
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local type = obj_attrs[1].value -- 类型
    if (type == '指定巷道移库') then
        local item_code = obj_attrs[2].value -- 物料号
        if (item_code == nil or item_code == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "物料号不能为空!")
        end
        local batch_no = obj_attrs[3].value -- 批次号
        if (batch_no == nil or batch_no == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "批次号不能为空!")
        end
        local start_roadway = obj_attrs[4].value -- 起始巷道
        if (start_roadway == nil or start_roadway == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "起始巷道不能为空!")
        end
        local end_roadway = obj_attrs[5].value -- 目的巷道
        if (end_roadway == nil or end_roadway == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "目的巷道不能为空!")
        end
        local qty = lua.StrToNumber(obj_attrs[6].value) -- 托数
        if qty <= 0 or qty ~= math.floor(qty) then
            lua.Error(strLuaDEID, debug.getinfo(1), "托数不能为0、小数或负数!")
        end
 
        -- 如果巷道相同则直接报错退出
        if (start_roadway == end_roadway) then
            lua.Error(strLuaDEID, debug.getinfo(1), "起始巷道和目的巷道不能相同!")
        end
 
        -- 判断巷道内该批次的物料托数是否能满足需要出的托数
        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"
        -- 查询返回的字段
        local strAttrInfo = " count(1) "
        -- 查询条件 物料编码和批次号相同,容器没有上锁,货位为内深位
        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), "queryMultiTable失败! " .. 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), "库存不满足移库的托数!")
        end
 
        -- 循环创建佳通任务
        for i = 1, qty do
            -- step2 获取内深位和外深位的托盘数量,如果内深位数量多则先出内深位 如果内深位和外深位数量相等则优先出外深位
            -- 查询内深位的托盘数量
            local inside_num, outside_num, inside_info, outside_info
            -- 查询返回的字段
            strAttrInfo = " count(1) "
            -- 查询条件 物料编码和批次号相同,容器没有上锁,货位为内深位
            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), "queryMultiTable失败! " .. inside_num)
            end
            inside_num = json.decode(inside_num)
            inside_num = tonumber(inside_num[1][1])
            lua.Debug(strLuaDEID, debug.getinfo(1), '内深位数量', inside_num)
 
            -- 查询条件 物料编码和批次号相同,容器没有上锁,货位为外深位
            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), "queryMultiTable失败! " .. outside_num)
            end
            outside_num = json.decode(outside_num)
            outside_num = tonumber(outside_num[1][1]) -- 外深位数量
            lua.Debug(strLuaDEID, debug.getinfo(1), '外深位数量', outside_num)
 
            -- 判断 内 > 外 数量,优先出多的内深位
            local start_loc, cntr_code
            if (tonumber(inside_num) > tonumber(outside_num)) then
                -- 获取起点和容器
                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), "queryMultiTable失败! " .. 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)
 
                    -- 判断对应的外深位是否存在货品或者正在执行
                    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)
 
                    -- 判断外深位是否存在货品并且货位未上锁,存在则创建移库作业,不存在则直接返回货位编码
                    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
                        -- 获取起点信息
                        nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. start_loc)
                        end
                        lua.Debug(strLuaDEID, debug.getinfo(1), '起点货位信息', start_loc)
                        start_loc = json.decode(start_loc)
                        break
                    else
                        -- 外深位有东西则触发被动移库
                        -- 获取起点信息
                        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_GetLocInfo失败!' .. start_loc)
                        end
 
                        -- 获取容器信息
                        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),
                                "获取【货位容器】信息失败! " .. new_cntr_loc)
                        end
 
                        -- 获取货品信息
                        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),
                                "获取【容器货品明细】信息失败! " .. new_cg_detail)
                        end
 
                        -- 获取物料类型
                        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 == '钢丝') then
                            layer = wms_base.Get_sConst(strLuaDEID, "佳通-立库钢丝货位层")
                        else
                            layer = wms_base.Get_sConst(strLuaDEID, "佳通-立库非钢丝货位层")
                        end
 
                        -- 获取终点信息
                        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
 
                        -- 创建佳通任务
                        local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
                        -- 起点信息
                        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
                        -- 终点信息
                        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 粉料调拨搬运 2 烘胶搬运 3 同巷道移库
                        gt_task.priority = 2 -- 大的优先
                        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), '创建【佳通任务】失败!' .. gt_task)
                        end
 
                        -- 获取起点信息
                        nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                        if (nRet ~= 0) then
                            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. start_loc)
                        end
                        lua.Debug(strLuaDEID, debug.getinfo(1), '起点货位信息', start_loc)
                        start_loc = json.decode(start_loc)
                        break
                    end
 
                    ::continue::
                end
                if (start_loc == nil) then
                    -- 获取起点和容器
                    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), "queryMultiTable失败! " .. outside_info)
                    end
                    outside_info = json.decode(outside_info)
                    local start_loc_code = outside_info[1][1]
                    cntr_code = outside_info[1][2]
 
                    -- 获取起点信息
                    nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                    if (nRet ~= 0) then
                        lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. start_loc)
                    end
                    lua.Debug(strLuaDEID, debug.getinfo(1), '起点货位信息', start_loc)
                    start_loc = json.decode(start_loc)
                end
            elseif (tonumber(inside_num) <= tonumber(outside_num)) then
                -- 获取起点和容器
                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), "queryMultiTable失败! " .. outside_info)
                end
                outside_info = json.decode(outside_info)
                local start_loc_code = outside_info[1][1]
                cntr_code = outside_info[1][2]
 
                -- 获取起点信息
                nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. start_loc)
                end
                lua.Debug(strLuaDEID, debug.getinfo(1), '起点货位信息', start_loc)
                start_loc = json.decode(start_loc)
            end
 
            -- 获取终点
            -- 获取容器上的物料
            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
            -- 获取物料类型
            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), '物料信息', material)
            -- 钢丝只能入指定层
            local str, end_loc_code
            if (item_type == '钢丝') then
                str = wms_base.Get_sConst(strLuaDEID, "佳通-立库钢丝货位层")
                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), "没有可移库货位!")
                end
            else
                str = wms_base.Get_sConst(strLuaDEID, "佳通-立库非钢丝货位层")
                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, "佳通-立库钢丝货位层")
                    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), "没有可移库货位!")
                    end
                end
            end
 
            -- 获取终点信息
            local end_loc
            nRet, end_loc = wms.wms_GetLocBaseInfo(end_loc_code)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. end_loc)
            end
            lua.Debug(strLuaDEID, debug.getinfo(1), '终点货位信息', end_loc)
            end_loc = json.decode(end_loc)
            -- 创建点对点移库任务
            local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
            lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
            -- 起点信息
            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
            -- 终点信息
            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), '创建【佳通任务】失败!' .. gt_task)
            end
            lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
 
            -- 佳通任务的起点终点货位上锁
            nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.start_loc_code,
                wms_base.Get_nConst(strLuaDEID, "锁类型-出库锁"), gt_task.code, gt_task.code,
                "指定巷道移库锁定货位")
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo)
            end
            nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.end_loc_code,
                wms_base.Get_nConst(strLuaDEID, "锁类型-入库锁"), gt_task.code, gt_task.code,
                "指定巷道移库锁定货位")
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo)
            end
        end
    else
        local start_loc_code = obj_attrs[7].value -- 起点
        if (start_loc_code == nil or start_loc_code == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "起点不能为空!")
        end
        local end_loc_code = obj_attrs[8].value -- 终点
        if (end_loc_code == nil or end_loc_code == '') then
            lua.Error(strLuaDEID, debug.getinfo(1), "终点不能为空!")
        end
 
        -- 获取起点信息
        local start_loc
        nRet, start_loc = wms.wms_GetLocBaseInfo(start_loc_code)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. start_loc)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), '起点货位信息', start_loc)
        start_loc = json.decode(start_loc)
 
        -- 获取起点绑定的容器
        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), '根据起点获取【货位容器】信息失败!' .. strRetInfo)
        end
        local cntr_code = strRetInfo.cntr_code
 
        -- 获取终点信息
        local end_loc
        nRet, end_loc = wms.wms_GetLocBaseInfo(end_loc_code)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "获取货位基本信息失败!" .. end_loc)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), '终点货位信息', end_loc)
        end_loc = json.decode(end_loc)
        -- 创建点对点移库任务
        local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
        lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
        -- 起点信息
        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
        -- 终点信息
        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), '创建【佳通任务】失败!' .. gt_task)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'gt_task', gt_task)
 
        -- 佳通任务的起点终点货位上锁
        nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.start_loc_code,
            wms_base.Get_nConst(strLuaDEID, "锁类型-出库锁"), gt_task.code, gt_task.code,
            "点对点移库锁定货位")
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo)
        end
        nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, gt_task.end_loc_code,
            wms_base.Get_nConst(strLuaDEID, "锁类型-入库锁"), gt_task.code, gt_task.code,
            "点对点移库锁定货位")
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo)
        end
    end
end