1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
--[[
    编码: WMS-24-13
    名称: 出库单-重置汇总信息
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: ResetSumInfo
 
    功能:
        1) 系统自动生成行号
    更改记录:
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function ResetSumInfo ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    -- 获取发货单号
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_NO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
 
    local obj_attrs = json.decode( strRetInfo ) 
    local oo_no = obj_attrs[1].value                 -- 出库单号
    if ( oo_no == '' )  then return end 
 
    local data_objs, n
    local strCondition = "S_OO_NO = '"..oo_no.."'"
    local strOrder = "N_ROW_NO"
 
    nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Outbound_Detail", strCondition, strOrder )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "QueryDataObject失败!"..data_objs) end
    local object_attr
    local sum_qty = 0
    local qty, volume, weight
    local sum_volume, sum_weight
    local item_set = {}
 
    sum_volume = 0
    sum_weight = 0
    if ( data_objs ~= '') then
        for n = 1, #data_objs do
            object_attr = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)
 
            qty = lua.StrToNumber( object_attr.F_QTY )
            volume = lua.StrToNumber( object_attr.F_VOLUME )
            weight = lua.StrToNumber( object_attr.F_WEIGHT )
 
            sum_qty = sum_qty + qty
            sum_volume = sum_volume +qty*volume
            sum_weight = sum_weight +qty*weight
            if ( lua.IsInTable( object_attr.S_ITEM_CODE, item_set ) == false ) then
                table.insert( item_set, object_attr.S_ITEM_CODE )
            end
        end
 
        local good_type_num = #item_set
 
        local strUpdate = "S_STATE = '定版', N_TOTAL_QTY = "..sum_qty..", N_GOOD_TYPE_NUM = "..good_type_num..", F_TOTAL_WEIGHT = "..sum_weight
        strUpdate = strUpdate..", F_TOTAL_VOLUME = "..sum_volume
 
        strCondition = "S_NO = '"..oo_no.."'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Order", strCondition, strUpdate )
        if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1),  "更新【出库单】信息失败!"..strRetInfo ) end          
    end    
end