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
ÿþ--[[
   x: GT-122-27
    Tðy:
   \O€ÿ
   åegÿ2025-03-26
 
   ýQpeÿ ClickOk
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
function ClickOk(strLuaDEID)
    local nRet, strRetInfo
    -- ·ƒÖSPDAÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "start_loc_code", "end_loc_code")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¹eÕlGetSysDataJsonúQ•") end
    local obj_attrs = json.decode(strRetInfo)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'obj_attrs', obj_attrs)
 
 
    local start_loc_code = obj_attrs[1].value
 
    -- ·ƒÖSw¹p¹[hV
    local cntr_loc
    local strCondition = "S_LOC_CODE = '" .. start_loc_code .. "'"
    nRet, cntr_loc = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0'MO¹[hV0áOo`1Y%! ") end
 
    -- ·ƒÖSw¹p
    local start_loc
    nRet, start_loc = wms_wh.GetLocInfo(start_loc_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo1Y%!' .. start_loc) end
 
    -- ‚Yœgw¹p:N…QñmMO—‰$R­eYñmMO/f&T
N• 
N•R¥b•Ðc:y ÿX[(W'ÁTRæ‰ÑS«ˆ¨Rûy“^
    if (tonumber(start_loc.pos) == 2) then
        -- ·ƒÖSù[”^YñmMO
        local new_loc_code
        nRet, new_loc_code = OuterDeepPosition(strLuaDEID, start_loc.row_group, start_loc.code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), new_loc_code) end
 
        -- $R­e/f&T
N•
        strCondition = "S_CODE = '" .. new_loc_code .. "' AND N_LOCK_STATE = 0"
        nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Location", strCondition)
        if (nRet == 1) then
            mobox.setInfo(strLuaDEID, "w¹pù[”^„vYñmMOò]
N•!")
            return
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
        end
 
        -- $R­e/f&TX[(W'ÁT ÿX[(W—‰ûy“^
        strCondition = "S_CODE = '" .. new_loc_code .. "' AND N_CURRENT_NUM = 1"
        nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Location", strCondition)
        if (nRet == 1) then
            goto back
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
        end
 
        -- Rú^ûy“^\ON
        -- ·ƒÖ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
    end
    ::back::
 
    local end_loc_code = obj_attrs[2].value
    -- ÇÙzðSMOn·ƒÖSÈ~¹p
    -- end_loc_code = wms_base.Get_sConst(strLuaDEID, end_loc_code)
    -- ·ƒÖSÈ~¹p
    local end_loc
    nRet, end_loc = wms_wh.GetLocInfo(end_loc_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo1Y%!' .. end_loc) end
 
    -- step4: Rú^,dЏ\ON
    local operation           = m3.AllocObject(strLuaDEID, "Operation")
    operation.start_wh_code   = start_loc.wh_code
    operation.start_area_code = start_loc.area_code
    operation.start_loc_code  = start_loc.code
 
    -- È~¹p/fsOWMS OǏeg„v
    operation.end_wh_code     = end_loc.wh_code
    operation.end_area_code   = end_loc.area_code
    operation.end_loc_code    = end_loc.code
 
    local strCode
    local ext_table           = {}
    local strHeader           = 'TA' .. os.date("%y%m%d") .. '-'
    nRet, strCode             = mobox.getSerialNumber("ûN¡R", strHeader, 5)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '3u÷‹0ûN¡R0x1Y%!' .. strCode) end
    ext_table.task_no     = strCode
    operation.ext_data    = lua.table2str(ext_table)
 
    operation.cntr_code   = cntr_loc.cntr_code
    operation.op_def_name = "¹pù[¹púQ“^"
    operation.op_type     = wms_base.Get_nConst(strLuaDEID, "\ON{|‹W-úQ“^")
    nRet, operation       = m3.CreateDataObj(strLuaDEID, operation)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0\ON01Y%!' .. operation) end
 
    -- w¹p R•Íd\O
    nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.start_loc_code,
        wms_base.Get_nConst(strLuaDEID, "•{|‹W-úQ“^•"),
        strCode, operation.code, operation.op_def_name)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo) end
 
    mobox.setInfo(strLuaDEID, "Íd\ObŸR!")
end