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
ÿþ--[[
    x: GT-06-10
     Tðy: $R­e¶r`/f&TŒ[b
    \O€ÿLZH
    åegÿ2024-6-3
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ StatusDoneOrNot
 
    ŸRý€:
        -- $R­eň±{å]US„v/}¡‹peϑ/f&T'YŽNI{ŽN¡‹Rpeϑ ÿ/fRîO9e¶r`:NŒ[b
 
    ôf9e°‹U_:
 
--]]
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
function StatusDoneOrNot(strLuaDEID)
    local nRet, strRetInfo
 
    local pack_rec, pack_order
    nRet, pack_rec = m3.GetSysCurEditDataObj(strLuaDEID, "GT_Packing_Rec")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), pack_rec) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'pack_rec', pack_rec)
 
    --·ƒÖSň±{å]US
    nRet, pack_order = m3.GetDataObjectByKey(strLuaDEID, "GT_Packing_Order", "S_PACK_NO", pack_rec.pack_no)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), pack_order) end
 
    -- $R­eň±{å]US„vň±{öNpe/f&T N:N0 ‚Yœg N:N0 $R­eň±{å]US„v /}¡‹Åˆ±{peϑ = Åˆ±{öNpe R¾‹nŒ[b¶r`
    if (tonumber(pack_order.pack_qty) ~= 0) then
        if (tonumber(pack_order.acc_qty) >= tonumber(pack_order.pack_qty)) then
            local strCondition = "S_PACK_NO = '" .. pack_order.pack_no .. "'"
            local strSetSQL = "S_STATE = 'Œ[b'"
            nRet, strRetInfo = mobox.updateTableAttrByCondition(strLuaDEID, "TN_GT_Packing_Order", strCondition,
                strSetSQL)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
        end
    end
 
    -- ·ƒÖSeQ“^US
    local order
    nRet, order = m3.GetDataObjectByKey(strLuaDEID, "GT_Incoming_Info", "S_ORDER_NO", pack_order.order_no)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), order) end
 
    -- $R­eeQ“^US N„v /}¡‹Åˆ±{peϑ = XbØvpeϑ RîO9eeQ“^USåNÊSeQ“^US N@b    g:N/T¨R¶r`„vň±{å]US:NŒ[b¶r`
 
    if (tonumber(order.acc_pack_qty) == tonumber(order.cntr_qty)) then
        local strCondition = "S_ORDER_NO = '" .. order.order_no .. "'"
        local strSetSQL = "S_STATE = 'Œ[b'"
        nRet, strRetInfo = mobox.updateTableAttrByCondition(strLuaDEID, "TN_GT_Incoming_Info", strCondition,
            strSetSQL)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
 
        strCondition = "S_ORDER_NO = '" .. order.order_no .. "' AND S_STATE = '/T(u'"
        local pack_order_list
        nRet, pack_order_list = m3.QueryDataObject(strLuaDEID, "GT_Packing_Order", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), pack_order_list) end
        if(pack_order_list == nil or #pack_order_list == 0) then
            return
        end
 
        for n = 1,#pack_order_list do
            local attrs = pack_order_list[n].attrs
            attrs = m3.KeyValueAttrsToObjAttr(attrs)
            strCondition = "S_PACK_NO = '" .. attrs.S_PACK_NO .. "'"
            strSetSQL = "S_STATE = 'Œ[b'"
            nRet, strRetInfo = mobox.updateTableAttrByCondition(strLuaDEID, "TN_GT_Packing_Order", strCondition,
                strSetSQL)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
        end
    elseif(tonumber(order.acc_pack_qty) > tonumber(order.cntr_qty)) then
        lua.Error(strLuaDEID, debug.getinfo(1), "ò]¾0ReQ“^US„vXbØvpeϑ ÿ NAQ¸‹eQ“^!")
    end
end