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
--[[
    编码: JX-108-02
    名称: 巨星任务-创建前
    作者:HAN  
    日期:2025-1-29
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        -- 如果 S_SOURNO 为空,系统申请一个巨星任务编码
 
    更改记录:
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_SOURNO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
 
    local obj_attrs = json.decode( strRetInfo ) 
    local no = obj_attrs[1].value             
 
    if ( no == '') then
        -- 生成组盘顺序号
        local strCode = ''
        local strHeader = 'JXT-'..os.date("%y%m")..'-'
        nRet,strCode = mobox.getSerialNumber( "巨星任务", strHeader, 5 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),  '申请巨星任务编码失败!'..strCode ) end
        
        -- 设置信息
        local   attr_value = {}
        attr_value[1] = lua.KeyValueObj( "S_SOURNO", strCode )
        nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【巨星任务】信息失败!  "..strRetInfo ) end   
    end
end