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
ÿþ--[[
    x: GT-02-01
     Tðy: Rú^MR
    \O€: LZH
    Rú^öeô•: 2024/7/3
    eQãSýQpeÿ
    ŸRý€ô‹fÿ
        -- $R­eîvƉaSpeϑ+eg™eáOo`/}¡‹Åˆ±{peϑ/f&T…Çeg™eáOo`„vž[E–peϑ
 
    ØSôf°‹U_:
    V1.1 LZH 20240718 $Rzz!hŒš ÿýQpegetDataObjAttrSum(W¡l    g<P„vÅ`µQ NԏÞV„v/fzzW[&{2N N/f0
    V1.2 LZH 20240806 ÎN0ir™e0hˆ-N·ƒÖS/f&TŒšÁ‹W[µk
    V1.3 LZH 20240809 1uŽNeg™eáOo`W[µkØS¨R ÿ·ƒÖSå‹eQ“^USnc4Y N„v@b    geQ“^USncLˆpeϑ+1$R­e/f&T'YŽNeQ“^USnc4Y„vXbØvpeϑ
    V1.4 LZH 20240909 ceňö€{|‹W„vir™e N—‰!hŒšpeϑ
--]]
 
json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require("oi_base_mobox")
require("GT-Base")
function BeforeDataObjCreate(strLuaDEID)
    local nRet, strRetInfo
    lua.Debug(strLuaDEID, debug.getinfo(1), '1', 1)
 
    -- ·ƒÖSS_MRRú^„vpencù[aŒ^\'`
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_ORDER_NO", "S_ITEM_CODE", "S_DISPERSOID", "S_SERIAL_NO")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS‘áOo`1Y% " .. strRetInfo)
    end
    local obj_attrs = json.decode(strRetInfo)
    local order_no = obj_attrs[1].value
    local item_code = obj_attrs[2].value
    local dispersoid = obj_attrs[3].value
    local serial_no = obj_attrs[4].value
 
    lua.Debug(strLuaDEID, debug.getinfo(1), '·ƒÖSÂSpe', strRetInfo)
    if (order_no == nil or order_no == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "eQ“^US÷S Ný€:Nzzÿ")
    end
    if (item_code == nil or item_code == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "ir™ex Ný€:Nzzÿ")
    end
 
    -- ·ƒÖSeg™eáOo`
    local incoming_info
    local strCondition = " S_ORDER_NO= '" .. order_no .. "'"
    nRet, incoming_info = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", strCondition)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. incoming_info)
    end
 
    local lable_crad
    local strCode = ''
    if (incoming_info.type == 'ºNå]U_eQ') then
        -- ê¨RubAm4l÷S(xĉR S + 7MOpeW[)
        nRet, strCode = mobox.getSerialNumber("ºNå]U_eQAm4l÷S", 'A', 7)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1),"3u÷‹ºNå]U_eQeQ“^USncLˆx1Y%!" .. strCode) end
    else
        -- !hŒšAm4l÷S Ný€:Nzz Ný€Í‘ Y
        strCondition = "S_SERIAL_NO = '" .. serial_no .. "'"
        nRet, lable_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition)
        if (nRet == 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "Am4l÷S Ný€Í‘ Y!")
        elseif (nRet == 2) then
            lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. lable_crad)
        end
    end
 
    -- V1.4 ·ƒÖSir™e{|‹W
    local item_type, material
    nRet, item_type, material = GT_Get_ItemType(strLuaDEID, item_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), item_type) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'ir™eáOo`', material)
    if (item_type ~= 'ceňö€') then
        -- V1.3 ·ƒÖS勐'US÷S NîvƉaSpeϑ;`ŒT
        local num
        nRet, num = mobox.getDataObjCount(strLuaDEID, "GT_Label_Crad", strCondition)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "getDataObjCount 1Y%!" .. num)
        end
 
        if (dispersoid ~= 'Y') then
            if (tonumber(num) + 1 > tonumber(incoming_info.cntr_qty)) then
                lua.Error(strLuaDEID, debug.getinfo(1), "eQ“^USncLˆ;`pe…ÇeQ“^USnc4Y„vXbØvpeϑ!")
            end
        end
    end
 
 
    -- V1.2 ¾‹náOo`
    local attr_value = {}
    attr_value[1] = lua.KeyValueObj("C_IS_VALIDATE", material.is_validate)
    if(strCode ~= '')then
        attr_value[2] = lua.KeyValueObj("S_SERIAL_NO", strCode)
        attr_value[3] = lua.KeyValueObj("S_REQ_NO", strCode)
    end
    nRet, strRetInfo = mobox.setCurEditDataObjAttr(strLuaDEID, lua.table2str(attr_value))
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "¾‹neQ“^USncLˆáOo`1Y%!  " .. strRetInfo) end
end