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
ÿþ--[[
    x: WMS-04-03
     Tðy: ybϑü[eQ
    \O€ÿHAN    
    eQãSýQpeÿImportLocation
 
    ŸRý€ô‹f:
        Yt¹[hVü[eQ ÿ(Wü[eQ„vöeP$R­eN¹[hV/f&TX[(Wÿ‚Yœg NX[(W‰°eRú^
        ü[eQ<h_Á‰
0#MOWMS-002 ¹[hVš[INhˆ.xlsx 0
    ØSôf†SòS:
 
--]]
wms_base = require( "wms_base" )
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·ƒÖS¹[hVü[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 strCntrCode = ''
    local strType = ''
    local cntr = {}
 
    -- ek¤š1 ·ƒÖSÎNexcelü[eQ„vNLˆpenc
    for row = 1, nRows do
        row_attrs = row_data[row]
        nCount = #row_attrs
        strCntrCode = ''
        nType = ''
        strType = ''
 
        -- RËYS ¹[hV ù[aŒ
        cntr = m3.AllocObject(strLuaDEID,"Container")
        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 == "¹[hVx") then
                    if (strValue == '') then lua.Error( strLuaDEID, debug.getinfo(1), strAttr .. " Ný€:Nzz!") end
                    strCntrCode = strValue
                --V1.2 
                elseif (strAttr == "{|‹W") then
                    if (strValue == '') then lua.Error( strLuaDEID, debug.getinfo(1), strAttr .. " Ný€:Nzz!") end
                    if(strValue == 'XbØv')then
                        nType = 1
                        strType = strValue
                    elseif(strValue == 'ö€Fh')then
                        nType = 2
                        strType = strValue
                    else
                        lua.Error( strLuaDEID, debug.getinfo(1), strAttr .. "/f*gš[IN„v¹[hV{|‹W!")
                    end
                end
            end
        end
        lua.Debug( strLuaDEID, debug.getinfo(1), 'strType', strType )
        lua.Debug( strLuaDEID, debug.getinfo(1), 'nType', nType )
        lua.Debug( strLuaDEID, debug.getinfo(1), 'strCntrCode', strCntrCode )
 
        -- ek¤š2 9hnc¹[hVxeg$R­eü[eQ„v¹[hV/f&Tò]Ï~X[(W
        --       ‚Yœgò]Ï~X[(W ÿ9hncü[eQ„vpencۏLˆ†‰Öv
        --       ‚Yœg NX[(W—‰Rú^
        local attrs
        local strCondition = "S_CODE='" .. strCntrCode .. "'"
        nRet, strRetInfo = mobox.existThisData(strLuaDEID, "Container", strCondition)
        if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "(WÀhåg¹[hV/f&TX[(Wöe1Y%! " .. strRetInfo) end
 
        if (strRetInfo == 'yes') then
            -- ò]Ï~X[(W ÿ9hncü[eQ„vpencۏLˆ†‰Öv
            strCondition = "S_CODE='" .. strCntrCode .. "'"
            strSetSQL = "N_TYPE = '" ..nType .."' , S_TYPE = '" .. strType .. "' "
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Container", strCondition, strSetSQL)
            if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo) end
        else
            cntr.code = strCntrCode
            cntr.type = nType
            cntr.strType = strType
            -- Rú^¹[hV
            nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, cntr )
            if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "Rú^¹[hV1Y%! " .. strRetInfo ) end
        end
    end
    mobox.setInfo(strLuaDEID,"ü[eQbŸR!")
end