--[[
|
编码: WMS-81-02
|
名称: 出入库测试-创建后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterDataObjCreate
|
|
功能:
|
-- 如果是 入库 创建后,会把 容器和目标货位进行绑定,并且增加库区、仓库量
|
-- 如果是 出库 创建后,容器和货位解绑,减库区、仓库量
|
更改记录:
|
--]]
|
|
wms_wh = require( "wms_wh" )
|
wms_inv = require( "wms_inventory" )
|
wms_pallet = require ("wms_palletizing")
|
|
function AfterDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
|
-- step1: 获取当前【出入库测试】对象
|
local test
|
nRet, test = m3.GetSysCurEditDataObj( strLuaDEID, "WMS_TEST_WH_IO" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "获取当前编辑属性失败! "..test )
|
return
|
end
|
if ( test.cntr_code == '' or test.cntr_code == nil ) then
|
lua.Stop( strLuaDEID, "容器号不能为空! " )
|
return
|
end
|
if (test.test_type == "入库") then
|
if (test.loc_code == nil or test.loc_code == nil ) then
|
lua.Stop( strLuaDEID, "入库必须要确定货位! " )
|
return
|
end
|
local loc
|
nRet, loc = wms_wh.GetLocInfo( test.loc_code)
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "WMS_GetLocInfo失败! "..loc )
|
return
|
end
|
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding( strLuaDEID, test.loc_code, test.cntr_code, "绑定解绑方法-人工", "测试数据用例" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, '货位容器绑定失败!'..strRetInfo )
|
return
|
end
|
|
-- 加库区/库量表
|
local cntr_from = test.cntr_from or ''
|
if ( cntr_from == "码盘单" ) then
|
local inb_pallet
|
nRet, inb_pallet = wms_pallet.Get_Current_INBP( strLuaDEID, test.cntr_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "查询【Inbound_Palletization】出错!"..inb_pallet )
|
return
|
end
|
nRet, strRetInfo = wms_inv.After_CntrLoc_Binding( strLuaDEID, inb_pallet, test.loc_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, 'wms_inv.After_CntrLoc_Binding 失败!'..strRetInfo )
|
return
|
end
|
elseif ( cntr_from == '' ) then
|
lua.Stop( strLuaDEID, '无法确定容器来源' )
|
return
|
end
|
elseif (test.test_type == "出库") then
|
local loc_code = wms_wh.GetLocCodeByCNTR( strLuaDEID, test.cntr_code )
|
if ( loc_code == "") then
|
lua.Stop( strLuaDEID, "容器号'"..test.cntr_code.."'没有和货位绑定!" )
|
return
|
end
|
local loc
|
bRet, loc = wms_wh.GetLocInfo( loc_code)
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "WMS_GetLocInfo失败! "..loc )
|
return
|
end
|
|
nRet, strRetInfo = wms_wh.Loc_Container_Unbinding( strLuaDEID, loc.code, test.cntr_code, "绑定解绑方法-人工", "测试数据用例" )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, '货位容器绑定失败!'..strRetInfo )
|
return
|
end
|
|
-- 容器和货位解绑后
|
nRet, strRetInfo = wms_inv.After_CntrLoc_UnBinding(strLuaDEID, test.cntr_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, 'wms_inv.After_CntrLoc_UnBinding 失败!'..strRetInfo )
|
return
|
end
|
else
|
lua.Stop( strLuaDEID, '非法的操作类型' )
|
return
|
end
|
end
|