Jianw
2025-05-14 29f8b36ebb718d2051bf0e7e701973ec4419ee80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--[[
    编码: WMS-08-01
    名称: 设备动作对象-创建前
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        1)通过 N_EQ_TYPE 的值根据字典获取这些值的说明文字赋值给 S_EQ_TYPE
        2)通过 N_ACTION_CODE 的值根据字典获取这些值的说明文字赋值给 S_ACTION
        
    更改记录:        
 
--]]
 
wms_base = require( "wms_base" )
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
    -- step1  获取当前货位绑定表的信息,获取 货位号,容器编号
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_EQ_TYPE","N_ACTION_CODE","S_EQ_TYPE","S_ACTION" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local eq_type = lua.StrToNumber( obj_attrs[1].value )            -- 设备类型
    local action_code = lua.StrToNumber( obj_attrs[2].value )        -- 动作编码
    local eq_type_name = obj_attrs[3].value                      -- 动作编码
    local action_name = obj_attrs[4].value                       -- 动作编码
 
    -- 根据字典获取 N_EQ_TYPE 的显示名称
    if ( eq_type_name == '' ) then
        eq_type_name = wms_base.GetDictItemName( strLuaDEID, "WMS_EquipmentType", eq_type ) 
    end
    -- 根据字典获取 N_ACTION_CODE 的显示名称
    if ( action_name == '' ) then
        action_name = wms_base.GetDictItemName( strLuaDEID, "WMS_EquipmentAction", action_code ) 
    end
 
    local   attr_value = {}
    attr_value[1] = lua.KeyValueObj( "S_EQ_TYPE", eq_type_name )
    attr_value[2] = lua.KeyValueObj( "S_ACTION", action_name )
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【设备动作队列】信息失败!  "..strRetInfo ) end   
end