--[[
|
编码: WMS-57-13
|
名称: 取消
|
作者:HAN
|
日期:2025-1-29
|
入口函数: ORGC_Cancel
|
|
功能说明:
|
预分配容器取消,如果组盘没创建作业,或创建了作业还没有执行(WCS层面的执行)均可取消 预分配容器
|
|
更改记录:
|
|
--]]
|
|
wms_in = require( "wms_inbound" )
|
|
function ORGC_Cancel ( strLuaDEID )
|
local nRet, strRetInfo
|
local objs
|
|
-- step1 获取当前点中的【预分配容器】
|
nRet, objs = m3.GetSysDataJson( strLuaDEID )
|
if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end
|
-- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
|
local nCount = #objs
|
if (nCount == 0) then return end
|
|
local obj_attrs
|
local b_state, can_cancel
|
local pac_obj
|
local operation = nil
|
|
for n = 1, nCount do
|
-- 检查一下N_B_STATE是否=0,1 其它的状态不能取消
|
obj_attrs = m3.KeyValueAttrsToObjAttr( objs[n].attrs )
|
if ( obj_attrs.N_B_STATE == nil ) then
|
mobox.setInfo( strLuaDEID, "预分配容器列表中必须要有N_B_STATE字段, 否则无法判断状态!" )
|
return
|
end
|
b_state = lua.Get_NumAttrValue( obj_attrs.N_B_STATE )
|
-- 0 未出库 1 -- 出库中
|
if ( b_state == 0 or b_state == 1 ) then
|
can_cancel = true
|
nRet, pac_obj = m3.GetDataObject( strLuaDEID, "Pre_Alloc_Container", lua.trim_guid_str(objs[n].id) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), pac_obj ) end
|
|
if ( b_state == 1 ) then
|
-- 需要判断一下作业是否可以取消
|
nRet, can_cancel, operation = wms_op.CanCancel( strLuaDEID, pac_obj.out_op_no )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), can_cancel ) end
|
end
|
|
if ( can_cancel ) then
|
nRet, strRetInfo = wms_in.Pre_Alloc_CNTR_Cancel( strLuaDEID, pac_obj )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), can_cancel ) end
|
-- 增加一个后台进程对组盘进行处理,触发配盘明细中的入库波次是否可以完成
|
local add_wfp = {
|
wfp_type = 1,
|
cls = "Pre_Alloc_Container",
|
obj_id = pac_obj.id,
|
obj_name = "组盘'"..pac_obj.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
|
end
|
|
local action = {}
|
if ( nCount == 1 ) then
|
action[1] =
|
{
|
action_type = "refresh_cur_row",
|
value = ""
|
}
|
else
|
action[1] =
|
{
|
action_type = "refresh",
|
value = ""
|
}
|
end
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end
|
|
end
|