--[[
|
编码: WMS-38-100
|
名称: 任务类型-任务完成
|
日期:2025-1-29
|
|
作者:HAN
|
入口函数: TaskFinish
|
|
功能说明:
|
-- 解绑开始货位
|
-- 和终点货位绑定
|
-- 库存量要转移
|
|
变更记录:
|
V2.0 HAN 20241115 加了起始货位解绑
|
V3.0 HAN 20250624 从容器中获取当前货位
|
--]]
|
wms_wh = require( "wms_wh" )
|
wms_inv = require ("wms_inventory")
|
|
function TaskFinish(strLuaDEID)
|
local nRet, strRetInfo
|
|
m3.PrintLuaDEInfo( strLuaDEID )
|
|
-- 获取当前触发脚本的任务信息(Task)
|
local task
|
nRet, task = m3.GetSysCurEditDataObj( strLuaDEID, "Task" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, '获取当前编辑对象失败!'..task )
|
return
|
end
|
-- 数据属性判断
|
if lua.StrIsEmpty( task.cntr_code ) or lua.StrIsEmpty( task.end_loc_code ) then
|
lua.Stop( strLuaDEID, "任务完成脚本失败, task 属性不合规!")
|
return
|
end
|
|
-- 得到容器当前货位(担心上传上来的 start_location 和当前容器的绑定货位不一致,还是从 Loc_Container 获取比较保险)
|
local cntr_cur_loc = wms_wh.GetLocCodeByCNTR( strLuaDEID, task.cntr_code )
|
if cntr_cur_loc == '' then
|
return 1,"容器 '"..cntr_code.."' 没有绑定货位!"
|
end
|
|
nRet, strRetInfo = wms_wh.Loc_Container_Unbinding( strLuaDEID, cntr_cur_loc, task.cntr_code, "绑定解绑方法-系统", task.code.."搬运完成" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, '货位容器绑定失败!'..strRetInfo )
|
return
|
end
|
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding( strLuaDEID, task.end_loc_code, task.cntr_code, "绑定解绑方法-系统", task.code.."搬运完成" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, '货位容器绑定失败!'..strRetInfo )
|
return
|
end
|
-- 解锁
|
nRet, strRetInfo = wms.wms_UnlockByTask( strLuaDEID, task.code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "wms_UnlockByTask 失败! "..strRetInfo )
|
return
|
end
|
|
-- 库存量转移
|
nRet, strRetInfo = wms_inv.Move( strLuaDEID, task.cntr_code, cntr_cur_loc, task.end_loc_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "wms_inv.Move 失败! "..strRetInfo )
|
return
|
end
|
end
|