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
ÿþ--[[
   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" )
wms_wh = require( "wms_wh" )
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 a = ''
    local b = ''
    local c = ''
    local d = ''
    local e = ''
    local f = ''
    local g = ''
    local h = ''
    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,"CG_Detail")
        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
                    a = strValue
                    local strCondition = "S_CODE = '" .. a .. "'"
                    nRet, strRetInfo = m3.QueryDataObject(strLuaDEID, "Container", strCondition)
                    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS¹[hVáOo`1Y%ÿ" .. strRetInfo) end
                    if (strRetInfo == '') then
                        -- Rú^¹[hV
                        local container = m3.AllocObject(strLuaDEID, "Container")
                        container.code = a
                        nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, container)
                        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¹eÕlCreateDataObjúQ•" .. strRetInfo) end
                    end
                elseif (strAttr == "'MOx") then
                    b = strValue
                end
            end
        end
 
            -- material.cntr_code = a
            -- material.serial_no = b
            -- material.item_code = c
            -- material.item_name = d
            -- material.batch_no = e
            -- material.qty = f
            -- -- Rú^¹[hV
            -- nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, material )
            -- if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "Rú^ir™e1Y%! " .. strRetInfo ) end
            local binding
            nRet, binding = wms_wh.Loc_Container_Binding(strLuaDEID, b, a, "Ñ~š[ã‰Ñ~¹eÕl-û|ß~", "û|ß~Ñ~š[")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVÑ~š[1Y%!' .. binding) end
        end
end