--[[
|
编码: JX-01-23
|
名称:
|
作者:
|
日期:2025-03-05
|
|
函数: ClickOK
|
功能:
|
|
更改记录:
|
|
--]]
|
|
wms_cntr = require( "wms_container" )
|
jx_base = require( "jx_base" )
|
wms_wh = require( "wms_wh" )
|
|
function ClickOK( strLuaDEID )
|
local attrs
|
local cell_mapping = {}
|
local action = {}
|
local max_cell_num
|
local strCondition
|
local cntr
|
local data_objs
|
local jx_task
|
|
local now = os.date("%Y%m%d%H%M%S")
|
local randomNum = math.random(1, 99999)
|
local strHeader = 'RK'..os.date("%y%m%d")..'-'
|
local str_no
|
|
-- 获取码盘单号
|
nRet, str_no = mobox.getSerialNumber( "巨星任务", strHeader, 4 )
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, '申请码盘单编码失败!'..str_no)
|
return
|
end
|
-- 获取输入参数
|
nRet, attrs = m3.GetSysInputParameter(strLuaDEID)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "获取当前输入面板里的属性失败! " .. attrs)
|
return
|
end
|
lua.Debug(strLuaDEID, debug.getinfo(1), "attrs", attrs)
|
|
local input_attr = m3.KeyValueAttrsToObjAttr(attrs)
|
|
local cntr_code = input_attr.S_CODE
|
local spec = input_attr.S_SPEC
|
local cell_code = input_attr.cell_code
|
|
if (spec == cell_code) then
|
mobox.setInfo(strLuaDEID, "料格编码不能与规格相同!")
|
goto continue
|
end
|
|
if (cntr_code == nil or cntr_code == '') then
|
mobox.setInfo(strLuaDEID, "容器编码不能为空!")
|
goto continue
|
end
|
if (cell_code == nil or cell_code == '') then
|
mobox.setInfo(strLuaDEID, "料格编码不能为空!")
|
goto continue
|
end
|
-- 定义 cell_code 到 max_cell_num 的映射
|
cell_mapping = {
|
A = 1,
|
B = 2,
|
C = 3,
|
D = 4,
|
E = 6
|
}
|
|
-- 根据 cell_code 获取 max_cell_num
|
max_cell_num = cell_mapping[cell_code]
|
lua.Debug(strLuaDEID, debug.getinfo(1), "max_cell_num", max_cell_num)
|
if (max_cell_num == nil) then
|
mobox.setInfo(strLuaDEID, "料格编码 '" .. cell_code .. "' 无效!")
|
goto continue
|
end
|
|
-- 删除对应的容器表,以容器号作为条件
|
strCondition = "S_CODE = '" .. cntr_code .. "'"
|
nRet, strRetInfo = mobox.deleteDataObject(strLuaDEID, "Container", strCondition)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "删除容器表失败! " .. strRetInfo)
|
goto continue
|
end
|
|
strConditioncode = "S_CNTR_CODE = '" .. cntr_code .. "'"
|
nRet, strRetInfo = mobox.deleteDataObject(strLuaDEID, "Container_Cell", strConditioncode)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "删除容器料格表失败! " .. strRetInfo)
|
goto continue
|
end
|
|
cntr = m3.AllocObject(strLuaDEID, "Container")
|
cntr.code = cntr_code
|
cntr.source = "巨沃"
|
cntr.max_cell_num = max_cell_num
|
cntr.type = 3
|
cntr.spec = cell_code
|
nRet, cntr = m3.CreateDataObj(strLuaDEID, cntr)
|
if (nRet ~= 0 ) then
|
mobox.setInfo( strLuaDEID, "创建料箱对象失败!"..cntr )
|
goto continue
|
end
|
|
-- -- 创建 JX_Task 任务池
|
-- -- 查询该料箱是否有任务池,有则不创建
|
-- strCondition = "S_CNTR_CODE = '" .. cntr_code .. "' AND ( N_B_STATE = 0 or N_B_STATE = 1 )"
|
-- nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JX_Task", strCondition)
|
-- if (nRet ~= 0) then
|
-- mobox.setInfo(strLuaDEID, debug.getinfo(1), "查询任务池失败! " .. data_objs)
|
-- goto continue
|
-- end
|
-- if (data_objs == '') then
|
|
|
-- jx_task = m3.AllocObject(strLuaDEID, "JX_Task")
|
-- jx_task.cntr_code = cntr_code -- 托盘号
|
-- jx_task.source_sys = "巨沃入库" -- 来源系统
|
-- jx_task.sour_no = str_no -- 上游任务号
|
-- jx_task.end_area_code = wms_base.Get_sConst(strLuaDEID, "料箱库存储区")
|
-- jx_task.task_type = "入库" -- 作业类型
|
-- jx_task.create_method = "JW-WMS"
|
-- jx_task.start_wh_code = wms_base.Get_sConst(strLuaDEID, "默认仓库标识")
|
|
-- nRet, jx_task = m3.CreateDataObj(strLuaDEID, jx_task)
|
-- if (nRet ~= 0) then
|
-- mobox.setInfo(strLuaDEID, "创建 JX_Task 任务池记录失败! " .. jx_task)
|
-- goto continue
|
-- end
|
-- end
|
-- 清空"料格转换"页面
|
mobox.setInfo(strLuaDEID, "转换成功!")
|
|
::continue::
|
action[1] = {
|
action_type = "clear_subpage_rows",
|
value = {
|
page_name = "料格转换"
|
}
|
}
|
action[2] = {
|
action_type = "set_dlg_attr",
|
value = {
|
{attr = "S_CODE", value = "" },
|
{attr = "S_SPEC", value = "" },
|
{attr = "cell_code", value = "" },
|
}
|
}
|
|
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "清空料格转换页面失败! " .. strRetInfo)
|
return
|
end
|
|
|
end
|