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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ÿþ--[[
   x:
    Tðy: Rú^T
   \O€ÿLZH
   åegÿ2024-09-18
 
   ýQpeÿ AfterDataObjCreate
   ŸRý€:  Rú^ûy“^\ON
 
   ôf9e°‹U_:
   V1.1 LZH 20241009 ûy“^US÷SMR:N ST ROHQ§~gNO,MR:N CK ãNhˆÙ*Nûy“^US/fúQ“^MRûy“^OHQ§~gؚ
 
--]]
 
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
 
function AfterDataObjCreate(strLuaDEID)
    local nRet, strRetInfo
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_WH_CODE","S_AREA_CODE","S_LOC_CODE","N_ROADWAY","S_CNTR_CODE","S_ST_NO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    lua.Debug(strLuaDEID, debug.getinfo(1), "ûy“^USRú^TÂSpe:", strRetInfo)
    local wh_code = obj_attrs[1].value
    local area_code = obj_attrs[2].value
    local loc_code = obj_attrs[3].value
    local roadway = obj_attrs[4].value
    local cntr_code = obj_attrs[5].value
    local st_no = obj_attrs[6].value
    local str = st_no:sub(1, 2)
    
 
    -- ·ƒÖS¹[hV
N„vir™eáOo`
    local strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'"
    local cg_detail
    nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0¹[hV'ÁTfÆ~0áOo`1Y%! " .. cg_detail) end
    local batch_no = cg_detail.batch_no
 
    local operation           = m3.AllocObject(strLuaDEID, "Operation")
    -- ub\ONx
    local strCode = ''
    local strHeader = 'OP'..os.date("%y%m%d")..'-'
    nRet,strCode = mobox.getSerialNumber( "\ON", strHeader, 5 )  
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '3u÷‹\ONx1Y%!'..strCode ) end
    operation.code   = strCode
 
    -- w¹páOo`
    operation.start_wh_code   = wh_code
    operation.start_area_code = area_code
    operation.start_loc_code  = loc_code
    
    -- È~¹páOo`
    operation.end_wh_code     = wh_code
    operation.end_area_code   = area_code
 
    if(str == 'CK') then
        operation.priority = 2 -- ‚Yœgûy“^US:NúQ“^MRûy“^ROHQ§~žXؚ
    else
        operation.priority = 0 -- ¾‹nûy“^\ON„vOHQ§~:NgNO ÿOHQ¨cúQeQ“^„v\ON
    end
    
    operation.op_type         = wms_base.Get_nConst(strLuaDEID, "\ON{|‹W-úQ“^")
    operation.op_def_name     = "ûy“^"
    operation.cntr_code       = cntr_code
    -- ¾‹nibU\ÂSpe&^eQ\ON/T¨R ÿûN¡RŒ[b
    local ext_table           = {}
    ext_table.roadway         = roadway
    ext_table.batch_no        = batch_no
 
    -- ibU\ÂSpe
    operation.ext_data        = lua.table2str(ext_table)
    lua.Debug(strLuaDEID, debug.getinfo(1), "\ONRú^MRáOo`:", operation)
    nRet, operation           = m3.CreateDataObj(strLuaDEID, operation)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0\ON01Y%!' .. operation) end
    
    -- îO9eûy“^USfÆ~„v\ONx
    strCondition = " S_ST_NO = '" .. st_no .. "'"
    local strSetSQL_update = " S_OP_CODE = '"..strCode.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "ST_Detail", strCondition, strSetSQL_update)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eûy“^USfÆ~\ONx1Y%ÿ" .. strRetInfo) end
end