--[[
|
编码: WMS-40-11
|
名称: 删除
|
作者:HAN
|
日期:2025-1-29
|
入口函数: ResetState
|
|
功能说明:
|
把错误状态设置为执行状态
|
更改记录:
|
|
--]]
|
|
wms_op = require( "wms_operation" )
|
|
function ResetState ( strLuaDEID )
|
local nRet, strRetInfo
|
local objs
|
|
-- 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 strObjJson
|
local success
|
local operation = {}
|
for n = 1, nCount do
|
-- 检查一下N_B_STATE是否=3(错误)
|
nRet, strObjJson = mobox.objAttrsToLuaJson( "Operation", lua.table2str( objs[n].attrs ) )
|
success, operation = pcall( json.decode, strObjJson )
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "objAttrsToLuaJson (Operation) 返回的的JSON格式不合法 !"..operation ) end
|
-- 3 错误/4 启动失败 /5 暂停
|
if ( operation.bs_state >= 3 ) then
|
-- 重新读取一下 operation 属性,这个属性是完整的,reset 需要完整的 作业 对象属性
|
nRet, operation = wms_op.GetInfo(strLuaDEID, operation.code)
|
if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "装载作业对象信息失败!" ) end
|
nRet, strRetInfo = wms_op.Reset( strLuaDEID, operation )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "WMS_Operation_Reset失败! "..strRetInfo ) end
|
end
|
end
|
|
-- 如果就是一行刷新当前行
|
if ( nCount == 1 ) then
|
local strAction = '[{"action_type":"refresh_cur_row","value":""}]'
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end
|
end
|
end
|