--[[
|
|
编码: JX-API-OUTBOUND-01
|
名称: 创建出库单及明细
|
作者:
|
日期: 2025-1-29
|
|
入口函数: main
|
请求示例:
|
{
|
"taskId": "361de469-8f6b-42c8-8cf1-054a8024ea5b",
|
"startLoc": "XC-01-01",
|
"destLoc": "XC-05-02",
|
"cid": "T001",
|
"priority": 0,
|
"memo": ""
|
}
|
响应示例:
|
{
|
"flag": "success",
|
"code": "0",
|
"message": "成功"
|
}
|
]]--
|
|
json = require("json")
|
mobox = require("OILua_JavelinExt")
|
m3 = require( "oi_base_mobox" )
|
wms_base = require( "wms_base" )
|
|
function CreateAgvOperation(strLuaDEID)
|
|
local nRet, strRetInfo
|
local data
|
local start_loc_info
|
local end_loc_info
|
|
-- step1 获取接口中的Data
|
nRet, data = m3.GetSysDataJson(strLuaDEID) -- 获取物料信息数据包
|
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), '任务创建接口获取data失败!')
|
end
|
|
local taskNo = tostring(data.taskId) -- 任务号
|
local locStart = data.startLoc -- 起点
|
local locEnd = data.destLoc -- 终点
|
local cntr = data.cid
|
local priority = data.priority
|
local memo = data.memo
|
|
---------------
|
-- local cntrcode = data.cntrCode --托盘码
|
|
-- if (task_type == nil or task_type == '') then
|
-- Error(strLuaDEID, debug.getinfo(1), '参数缺少任务类型!')
|
-- end
|
|
if (locStart == nil or locStart == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少起点!')
|
end
|
if (locEnd == nil or locEnd == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少终点!')
|
end
|
if (priority == nil or priority == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少优先级!')
|
end
|
|
if (taskNo == nil or taskNo == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少任务号!')
|
end
|
|
if (cntr == nil or cntr == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), '参数容器!')
|
end
|
|
-- -- 获取起点信息
|
-- nRet, start_loc_info = WMS_GetLocInfo(locStart)
|
|
-- if (nRet ~= 0) then
|
-- Error(strLuaDEID, debug.getinfo(1), start_loc_info)
|
-- end
|
-- Debug(strLuaDEID, debug.getinfo(1), "start_loc_info", start_loc_info)
|
|
-- -- 获取终点信息
|
-- nRet, end_loc_info = WMS_GetLocInfo(locEnd)
|
-- if (nRet ~= 0) then
|
-- Error(strLuaDEID, debug.getinfo(1), end_loc_info)
|
-- end
|
-- Debug(strLuaDEID, debug.getinfo(1), "end_loc_info", end_loc_info)
|
|
|
-- 创建作业
|
local operation = m3.AllocObject(strLuaDEID, 'Operation')
|
|
operation.factory = "HC" -- 工厂
|
operation.op_def_name = "AGV点对点" -- 作业名称
|
operation.ext_data = taskNo -- 扩展数据(任务号)
|
operation.priority = priority -- 优先级
|
operation.op_type = 1
|
operation.bs_state = 1
|
-- 起点信息
|
-- operation.start_wh_code = start_loc_info.wh_code -- 仓库
|
-- operation.start_area_code = start_loc_info.area_code -- 库区
|
operation.start_loc_code = locStart-- 货位
|
-- 终点信息
|
-- operation.end_wh_code = end_loc_info.wh_code -- 终点仓库
|
-- operation.end_area_code = end_loc_info.area_code -- 终点库区
|
operation.end_loc_code = locEnd -- 终点货位
|
|
operation.cntr_code = cntr
|
operation.note = memo
|
|
nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, operation)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. strRetInfo)
|
end
|
-- local errMsg = "作业创建成功"
|
-- mobox.returnValue(strLuaDEID, 1, errMsg)
|
|
local result = '{"flag":"success","code":"0","message":"成功"}'
|
mobox.returnValue(strLuaDEID, 1, result)
|
end
|