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
ÿþ--[[
   x: GT-19-13
    Tðy: 
   \O€ÿ
   åegÿ2025-06-19
 
   ýQpeÿ Query
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require ("oi_base_mobox")
 
function Query(strLuaDEID)
    local nRet, strRetInfo
    local parameter = {}
    local attrs
    local strSQL = ''
    -- ·ƒÖSågâ‹b—g̑„v“eQ^\'`
    nRet, attrs = m3.GetSysInputParameter(strLuaDEID)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetSysInputParameter 1Y%! " .. attrs)
    end
    parameter = m3.KeyValueAttrsToObjAttr(attrs)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'attrs', attrs)
 
    local cntr_code = lua.Get_StrAttrValue(parameter.S_CNTR_CODE)           -- ™e±{x
    local area_code = lua.Get_StrAttrValue(parameter.S_AREA_CODE)                   -- egnN¡RUS÷S
    local item_code = lua.Get_StrAttrValue(parameter.S_ITEM_CODE)           -- ir™ex
    local type = lua.Get_StrAttrValue(parameter.S_TYPE)                 -- ¨R\O{|‹W Tðy
    local batch_no = lua.Get_StrAttrValue(parameter.S_BATCH_NO)          -- Ó~_göeô•
 
    -- „gú^ågâ‹agöN
    if (area_code ~= '') then
        if (strSQL ~= '') then strSQL = strSQL .. " AND " end
        strSQL = strSQL .. "S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_Loc_Container WHERE S_LOC_CODE IN (SELECT S_CODE FROM TN_Location WHERE S_AREA_CODE LIKE '%%" .. area_code .. "%%'))"
    end
    if (cntr_code ~= '') then
        if (strSQL ~= '') then strSQL = strSQL .. " AND " end
        strSQL = strSQL .. "S_CNTR_CODE like '%%" .. cntr_code .. "%%'"
    end
    if (item_code ~= '') then
        if (strSQL ~= '') then strSQL = strSQL .. " AND " end
        strSQL = strSQL .. "S_ITEM_CODE like '%%" .. item_code .. "%%'"
    end
    
    if (batch_no ~= '') then
        if (strSQL ~= '') then
            strSQL = strSQL .. " AND "
        end
        strSQL = strSQL .. "S_BATCH_NO like '%%" .. batch_no .. "%%'"
    end
    
    if (type == '™e') then
        if (strSQL ~= '') then
            strSQL = strSQL .. " AND "
        end
        strSQL = strSQL .. "N_IS_TL = 1"
    elseif(type == ' YÀh') then
        if (strSQL ~= '') then
            strSQL = strSQL .. " AND "
        end
        strSQL = strSQL .. "N_IS_FJ = 1"
    end
 
    -- ¾‹någâ‹agöN
    local action = {}
    action[1] = {
        action_type = "set_query_condition",
        value = {
            condition = strSQL,
            order = "a.T_CREATE DESC"
        }
    }
    
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction1Y%! " .. strRetInfo .. ' action = ' .. strAction)
    end
end