--[[
|
编码: JX-40-04
|
名称: 作业查询
|
作者:KUN
|
日期:2025-01-24
|
|
级别:
|
|
函数: Query
|
|
功能:
|
根据查询面板里的输入,组成SQL的查询条件
|
|
--]]
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
lua = require ("oi_base_func")
|
|
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), "GetSysInputParameter 失败! " .. attrs)
|
end
|
parameter = m3.KeyValueAttrsToObjAttr(attrs)
|
|
local b_state = lua.Get_NumAttrValue(parameter.N_B_STATE) -- 状态
|
local createtTime = lua.Get_StrAttrValue(parameter.T_CREATE) -- 开始时间
|
local endTime = lua.Get_StrAttrValue(parameter.T_END_TIME) -- 结束时间
|
local source_sys = lua.Get_StrAttrValue(parameter.S_SOURCE_SYS) -- 来源系统
|
|
local strSQL = ''
|
if (source_sys ~= '' and source_sys ~= '不考虑') then
|
if (strSQL ~= '') then
|
strSQL = strSQL .. " AND "
|
end
|
strSQL = strSQL .. "S_SOURCE_SYS = '" .. source_sys .. "'"
|
end
|
|
-- 生成状态查询
|
local sub_condition = ''
|
|
if (b_state == 0) then
|
sub_condition = "N_B_STATE = 0 "
|
elseif (b_state == 1) then
|
sub_condition = "N_B_STATE = 1 "
|
elseif (b_state == 2) then
|
sub_condition = "N_B_STATE = 2 "
|
elseif (b_state == 3) then
|
sub_condition = "N_B_STATE = 3 "
|
elseif (b_state == 4) then
|
sub_condition = "N_B_STATE = 4 "
|
elseif (b_state == 5) then
|
sub_condition = "N_B_STATE = 5 "
|
elseif (b_state == 6) then
|
sub_condition = "N_B_STATE = 6 "
|
elseif (b_state == 7) then
|
sub_condition = "N_B_STATE = 7 "
|
elseif (b_state == 8) then
|
sub_condition = "N_B_STATE = 8 "
|
end
|
if (sub_condition ~= '') then
|
if (strSQL ~= '') then strSQL = strSQL .. " AND " end
|
strSQL = strSQL .. sub_condition
|
end
|
if (createtTime ~= '') then
|
if (strSQL ~= '') then
|
strSQL = strSQL .. " AND "
|
end
|
strSQL = strSQL .. "T_CREATE >= '" .. createtTime .. "'"
|
end
|
|
if (endTime ~= '') then
|
if (strSQL ~= '') then
|
strSQL = strSQL .. " AND "
|
end
|
strSQL = strSQL .. "T_END_TIME <= '" .. endTime .. "'"
|
end
|
|
|
-- 设置查询条件
|
local action = {}
|
action[1] = {
|
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.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. lua.table2str(action))
|
end
|
end
|