1
Jianw
10 天以前 f6f5e6b632d6649386a380558d84003f3de7ec6c
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
--[[
    编码: WMS-01-19
    名称: 容器-Rest
    作者:HAN  
    日期:2025-1-29
 
    级别: 项目
    
    函数: Reset
 
    功能:
        -- 这个脚本用于 Grid 中选中行点 重置 后触发
        -- 根据 INV_Detail 重新设置容器的明细数量,容器、料格空满状态
 
    更改记录:
 
--]]
wms_cntr = require( "wms_container" )
 
function Reset( strLuaDEID ) 
    local nRet, strRetInfo
    local data_json
 
    m3.PrintLuaDEInfo( strLuaDEID )
    
    nRet, data_json = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then 
        lua.Stop( strLuaDEID, data_json )
        return 
    end  
    local nCount = #data_json
    if ( nCount == 0 ) then  return end
    local cntr
 
    nRet, cntr = m3.ObjAttrStrToLuaObj( "Container", data_json[1].attrs )
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, cntr )
        return 
    end  
    local cntr_code = cntr.code or ''
    
    -- 先清除一下 INV_Detail 中Qty <=0 的记录
    local strCondition = "S_CNTR_CODE = '" .. cntr_code .."' AND F_QTY <= 0"
    nRet, strRetInfo = mobox.dbdeleteData(strLuaDEID, "INV_Detail", strCondition)
    if (nRet ~= 0) then 
        lua.Stop( strLuaDEID, "删除【INV_Detail】失败!"..strRetInfo )
        return
    end   
    nRet, cntr = wms_cntr.GetInfo( strLuaDEID, cntr_code )
    if (nRet ~= 0) then 
        lua.Stop( strLuaDEID, "wms_cntr.GetInfo 失败!"..cntr )
        return
    end 
 
    -- 重置容器属性
    nRet, strRetInfo = wms_cntr.Reset( strLuaDEID, cntr )
    if ( nRet ~= 0 ) then
        lua.Stop( strLuaDEID, strRetInfo )
        return
    end        
 
end