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
ÿþ--[[
   x: GT-23-13
    Tðy: “^X[ß~¡‹
   \O€ÿLZH
   åegÿ2024-10-28
 
   ýQpeÿ InventoryStatistics
   ŸRý€:  (WeQ“^¥cãSŒTúQ“^PDȂb—Œ(uُ*N‹NöN ÿ͑°e¡‹—{Øpö€ô~¤b̑b—ir™e(W708÷]SÌ‘b—„v“^X[͑ϑ
 
   ôf9e°‹U_:
 
--]]
 
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
 
function InventoryStatistics(strLuaDEID)
    -- ·ƒÖS@b    gØpö€ô~¤bir™e
    local strCondition = "S_ITEM_CODE = S_ITEM_CODE"
    local nRet, glue_drying = mobox.queryDataObjAttr2(strLuaDEID, "GT_Glue_Drying", strCondition, "", 100, "S_ITEM_CODE")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "ågâ‹0Øpö€ô~¤b0áOo`1Y%!" .. glue_drying) end
    if (glue_drying == nil or glue_drying == '') then return end
    local queryInfo = json.decode(glue_drying)
    local nPageCount = queryInfo.pageCount
    local dataSet = queryInfo.dataSet
    local queryID = queryInfo.queryID
    lua.Debug(strLuaDEID, debug.getinfo(1), 'queryInfo:', queryInfo)
 
    -- Ru˜·ƒÖSØpö€ô~¤b„vpenc
    for i = 1, nPageCount do
        lua.Debug(strLuaDEID, debug.getinfo(1), 'dataSet', dataSet)
        for j = 1, #dataSet do
            local attrs = m3.KeyValueAttrsToObjAttr(dataSet[j].attrs)
            local item_code = attrs.S_ITEM_CODE
 
            -- Çir™ex·ƒÖS708÷]S;`͑ϑ
            strCondition = "S_ITEM_CODE = '" .. item_code .. "' AND "
            strCondition = strCondition .. " S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_Loc_Container "
            strCondition = strCondition .. "WHERE S_LOC_CODE IN (SELECT S_CODE FROM TN_Location WHERE N_ROADWAY IN (7,8)))"
            local sumQty
            nRet, sumQty = mobox.getDataObjAttrSum(strLuaDEID, "CG_Detail", strCondition, "F_QTY")
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "" .. sumQty)
            end
            sumQty = json.decode(sumQty)
            sumQty = tonumber(sumQty[1])
 
            -- îO9eØpö€ô~¤bù[”^ir™e„v“^X[ϑ
            local strSetSQL_update, strRetInfo
            strCondition = "S_ITEM_CODE = '" .. item_code .. "'"
            strSetSQL_update = " N_QTY = " .. sumQty
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Glue_Drying", strCondition,
                strSetSQL_update)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eØpö€ô~¤b“^X[ϑ1Y%!" .. strRetInfo) end
        end
 
        if ((i + 1) <= nPageCount) then
            -- ÖS NNu˜
            local data
            nRet, data = mobox.queryDataObjAttr2(queryID, (i+1))
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "ågâ‹0“^:Sϑhˆ01Y%! nPage=" .. i+1 .. "  " .. data)
            end
            data = json.decode(data)
            dataSet = data.dataSet
        end
    end
end