--[[
|
编码: JX-65-15
|
名称:
|
作者:
|
日期:2025-04-14
|
|
函数: Query
|
功能:
|
|
更改记录:
|
|
--]]
|
|
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_CNTR_CODE) -- 料箱编码
|
local bs_no = lua.Get_StrAttrValue(parameter.S_BS_NO) -- 来源业务单号
|
local item_code = lua.Get_StrAttrValue(parameter.S_ITEM_CODE) -- 物料编码
|
local action = lua.Get_StrAttrValue(parameter.S_ACTION) -- 动作类型名称
|
local createtTime = lua.Get_StrAttrValue(parameter.T_CREATE) -- 创建时间
|
local endTime = lua.Get_StrAttrValue(parameter.T_END_TIME) -- 结束时间
|
|
-- 构建查询条件
|
if (bs_no ~= '') then
|
if (strSQL ~= '') then strSQL = strSQL .. " AND " end
|
strSQL = strSQL .. "S_BS_NO like '%%" .. bs_no .. "%%'"
|
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 (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_CREATE < '" .. endTime .. "'"
|
end
|
|
-- 生成回报状态查询
|
local sub_condition = ''
|
if (action == '入库') then
|
sub_condition = "S_ACTION = + "
|
elseif (action == '出库') then
|
sub_condition = "S_ACTION = - "
|
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 = "T_CREATE DESC"
|
}
|
}
|
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction)
|
end
|
end
|