--[[
|
编码: WMS-01-02#1
|
名称: 容器-创建后
|
作者:HAN
|
日期:2025-01-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterDataObjCreate
|
|
功能:
|
-- 根据容器中的规格字段 S_SPEC 生成 Container_Cell
|
|
来源项目: 巨星料箱库
|
适合带料格的料箱创建
|
更改记录:
|
|
--]]
|
wms_base = require( "wms_base" )
|
|
-- 创建 Container_Cell
|
-- cntr_code 料箱编码 cntr_spec 料箱规格 num 料格数量
|
local function create_container_cell( strLuaDEID, cntr_code, cntr_spec, num )
|
local cntr_cell
|
for n = 1, num do
|
cntr_cell = m3.AllocObject(strLuaDEID,"Container_Cell")
|
cntr_cell.cntr_code = cntr_code
|
cntr_cell.cell_no = cntr_spec.."-"..n
|
|
if ( cntr_spec == 'A') then
|
cntr_cell.long = 60
|
cntr_cell.middle = 40
|
cntr_cell.short = 30
|
elseif ( cntr_spec == 'B') then
|
cntr_cell.long = 40
|
cntr_cell.middle = 30
|
cntr_cell.short = 30
|
elseif ( cntr_spec == 'C') then
|
cntr_cell.long = 40
|
cntr_cell.middle = 30
|
cntr_cell.short = 20
|
elseif ( cntr_spec == 'D') then
|
cntr_cell.long = 30
|
cntr_cell.middle = 30
|
cntr_cell.short = 20
|
elseif ( cntr_spec == 'E') then
|
cntr_cell.long = 30
|
cntr_cell.middle = 20
|
cntr_cell.short = 20
|
end
|
cntr_cell.volume = cntr_cell.long*cntr_cell.middle*cntr_cell.short
|
cntr_cell.cell_type = cntr_spec
|
nRet, cntr_cell = m3.CreateDataObj(strLuaDEID, cntr_cell)
|
if (nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),"创建【容器箱格】失败!"..cntr_cell ) end
|
end
|
end
|
|
function AfterDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
|
-- step1 获取当前货位绑定表的信息,获取 货位号,容器编号
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_SPEC", "S_CODE", "S_TYPE")
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), " 获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local cntr_spec = obj_attrs[1].value -- 容器规格
|
local cntr_code = obj_attrs[2].value -- 容器编码
|
local cntr_type = obj_attrs[3].value
|
|
if ( cntr_type ~= "Cell_Box" ) then return end
|
if ( cntr_spec == nil or cntr_spec == '' ) then return end
|
if ( cntr_code == nil or cntr_code == '' ) then return end
|
|
-- 根据不同类型的料箱类型生成料格对象
|
local cntr_cell
|
local num = 0
|
if ( cntr_spec == 'A') then
|
num = 1
|
elseif ( cntr_spec == 'B') then
|
num = 2
|
elseif ( cntr_spec == 'C') then
|
num = 3
|
elseif ( cntr_spec == 'D') then
|
num = 4
|
elseif ( cntr_spec == 'E') then
|
num = 6
|
else
|
return
|
end
|
create_container_cell( strLuaDEID, cntr_code, cntr_spec, num )
|
end
|