--[[ 项目中Lua调用外部 API 更新记录: --]] wms_base = require( "wms_base" ) local external_api = {_version = "0.1.1"} --[[ 1# Task_Cancel 通知WCS任务取消 2# Get_DEV_State 获取设备的状态 ]] --////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- 通过WCS的接口,获取设备状态 -- reqDev 设备号, readingBit -- 读码位 function external_api.Get_DEV_State( strLuaDEID, reqDev ) local dev_state = { {DVC_NO = "ZD01", IS_USE = 1}, {DVC_NO = "ZD02", IS_USE = 1}, {DVC_NO = "ZD03", IS_USE = 0}, {DVC_NO = "ZD04", IS_USE = 1} } return 0, dev_state end --[[ local nRet, strRetInfo local now = os.date("%Y%m%d%H%M%S") local randomNum = math.random(1, 99999) local requestPk = "PK"..now..randomNum local wcs_url nRet, wcs_url = wms_base.Get_sConst2( strLuaDEID, "WCS服务地址") if ( nRet ~= 0 ) then return 1, "系统无法获取常量'WCS服务地址'" end local strurl = wcs_url..'/wcs-admin/api/dvc-state' local body = { requestPk = requestPk, reqDvc = reqDvc, } lua.Debug( strLuaDEID, debug.getinfo(1), "调WCS接口-->", strurl ) lua.Debug( strLuaDEID, debug.getinfo(1), "body", body ) nRet, strRetInfo = mobox.sendHttpRequest( strurl, "", lua.table2str(body) ) if ( nRet ~= 0 or strRetInfo == '' ) then lua.Error( strLuaDEID, debug.getinfo(1), "调用WCS /wcs-admin/api/receive 接口失败! "..strRetInfo ) end lua.Debug( strLuaDEID, debug.getinfo(1), "strRetInfo", strRetInfo ) local ret_info = json.decode(strRetInfo) return 0, ret_info.data end ]] --////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --Task_Cancel 取消任务 --cntr_code 容器号, task_code 任务号 function external_api.Task_Cancel(strLuaDEID, cntr_code, task_code) return 0, "" end --[[ local nRet, strRetInfo,n -- local now = os.date("%Y%m%d%H%M%S") -- local randomNum = math.random(1, 99999) -- local requestPk = "PK"..now..randomNum local wcs_url nRet, wcs_url = wms_base.Get_sConst2( strLuaDEID, "WCS服务地址") if ( nRet ~= 0 ) then return 1, "系统无法获取常量'WCS服务地址'" end local strurl = wcs_url..'/wcs-admin/api/cancel' local body = { requestPk = task_code, contNo = cntr_code, clientCode = wms, reqTime = 2022-11-11 } lua.Debug( strLuaDEID, debug.getinfo(1), "调WCS接口-->", strurl ) lua.Debug( strLuaDEID, debug.getinfo(1), "body", body ) nRet, strRetInfo = mobox.sendHttpRequest( strurl, "",lua.table2str(body) ) if ( nRet ~= 0 or strRetInfo == '' ) then lua.Error( strLuaDEID, debug.getinfo(1), "调用WCS /wcs-admin/api/receive 接口失败! "..strRetInfo ) end lua.Debug( strLuaDEID, debug.getinfo(1), "strRetInfo", strRetInfo ) local ret_info = json.decode(strRetInfo) return 0, ret_info.msg end ]] return external_api