--[[
|
编码: WMS-38-05
|
名称: 任务-行按钮-设置任务完成
|
作者:HAN
|
日期:2023-02-25
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: SetTaskFinish
|
|
功能:
|
强制设置任务完成
|
|
更改记录:
|
--]]
|
wms_task = require("wms_task")
|
wms_wh = require("wms_wh")
|
wms_cntr = require("wms_container")
|
function SetTaskFinish(strLuaDEID)
|
local nRet, strRetInfo
|
|
-- step1 获取当前点中的任务
|
nRet, objs = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), objs) end
|
-- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
|
local nCount = #objs
|
if (nCount == 0) then return end
|
|
local task = m3.KeyValueAttrsToObjAttr(objs[1].attrs)
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), 'task', task)
|
|
-- 检查一下脚本里用到的task属性是否在datajson中,没有要提示一下
|
if (task.S_CODE == nil) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "在任务显示Grid中必须要有任务编码属性 S_CODE!")
|
end
|
if (task.S_CODE == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), "任务编码不能为空!")
|
end
|
|
nRet, task = wms_task.GetInfo(strLuaDEID, task.S_CODE)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), task) end
|
lua.Debug(strLuaDEID, debug.getinfo(1), 'task', task)
|
|
-- 根据获取到的任务判断不同的作业名称
|
|
if (tonumber(task.schedule_type) == wms_base.Get_nConst(strLuaDEID, "调度类型-国自")) then
|
if (task.op_name == '立库出库' or task.op_name == '呼叫空托' or task.op_name == '采购退货') then
|
-- 容器货位解绑
|
nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, task.cntr_code,
|
"绑定解绑方法-系统",
|
"完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器解绑失败!' .. strRetInfo) end
|
else
|
-- 容器货位绑定
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "绑定解绑方法-系统",
|
"完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器绑定失败!' .. strRetInfo) end
|
end
|
|
if (task.op_name == '移库') then
|
-- 容器货位解绑
|
nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, task.cntr_code,
|
"绑定解绑方法-系统",
|
"完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器解绑失败!' .. strRetInfo) end
|
|
-- 容器货位绑定
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "绑定解绑方法-系统",
|
"完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器绑定失败!' .. strRetInfo) end
|
end
|
elseif (tonumber(task.schedule_type) == wms_base.Get_nConst(strLuaDEID, "调度类型-AGV")) then
|
if (task.op_name == '移库') then
|
-- 容器货位解绑
|
nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, task.cntr_code,
|
"绑定解绑方法-系统",
|
"完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器解绑失败!' .. strRetInfo) end
|
|
-- 容器货位绑定
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "绑定解绑方法-系统",
|
"完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器绑定失败!' .. strRetInfo) end
|
end
|
if (task.op_name == '粉料入库') then
|
nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "绑定解绑方法-系统", "完成")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '货位容器解绑失败!' .. strRetInfo) end
|
end
|
end
|
|
-- 设置任务完成
|
nRet, strRetInfo = wms.wms_TaskFinish(strLuaDEID, task.code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "任务编码='" .. task.code .. "'的任务设置完成失败!" .. strRetInfo) end
|
|
-- 增加 任务动作 对象
|
local task_action = m3.AllocObject(strLuaDEID, "Task_Action")
|
task_action.task_code = task.code
|
task_action.action_code = 2
|
task_action.action = "强制任务完成"
|
task_action.eq_code = "system"
|
task_action.eq_type_name = '完成'
|
nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, task_action)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '创建【任务动作】对象失败!' .. strRetInfo) end
|
end
|