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
ÿþ--[[
   x: GT-Public-07
    Tðy: ceňö€_8^Yt
   \O€ÿLZH
   åegÿ2024-10-14
 
   ýQpeÿ AfterClickOk
   ŸRý€:  Çyb!k÷Sågâ‹>\XbúQ“^ ÿv^Œ(uWMS¥cãSÍSˆ™yb!k÷SŒTYYO„vceňö€WWpe
 
   ôf9e°‹U_:
 
--]]
 
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
wms_wh = require( "wms_wh" )
function AfterClickOk(strLuaDEID)
    local nRet, strRetInfo
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_BATCH_NO", "N_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 qty = obj_attrs[2].value      -- ceňö€YYOWWpe
 
    -- !hŒš YÀhXbpe/f&T/f tepe pe<P{|‹W
    if (qty ~= nil and qty ~= '') then
        qty = lua.StrToNumber(qty)
        if qty < 0 or qty ~= math.floor(qty) then
            mobox.steInfo(strLuaDEID, "÷‹“eQcktepe!")
            return
        end
    end
 
    -- 9hncyb!k÷Sågâ‹>\Xb
    local strCondition = "S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_CG_Detail WHERE S_BATCH_NO = '" .. batch_no .. "')"
    strCondition = strCondition .. " AND S_LOC_CODE <> 'GSSXK-03'"
    nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Loc_Container", strCondition, "T_CREATE DESC")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS'MO¹[hVÑ~š[1Y%!") end
    local attrs = json.decode(strRetInfo)[1].attrs
    attrs = m3.KeyValueAttrsToObjAttr(attrs)
    local cntr_code = attrs.S_CNTR_CODE
    local loc_code = attrs.S_LOC_CODE
 
    local start_loc,end_loc
    -- ·ƒÖ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
 
 
    -- Œ(uWMSÍSˆ™¥cãS
 
    mobox.setInfo(strLuaDEID, "ceňö€ YÀhúQ“^ûN¡R NÑSbŸR!")
end