--[[
|
版本: Version 2.1
|
创建日期: 2025-1-29
|
创建人: HAN
|
|
WMS-Basis-Model-Version: V15.5
|
|
功能:
|
wms_equipment Lua程序包整合了一些和设备,设备动作等相关的一些函数
|
|
-- Equipment_GetInfo 根据设备号获取设备属性
|
-- MQ_EQAction_Exist 判断是否消息队列里是否存在
|
|
更改说明:
|
--]]
|
wms_base = require ("wms_base")
|
|
local wms_eq = {_version = "0.2.1"}
|
|
--[[ 根据设备号获取设备属性
|
返回2个值: nRet
|
0 获取设备信息 1 不存在 2 错误
|
eq 设备对象
|
--]]
|
function wms_eq.GetInfo( strLuaDEID, eq_code )
|
local nRet, strRetInfo, id
|
|
if ( eq_code == nil or eq_code == '' ) then
|
return 1, "调用 wms_eq.Equipment_GetInfo 函数时参数不正确,设备编码不能为空!"
|
end
|
local strCondition = "S_CODE = '"..eq_code.."'"
|
nRet, id, strRetInfo = mobox.getDataObjAttrByKeyAttr( strLuaDEID, "Equipment", strCondition )
|
if ( nRet == 1 ) then
|
return 1, "设备编码='"..eq_code.."'的设备不存在!"
|
end
|
if ( nRet ~= 0 ) then
|
return 2, "getDataObjAttrByKeyAttr 发生错误!"..id
|
end
|
|
nRet, strRetInfo = mobox.objAttrsToLuaJson( "Equipment", strRetInfo )
|
if ( nRet ~= 0 ) then
|
return 2, "objAttrsToLuaJson Equipment 失败!"..strRetInfo
|
end
|
|
local object, success
|
success, object = pcall( json.decode, strRetInfo )
|
if ( success == false ) then
|
error( "objAttrsToLuaJson('Equipment') 返回的的JSON格式不合法!" )
|
end
|
object.id = id
|
return 0, object
|
end
|
|
--[[
|
判断是否消息队列里是否存在 eq_code 和 action_type 一样的记录 N_B_STATE =0 表示没处理的
|
这个函数在输送线不适用,需要判断线体
|
-- 返回参数 nRet, strResult
|
-- nRet = 0 表示函数调用成功 非零表示有错
|
-- strResult = "no" 表示不存在, "yes" 表示存在
|
--]]
|
function wms_eq.MQ_EQAction_Exist( strLuaDEID, mq_eq_action )
|
local strCondition, nRet, strRetInfo
|
|
strCondition = "N_ACTION_CODE = "..mq_eq_action.action_code.." AND S_EQ_CODE = '"..mq_eq_action.eq_code.."' AND N_B_STATE = 0 "
|
nRet, strRetInfo = mobox.existThisData( strLuaDEID, "MQ_EQAction", strCondition )
|
return nRet, strRetInfo
|
end
|
|
return wms_eq
|