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: GT-100-03
     Tðy: GT-WMS
    \O€ÿLZH
    eQãSýQpeÿ MaterialMaintain
 
 
    ŸRý€ô‹f:
        GT-WMS NÑSúW@xir™eáOo`Ù~ GZ-WMSû|ß~ ÿGZ-WMSû|ß~ù[úW@xpencۏLˆ°ežX/îO9e        
 
        “eQpencÿ        
        [{
            "item_code": "xxx",  -- ir™ex
            "item_name": "xxx",  -- ir™eÏcð
            "is_validate": "Y",  -- /f&TagxŒšÁ‹
            "sub_type": "‰|™e01",  -- -N{|
            "minor_type": "‰|™e0102",  --\{|
            "isothermal": "Y",  -- /f&TR`)n
            "is_insulate": "N",  -- /f&TÝO)n
            "is_pack": "N",  -- /f&Tãb    
            "wh_code": "AHYLK",  -- ÓN“^÷S
            "area_code": "hQ¢”",  -- “^:S
            "remark1": "",  -- Yèl ‚f*g/T(u
            "remark2": "",  -- Yèl ‚f*g/T(u
            "remark3": "",  -- Yèl ‚f*g/T(u
            "remark4": ""   -- Yèl ‚f*g/T(u
        },
        ...
        ]
 
        Yt;‘
        -- step1 ã‰g¥cãS O„v datajson ÂSpe
        -- step2 !hŒšÅ_ OW[µk/f&T:Nzz ÿ:NzzR¥b•
        -- step3 9hnc¥cãS{|‹WW[µkù[úW@xpencۏLˆ°ežXbîO9eÍd\O
                                                                    
    ØSôf°‹U_:
    20241111 LZH V1.1 GT-WMS‰Bl<h_:NList
    20250221 LZH V1.2 °ežX4*NY(uW[µk
--]]
m3    = require("oi_base_mobox")
json  = require("json")
mobox = require("OILua_JavelinExt")
function MaterialMaintain(strLuaDEID)
    lua.Debug(strLuaDEID, debug.getinfo(1), '111:', 111)
    local nRet, strRetInfo, in_date, material
    -- step1 ·ƒÖS¥cãSpenc
    local list
    nRet, list = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback àeÕl·ƒÖSpencS!" .. list) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'ir™eúW@x^\'` NÑSÂSpe:', list)
    local count = #list
    if (list == nil or count == 0) then return end
 
    for i = 1, count do
        in_date = list[i]
        -- step2 $R­e/f&Tý    g<Pÿ¡l<P¥b•ԏÞV
        local item_code = in_date.item_code
        if (item_code == nil or item_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™ex Ný€:Nzz!") end
        local wh_code = in_date.wh_code
        local sub_type = in_date.sub_type
        local item_name = in_date.item_name
        local is_validate = in_date.is_validate
        local minor_type = in_date.minor_type
        local isothermal = in_date.isothermal
        local is_pack = in_date.is_pack
        local area_code = in_date.area_code
        -- V1.2 °ežXY(uW[µk
        local remark1 = in_date.remark1
        local remark2 = in_date.remark2
        local remark3 = in_date.remark3
        local remark4 = in_date.remark4
 
        local strSetSQL_update = ""
        -- üb¥cîO9eí‹åS
        if (wh_code ~= nil and wh_code ~= '') then
            strSetSQL_update = strSetSQL_update .. ",S_WH_CODE = '" .. wh_code .. "'"
        end
        if (item_name ~= nil and item_name ~= '') then
            strSetSQL_update = strSetSQL_update .. ",S_ITEM_NAME = '" .. item_name .. "'"
        end
        if (is_validate ~= nil and is_validate ~= '') then
            strSetSQL_update = strSetSQL_update .. ",C_IS_VALIDATE = '" .. is_validate .. "'"
        end
        if (sub_type ~= nil and sub_type ~= '') then
            strSetSQL_update = strSetSQL_update .. ",S_SUB_TYPE = '" .. sub_type .. "'"
        end
        if (minor_type ~= nil and minor_type ~= '') then
            strSetSQL_update = strSetSQL_update .. ",S_MINOR_TYPE = '" .. minor_type .. "'"
        end
        if (isothermal ~= nil and isothermal ~= '') then
            strSetSQL_update = strSetSQL_update .. ",C_IS_ISOTHERMAL = '" .. isothermal .. "'"
        end
        if (is_pack ~= nil and is_pack ~= '') then
            strSetSQL_update = strSetSQL_update .. ",C_IS_PACK = '" .. is_pack .. "'"
        end
        if (area_code ~= nil and area_code ~= '') then
            strSetSQL_update = strSetSQL_update .. ",S_AREA_CODE = '" .. area_code .. "'"
        end
 
        -- $R­eîO9eí‹åS/f&T:Nzz ÿ:NzzR NZPÍd\O ÿ N:NzzR Rd–üb¥cí‹åS„v,{N*N ÷SW[&{v^îO9e
        if (strSetSQL_update ~= "") then
            strSetSQL_update = strSetSQL_update:sub(2)
            local strCondition = "S_ITEM_CODE = '" .. item_code .. "'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Material", strCondition,
                strSetSQL_update)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9e0ir™e0áOo`1Y%ÿ" .. strRetInfo) end
            lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo:', strRetInfo)
            if (tonumber(strRetInfo) == 0) then
                -- step3 ·ƒÖSN*NRËY„v0ir™e0pencù[aŒ
                material = m3.AllocObject(strLuaDEID, "Material")
                material.item_code = item_code
                material.wh_code = wh_code
                material.item_name = item_name
                material.is_validate = is_validate
                material.sub_type = sub_type
                material.minor_type = minor_type
                material.isothermal = isothermal
                material.is_pack = is_pack
                material.area_code = area_code
                nRet, material = m3.CreateDataObj(strLuaDEID, material)
                if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0ir™e0ù[aŒ1Y%!' .. material) end
            end
        end
    end
end