1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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-05-01
    名称: 逻辑库区-创建前
    作者:HAN  
    日期:2025-1-29
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        -- 生成逻辑库区编码
        -- 生成一些数值属性的名称 N_LOCK_STATE,N_TYPE
 
    更改记录:
            
--]]
wms_base = require( "wms_base" )
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_LOCK_STATE", "N_TYPE" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local nLockState = lua.StrToNumber(obj_attrs[1].value)           -- 锁状态
    local nZoneType = lua.StrToNumber(obj_attrs[2].value)           -- 逻辑库区类型
 
    -- 生成【逻辑库区】编码
    local strCode = ''
    local strHeader = 'Z'
    nRet,strCode = mobox.getSerialNumber( "逻辑库区", strHeader, 4 )  
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),'[1] 申请【逻辑库区】编码失败!'..strCode ) end
   
    -- 根据字典获取 N_LOCK_STATE 的显示名称
    local str_lock_state = wms_base.GetDictItemName( strLuaDEID, "WMS_LocationLockState", nLockState ) 
    -- 根据字典获取 N_ZONE_TYPE 的显示名称
    local str_zone_type = wms_base.GetDictItemName( strLuaDEID, "WMS_AreaType", nZoneType ) 
 
    -- 设置信息
    local   attr_value = {}
    attr_value[1] = lua.KeyValueObj( "S_CODE", strCode )
    attr_value[2] = lua.KeyValueObj( "S_LOCK_STATE", str_lock_state )
    attr_value[3] = lua.KeyValueObj( "S_TYPE", str_zone_type )
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),"[2] 设置【逻辑库区】信息失败!  "..strRetInfo ) end   
end