m3 = require("oi_base_mobox")
|
lua = require("oi_base_func")
|
json = require("json")
|
mobox = require("OILua_JavelinExt")
|
wms_base = require("wms_base")
|
wms_cntr = require("wms_container")
|
|
function CreateOpbyNum(strLuaDEID)
|
local nRet, strRetInfo
|
-- step1获取当前表头输入的数量
|
nRet, strRetInfo = m3.GetSysInputParameter(strLuaDEID)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "获取当前输入面板里的属性失败! " .. strRetInfo)
|
end
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), "strRetInfo", strRetInfo)
|
local input_attr = m3.KeyValueAttrsToObjAttr(strRetInfo.attrs)
|
|
|
local op_num = tonumber(input_attr.N_NUM)
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), "op_num", op_num)
|
local cntr_code
|
|
for n = 1, op_num do
|
-- 申请一个托盘码
|
local strHeader = "FB-"
|
nRet, cntr_code = mobox.getSerialNumber("容器", strHeader, 4)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), '申请【容器】编码失败!' .. cntr_code)
|
end
|
|
|
-- 创建容器
|
local container = m3.AllocObject(strLuaDEID, "Container")
|
container.code = cntr_code -- 容器编码
|
container.ctd_code = "CTD-001" -- 容器编码
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), "container:", container)
|
nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, container)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "创建容器失败!" .. strRetInfo)
|
end
|
|
|
-- 创建作业
|
local operation = m3.AllocObject(strLuaDEID, 'Operation')
|
-- operation.op_def_code = op_code -- 作业定义编码
|
operation.op_type = 1
|
operation.op_def_name = "货品入库" -- 作业名称
|
operation.bs_state = 0 -- 状态
|
operation.cntr_code = cntr_code
|
|
-- 起点信息
|
operation.start_wh_code = "0001" -- 仓库
|
operation.start_area_code = "0001" -- 库区
|
operation.start_loc_code = "" -- 货位
|
-- 终点信息
|
operation.end_wh_code = "0001" -- 终点仓库
|
operation.end_area_code = "0001" -- 终点库区
|
operation.end_loc_code = "" -- 终点货位
|
|
-- operation.cntr_code = cntrcode
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), '作业创建前:', operation)
|
|
nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, operation)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. strRetInfo)
|
end
|
end
|
end
|