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
ÿþ--[[
   x: GT-Public-08
    Tðy: PDAËz“^úQ“^ûN¡R NÑS
   \O€ÿLZH
   åegÿ2024-11-18
 
   ýQpeÿ DeliverTask
   ŸRý€:  ÇPDA NÑSËz“^úQ“^ûN¡R
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
require("GT-Base")
function DeliverTask( strLuaDEID )
    local nRet, strRetInfo
    -- ·ƒÖSÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "task_no", "batch_no", "item_code", "end_loc", "qtys")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local task_no = obj_attrs[1].value
    local batch_no = obj_attrs[2].value
    local item_code = obj_attrs[3].value
    local end_loc = obj_attrs[4].value
    local qty = tonumber(obj_attrs[5].value)
    
    -- $RzzŒT!hŒš
    if (task_no == nil or task_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡R÷S Ný€:Nzz! ") end
    if (batch_no == nil or batch_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S Ný€:Nzz! ") end
    if (item_code == nil or item_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™e÷S Ný€:Nzz! ") end
    if (end_loc == nil or end_loc == '') then lua.Error(strLuaDEID, debug.getinfo(1), "È~¹p Ný€:Nzz! ") end
    if (qty == nil or qty < 0 or qty ~= math.floor(qty)) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Xbpe Ný€:Nzzb\peŒTpe! ")
    end
 
    -- ·ƒÖS N—‰¡[8h„vir™e{|‹WW[xQ
    local dictItem
    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
 
    -- îvMRËz“^̑b—êSX[ö€™eŒT¢”N„vir™e,vQÖN„vir™eRôv¥c¥b•
    if(item_type ~= '¢”N' and item_type ~= ')Y6qö€' and item_type ~= 'ceňö€')then
        lua.Error(strLuaDEID, debug.getinfo(1),item_type .. "{|‹Wir™e N(WËz“^-N!")
    end
 
    for i = 1,qty do
        -- ·ƒÖ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.end_loc_code = end_loc
        stock_out.is_pack = material.is_pack
        -- 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"
            end
        end
        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)
 
        -- Œ(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
    end
end