--[[
|
编码: WMS-80-01
|
名称: 设备-创建前
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeDataObjCreate
|
|
功能:
|
1)根据 N_TYPE 设置 S_TYPE
|
2)获取操作人员的 工厂标识
|
|
更改记录:
|
|
--]]
|
wms_base = require ("wms_base")
|
|
function BeforeDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
-- step1 获取设备类型
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_TYPE" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local type = lua.StrToNumber(obj_attrs[1].value) -- 设备类型
|
|
-- 根据字典获取 N_TYPE 的显示名称
|
local str_type = wms_base.GetDictItemName( strLuaDEID, "WMS_EquipmentType", type )
|
|
local factory
|
nRet, factory = wms_base.GetMyFactory( strLuaDEID )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetMyFactory失败! "..factory ) end
|
if ( factory == '') then
|
nRet, factory = wms_base.Get_sConst2( "WMS_Default_Factory")
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "系统无法获取常量'WMS_Default_Factory'")
|
return
|
end
|
end
|
|
-- 设置【设备】信息
|
local attr_value = {}
|
attr_value[1] = lua.KeyValueObj( "S_TYPE", str_type )
|
attr_value[2] = lua.KeyValueObj( "S_FACTORY", factory )
|
nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【设备】信息失败! "..strRetInfo ) end
|
end
|