Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: WMS-26-01
    名称: 机台-创建前
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
 
    更改记录:
 
--]]
wms_base = require ("wms_base")
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_FACTORY" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
 
    local obj_attrs = json.decode( strRetInfo ) 
    local factory = obj_attrs[1].value                
    if ( factory == '' )  then 
        nRet, factory = m3.GetMyFactory( strLuaDEID )
        if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "GetMyFactory失败! "..factory ) end 
        if ( factory == '' ) then
            nRet, factory = wms_base.Get_sConst2( strLuaDEID, "默认工厂标识" )
            if ( nRet ~= 0 ) then
                lua.Stop( strLuaDEID, "系统无法获取常量'默认工厂标识'")
                return
            end           
        end        
    end 
 
    -- 设置信息
    local   attr_value = {}
    attr_value[1] = 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