--[[
|
编码: WMS-01-22
|
名称: 空料箱入库
|
作者:HAN
|
日期:2025-7-1
|
入口函数: Import
|
来源:
|
巨星,国科料箱库
|
|
功能说明:
|
导入格式如下
|
|--料箱类型--|--料格类型--|--库区--|--数量--|
|
|
变更历史:
|
|
--]]
|
wms_base = require ("wms_base")
|
wms_wh = require ("wms_wh")
|
|
function Import(strLuaDEID)
|
local nRet, strRetInfo, strNo
|
-- 获取导入的数据, 返回 [{"attr":"xx","value":""},...]
|
local row_data = {}
|
nRet, row_data = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0 or strRetInfo == '') then
|
lua.Stop( strLuaDEID, "无法获取导入数据!")
|
return
|
end
|
|
local row_attrs
|
local n, nCount, nRows
|
|
-- 导入是可分多页分批导入, 因此每次的起始行不一样
|
nRet, strRetInfo = mobox.getGlobalAttrValue( strLuaDEID, "start_row" )
|
if ( nRet ~= 0 ) then
|
mobox.error( strLuaDEID, "获取批量导入全局参数 start_row 失败!"..strRetInfo )
|
return
|
end
|
local nStartRow = tonumber( strRetInfo )
|
-- 步骤1 获取从excel导入的一行数据
|
local cntr, area, loc
|
nRow = nStartRow
|
for row = 1, #row_data do
|
row_attrs = row_data[row]
|
nCount = #row_attrs
|
|
num = 1
|
ctd_code = ''
|
cell_type = ''
|
area_code = ''
|
|
for n = 1, nCount do
|
strAttr = row_attrs[n].attr
|
strValue = row_attrs[n].value
|
if (strAttr ~= '') then
|
if (strAttr == "容器类型") then
|
ctd_code = strValue
|
elseif (strAttr == "料格类型") then
|
cell_type = strValue
|
elseif (strAttr == "库区") then
|
area_code = strValue
|
elseif (strAttr == "数量") then
|
num = lua.Get_NumAttrValue( strValue )
|
end
|
end
|
end
|
|
if ctd_code == '' then
|
lua.Stop( strLuaDEID, "第"..nRow.."行缺少容器类型!" )
|
return
|
end
|
|
if cell_type == '' then
|
lua.Stop( strLuaDEID, "第"..nRow.."行缺少料格类型!" )
|
return
|
end
|
|
if area_code == '' then
|
lua.Stop( strLuaDEID, "第"..nRow.."行缺少库区!" )
|
return
|
end
|
|
nRet, area = wms_wh.GetAreaInfo( area_code )
|
if (nRet ~= 0) then
|
lua.Stop( strLuaDEID, "从内存获取编码'"..area_code.."'的库区信息失败!, 库区不存在!" )
|
return
|
end
|
|
for n = 1, num do
|
cntr = m3.AllocObject(strLuaDEID,"Container")
|
cntr.ctd_code = ctd_code
|
cntr.type = "Cell_Box"
|
cntr.spec = cell_type
|
|
nRet, cntr = m3.CreateDataObj( strLuaDEID, cntr )
|
if nRet ~= 0 then
|
lua.Stop( strLuaDEID, cntr )
|
return
|
end
|
-- 分配一个库区的空货位绑定空料箱
|
strCondition = "S_AREA_CODE = '"..area_code.."' AND N_CURRENT_NUM = 0 AND N_LOCK_STATE = 0 AND C_ENABLE = 'Y'"
|
nRet, loc = m3.GetDataObjByCondition( strLuaDEID, "Location", strCondition, "N_POS_WEIGHT" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "获取【Location】信息失败!"..cp_cntr )
|
return
|
end
|
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding( strLuaDEID, loc.code, cntr.code, "绑定解绑方法-系统", "测试用" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, '货位容器绑定失败!'..strRetInfo )
|
return
|
end
|
end
|
end
|
end
|