--[[
|
编码: WMS-40-21#3
|
名称: 作业-入库-任务完成
|
作者:HAN
|
日期:2025-1-29
|
|
版本: V1.0
|
|
场景:作业中的任务完成后触发这个脚本
|
当前数据对象指针是 作业
|
任务对象属性保存在 输入参数 InputParamter
|
需要判断一下这个任务完成是否可以关闭 作业
|
|
目前这个脚本是针对 国科 Picking 车的场景,任务完成后就是作业完成
|
|
函数: TaskFinish
|
|
功能:
|
|
更改记录:
|
|
--]]
|
wms_op = require( "wms_operation" )
|
wms_pac = require( "wms_pac_cbg" )
|
|
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.Stop( strLuaDEID, "getInputParameter2 失败!" )
|
return
|
end
|
|
-- 把 [{"attr":"xxx","value":""},...] 转换成 task json object
|
nRet, task = m3.AttrValueStrToLuaJson( "Task", input_paramters )
|
if nRet ~= 0 then
|
lua.Stop( strLuaDEID, task )
|
return
|
end
|
|
local strUpdateSql, strCondition
|
local operation
|
nRet, operation = m3.GetSysCurEditDataObj( strLuaDEID, "Operation" )
|
if (nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, operation )
|
return
|
end
|
nRet, strRetInfo = wms_op.SetFinish( strLuaDEID, operation )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "设置作业编号='"..operation.code.."' 的作业完成失败!"..strRetInfo )
|
return
|
end
|
|
-- 根据不同的作业类型做不同的后处理
|
if operation.op_def_name == '国科入库' then
|
local carry_cb_no = lua.Get_StrAttrValue( operation.carry_cb_no )
|
if ( operation.carry_cb_cls == "Distribution_CNTR" ) then
|
-- 拣货后回库
|
-- 如果作业的配盘后料箱回库,需要设置配盘对象的状态 = 6
|
if ( carry_cb_no ~= '' ) then
|
strUpdateSql = "N_B_STATE = "..DIST_CNTR_STATE.Finish
|
strCondition = "S_DC_NO = '"..carry_cb_no.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Distribution_CNTR", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "更新【配盘】信息失败!"..strRetInfo )
|
return
|
end
|
end
|
-- 如果携带的容器的业务类型 = 预分配容器
|
elseif ( operation.carry_cb_cls == "Pre_Alloc_Container" ) then
|
if ( carry_cb_no ~= '' ) then
|
strUpdateSql = "N_B_STATE = "..PAC_STATE.Finish
|
strCondition = "S_PAC_NO = '"..carry_cb_no.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Pre_Alloc_Container", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "更新【预分配容器】信息失败!"..strRetInfo )
|
return
|
end
|
|
local pac_cntr
|
nRet, pac_cntr = m3.GetDataObjByCondition( strLuaDEID, "Pre_Alloc_Container", strCondition )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "获取【预分配容器】信息失败!"..strRetInfo )
|
return
|
end
|
-- 预分配容器入库完成后
|
nRet, strRetInfo = wms_pac.After_PAC_Finish( strLuaDEID, carry_cb_no )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "wms_pac.After_PAC_Finish 失败!"..strRetInfo )
|
return
|
end
|
-- 增加一个后台进程对组盘进行处理,触发配盘明细中的入库波次是否可以完成
|
local add_wfp = {
|
wfp_type = 1,
|
cls = "Pre_Alloc_Container",
|
obj_id = pac_cntr.id,
|
obj_name = "预分配容器'"..carry_cb_no.."'-->入库后处理",
|
trigger_event = "入库后处理"
|
}
|
nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "AddSysWFP失败!"..strRetInfo )
|
return
|
end
|
end
|
end
|
end
|
end
|