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
ÿþ-- 9hncyb!k·ƒÖSËz“^úQ“^'MO
-- OHQ§~ 10YñmMO \ 20YñmMO¡l    g'ÁT„vUS*N…QñmMO
local function GT_GetLocCodeByBatchNo(strLuaDEID, batch_no)
    -- ·ƒÖSYñmMO'MO
    local nRet, inside_data
    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"
    -- ågâ‹ÔÞV„vW[µk
    local strAttrInfo = " a.S_LOC_CODE,a.S_CNTR_CODE "
    -- ågâ‹agöN yb!k÷Søv T ¹[hV¡l    g
N• 'MO:NYñmMO 'MO¡l    g
N•
    local strCondition = "b.S_BATCH_NO = '" .. batch_no .. "' AND c.N_POS = 1 AND c.N_LOCK_STATE = 0 AND c.S_AREA_CODE = 'LK'"
    nRet, inside_data = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. inside_data) end
    -- ‚Yœgå‹yb!k NX[(WYñmMO„v'MORåg⋅QñmMO'MO
    if (inside_data == '') then
        strCondition = "b.S_BATCH_NO = '" .. batch_no .. "' AND c.N_POS = 2 AND c.N_LOCK_STATE = 0 AND c.S_AREA_CODE = 'LK'"
        nRet, inside_data = mobox.queryMultiTable(strLuaDEID, strAttrInfo, strFromTabInfo, 1, strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "queryMultiTable1Y%! " .. inside_data) end
        if (inside_data == '') then lua.Error(strLuaDEID, debug.getinfo(1), "Ëz“^ NX[(Wyb!k÷S:N" .. batch_no .. "„v'ÁT!") end
    end
    inside_data = json.decode(inside_data)
    local loc_code = inside_data[1][1]  -- 'MO
    local cntr_code = inside_data[1][2] -- ¹[hV
    lua.Debug(strLuaDEID, debug.getinfo(1), ''MO', loc_code)
    lua.Debug(strLuaDEID, debug.getinfo(1), '¹[hV', cntr_code)
    return loc_code, cntr_code
end
--[[
    x: GT-Public-06
     Tðy: ¹pûQnxš[    c®”T
    \O€ÿLZH
    åegÿ2024-9-10
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ AfterClickOk
 
    ŸRý€:
        1ÿ!hŒš¹[hV/f&TX[(WËz“^
        2ÿRú^úQ“^\ON ÿÎN¹[hV„vwËYMOnúQ0R¢”N,{    N*N
N¿~ãS
 
 
    ôf9e°‹U_:
 
--]]
json  = require("json")
mobox = require("OILua_JavelinExt")
wms_wh = require( "wms_wh" )
wms_base = require( "wms_base" )
wms_cntr = require( "wms_container" )
function AfterClickOk(strLuaDEID)
    local nRet, strRetInfo
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_BATCH_NO", "N_CNTR_QTY")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    lua.Debug(strLuaDEID, debug.getinfo(1), ' YÀhúQ“^nxš[TÂSpe', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local batch_no = obj_attrs[1].value -- yb!k÷S
    local cntr_qty = obj_attrs[2].value --  YÀhXbpe
 
    -- 10!hŒš YÀhXbpe/f&T/f tepe pe<P{|‹W
    if (cntr_qty ~= nil and cntr_qty ~= '') then
        local qty = lua.StrToNumber(cntr_qty)
        if qty < 0 or qty ~= math.floor(qty) then
            mobox.steInfo(strLuaDEID, "÷‹“eQcktepe!")
            return
        end
    end
 
    local strCondition = "S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_CG_Detail WHERE S_BATCH_NO = '" ..
        batch_no .. "')"
 
    -- 20!hŒšyb!k÷S/f&TX[(W“^X[
    if (batch_no ~= nil and batch_no ~= '') then
        nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Loc_Container", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
        if (tonumber(strRetInfo) <= 0) then
            mobox.steInfo(strLuaDEID, "yb!k÷S¡l    g“^X[!")
            return
        end
    end
 
    -- 30!hŒšyb!k÷S“^X[/f&Tán³“eQ„v YÀhXbpe
    if (cntr_qty ~= nil and cntr_qty ~= '' and batch_no ~= nil and batch_no ~= '') then
        nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Loc_Container", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
        if (tonumber(strRetInfo) < tonumber(cntr_qty)) then
            mobox.steInfo(strLuaDEID, "yb!k÷S„v“^X[ Nán³ YÀhXbpe!")
            return
        end
    end
 
    local start_loc, end_loc
    for i = 1, tonumber(cntr_qty) do
        -- 9hncyb!k÷S·ƒÖS'MOx
        local loc_code, cntr_code = GT_GetLocCodeByBatchNo(strLuaDEID, batch_no)
        -- ·ƒÖSw¹p
        nRet, start_loc = wms_wh.Location_GetInfo(strLuaDEID, loc_code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WMS_Location_GetInfo1Y%!" .. start_loc) end
        -- ·ƒÖSÈ~¹p
        nRet, end_loc = wms_wh.Location_GetInfo(strLuaDEID, "GSSXK-03")
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WMS_Location_GetInfo1Y%!" .. end_loc) end
 
        -- step3 Rú^\ON
        local operation           = m3.AllocObject(strLuaDEID, "Operation")
        -- w¹páOo`
        operation.start_wh_code   = start_loc.wh_code
        operation.start_area_code = start_loc.area_code
        operation.start_loc_code  = start_loc.code
        -- È~¹páOo`
        operation.end_wh_code     = end_loc.wh_code
        operation.end_area_code   = end_loc.area_code
        operation.end_loc_code    = end_loc.code
 
        operation.op_type         = wms_base.Get_nConst(strLuaDEID, "\ON{|‹W-úQ“^")
        operation.op_def_name     = " YÀhúQ“^"
        operation.cntr_code       = cntr_code
 
        -- àV:N/f(W\ON̑b—1\—‰•š['MO ÿ@båNÐcMRK<P–™!kûN¡R÷S ÿ(uŽN•š['MO
        local strCode             = ''
        local strHeader           = 'TA' .. os.date("%y%m%d") .. '-'
        nRet, strCode             = mobox.getSerialNumber("ûN¡R", strHeader, 5)
        -- ¾‹nibU\ÂSpe&^eQ\ON/T¨R ÿûN¡RŒ[b
        local ext_table           = {}
        ext_table.task_no         = strCode
        -- ibU\ÂSpe
        operation.ext_data        = lua.table2str(ext_table)
        nRet, operation           = m3.CreateDataObj(strLuaDEID, operation)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0\ON01Y%!' .. operation) end
 
        -- Ù~w¹p'MO R
NúQ“^•
        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
    end
    mobox.setInfo(strLuaDEID, " YÀhúQ“^ûN¡R NÑSbŸR!")
end