--[[
|
编码: WMS-100-04
|
名称: EQAction
|
作者:HAN
|
日期:2025-1-29
|
|
入口函数: EQActionProcess
|
处理和输送线相关的【MQ_EQAction】设备动作码
|
|
功能说明:
|
当入库线,出库线出口的线体有 10 动作码时标记输送线线体任务完成
|
|
变更记录:
|
--]]
|
wms_task = require( "wms_task" )
|
|
function EQActionProcess ( strLuaDEID )
|
local nRet, strRetInfo
|
|
-- step1 获取设备动作队列 MQ_EQAction
|
local mq_eq_action
|
nRet, mq_eq_action = m3.GetSysCurEditDataObj( strLuaDEID, "MQ_EQAction ")
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), mq_eq_action ) end
|
|
lua.Debug( strLuaDEID, debug.getinfo(1), "mq_eq_action", lua.table2str(mq_eq_action))
|
-- step2:
|
-- 获取任务信息,如果有任务编码检查一下任务是否存在
|
-- 检查任务的状态是否=完成,已经完成的任务也不能继续接收 action
|
local task = {}
|
if ( mq_eq_action.task_code ~= '') then
|
nRet, task = wms_task.GetInfo( strLuaDEID, mq_eq_action.task_code )
|
-- 如果任务不存在或出错, 返回
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), task ) end
|
else
|
task = nil
|
end
|
if ( task == nil ) then lua.Error( strLuaDEID, debug.getinfo(1), "监听程序无法定位任务信息, 请检查任务编号是否存在! " ) end
|
|
-- 任务已经完成
|
if ( task.bs_state == wms_base.Get_nConst(strLuaDEID, "任务状态-完成") ) then return end
|
|
-- step3 根据设备的动作码进行处理
|
-- 以下这些动作要判断一下任务里是否已经有,有返回
|
if ( mq_eq_action.action_code == wms_base.Get_nConst(strLuaDEID, "输送线-出库口到货") or
|
mq_eq_action.action_code == wms_base.Get_nConst(strLuaDEID, "输送线-入库口到货") ) then
|
|
nRet, strRetInfo = wms_task.Action_Exist( strLuaDEID, task.code, mq_eq_action.action_code )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "任务动作检查时出错! "..strRetInfo ) end
|
-- 如果这些动作码的任务动作已经存在就返回
|
if ( strRetInfo == "yes" ) then return end
|
|
-- 设置任务完成
|
nRet, strRetInfo = wms.wms_TaskFinish( strLuaDEID, task.code )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "任务编码='"..task.code.."'的任务设置完成失败!"..strRetInfo ) end
|
end
|
|
-- 增加 任务动作 对象
|
local task_action = m3.AllocObject(strLuaDEID,"Task_Action")
|
|
task_action.task_code = mq_eq_action.task_code
|
task_action.action_code = mq_eq_action.action_code
|
task_action.action = mq_eq_action.action
|
task_action.eq_code = mq_eq_action.eq_code
|
task_action.eq_type_name = mq_eq_action.eq_type_name
|
task_action.data = lua.FormatJsonString( mq_eq_action.data )
|
nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, task_action )
|
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '创建【任务动作】对象失败!'..strRetInfo ) end
|
end
|