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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
--[[
    编码: WMS-20-27
    名称: 获取入库空料箱计算结果
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: GetEmptyBoxOutResult
 
    功能:
        -- 点击领用按钮
 
    更改记录:
        V3.0 HAN 20241231 改成后台线程来处理空料箱呼出计算,因为这个过程是一个比较长的事务,有并发锁表的风险
                          本次改进的目的就是将这些长事务统一交给后台一个线程排队处理
--]]
 
wms_base = require ("wms_base")
 
function GetEmptyBoxOutResult ( strLuaDEID ) 
    local nRet, strRetInfo, n
    local paramter
 
    nRet, paramter = m3.GetSysDataJson( strLuaDEID )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), paramter ) end
 
    nRet, strRetInfo = mobox.getBackendScriptProcResult( paramter.proc_id )
    local action = {}
    if ( nRet == 0 ) then
        -- 后台脚本还没处理完成
        action[1] = 
        {
            action_type = "wait",
            value = {
                time = 1,
                event = {
                    cls_name = "入库单",
                    event_name = "获取入库空料箱计算结果",
                    data_json = { proc_id = paramter.proc_id }
                }
            }
        }
    elseif ( nRet == 1 ) then
        -- 后台脚本执行成功
        local result = json.decode( strRetInfo )
 
        local input_parameter = {
            cls_id = "Inbound_Wave",
            obj_id = result.wave_obj_id
        }        
        local data_json = {
            cntr_count = result.cntr_count,
            cntr_cell_list = result.cntr_cell_list
        }
        action = 
        {
            {
                action_type = "open_html_dlg",
                value = {
                    dlg_name = "空料箱呼出确认",
                    cls_id = "Inbound_Order",
                    data_json =  data_json,
                    input_parameter = input_parameter
                }
            },
            {
                action_type = "refresh",
                value = ""
            }
        }
    else
        -- 错误
        mobox.setInfo( strLuaDEID, strRetInfo )
        return
    end
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end        
 
end