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
--[[
    编码: WMS-01-12
    名称: 容器-CountDiffPostProcess
    作者:HAN  
    日期:2025-1-29
    级别: 项目
    
    函数: AfterCountDiff
 
    功能:
        -- 这个脚本一般由WPF进行调用
        -- 根据 CG_Detail 重新设置容器的明细数量,容器、料格空满状态
        -- 盘点发现容器货品不正确有差异,系统会把容器设置为不可用,如果发现容器相关的差异已经全部处理,容器设置为可用
    更改记录:
 
--]]
 
wms_cntr = require( "wms_container" )
 
function AfterCountDiff( strLuaDEID ) 
    local nRet, strRetInfo
    local cntr
    nRet, cntr = m3.GetSysCurEditDataObj( strLuaDEID, "Container" )
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..task ) end  
    
    -- 判断一下 该容器的 盘点差异是否全部已经移库,如果全部移库需要把 容器 的 C_ENABLE 设置为 Y (启用)
    local strCondition = "S_CNTR_CODE = '"..cntr.code.."' AND C_DIFF_MOVE = 'N'"
    nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "Count_Diff", strCondition )
    if ( nRet ~= 0 ) then return nRet, strRetInfo end 
    local num = lua.StrToNumber( strRetInfo )     
 
    if ( num == 0 ) then
        local strUpdateSql = "C_ENABLE = 'Y'"
        strCondition = "S_CODE = '"..cntr.code.."'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Container", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【容器】信息失败!"..strRetInfo ) end 
 
        -- 容器重置
        local add_wfp = {
            wfp_type = 1,                  -- 触发数据对象事件(指定数据对象标识)
            cls = "Container",
            obj_id = cntr.id,
            obj_name = "容器'"..cntr.code.."因盘点差异移库触发容器Reset事件",
            trigger_event = "Reset"
        }
        nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )  
        if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "新增WFP信息失败!"..strRetInfo ) end   
    end
end