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
121
122
123
124
125
126
ÿþ--[[
   x: 
    Tðy: 
   \O€ÿ
   åegÿ2024-11-25
 
   ýQpeÿ Import
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
 
function Import( strLuaDEID )
    local nRet, strRetInfo
    -- ·ƒÖSü[eQ„vpenc, ÔÞV [{"attr":"xx","value":""},...]
    local row_data = {}
    nRet, row_data = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0 or strRetInfo == '') then lua.Error( strLuaDEID, debug.getinfo(1), "àeÕl·ƒÖSir™eü[eQpenc!") end
 
    lua.Debug( strLuaDEID, debug.getinfo(1), 'row_data', row_data )
 
    local row_attrs
    local n, nCount, nValue, nRows
    nRows = #row_data
    if ( nRows == 0 ) then return end
 
    -- N›NsQ.•^\'`
    local strItemCode = ''
    local strItemName = ''
    local strAreaCode = ''
    local strIsYz = ''
    local strIsHw = ''
    local strIsBw = ''
    local strZl = ''
    local strXl = ''
    local material = {}
 
    -- ek¤š1 ·ƒÖSÎNexcelü[eQ„vNLˆpenc
    for row = 1, nRows do
        row_attrs = row_data[row]
        nCount = #row_attrs
        strItemCode = ''
        strItemName = ''
        strAreaCode = ''
        strIsYz = ''
        strIsHw = ''
        strIsBw = ''
        strZl = ''
        strXl = ''
 
        -- RËYS ir™e ù[aŒ
        material = m3.AllocObject(strLuaDEID,"Material")
        for n = 1, nCount do
            strAttr = row_attrs[n].attr
            strValue = row_attrs[n].value
            if (strAttr ~= '') then
 
                -- 9hncü[eQ„vexcelR4Y TðyۏLˆ$R­e
                -- sQ.•^\'`$R­e ÿ‚Yœg^\'` NX[(W‰¥b•
                if (strAttr == "ir™e÷S") then
                    if (strValue == '') then lua.Error( strLuaDEID, debug.getinfo(1), strAttr .. " Ný€:Nzz!") end
                    strItemCode = strValue
                elseif (strAttr == "ir™e Tðy") then
                    if (strValue == '') then lua.Error( strLuaDEID, debug.getinfo(1), strAttr .. " Ný€:Nzz!") end
                    strItemName = strValue
                elseif (strAttr == "‰|™e“^:S") then
                    if (strValue ~= 'JS¢”' and strValue ~= 'hQ¢”' and strValue ~= 'àe' and strValue ~= '') then lua.Error( strLuaDEID, debug.getinfo(1), strValue .. "/f*gš[IN„v‰|™e“^:S!") end
                    if (strValue == '') then strAreaCode = 'àe' end
                    strAreaCode = strValue
                elseif (strAttr == "/f&TŒšÁ‹") then
                    if (strValue ~= 'Y' and strValue ~= 'N' and strValue ~= '') then lua.Error( strLuaDEID, debug.getinfo(1), strValue .. "/f*gš[IN„v{|‹W!") end
                    if (strValue == '') then strAreaCode = 'N' end
                    strIsYz = strValue
                elseif (strAttr == "/f&TÝO)n") then
                    if (strValue ~= 'Y' and strValue ~= 'N' and strValue ~= '') then lua.Error( strLuaDEID, debug.getinfo(1), strValue .. "/f*gš[IN„v{|‹W!") end
                    if (strValue == '') then strAreaCode = 'N' end
                    strIsBw = strValue
                elseif (strAttr == "/f&TR`)n") then
                    if (strValue ~= 'Y' and strValue ~= 'N' and strValue ~= '') then lua.Error( strLuaDEID, debug.getinfo(1), strValue .. "/f*gš[IN„v{|‹W!") end
                    if (strValue == '') then strAreaCode = 'N' end
                    strIsHw = strValue
                    strCntrCode = strValue
                elseif (strAttr == "-N{|") then
                    if (strValue == '') then lua.Error( strLuaDEID, debug.getinfo(1), strAttr .. " Ný€:Nzz!") end
                    strZl = strValue
                elseif (strAttr == "\{|") then
                    strXl = strValue
                end
            end
        end
 
 
        -- ek¤š2 9hncxeg$R­eü[eQ„vir™e/f&Tò]Ï~X[(W
        --       ‚Yœgò]Ï~X[(W ÿ9hncü[eQ„vpencۏLˆ†‰Öv
        --       ‚Yœg NX[(W—‰Rú^
        local attrs
        local strCondition = "S_ITEM_CODE ='" .. strItemCode .. "'"
        nRet, strRetInfo = mobox.existThisData(strLuaDEID, "Material", strCondition)
        if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "(WÀhågir™e/f&TX[(Wöe1Y%! " .. strRetInfo) end
 
        if (strRetInfo == 'yes') then
            -- ò]Ï~X[(W ÿ9hncü[eQ„vpencۏLˆ†‰Öv
            strCondition = "S_ITEM_CODE='" .. strItemCode .. "'"
            strSetSQL = "S_ITEM_NAME = '" ..strItemName .."' , S_AREA_CODE = '" .. strAreaCode .. "' , C_IS_VALIDATE = '" .. strIsYz .. "', C_IS_INSULATE = '" .. strIsBw .. "', C_IS_ISOTHERMAL = '" .. strIsHw .. "', S_SUB_TYPE = '" .. strZl .. "', S_MINOR_TYPE = '" .. strXl .. "'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Material", strCondition, strSetSQL)
            if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo) end
        else
            material.item_code = strItemCode
            material.item_name = strItemName
            material.area_code = strAreaCode
            material.is_validate = strIsYz
            material.is_insulate = strIsBw
            material.isothermal = strIsHw
            material.sub_type = strZl
            material.minor_type = strXl
            -- Rú^¹[hV
            nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, material )
            if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "Rú^ir™e1Y%! " .. strRetInfo ) end
        end
    end
end