fy36
2025-07-01 350eb5ec9163d3ea21416b1525bb80191e958071
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
--[[
    编码: WMS-32-01
    名称: 巷道-创建前
    作者:HAN  
    日期:2025-3-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        -- 生成巷道编码, 格式:A-001
 
    更改记录:
 
--]]
 
wms_base = require( "wms_base" )
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
    -- step1  获取当前创建的作业信息 -- 作业类型,业务状态
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_AISLE_CODE" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local aisle_code = lua.Get_StrAttrValue( obj_attrs[1].value )        -- 巷道编码
 
 
    -- 生成作业编码
    if ( aisle_code == '' ) then
        local strCode = ''
        local strHeader = 'A-'
        nRet,strCode = mobox.getSerialNumber( "Aisle", strHeader, 3 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '申请巷道编码失败!'..strCode ) end
    
        -- 设置信息
        local   attr_value = {}
        attr_value[1] = lua.KeyValueObj( "S_AISLE_CODE", strCode )
        nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置巷道信息失败!  "..strRetInfo ) end 
    end
end