---
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
--- Created by HUI.
|
--- DateTime: 2024/3/6 8:48
|
---
|
|
json = require("json")
|
mobox = require("OILua_JavelinExt")
|
require("oi_basestrfunc")
|
require("WMS-DevComm")
|
require("WMS-Equipment")
|
require("WMS-Container")
|
require("WMS-WHAreaLoc")
|
require("XX-BASE")
|
|
function AfterConfirm (strLuaDEID)
|
|
Debug(strLuaDEID, debug.getinfo(1), "码盘入库-作业创建", 1)
|
|
local nRet, strRetInfo, InStockInfo
|
|
-- 首先获取页面输入数据
|
nRet, strRetInfo = GetSysInputParameter(strLuaDEID)
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), "获取当前编辑对象失败" .. strRetInfo)
|
end
|
if (strRetInfo == '') then
|
mobox.setInfo(strLuaDEID, "输入信息不能为空!")
|
return
|
end
|
Debug(strLuaDEID, debug.getinfo(1), "主窗口数据:", strRetInfo)
|
|
-- 获取待入库窗口信息
|
nRet, InStockInfo = mobox.getCurEditDataPacket(strLuaDEID)
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), "无法获取Lua数据包!")
|
end
|
if (InStockInfo == '') then
|
mobox.setInfo(strLuaDEID, "待入库中的信息不能为空!")
|
return
|
end
|
Debug(strLuaDEID, debug.getinfo(1), "待入库窗口数据:", InStockInfo)
|
|
-- 起点货位
|
local start_bit = InStockInfo.S_START_BIT
|
-- 终点货位
|
local end_bit = InStockInfo.S_END_BIT
|
-- 容器编码
|
local cntr_code = InStockInfo.S_CNTR_CODE
|
-- 容器类型
|
local cntr_type = InStockInfo.S_CNTR_TYPE
|
-- 物料名称
|
local item_name = InStockInfo.S_ITEM_NAME
|
-- 物料编码
|
local item_code = InStockInfo.S_ITEM_CODE
|
-- 数量
|
local num = InStockInfo.N_NUM
|
|
|
-- 将物料和托盘进行绑定
|
local container_good = AllocObject(strLuaDEID, "Container_Good")
|
container_good.cntr_no = cntr_code
|
container_good.item_code = item_code
|
container_good.item_name = item_name
|
container_good.uom = "千克"
|
container_good.qty = num
|
nRet, strRetInfo = CreateDataObj(strLuaDEID, container_good)
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), '创建【容器货品】失败!' .. strRetInfo)
|
end
|
|
-- 获取起点货位信息
|
local location_start
|
nRet, location_start = WMS_Location_GetInfo(strLuaDEID, start_bit)
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), 'WMS_Location_GetInfo获取货位信息失败!' .. location_start)
|
end
|
|
-- 获取终点货位信息
|
local location_end
|
nRet, location_end = WMS_Location_GetInfo(strLuaDEID, end_bit)
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), 'WMS_Location_GetInfo获取货位信息失败!' .. location_end)
|
end
|
|
-- 创建作业
|
local operation = AllocObject(strLuaDEID, "Operation")
|
operation.start_wh_code = location_start.wh_code
|
operation.start_area_code = location_start.area_code
|
operation.start_loc_code = location_start.code
|
operation.end_wh_code = location_end.wh_code
|
operation.end_area_code = location_end.area_code
|
operation.end_loc_code = location_end.code
|
operation.op_type = WMS_nConst(strLuaDEID, "作业类型-入库")
|
operation.op_def_name = "码盘入库"
|
operation.cntr_code = cntr_code
|
|
Debug(strLuaDEID, debug.getinfo(1), "作业创建前:", operation)
|
|
nRet, strRetInfo = CreateDataObj(strLuaDEID, operation)
|
if (nRet ~= 0) then
|
Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. strRetInfo)
|
end
|
|
end
|