lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
ÿþ--[[
   x: 
    Tðy: 
   \O€ÿ
   åegÿ2025-01-06
 
   ýQpeÿ AfterDataObjCreate
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
 
function AfterDataObjCreate( strLuaDEID )
    local nRet, strRetInfo, cls_id, id
    nRet,cls_id,id = mobox.getCurEditDataObjID( strLuaDEID )
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MRpenc¤N’N:Sid1Y%! " .. cls_id) end
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID,"T_START","T_END","S_ITEM_CODE","S_AREA_CODE","BHJB")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_S_MR‘ù[aŒ^\'`1Y%! " .. strRetInfo) end
 
    local obj_attrs = json.decode(strRetInfo)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'obj_attrs', obj_attrs)
    local t_start = obj_attrs[1].value
    local t_end = obj_attrs[2].value
    local item_code = obj_attrs[3].value
    local area_code = obj_attrs[4].value
    local bhjb = obj_attrs[5].value
    
    -- îO9e8^ϑ„v<P
    local strCondition = "S_NAME = 'sO-‰|™eŒèb_ËYöeô•'"
    local strSetSQL = "S_VALUE = '"..t_start.."'"
    local nRet, strRetInfo = mobox.updateTableAttrByCondition(strLuaDEID, "TN_WMS_Const", strCondition,strSetSQL)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
    strCondition = "S_NAME = 'sO-‰|™eŒèbÓ~_göeô•'"
    strSetSQL = "S_VALUE = '"..t_end.."'"
    nRet, strRetInfo = mobox.updateTableAttrByCondition(strLuaDEID, "TN_WMS_Const", strCondition,strSetSQL)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
    -- îO9e@b    g„v_ËYöeô•ŒTÓ~_göeô•
    strCondition = "S_ITEM_CODE = S_ITEM_CODE"
    strSetSQL = "T_START = '"..'2025-01-01 '..t_start.."',T_END = '"..'2025-01-01 '..t_end.."'"
    nRet, strRetInfo = mobox.updateTableAttrByCondition(strLuaDEID, "TN_GT_Allot_Order", strCondition,strSetSQL)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
    
    -- ‚Yœg/f'}%`„vôv¥cRú^ûN¡Ràe—¡[8h
    if(bhjb == ''}%`')then
        -- 3u÷‹ûN¡R„v„vN¡R÷S
        local strHeader = 'FLDB'..os.date("%y%m%d")..'-'
        nRet,strCode = mobox.getSerialNumber( "‰|™eŒèb", strHeader, 5 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '3u÷‹0‰|™eŒèb0x1Y%!'..strCode ) end
        
        -- îO9e¶r`:N  ÑS^ 
        strCondition = "S_ID = '" .. id .. "'"
        strSetAttr = "S_STATE = 'ÑS^',S_B_STATE = 2,S_NO = '"..strCode.."'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Allot_Order", strCondition, strSetAttr)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "¾‹n¶r`1Y%!" .. strRetInfo) end
        
        local obj_display_name = "0sOûN¡R0"
        local wfp_list_show_name = "'" .. item_code .. "-" .. area_code .. "'0‰|™eŒèb0-'}%`eˆ'"
        local nRet, strRetInfo = mobox.addSysWFP(strLuaDEID, 1, "", "GT_Allot_Order", id, obj_display_name, 0, "", "Rú^ûN¡R",
                wfp_list_show_name, "0‰|™eŒèb0", 0)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "addSysWFP 1Y%!" .. strRetInfo) end
    end
end