--[[
|
编码: WMS-20-26#2
|
名称: 入库预分配料箱2#算法
|
作者:HAN
|
日期:2025-5-29
|
|
级别:项目
|
来源艾默生料箱库, 选中一个入库单进行预分配料箱(适用堆垛机立库)
|
|
函数: RunEmptyBoxOutProcess
|
|
功能:
|
-- 后台脚本计算入库需要呼出多少空料箱
|
|
更改记录:
|
|
--]]
|
|
wms_pac = require ("wms_pac_cbg") -- 空料箱预先分配算法
|
|
|
-- 返回结果 result = { cntr_count = 2, cntr_cell_list = {}}
|
-- cntr_cell_list 预分配料格列表
|
function RunEmptyBoxOutProcess ( strLuaDEID )
|
local nRet, strRetInfo, n
|
local parameter, data_json
|
local result = { cntr_count = 0 }
|
|
m3.PrintLuaDEInfo( strLuaDEID )
|
nRet, parameter = m3.GetSysDataJson( strLuaDEID )
|
lua.DebugEx( strLuaDEID, "入库预分配料箱2#算法 --> parameter", parameter)
|
|
--[[
|
parameter = {
|
factory
|
station = station,
|
login = strUserLogin,
|
user_name = strUserName,
|
data_json = data_json -- 选中的入库单
|
cntr_out_op_def -- 预分配容器出库作业定义
|
cntr_back_op_def -- 入库作业定义
|
}
|
]]
|
|
if (nRet ~= 0) then
|
lua.Stop( strLuaDEID, data_json )
|
return 1
|
end
|
|
data_json = parameter.data_json
|
nCount = #data_json
|
if ( nCount == 0 ) then
|
result = { cntr_count = 0 }
|
mobox.returnValue( strLuaDEID, RETSTR_TYPE.Json, lua.table2str(result) )
|
return 0
|
end
|
if nCount > 1 then
|
lua.Stop( strLuaDEID, "抱歉目前只支持一个一个入库单呼出!" )
|
return 1
|
end
|
|
-- 从入库单这里获取 仓库、库区编码,如果不一样报错
|
local wh_code = ''
|
local area_code = ''
|
local compose = {}
|
local obj_attrs, strCondition
|
local wave_detail_list = {}
|
local inbound_order
|
|
obj_attrs = m3.KeyValueAttrsToObjAttr( data_json[1].attrs )
|
bs_no = obj_attrs.S_NO
|
if ( bs_no == '' ) then
|
lua.Stop( strLuaDEID, "入库单列表栅格中'入库单号'列不能为空!" )
|
return 1
|
end
|
|
wh_code = obj_attrs.S_WH_CODE or ''
|
if ( wh_code == '' ) then
|
lua.Stop( strLuaDEID, "入库单列表栅格中仓库列不能为空!" )
|
return 1
|
end
|
area_code = obj_attrs.S_AREA_CODE or ''
|
|
-- 呼出空料箱算法
|
local pac_list = {}
|
local pac_detail_list = {}
|
local enable_aisle = "" -- 可用巷道
|
|
if ( area_code ~= '' and parameter.as_model == "stacker" ) then
|
nRet, enable_aisle = prj_base.Get_Available_Aisle( strLuaDEID, area_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, 'prj_base.Get_Available_Aisle!'..enable_aisle )
|
return
|
end
|
if ( enable_aisle == '' ) then
|
lua.Stop( strLuaDEID, "库区里的所有堆垛机状态都是不可用,无法继续呼出料箱!")
|
return 1
|
end
|
end
|
|
-- 组织预分配料箱呼出时的配置参数
|
local pac_parameter = {
|
factory = parameter.factory,
|
as_model = parameter.as_model, -- 自动化立库模式 stacker 堆垛机 agv、picking
|
wh_code = wh_code, area_code = area_code,
|
station = parameter.station or '',
|
aisle = enable_aisle,
|
bs_type = "Inbound_Order", bs_no = bs_no,
|
cntr_out_op_def = parameter.cntr_out_op_def or '',
|
cntr_back_op_def = parameter.cntr_back_op_def or '',
|
empty_cntr_out_rule = parameter.empty_cntr_out_rule
|
}
|
nRet, strRetInfo = wms_pac.Pre_Alloc_Cntr( strLuaDEID, pac_parameter, pac_list, pac_detail_list )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "Pre_Alloc_Cntr 错误: "..strRetInfo)
|
return 1
|
end
|
|
result = {
|
cntr_count = #pac_list,
|
cntr_cell_list = pac_detail_list,
|
cls_id = "Inbound_Order",
|
obj_id = data_json[1].id
|
}
|
mobox.returnValue( strLuaDEID, RETSTR_TYPE.Json, lua.table2str(result) )
|
|
return 0
|
end
|