--[[
|
编码: WMS-38-01
|
名称: 搬运指令-创建前
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeDataObjCreate
|
|
功能:
|
1)生成任务编码
|
2)对一些数值类型的属性生成这些类型的解析属性
|
更改记录:
|
|
--]]
|
|
wms_base = require( "wms_base" )
|
|
function BeforeDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
local task
|
nRet, task = m3.GetCurEditDataObj( strLuaDEID )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..task ) end
|
|
local state = lua.Get_NumAttrValue( task.bs_state ) -- 状态
|
local schedule = lua.Get_NumAttrValue( task.schedule_type ) -- 调度系统类型
|
local task_type = lua.Get_NumAttrValue( task.type ) -- 任务类型
|
local eq_task_code = lua.Get_StrAttrValue( task.eq_task_code ) -- 设备任务编码
|
local strCode = lua.Get_StrAttrValue( task.code ) -- 任务编码
|
local end_loc_code = lua.Get_StrAttrValue( task.end_loc_code )
|
local start_loc_code = lua.Get_StrAttrValue( task.start_loc_code )
|
local start_aisle = 0
|
local end_aisle = 0
|
local start_aisle_code = ""
|
local end_aisle_code = ""
|
local loc
|
|
-- 获取货位的巷道值
|
if ( end_loc_code ~= '' ) then
|
nRet, loc = wms_wh.GetLocInfo( end_loc_code )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "货位'"..end_loc_code.."'不存在!" )
|
end
|
end_aisle = loc.aisle
|
end_aisle_code = loc.aisle_code
|
end
|
if ( start_loc_code ~= '' ) then
|
nRet, loc = wms_wh.GetLocInfo( start_loc_code )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "货位'"..start_loc_code.."'不存在!" )
|
end
|
start_aisle = loc.aisle
|
start_aisle_code = loc.aisle_code
|
end
|
|
-- 根据字典获取 N_B_STATE 的显示名称
|
local str_b_state = wms_base.GetDictItemName( strLuaDEID, "WMS_TaskState", state )
|
-- 取调度系统类型信息
|
local str_schedule_type = wms_base.GetDictItemName( strLuaDEID, "WMS_ScheduleSystemType", schedule )
|
-- 取任务类型信息
|
local str_task_type = wms_base.GetDictItemName( strLuaDEID, "WMS_TaskType", task_type )
|
|
-- 生成【任务】编码
|
if ( strCode == '' ) then
|
local strHeader = 'TA'..os.date("%y%m%d")..'-'
|
nRet,strCode = mobox.getSerialNumber( "任务", strHeader, 5 )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '申请【任务】编码失败!'..strCode ) end
|
if (eq_task_code == '') then eq_task_code = strCode end
|
end
|
|
-- 设置信息
|
local attr_value =
|
{
|
{ attr = "S_B_STATE", value = str_b_state },
|
{ attr = "S_SCHEDULE_TYPE", value = str_schedule_type },
|
{ attr = "S_CODE", value = strCode },
|
{ attr = "S_TYPE", value = str_task_type },
|
{ attr = "N_START_AISLE", value = start_aisle },
|
{ attr = "N_END_AISLE", value = end_aisle },
|
{ attr = "S_START_AISLE_CODE", value = start_aisle_code },
|
{ attr = "S_END_AISLE_CODE", value = end_aisle_code },
|
{ attr = "S_EQ_TASK_CODE", value = eq_task_code }
|
}
|
nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【任务】信息失败! "..strRetInfo ) end
|
end
|