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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
ÿþ-- š[INÔkƒýQpe
local function compare(a, b)
    return a.level < b.level
end
--[[
   x:
    Tðy:
   \O€ÿ
   åegÿ2024-11-13
 
   ýQpeÿ AfterDataObjModify
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
 
function AfterDataObjModify(strLuaDEID)
    local nRet, strRetInfo,strCondition
    -- step1  ·ƒÖSS_MRRú^„váOo`
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_STATUS", "S_ITEM_TYPE", "S_TYPE", "S_CODE")
    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), 'strRetInfo', strRetInfo)
    local s_status = obj_attrs[1].value  -- è•MO¶r`
    local item_type = obj_attrs[2].value -- ir™eÍy{|
    local types = obj_attrs[3].value     -- {|‹W
    local code = obj_attrs[4].value
 
    if (s_status ~= 'zzò•-N') then
        return
    end
 
    if (types == 'yrš[') then
        local train
        strCondition = "S_STATUS = '’c–-N' AND S_ITEM_TYPE = '" .. item_type .. "'"
        nRet, train = m3.GetDataObjByCondition(strLuaDEID, "GT_Train_Detail", strCondition, "T_CREATE")
        if (nRet == 1) then
            return
        elseif (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "GetDataObjByCondition1Y%! " .. train)
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'train', train)
 
        -- îO9ef!kæ‹Å`„v¶r`:N xS'-N
        strCondition = "S_CODE = '" .. train.code .. "'"
        local strUpdateSQL = "S_STATUS = 'xS'-N'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Train_Detail", strCondition, strUpdateSQL)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition1Y%! " .. strRetInfo) end
 
        -- îO9e 0xS'è•¡{t0„v¶r`:NxS'-N
        strCondition = "S_CODE = '" .. code .. "'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Dock_Doors", strCondition, strUpdateSQL)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition1Y%! " .. strRetInfo) end
 
    else
        local param = {}
        local num = 0
        -- (uAm z
        -- ·ƒÖS ir™eÍy{|:N(u eQ‚Söeô•gée „v3*Nf!káOo`
        strCondition = "S_STATUS = '’c–-N' AND S_ITEM_TYPE IN ('¢”N','‰|™e','…Pg',')Y6qö€')"
        local strFieldList = '["S_CODE","S_ITEM_TYPE"]'
        local strOrderBy = "T_CREATE"
        nRet, strRetInfo = mobox.queryTable( strLuaDEID,"TN_GT_Train_Detail", strFieldList, 3, strCondition, strOrderBy )
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "¡l    gÎNcš[hˆ-NÖS0RáOo`"..strRetInfo) end
 
        if(strRetInfo == '[]')then
            lua.Debug(strLuaDEID, debug.getinfo(1), "strRetInfoÎNcš[hˆÔÞVáOo`3",strRetInfo)
            return
        end
 
        local resJson = json.decode(strRetInfo)
        for i = 1,#resJson do
            -- ·ƒÖSù[”^ir™eÍy{|„vOHQ§~
            local code_i = resJson[i].S_CODE
            local item_type_i = resJson[i].S_ITEM_TYPE
 
            -- ·ƒÖSOHQ§~
            local loc_material
            strCondition = "S_ITEM_TYPE = '" .. item_type_i .. "'"
            nRet, loc_material = m3.GetDataObjByCondition(strLuaDEID, "GT_Loc_Material", strCondition, "T_CREATE")
            if (nRet == 1) then
                return
            elseif (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "GetDataObjByCondition1Y%! " .. loc_material)
            end
 
            num = num + 1
            param[num] = {
                code = code_i,
                item_type = item_type_i,
                level = loc_material.level
            }
        end
 
        -- ÇOHQ§~ù[3*Nf!kۏLˆ’c^
        if(#param ~= 0)then
            -- O(utable.sortýQpeۏLˆ’c^
            table.sort(param, compare)
 
            -- îO9ef!kæ‹Å`„v¶r`:N xS'-N
            strCondition = "S_CODE = '" .. param[1].code .. "'"
            local strUpdateSQL = "S_STATUS = 'xS'-N',S_DOOR_CODE = '"..code.."'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Train_Detail", strCondition, strUpdateSQL)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition1Y%! " .. strRetInfo) end
 
            -- îO9e 0xS'è•¡{t0„v¶r`:NxS'-N
            strCondition = "S_CODE = '" .. code .. "'"
            strUpdateSQL = "S_STATUS = 'xS'-N'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Dock_Doors", strCondition, strUpdateSQL)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition1Y%! " .. strRetInfo) end
        else
            lua.Error(strLuaDEID, debug.getinfo(1), "ir™eÍy{|(W0“^MOir™ehÆQ0-N*g~b0Rô~¤b„vOHQ§~! ")
        end
    end
end