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
ÿþ--[[
    x: GT-100-02
     Tðy: GT-WMSúQ“^ûN¡R NÑS
    \O€ÿLZH
    eQãSýQpeÿ SendOutboundOrder
 
 
    ŸRý€ô‹f:
        GT-WMS NÑSúQ“^áOo`Ù~ GZ-WMSû|ß~ ÿGZ-WMSû|ß~9hncúQ“^áOo`ub0úQ“^USnc0ŒT0\ON0            
 
        “eQpencÿ        
        {
            "task_no": "xxxx",    -- úQ“^ûN¡R÷S
            "batch_no": "xxx",    -- yb!k÷S
            "item_code": "xxx",         -- ir™ex
            "end_loc": "xxx",       -- :gðS
            "qty": "xxx",         -- peϑ؞¤‹1Xb
            "wh_code": "xxx",     -- ÓN“^÷S
            "mes_task_no": "xxx",     -- MESûN¡RUS÷S
            "wms_lot":"xxx",    --   GTWMS…Qèyb÷S
            "wms_task_no":"xxx", -- GTMWS …QèUS÷SW[µk 
            "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
                $R­e json ã‰g/f&TbŸR ÿ NbŸRԏÞV¥b•
                $R­e W[µk /f&Tý    g<Pÿ¡l<P¥b•ԏÞV
 
        -- step2 9hncW[µkáOo`u§N0úQ“^US0
        -- step3 Œ(u0úQ“^US0Rú^\ON‹NöN
                                                                    
    ØSôf°‹U_:
    20241122 LZH V1.1 úQ“^USîO9e:N;NP[hˆ ÿãNxŒte
    20250221 LZH V1.2 °ežX4*NY(uW[µk
    20250429 LZH V1.3 °ežXMESûN¡RUS÷S
--]]
m3    = require("oi_base_mobox")
json  = require("json")
mobox = require("OILua_JavelinExt")
require("GT-Base")
function CreateDelivery(strLuaDEID)
    local nRet, strRetInfo, in_date, dictItem
    -- 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), 'úQ“^USnc NÑSÂSpe:', in_date)
 
    -- ·ƒÖS task_no0wh_code 0batch_no0end_loc0item_code $R­e/f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local task_no = in_date.task_no
    if (task_no == nil or task_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "úQ“^ûN¡R÷S Ný€:Nzz!") end
    local wh_code = in_date.wh_code
    if (wh_code == nil or wh_code == '') then wh_code = 'wmwhse1' 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 end_loc = in_date.end_loc
    if (end_loc == nil or end_loc == '') then lua.Error(strLuaDEID, debug.getinfo(1), ":gð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™e÷S Ný€:Nzz!") end
    -- 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
    -- V1.3 °ežXMESûN¡RUS÷S
    local mes_task_no = in_date.mes_task_no
    local wms_lot = in_date.wms_lot
    local wms_task_no = in_date.wms_task_no
 
    -- ·ƒÖS N—‰¡[8h„vir™e{|‹WW[xQ
    nRet, dictItem = mobox.getDictItemIInfo("GT_NotAuditType")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), dictItem) end
    dictItem = json.decode(dictItem)
    lua.Debug(strLuaDEID, debug.getinfo(1), ' N—‰¡[8h„vir™e:', dictItem)
 
    -- ·ƒÖSå‹ir™e„vir™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
 
    -- ·ƒÖSN*NRËY„v0úQ“^US0pencù[aŒ
    local stock_out = m3.AllocObject(strLuaDEID, "GT_Stock_Out")
    stock_out.delivery_no = task_no
    stock_out.batch_no = batch_no
    stock_out.wh_code = wh_code
    stock_out.item_code = item_code
    stock_out.ms_code = end_loc
    stock_out.type = "GTWMS NÑS"
    stock_out.wms_lot = wms_lot
    stock_out.wms_task_no = wms_task_no
    -- V1.3 °ežXMESûN¡RUS÷S
    stock_out.mes_task_no = mes_task_no
    -- step3 ‚YœgúQ“^“^:S:NËz“^„vúQ“^US ÿæ‰ÑSTðS,gۏLˆM‘';‘
    for m = 1, #dictItem do
        if (item_type == dictItem[m].name) then
            stock_out.state = "/T(u"
            goto back
        end
    end
    ::back::
    nRet, stock_out = m3.CreateDataObj(strLuaDEID, stock_out)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0úQ“^US0ù[aŒ1Y%!' .. stock_out) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'stock_out:', stock_out)
 
    if(item_type ~= '³xў' and item_type ~= '^P[^' and item_type ~= '…Pg')then
        -- Œ(uRú^\ON‹NöN
        nRet, strRetInfo = mobox.triggerClsEvent(strLuaDEID, "GT_Stock_Out", stock_out.id, "Rú^\ON")
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "gbLˆ0úQ“^US0Rú^\ON,g1Y%!" .. strRetInfo) end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'nRet:', nRet)
        lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo:', strRetInfo)
    end
end