--[[
|
编码: WMS-08-20
|
名称: 查询面板-查询
|
作者: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.Stop( strLuaDEID, "GetRuntimeParam失败! "..runtime_parameter )
|
return
|
end
|
local strSQL = lua.Get_StrAttrValue( runtime_parameter.base_condition )
|
|
-- 获取查询面板里的输入属性
|
nRet, attrs = m3.GetSysInputParameter( strLuaDEID )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "m3.GetSysInputParameter 失败! "..attrs )
|
return
|
end
|
parameter = m3.KeyValueAttrsToObjAttr( attrs )
|
local task_code = lua.Get_StrAttrValue( parameter.S_TASK_CODE ) -- 任务编码
|
local cntr_code = lua.Get_StrAttrValue( parameter.S_CNTR_CODE ) -- 容器编码
|
local action = lua.Get_StrAttrValue( parameter.S_ACTION ) -- 动作
|
local dev_id = lua.Get_StrAttrValue( parameter.S_EQ_CODE ) -- 设备编码
|
|
if ( cntr_code ~= '' ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = "S_CNTR_CODE = '"..cntr_code.."'"
|
end
|
if (task_code ~= '' ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = strSQL.."S_TASK_CODE = '"..task_code.."'"
|
end
|
|
if ( action ~= '' ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = strSQL.."S_ACTION = '"..action.."'"
|
end
|
|
if ( dev_id ~= '' ) then
|
if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
|
strSQL = strSQL.."S_EQ_CODE = '"..dev_id.."'"
|
end
|
|
-- 设置查询条件
|
local action = {
|
{
|
action_type = "set_query_condition",
|
value = {
|
condition = strSQL,
|
order = "T_CREATE Desc"
|
}
|
}
|
}
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action ) )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction )
|
return
|
end
|
|
end
|