--[[
|
编码: WMS-40-21#1
|
名称: 作业-成品入库-任务完成
|
作者:HAN
|
日期:2025-1-29
|
|
版本: V1.0
|
|
场景:作业中的任务完成后触发这个脚本
|
当前数据对象指针是 作业
|
任务对象属性保存在 输入参数 InputParamter
|
需要判断一下这个任务完成是否可以关闭 作业
|
|
函数: TaskFinish
|
|
功能:
|
1)根据任务类型判断是否结束作业
|
|
更改记录:
|
|
|
--]]
|
wms_op = require( "wms_operation" )
|
|
function TaskFinish ( strLuaDEID )
|
local nRet, strRetInfo
|
local strErr = ''
|
|
-- 获取 触发【作业】任务完成事件的场景参数
|
-- step1 获取任务信息
|
local task
|
local input_paramters
|
nRet, input_paramters = mobox.getInputParameter2(strLuaDEID)
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "getInputParameter2 失败!" ) end
|
|
-- 把 [{"attr":"xxx","value":""},...] 转换成 task json object
|
local strObjJson
|
nRet, strObjJson = mobox.objAttrsToLuaJson( "Task", input_paramters )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "objAttrsToLuaJson Task 失败!"..strObjJson ) end
|
local success
|
success, task = pcall( json.decode, strObjJson )
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "objAttrsToLuaJson (task) 返回的的JSON格式不合法 !"..task ) end
|
if ( task.start_wh_code == '') then lua.Error( strLuaDEID, debug.getinfo(1), "作业中起点仓库为空!") end
|
|
-- 判断任务类型
|
if ( task.type == wms_base.Get_nConst(strLuaDEID, "任务类型-AGV入库搬运") ) then
|
-- step2 获取作业信息
|
local operation
|
nRet, operation = m3.GetSysCurEditDataObj( strLuaDEID, "Operation" )
|
if (nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), operation ) end
|
|
-- AGV 搬运完成后可以认为作业完成
|
nRet, strRetInfo = wms_op.SetFinish( strLuaDEID, operation.code )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "设置作业编号='"..operation.code.."' 的作业完成失败!"..strRetInfo )
|
end
|
end
|
end
|