--[[
|
编码: GT-100-23
|
名称: NotifyDeviceSignal
|
作者: LZH
|
入口函数:NotifyDeviceSignal
|
功能说明: 004-设备信号反馈,当WCS异常时调用,下发一段agv任务拉到异常区
|
变更历史:
|
--]]
|
wms_task = require("wms_task")
|
require("WMS-Equipment")
|
wms_cntr = require("wms_container")
|
wms_wh = require("wms_wh")
|
require("GT-Base")
|
require("GT_InAndOutboundPolicies")
|
function notifyDeviceSignal(strLuaDEID)
|
local nRet, in_date, strRetInfo
|
-- step1 获取接口数据
|
nRet, in_date = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "无法获取数据包!" .. in_date) end
|
lua.Debug(strLuaDEID, debug.getinfo(1), '004-设备信号反馈参数:', in_date)
|
|
-- step2 判断 必填项 是否都有值?没值报错返回
|
local loc_code = in_date.loc -- 货位
|
local cntr_code = in_date.cntr_code -- 容器
|
-- local extData = in_date.extData
|
-- if (type(extData) ~= 'table') then
|
-- lua.Error(strLuaDEID, debug.getinfo(1), "扩展参数不是列表!")
|
-- end
|
local signalType = lua.StrToNumber(in_date.signalType) -- 1:下线请求,2:叫料请求 3:读码请求,4:下线记录,5:异常申请(固定传3)
|
if (loc_code == nil or loc_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "站点不能为空!") end
|
if (cntr_code == nil or cntr_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "FRID不能为空!") end
|
if (signalType == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "类型不能为空!") end
|
local flag = lua.StrToNumber(in_date.extData) -- 扩展参数 0正常 1异常
|
if (flag == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "扩展参数不能为空!") end
|
|
if (signalType ~= 3) then
|
lua.Error(strLuaDEID, debug.getinfo(1), signalType .. "未启用的请求类型!")
|
end
|
lua.Debug(strLuaDEID, debug.getinfo(1), '111:', 111)
|
|
-- 判断WCS反馈正常还是异常
|
if (tonumber(flag) == 1) then
|
lua.Debug(strLuaDEID, debug.getinfo(1), '222:', 222)
|
-- 任务异常则下发agv任务拉到异常区
|
local strCode
|
local strHeader = 'TA' .. os.date("%y%m%d") .. '-'
|
nRet, strCode = mobox.getSerialNumber("任务", strHeader, 5)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '申请【任务】编码失败!' .. strCode) end
|
-- 获取站台起点
|
loc_code = wms_base.Get_sConst(strLuaDEID, loc_code)
|
local start_loc
|
nRet, start_loc = wms_wh.GetLocInfo(loc_code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo失败!' .. start_loc) end
|
|
-- 根据起点站台获取对应的异常库区
|
-- 异常库区 TWO-BGYCKQ,TWO-QGYCKQ,THREE-BGYCKQ,THREE-QGYCKQ
|
local area_info
|
local strCondition = "S_CODE = '" .. start_loc.area_code .. "'"
|
nRet, area_info = m3.GetDataObjByCondition(strLuaDEID, "Area", strCondition)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取库区信息失败!" .. area_info) end
|
lua.Debug(strLuaDEID, debug.getinfo(1), 'area_info:', area_info)
|
|
local yc_area = ''
|
if (tonumber(area_info.floor) == 2) then
|
lua.Debug(strLuaDEID, debug.getinfo(1), "333!", 3333)
|
if (area_info.note == '半钢') then
|
yc_area = "TWO-BGYCKQ"
|
elseif (area_info.note == '全钢') then
|
yc_area = "TWO-QGYCKQ"
|
else
|
lua.Error(strLuaDEID, debug.getinfo(1), "未定义该站点的库区描述是属于半钢还是全钢!")
|
end
|
elseif (tonumber(area_info.floor) == 3) then
|
if (area_info.note == '半钢') then
|
yc_area = "THREE-BGYCKQ"
|
elseif (area_info.note == '全钢') then
|
yc_area = "THREE-QGYCKQ"
|
else
|
lua.Error(strLuaDEID, debug.getinfo(1), "未定义该站点的库区描述是属于半钢还是全钢!")
|
end
|
else
|
lua.Error(strLuaDEID, debug.getinfo(1), "该楼层未定义异常库区!")
|
end
|
lua.Debug(strLuaDEID, debug.getinfo(1), 'yc_area:', yc_area)
|
|
-- 获取异常区终点
|
local end_loc
|
nRet, end_loc = wms_base.GetAreaAvaliableLoc(strLuaDEID, yc_area)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_base.GetAreaAvaliableLoc 失败! " .. end_loc) end
|
nRet, end_loc = wms_wh.GetLocInfo(end_loc)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo失败!' .. end_loc) end
|
lua.Debug(strLuaDEID, debug.getinfo(1), 'end_loc:', end_loc)
|
-- 创建作业
|
local operation = m3.AllocObject(strLuaDEID, "Operation")
|
operation.start_wh_code = start_loc.wh_code
|
operation.start_area_code = start_loc.area_code
|
operation.start_loc_code = start_loc.code
|
|
-- 终点信息
|
operation.end_wh_code = end_loc.wh_code
|
operation.end_area_code = end_loc.area_code
|
operation.end_loc_code = end_loc.code
|
|
operation.op_type = wms_base.Get_nConst(strLuaDEID, "作业类型-入库")
|
local ext_table = {
|
task_no = strCode
|
}
|
operation.op_def_name = "AGV库内搬运"
|
operation.cntr_code = cntr_code
|
operation.ext_data = lua.table2str(ext_table)
|
|
nRet, operation = m3.CreateDataObj(strLuaDEID, operation)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. operation) end
|
lua.Debug(strLuaDEID, debug.getinfo(1), "作业创建后信息", operation)
|
end
|
end
|