wsz
2025-06-20 19898bd66dec87b500b200d5d50961d0fb538ce5
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
--[[
    编码: WMS-04-11
    名称: 货位-查询面板-查询
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: Query
 
    功能:
        根据查询面板里的输入,组成SQL的查询条件
 
    更改记录:
            加了一个货位查询,自定义表单也加了对应的查询条件
     
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function Query ( strLuaDEID ) 
    local nRet, strRetInfo
    local parameter = {}
    local attrs
 
    -- 获取查询面板里的输入属性
    nRet, attrs = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "m3.GetSysInputParameter 失败! "..attrs ) end 
    parameter = m3.KeyValueAttrsToObjAttr( attrs )
 
    local wh_code = lua.Get_StrAttrValue( parameter.S_WH_CODE )          
    local area_code = lua.Get_StrAttrValue( parameter.S_AREA_CODE ) 
    local aisle = lua.Get_NumAttrValue( parameter.Aisle ) 
    local row = lua.Get_NumAttrValue( parameter.Row )  
    local empty_full = lua.Get_StrAttrValue( parameter.EmptyFull )
    local code = lua.Get_StrAttrValue(parameter.S_CODE)--货位查询
    local lock = lua.Get_StrAttrValue( parameter.LockState ) 
    
 
    local strSQL = ''
 
    if ( wh_code ~= '' ) then
        strSQL = "S_WH_CODE = '"..wh_code.."'"
    end
    if ( area_code ~= '' ) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = strSQL.."S_AREA_CODE = '"..area_code.."'"
    end
    if ( code ~= '' ) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = strSQL.."S_CODE = '"..code.."'"
    end
    if ( aisle > 0 ) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = strSQL.."N_AISLE = "..aisle
    end
    if ( row > 0 ) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = strSQL.."N_ROW = "..row
    end    
 
    -- 生成空满状态查询
    local sub_condition = ''
    if ( empty_full == '空') then
        sub_condition = "N_CURRENT_NUM = 0 "
    elseif ( empty_full == '满') then
        sub_condition = "N_CURRENT_NUM = N_CAPACITY "
    elseif ( empty_full == '未满') then
        sub_condition = "N_CURRENT_NUM < N_CAPACITY "
    end
    if ( sub_condition ~= '' ) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = strSQL..sub_condition
    end
    -- 生成锁状态查询
    sub_condition = ''
    if ( lock == '无') then
        sub_condition = "N_LOCK_STATE = 0 "
    elseif ( lock == '入库锁') then
        sub_condition = "N_LOCK_STATE = 1 "
    elseif ( lock == '出库锁') then
        sub_condition = "N_LOCK_STATE = 2 "
    elseif ( lock == '其它') then
        sub_condition = "N_LOCK_STATE = 3 "                
    end
    if ( sub_condition ~= '' ) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = strSQL..sub_condition
    end
 
    -- 设置查询条件
    local action = {}
    action[1] = {
        action_type = "set_query_condition",
        value = {
            condition = strSQL,
            order = "S_CODE"
        }
    }
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action )  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
 
end