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-21
   名称: 呼出空料箱点确定按钮
   作者:
   日期:2025-1-29
 
   函数: main
   功能:
         确定呼出的空料箱,组盘容器创建出库作业
         
   更改记录:
        V2.0 HAN 20250113
             -- 增加后台线程创建组盘出库作业
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function main( strLuaDEID )
    local nRet, strRetInfo
    local strCondition, strSetAttr
 
    -- 这里的 paramter 是在点击领用按钮后,传入的 入库波次对象,如果取消就是删除波次对象
    nRet, parameter = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取input parameter 失败! "..parameter ) end 
 
    local from = parameter.from
    if ( from == "Overweight_call" ) then
        -- 呼出空料箱来自 站台的超重货品入库呼出,需要把【站台货品明细】中相关的记录更新状态
        local station = lua.Get_StrAttrValue( parameter.station )
        local bs_type = lua.Get_StrAttrValue( parameter.bs_type )
        local bs_no = lua.Get_StrAttrValue( parameter.bs_no )
        if ( station == '' or bs_type == '' or bs_no == '' ) then 
            mobox.stopProgram( strLuaDEID, "paramter 参数中 属性 station, bs_type, bs_no 不能为空!")
            return
        end
        strCondition = "S_STATION_NO = '"..station.."' AND S_BS_TYPE = '"..bs_type.."' AND S_BS_NO = '"..bs_no.."'"
        strSetAttr = "N_B_STATE = 2"        -- 2 系统已组盘完成
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Station_Goods_Detail", strCondition, strSetAttr )
        if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【站台货品明细】信息失败!"..strRetInfo ) end 
    end
 
    -- 获取入库批次对象
    nRet, iw_obj = m3.GetDataObject( strLuaDEID, parameter.cls_id, parameter.obj_id ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), iw_obj ) end 
    
    -- 获取入库批次创建的组盘容器,触发这些组盘容器创建出库作业
    local strCondition = "S_BS_TYPE = '"..parameter.cls_id.."' AND S_BS_NO = '"..iw_obj.wave_no.."'"
    nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Pre_Alloc_Container", strCondition )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "查询组盘失败! "..data_objs ) end
    if ( data_objs ~= '' ) then
        local n, data_attrs
 
        for n = 1, #data_objs do
            data_attrs = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)  
            local add_wfp = {
                wfp_type = 1,
                cls = "Pre_Alloc_Container",
                obj_id = lua.trim_guid_str( data_objs[n].id ),
                obj_name = "预分配料箱流水号'"..data_attrs.S_PAC_NO.."'-->创建作业",
                trigger_event = "后台创建空料箱出库作业"
            }
            nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )
            if ( nRet ~= 0 ) then 
                lua.Error( strLuaDEID, debug.getinfo(1), "AddSysWFP失败!"..strRetInfo )  
            end              
        end
    end
    
    local action = {
        {
            action_type = "close_dlg",
            value = ""
        }
    }
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end        
 
end