--[[
|
编码: WMS-01-20#1
|
名称: 容器-查询面板-查询
|
作者:HAN
|
日期:2025-01-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
|
|
-- 改进测试
|
|
local runtime_parameter
|
nRet, runtime_parameter = m3.GetRuntimeParam(strLuaDEID)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetRuntimeParam失败! "..runtime_parameter ) end
|
local strSQL = lua.Get_StrAttrValue( runtime_parameter.base_condition )
|
|
-- 获取查询面板里的输入属性
|
nRet, attrs = m3.GetSysInputParameter( strLuaDEID )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "m3.GetSysInputParameter 失败! "..attrs ) end
|
parameter = m3.KeyValueAttrsToObjAttr( attrs )
|
local cntr_code = lua.Get_StrAttrValue( parameter.S_CODE ) -- 容器编码
|
local cntr_spec = lua.Get_StrAttrValue( parameter.S_SPEC ) -- 规格
|
local empty_full = lua.Get_StrAttrValue( parameter.EmptyFull ) -- 空满状态
|
local lock = lua.Get_StrAttrValue( parameter.S_LOCK_STATE ) -- 锁状态
|
local bind_loc = parameter.InWHArea
|
|
if ( cntr_code ~= '' ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = "S_CODE = '"..cntr_code.."'"
|
end
|
if (cntr_spec ~= '' and cntr_spec ~= '全部' ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = strSQL.."S_SPEC = '"..cntr_spec.."'"
|
end
|
-- 生成空满状态查询
|
local sub_condition = ''
|
if ( empty_full == '空') then
|
sub_condition = "N_EMPTY_FULL = 0 "
|
elseif ( empty_full == '满') then
|
sub_condition = "N_EMPTY_FULL = 2 "
|
elseif ( empty_full == '未满') then
|
sub_condition = "N_EMPTY_FULL = 1 "
|
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 = 4 "
|
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
|
-- 是否已经和货位绑定
|
if ( #bind_loc > 0 ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = strSQL.." S_POSITION <> ''"
|
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
|