--[[
|
编码: WMS-04-01
|
名称: 货位-创建前
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeDataObjCreate
|
|
功能:
|
1)把 N_PURPOSE N_TYPE 等属性根据字典获取这些值的说明
|
更改记录:
|
|
--]]
|
|
wms_wh = require( "wms_wh" )
|
|
function BeforeDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
-- step1 获取当前货位绑定表的信息,获取 货位号,容器编号
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_PURPOSE","N_TYPE","N_LOCK_STATE","S_AREA_CODE","N_COL","N_LAYER" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local purpose = lua.StrToNumber(obj_attrs[1].value) -- 货位用途
|
local loc_type = lua.StrToNumber(obj_attrs[2].value) -- 货位类型
|
local lock_state = lua.StrToNumber(obj_attrs[3].value) -- 货位锁状态
|
local area_code = obj_attrs[4].value -- 库区编码
|
local col = lua.StrToNumber(obj_attrs[5].value) -- 货位所在列
|
local layer = lua.StrToNumber(obj_attrs[6].value) -- 货位所在层
|
|
if ( lock_state == "" ) then lock_state = 0 end
|
|
-- 从库区编码获取库区类型
|
if ( loc_type == 0 ) then
|
local area
|
nRet, area = wms_wh.Area_GetInfo( strLuaDEID, area_code )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_wh.Area_GetInfo 失败! "..area ) end
|
loc_type = area.loc_type
|
end
|
|
-- 根据字典获取 N_PURPOSE 的显示名称
|
local str_purpose = wms_base.GetDictItemName( strLuaDEID, "WMS_LocationPurpose", purpose )
|
-- 取货位类型信息
|
local str_loc_type = wms_base.GetDictItemName( strLuaDEID, "WMS_LocationType", loc_type )
|
-- 取货位锁状态信息
|
local str_loc_state = wms_base.GetDictItemName( strLuaDEID, "WMS_LocationLockState", lock_state )
|
|
-- 设置货位信息
|
local attr_value = {}
|
local pos_weight = col+layer
|
|
attr_value[1] = lua.KeyValueObj( "S_PURPOSE", str_purpose )
|
attr_value[2] = lua.KeyValueObj( "S_TYPE", str_loc_type )
|
attr_value[3] = lua.KeyValueObj( "S_LOCK_STATE", str_loc_state )
|
attr_value[4] = lua.KeyValueObj( "N_POS_WEIGHT", pos_weight )
|
nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置货位信息失败! "..strRetInfo ) end
|
end
|