--[[
|
编码:
|
名称: 解盘表头
|
作者:KUN
|
日期:2025-2-14
|
级别:项目
|
函数: Remove
|
功能:
|
更改记录:
|
--]]
|
wms_cntr = require( "wms_container" )
|
jx_base = require( "jx_base" )
|
wms_wh = require( "wms_wh" )
|
|
function Remove( strLuaDEID )
|
|
local nRet, strRetInfo
|
local dis_cntr
|
local dc_detail_array
|
local dr_detail_array
|
|
-- 获取当前输入面板的属性
|
nRet, strRetInfo = m3.GetSysInputParameter(strLuaDEID)
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "获取当前输入面板里的属性失败! " .. strRetInfo)
|
return
|
end
|
local input_attr = m3.KeyValueAttrsToObjAttr(strRetInfo)
|
local cntr_code = input_attr.S_CNTR_CODE
|
|
-- 获取该容器对应的配盘单
|
-- 查询容器号下所有料格的数据
|
local container_data, nRet
|
local strCondition = "S_TO_NO IN (SELECT S_NO FROM TN_JX_Transfer_Order WHERE S_CNTR_CODE = '" .. cntr_code .. "' AND N_B_STATE IN (0, 1))"
|
-- 查询 JX_TO_Detail 表
|
nRet, container_data = m3.QueryDataObject(strLuaDEID, "JX_TO_Detail", strCondition)
|
if (nRet ~= 0 or container_data == '') then
|
mobox.setInfo( strLuaDEID, '查询JX_TO_Detail失败!'..container_data )
|
return
|
end
|
|
local page_info = {}
|
|
-- 合并相同料箱号、料格号、物料编码的数据
|
local merged_data = {}
|
|
-- 遍历container_data并合并数据
|
local cell_no, item_code, item_name, qty
|
|
for i = 1, #container_data do
|
local record = m3.KeyValueAttrsToObjAttr(container_data[i].attrs)
|
cell_no = record.S_CELL_NO -- 料格号
|
item_code = record.S_ITEM_CODE -- 物料编码
|
item_name = record.S_ITEM_NAME -- 物料名称
|
qty = lua.Get_NumAttrValue(record.F_QTY) -- 数量
|
|
|
|
local key = cntr_code .. "_" .. cell_no .. "_" .. item_code
|
|
-- 如果该组合键已存在,则合并数据(如合并数量)
|
if not merged_data[key] then
|
merged_data[key] = {
|
cntr_code = cntr_code,
|
cell_no = cell_no,
|
item_code = item_code,
|
item_name = item_name,
|
qty = qty,
|
}
|
else
|
-- 如果已存在,增加数量
|
merged_data[key].qty = merged_data[key].qty + qty
|
end
|
end
|
|
-- 将合并后的数据转换回一个数组,方便后续操作
|
for _, merged_record in pairs(merged_data) do
|
local id = "ID_" .. os.time() .. "_" .. math.random(1000, 9999)
|
local state = "编辑"
|
local attrs = {
|
{ value = merged_record.cntr_code, attr = "S_CNTR_CODE" },
|
{ value = merged_record.cell_no, attr = "S_CELL_NO" },
|
{ value = merged_record.item_code, attr = "S_ITEM_CODE" },
|
{ value = merged_record.item_name, attr = "S_ITEM_NAME" },
|
{ value = tostring(merged_record.qty), attr = "F_QTY" }
|
}
|
|
local item = {
|
id = id,
|
state = state,
|
attrs = attrs
|
}
|
|
table.insert(page_info, item)
|
end
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), "page_info--->", page_info)
|
|
-- 设置待分拣页面信息
|
local action_array = {}
|
action_array[1] = {
|
action_type = "set_subtable_page_content",
|
value = {
|
page_name = "需解盘",
|
content = page_info,
|
clear = true,
|
clear_confirm = false,
|
checkbox = false
|
}
|
}
|
|
lua.Debug(strLuaDEID, debug.getinfo(1), "分拣回库-容器变化后setAction数据:", lua.table2str(action_array))
|
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action_array))
|
if (nRet ~= 0) then
|
mobox.setInfo(strLuaDEID, "setAction失败! " .. strRetInfo)
|
return
|
end
|
|
end
|