--[[
|
编码: WMS-10-01
|
名称: 货位容器绑定-创建后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterDataObjCreate
|
|
功能:
|
1. 创建一个【货位容器绑定记录】
|
2. 容器和货位绑定后 【库存量变化表】 会有变化,调用mobox的标准接口进行处理
|
3. 更改【货位】中的 N_CURRENT_NUM
|
更改记录:
|
|
--]]
|
|
wms_base = require( "wms_base" )
|
|
function AfterDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
|
-- step1 获取当前货位绑定表的信息,获取 货位号,容器编号
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_LOC_CODE","S_CNTR_CODE","N_BINDING_METHOD","S_ACTION_SRC","S_BINDING_METHOD" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "【货位容器绑定】#创建后#: 获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local loc_code = obj_attrs[1].value -- 货位编码
|
local cntr_code = obj_attrs[2].value -- 容器编码
|
local nCount = #obj_attrs
|
|
-- step1 生成【货位容器绑定记录】动作类型 = 绑定
|
obj_attrs[nCount+1] = lua.KeyValueObj( "N_ACTION_TYPE", wms_base.Get_nConst(strLuaDEID, "货位容器动作-绑定") )
|
nRet, strRetInfo = mobox.createDataObj( strLuaDEID, "货位容器绑定记录", lua.table2str(obj_attrs) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '【货位容器绑定】#创建后#: mobox 创建【货位容器绑定记录】对象失败!'..strRetInfo ) end
|
|
-- step2 容器和货位绑定 -- 逻辑库区量表会变化
|
nRet, strRetInfo = wms.wms_ContainerLocAction( strLuaDEID, cntr_code, loc_code, wms_base.Get_nConst(strLuaDEID, "货位容器动作-绑定") )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '【货位容器绑定】#创建后#: wms_ContainerLocAction 发生错误!'..strRetInfo ) end
|
--[[
|
local strCondition = "S_CODE = '"..cntr_code.."'"
|
local strSetAttr = "S_POSITION = '"..loc_code.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Container", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【容器】信息失败!"..strRetInfo ) end
|
]]
|
-- 如果绑定的货位的类型是存储货位,需要对容器信息进行重置
|
local loc
|
nRet, loc = wms_wh.GetLocInfo( loc_code )
|
-- purpose = 1 说明货位的用途是存储
|
if ( nRet == 0 and loc.purpose == 1 ) then
|
local cntr
|
local strCondition = "S_CODE = '"..cntr_code.."'"
|
nRet, cntr = m3.GetDataObjByCondition( strLuaDEID, "Container", strCondition )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【容器】信息失败!"..strRetInfo ) end
|
|
local add_wfp = {}
|
add_wfp.wfp_type = 1 -- 触发数据对象事件(指定数据对象标识)
|
add_wfp.cls = "Container"
|
add_wfp.obj_id = cntr.id
|
add_wfp.obj_name = "容器'"..cntr_code.."和货位'"..loc_code.."'绑定触发容器Reset事件"
|
add_wfp.trigger_event = "Reset"
|
nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "新增WFP信息失败!"..strRetInfo ) end
|
end
|
end
|