--[[
|
编码: WMS-90-01#1
|
名称: SKU-创建前
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeDataObjCreate
|
|
功能:
|
根据输入的长中短边计算料箱类型, 适合于需要根据货品外形来确定可存储的料格模式
|
|
来源:
|
巨星二期料箱库
|
|
更改记录:
|
V2.0 HAN 20241024
|
-- 对长边超出料箱要求的货品进行特别处理
|
|
--]]
|
prj_base = require( "prj_base" )
|
|
function BeforeDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo, storer
|
local sku
|
nRet, sku = m3.GetSysCurEditDataObj( strLuaDEID, "SKU" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..sku ) end
|
|
-- 如果没有设置货主取默认货主
|
storer = lua.Get_StrAttrValue( sku.storer )
|
if ( storer == '' ) then
|
nRet, storer = wms_base.Get_sConst2( strLuaDEID, "WMS_Default_Storer" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "系统常量'WMS_Default_Storer'不存在!")
|
return
|
end
|
if ( storer == '' ) then
|
lua.Stop( strLuaDEID, "系统常量'WMS_Default_Storer'必须有值!")
|
return
|
end
|
end
|
|
local str_cell_type = ''
|
-- 设置【料箱类型】信息
|
nRet, strRetInfo = prj_base.GetBoxStyle( strLuaDEID, sku.long, sku.middle, sku.short )
|
if ( nRet == 0 ) then
|
-- 获取最小的 cell_type
|
local box_style = json.decode( strRetInfo )
|
local n = #box_style
|
if ( n > 0 ) then str_cell_type = box_style[n] end
|
else
|
strRetInfo = ''
|
end
|
|
local attr_value = {
|
{ attr = "S_STORER", value = storer },
|
{ attr = "S_AVL_SPEC", value = strRetInfo },
|
{ attr = "S_CELL_TYPE", value = str_cell_type },
|
{ attr = "F_VOLUME", value = sku.long * sku.middle * sku.short }
|
}
|
nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【SKU】信息失败! "..strRetInfo ) end
|
end
|