--[[
|
编码: JX-19-15
|
名称:
|
作者:
|
日期:
|
|
级别:
|
|
函数: ClickOK
|
|
|
--]]
|
|
wms_base = require( "wms_base" )
|
wms_wh = require( "wms_wh" )
|
|
-- 主函数
|
function ClickOK(strLuaDEID)
|
local nRet, strRetInfo
|
local attrs
|
|
-- 获取输入参数
|
nRet, attrs = m3.GetSysInputParameter(strLuaDEID)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "获取当前输入面板里的属性失败! " .. attrs)
|
return
|
end
|
|
local input_attr = m3.KeyValueAttrsToObjAttr(attrs)
|
local cntr_code = input_attr.S_CNTR_CODE --容器号
|
local strCode = input_attr.S_EXT_ATTR1 --码盘单号
|
|
if (cntr_code == nil or cntr_code == '') then
|
mobox.setInfo(strLuaDEID, "容器编码不能为空!")
|
return
|
end
|
|
-- 获取已码盘数据
|
local obj
|
nRet, obj = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "无法获取已码盘数据包!" .. obj)
|
return
|
end
|
|
local item_list = obj[1].item_list
|
local strUpdateSql
|
local action = {}
|
local cell_no,item_code,qty
|
local f_qty, f_acc_p_qty, f_acc_p_qty, f_acc_m_qty
|
|
-- 删除 对应的码盘单明细表,以码盘号作为条件
|
local strCondition = "S_TO_NO = '" .. strCode .. "'"
|
nRet, strRetInfo = mobox.deleteDataObject(strLuaDEID, "JX_TO_Detail", strCondition)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "删除 JX_TO_Detail 失败! " .. strRetInfo)
|
return
|
end
|
-- 循环遍历已码盘的数据,创建对应的码盘明细单
|
for i = 1, #item_list do
|
local item = item_list[i]
|
local attrs_obj = m3.KeyValueAttrsToObjAttr(item.attrs)
|
cell_no = attrs_obj.S_CELL_NO -- 料格号
|
item_code = attrs_obj.S_ITEM_CODE -- 物料编码
|
qty = lua.Get_NumAttrValue(attrs_obj.F_QTY) -- 数量
|
|
-- 查询巨沃移库量表,校验库存数量
|
local strCondition = "S_ITEM_CODE = '" .. item_code .. "'"
|
nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "JX_Inventory_Transfer", strCondition)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "查询巨沃移库量表失败: " .. strRetInfo)
|
return
|
end
|
|
f_qty = lua.Get_NumAttrValue(strRetInfo.qty)
|
f_acc_m_qty = lua.Get_NumAttrValue(strRetInfo.acc_m_qty)
|
f_acc_p_qty = f_qty - f_acc_m_qty -- 可移库数量
|
|
if (qty > f_acc_p_qty) then
|
mobox.setInfo(strLuaDEID, "物料编码 " .. item_code .. " 的数量超出库存量!")
|
return
|
end
|
|
-- 查询物料信息
|
local strCondition = "S_ITEM_CODE = '" .. item_code .. "'"
|
nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Material", strCondition)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "查询 Material 表失败: " .. strRetInfo)
|
return
|
end
|
|
-- 创建JX_TO_Detail对象并插入数据
|
local to_detail = m3.AllocObject(strLuaDEID, "JX_TO_Detail")
|
to_detail.to_no = strCode -- 码盘号
|
to_detail.cntr_code = cntr_code -- 容器编码
|
to_detail.item_code = item_code -- 物料编码
|
to_detail.item_name = strRetInfo.item_name -- 物料名称
|
to_detail.qty = qty -- 数量
|
to_detail.cell_no = cell_no -- 料格号
|
to_detail.f_alloc_qty = f_acc_p_qty -- 可移库数量
|
to_detail.volume = strRetInfo.volume -- 体积
|
to_detail.weight = strRetInfo.weight -- 重量
|
|
nRet, to_detail = m3.CreateDataObj(strLuaDEID, to_detail)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID,'创建码盘明细表对象失败!' .. to_detail)
|
return
|
end
|
|
end
|
-- 查询明细数据
|
local detail_strCondition = "S_TO_NO = '" .. strCode .. "'"
|
local detail_data_objs
|
nRet, detail_data_objs = m3.QueryDataObject(strLuaDEID, "JX_TO_Detail", detail_strCondition)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "查询明细数据失败! " .. detail_data_objs)
|
return
|
end
|
lua.Debug(strLuaDEID, debug.getinfo(1), "detail_data_objs", detail_data_objs)
|
-- 将所有行数据批量插入到页面
|
action[1] = {
|
action_type = "set_subtable_page_content",
|
value = {
|
page_name = "已码盘",
|
content = detail_data_objs,
|
clear = true,
|
clear_confirm = false,
|
checkbox = false
|
}
|
}
|
|
-- 执行所有操作
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID,"执行操作失败! " .. strRetInfo)
|
return
|
end
|
|
mobox.setInfo(strLuaDEID, "调整成功!")
|
end
|