--[[
|
编码: WMS-20-21
|
名称: 呼出空料箱点确定按钮
|
作者:
|
日期:2025-1-29
|
|
函数: ClickOK
|
功能:
|
确定呼出的空料箱,预分配容器创建出库作业
|
|
更改记录:
|
V2.0 HAN 20250113
|
-- 增加后台线程创建组盘出库作业
|
--]]
|
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function ClickOK( strLuaDEID )
|
local nRet, strRetInfo
|
local strCondition, strSetAttr
|
|
-- 这里的 paramter 是在点击领用按钮后,传入的 入库波次对象,如果取消就是删除波次对象
|
nRet, parameter = m3.GetSysInputParameter( strLuaDEID )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取input parameter 失败! "..parameter ) end
|
|
local from = parameter.from
|
if ( from == "Overweight_call" ) then
|
-- 呼出空料箱来自 站台的超重货品入库呼出,需要把【站台货品明细】中相关的记录更新状态
|
local station = lua.Get_StrAttrValue( parameter.station )
|
local bs_type = lua.Get_StrAttrValue( parameter.bs_type )
|
local bs_no = lua.Get_StrAttrValue( parameter.bs_no )
|
if ( station == '' or bs_type == '' or bs_no == '' ) then
|
mobox.stopProgram( strLuaDEID, "paramter 参数中 属性 station, bs_type, bs_no 不能为空!")
|
return
|
end
|
strCondition = "S_STATION_NO = '"..station.."' AND S_BS_TYPE = '"..bs_type.."' AND S_BS_NO = '"..bs_no.."'"
|
strSetAttr = "N_B_STATE = 2" -- 2 系统已组盘完成
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Station_Goods_Detail", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【站台货品明细】信息失败!"..strRetInfo ) end
|
end
|
|
-- 获取入库批次对象
|
local data_obj
|
nRet, data_obj = m3.GetDataObject( strLuaDEID, parameter.cls_id, parameter.obj_id )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), iw_obj ) end
|
local bs_no = ''
|
|
if parameter.cls_id == "Inbound_Wave" then
|
bs_no = data_obj.wave_no
|
elseif parameter.cls_id == "Inbound_Order" then
|
bs_no = data_obj.no
|
else
|
return 1, "parameter.cls_id 参数不合规!"
|
end
|
if bs_no == nil or bs_no == '' then
|
return 1, "parameter.obj_id 参数不合规!"
|
end
|
|
-- 获取入库批次创建的预分配容器,触发这些预分配容器创建出库作业
|
local strCondition = "S_BS_TYPE = '"..parameter.cls_id.."' AND S_BS_NO = '"..bs_no.."'"
|
nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Pre_Alloc_Container", strCondition )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "查询组盘失败! "..data_objs ) end
|
if ( data_objs ~= '' ) then
|
local n, data_attrs
|
|
for n = 1, #data_objs do
|
data_attrs = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)
|
local add_wfp = {
|
wfp_type = 1,
|
cls = "Pre_Alloc_Container",
|
obj_id = lua.trim_guid_str( data_objs[n].id ),
|
obj_name = "预分配料箱流水号'"..data_attrs.S_PAC_NO.."'-->创建作业",
|
trigger_event = "后台创建空料箱出库作业"
|
}
|
nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "AddSysWFP失败!"..strRetInfo )
|
end
|
end
|
end
|
|
local action = {
|
{
|
action_type = "close_dlg",
|
value = ""
|
}
|
}
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end
|
|
end
|