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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
ÿþ--[[
    x: GT-100-04
     Tðy: GT-WMS
    \O€ÿLZH
    eQãSýQpeÿ CreateIncomingInfo
 
 
    ŸRý€ô‹f:
        GT-WMS NÑSeQ“^USnc4YáOo`Ù~ GZ-WMSû|ß~ ÿGZ-WMSû|ß~ù[úW@xpencۏLˆ°ežX
 
        “eQpencÿ                                                                                        
        {    
        "delivery_no": "xxx",    6e'US÷S
        "delivery_row_no": "xxx",    6e'USLˆ÷S
        "delivery_type": "xxx",    6e'USnc{|‹W
        "batch_no": "xxx",    yb!k÷S
        "actual_qty": 123,    yb!k÷S;`͑
        "item_code": "xxx",    ir™ex]NMOx
        "po_no": "xxx",    Ç‘-¢‹US÷S
        "po_row_no": 1,    Ç‘-¢‹USLˆ÷S
        "cntr_qty": 3,    XbØvpeϑ
        "wh_code": "xxx",    ÓN“^÷S
        "level": "xxx",   ö€„vI{§~
        "vendor": "xxx",   ›O”^FUx
        "Item_code_9": "xxx",   ir™exmQMOx
        "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 $R­e6e'US÷SŒT6e'USLˆ÷S/f&Tò]X[(WeQ“^USnc4Y ÿX[(WR¥b•
        -- step4 Rú^eQ“^USnc4Y
                                                                    
    ØSôf°‹U_:
    20250221 LZH V1.1 °ežX4*NY(uW[µk, Rd–0Rgöeô•0xØvĉR0ceňö€hƋ
 
--]]
m3    = require("oi_base_mobox")
json  = require("json")
mobox = require("OILua_JavelinExt")
require("GT-Base")
function CreateIncomingInfo(strLuaDEID)
    local nRet, strRetInfo, in_date
    -- step1 ·ƒÖS¥cãSpenc
    nRet, in_date = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback àeÕl·ƒÖSpencS!" .. in_date) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'eQ“^USnc4Y NÑSÂSpe:', in_date)
 
    -- step2 $R­e/f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local delivery_no = in_date.delivery_no
    if (delivery_no == nil or delivery_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "6e'US÷S Ný€:Nzz!") end
    local delivery_row_no = in_date.delivery_row_no
    if (delivery_row_no == nil or delivery_row_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "6e'USLˆ÷S Ný€:Nzz!") end
    local delivery_type = in_date.delivery_type
    if (delivery_type == nil or delivery_type == '') then lua.Error(strLuaDEID, debug.getinfo(1), "6e'USnc{|‹W Ný€:Nzz!") end
    local batch_no = in_date.batch_no
    if (batch_no == nil or batch_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S Ný€:Nzz!") end
    local actual_qty = tonumber(in_date.actual_qty)
    if (actual_qty == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S;`͑ Ný€:Nzz!") end
    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 po_no = in_date.po_no
    if (po_no == nil or po_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "Ǒ-¢‹US÷S Ný€:Nzz!") end
    local po_row_no = tonumber(in_date.po_row_no)
    if (po_row_no == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "Ǒ-¢‹USLˆ÷S Ný€:Nzz!") end
    local cntr_qty = tonumber(in_date.cntr_qty)
    if (cntr_qty == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "XbØvpeϑ Ný€:Nzz!") end
    local wh_code = in_date.wh_code
    local level = in_date.level
    local vendor = in_date.vendor
    -- 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 Item_code_9 = in_date.item_code_9
    if (Item_code_9 == nil or Item_code_9 == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™ex Ný€:Nzz!") end
 
    -- step3 $R­e6e'US÷SŒT6e'USLˆ÷S/f&Tò]X[(WeQ“^USnc4Y ÿX[(WR¥b•
    -- V1.2 nRet = 0 ãNhˆX[(WeQ“^US,‰$R­eå‹eQ“^US/f&TX[(W/T¨R¶r`„vň±{å]US,X[(W¥b• ÿ NX[(Wôf°eeQ“^US…Q¹[
    -- nRet = 1ãNhˆ NX[(WeQ“^US,‰Rú^eQ“^US,‚Yœg/fceňö€Ø‰Rú^/T¨R¶r`„vň±{å]US
    -- nRet = 2ãNhˆ¥b•
    local strCondition = "S_DELIVERY_NO = '" .. delivery_no .. "' AND N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", strCondition)
    if (nRet == 2) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. strRetInfo)
    elseif (nRet == 0) then
        local order_no = strRetInfo.order_no
        -- $R­e/f&TX[(W/T¨R¶r`„vň±{å]US
        strCondition = "S_ORDER_NO = '" .. order_no .. "' AND S_STATE = '/T(u'"
        nRet, strRetInfo = mobox.existThisData(strLuaDEID, "GT_Packing_Order", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "(WÀhåg0ň±{å]US0/f&TX[(Wöe1Y%! " .. strRetInfo) end
        if (strRetInfo == 'no') then
            -- å‹eQ“^US NX[(W/T¨R¶r`„vň±{å]USRôf°eeQ“^US
            strCondition = "S_ORDER_NO = '" .. order_no .. "'"
            local update_sql = "S_DELIVERY_NO = '" .. delivery_no .. "',N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
            update_sql = update_sql .. ",S_DELIVERY_TYPE = '" .. delivery_type .. "',S_BATCH_NO = '" .. batch_no .. "'"
            update_sql = update_sql .. ",F_ACTUAL_QTY = " .. actual_qty .. ",S_ITEM_CODE_9 = '" .. item_code .. "'"
            update_sql = update_sql ..
            ",S_PO_NO = '" .. po_no .. "',S_PO_ROW_NO ='" .. po_row_no .. "'"
            if (wh_code ~= nil and wh_code ~= '') then
                update_sql = update_sql .. ",S_WH_CODE = '" .. wh_code .. "'"
            end
            if (level ~= nil and level ~= '') then
                update_sql = update_sql .. ",S_LEVEL = '" .. level .. "'"
            end
            if (vendor ~= nil and vendor ~= '') then
                update_sql = update_sql .. ",S_VENDOR = '" .. vendor .. "'"
            end
            if (Item_code_9 ~= nil and Item_code_9 ~= '') then
                update_sql = update_sql .. ",S_ITEM_CODE = '" .. Item_code_9 .. "'"
            end
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Incoming_Info", strCondition, update_sql)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USáOo`1Y%ÿ" .. strRetInfo) end
        else
            lua.Error(strLuaDEID, debug.getinfo(1), "0eQ“^USnc4Y0ò]X[(W/T¨R¶r`„vň±{å]US! ")
        end
    elseif (nRet == 1) then
        -- ·ƒÖSir™eáOo`„vir™eÍy{|
        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
 
        -- step4 Rú^eQ“^USnc4Y
        -- ·ƒÖSN*NRËY„v0eQ“^USnc4Y0pencù[aŒ
        strRetInfo = m3.AllocObject(strLuaDEID, "GT_Incoming_Info")
        strRetInfo.delivery_no = delivery_no
        strRetInfo.delivery_row_no = delivery_row_no
        strRetInfo.delivery_type = delivery_type
        strRetInfo.po_no = po_no
        strRetInfo.po_row_no = po_row_no
        strRetInfo.batch_no = batch_no
        strRetInfo.item_code_9 = item_code
        strRetInfo.item_name = material.item_name
        strRetInfo.actual_qty = actual_qty
        strRetInfo.cntr_qty = cntr_qty
        strRetInfo.wh_code = wh_code
        strRetInfo.level = level
        strRetInfo.vendor = vendor
        strRetInfo.item_code = Item_code_9
        strRetInfo.type = "GTWMS NÑS"
        nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, strRetInfo)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0eQ“^USnc4Y0ù[aŒ1Y%!' .. strRetInfo) end
 
    end
end