Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: WMS-19-08
    名称: 容器货品明细-修改后
    作者:HANXU  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: AfterDataObjModify
 
    功能:
        -- 获取修改后的N_货品状态,来修改S_货品状态
        -- 如果 C_ITEM_MERGE = Y 的时候,要判断一下是否有修改数量,如果数量修改要修改 Container_Good 中的数量
 
    更改记录:
 
--]]
wms_base = require( "wms_base" )
 
function AfterDataObjModify ( strLuaDEID ) 
    local cg_detail
    local nRet, strRetInfo
 
    nRet, cg_detail = m3.GetSysCurEditDataObj( strLuaDEID, "CG_Detail" )
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..cg_detail ) end
 
    local n_item_state = lua.StrToNumber(cg_detail.item_state)
    local s_item_state = wms_base.GetDictItemName( strLuaDEID, "WMS_ItemState", n_item_state )
 
    --获取当前编辑的数据对象标识
    --V2.0
    local strClsID, strObjID
    nRet, strClsID, strObjID = mobox.getCurEditDataObjID( strLuaDEID )
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "getCurEditDataObjID失败! " ) end
    local strCondition = "S_ID = '"..strObjID.."'"
    local strSetSQL = "S_ITEM_STATE = '" ..s_item_state .."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "CG_Detail", strCondition, strSetSQL)
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo) end
 
    --V2.0
    if ( cg_detail.item_merge == 'Y') then
        local cg_id = cg_detail.cg_id 
        local qty = cg_detail.qty
        local old_cg_detail
        local qty
 
        nRet, old_cg_detail = m3.GetSysCurEditOldDataObj( strLuaDEID, "CG_Detail" )
        if ( cg_detail.qty ~= old_cg_detail.qty ) then
            -- 更新 Container_Good
            local strSetAttr
            strCondition = "S_ID = '"..cg_detail.cg_id.."'"
            if ( cg_detail.qty > old_cg_detail.qty ) then
                qty = cg_detail.qty - old_cg_detail.qty
                strSetAttr = "F_QTY = F_QTY + "..qty
            else
                qty = old_cg_detail.qty - cg_detail.qty
                strSetAttr = "F_QTY = F_QTY - "..qty
            end
            nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Container_Good", strCondition, strSetAttr )
            if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【容器货品】数量失败!"..strRetInfo ) end 
        end
    end    
end