1
Jianw
2025-07-09 88e26a2a960dbbc148332772448b79b9877102d8
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
--[[
    编码: GK-20-29
    名称: 国科-入库单-点领用按钮后
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
        来源国科项目,选中一个入库单进行入库
        搬运模式
 
        [Station]->[Picking AS/RS]
        
    函数: ClickReceiveButton
 
    功能:
        -- 点击领用按钮
 
    更改记录:
 
--]]
 
wms_base = require ("wms_base")
 
function ClickReceiveButton ( strLuaDEID ) 
    local nRet, strRetInfo, n
    local data_json
 
    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 
        mobox.setInfo( strLuaDEID, "必须选中一个入库单!" )
        return 
    end
    if ( nCount > 1 ) then 
        mobox.setInfo( strLuaDEID, "多选无用,只会先一个入库单进行领用!" )
    end    
 
    --V4.0 HAN 2025/3/12 
    local inbound_obj
    local checked_data_json = {}
 
    nRet, inbound_obj = m3.GetDataObject( strLuaDEID, "Inbound_Order", data_json[1].id ) 
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, inbound_obj ) 
        return
    end 
 
    table.insert( checked_data_json, data_json[1] )
 
    -- 获取输入界面中的工作台属性
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STATION_NO" ) 
    if nRet ~= 0 then
        lua.Stop( strLuaDEID, strRetInfo )
        return
    end
    if strRetInfo == '' then
        mobox.setInfo( strLuaDEID, "站台必须选中!")
        return
    end
    local input_value = json.decode( strRetInfo ) 
    local station = lua.Get_StrAttrValue( input_value[1].value )
 
    if ( station == '' ) then
        mobox.setInfo( strLuaDEID, "必须选择一个工作站!" )
        return         
    end
    local strUserLogin, strUserName
    nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID )
    if ( nRet ~= 0 ) then 
        mobox.setInfo( strLuaDEID,  "获取当前操作人员信息失败! "..strUserLogin )
        return 
    end  
 
    -- 组织后台脚本执行的输入参数
    local parameter = {
        factory = inbound_obj.factory,
        as_model = "picking",               -- 自动化立库模式 stacker、agv、picking
        station = station,
        login = strUserLogin,
        user_name = strUserName,
        data_json = checked_data_json,
        cntr_out_op_def = "国科出库",
        cntr_back_op_def = "国科入库",
        empty_cntr_out_rule = "ECOS-001"       
    }  
 
    nRet, strRetInfo = mobox.addBackendScriptProc( "Inbound_Order","入库预分配料箱2#算法", lua.table2str( parameter ) )
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, strRetInfo ) 
        return
    end
 
    local data_json = {proc_id = strRetInfo}
    local action = 
    {
        {
            action_type = "wait",
            value = {
                time = 1,
                event = {
                    cls_name = "入库单",
                    event_name = "获取入库空料箱计算结果",
                    data_json = data_json
                }
            }
        },
    }
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction )
        return
    end        
 
end