--[[
|
编码: WMS-56-21
|
名称: 组盘明细-条码输入变化后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterUPCChange
|
|
功能:
|
-- 根据输入的条码到【Material_Barcode】找到货品编码
|
-- 如果当前入库任务的货品编码相同 组盘数量+1
|
|
更改记录:
|
V2.0 HAN 20250422 JX_Material_Barcode 改为 Material_Barcode
|
|
--]]
|
wms_wh = require( "wms_wh" )
|
wms_cntr= require( "wms_container" )
|
prj_base= require( "prj_base" )
|
|
function AfterUPCChange ( strLuaDEID )
|
local nRet, strRetInfo
|
|
-- 获取UPC
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "UPC","S_ITEM_CODE","F_ACT_QTY", "F_QTY" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local upc = lua.Get_StrAttrValue( obj_attrs[1].value )
|
local item_code = lua.Get_StrAttrValue( obj_attrs[2].value )
|
local act_qty = lua.Get_NumAttrValue( obj_attrs[3].value )
|
local qty = lua.Get_NumAttrValue( obj_attrs[4].value )
|
local enable = true
|
if ( upc == '' ) then return end
|
|
-- 通过条码找到物料编码
|
local material_barcode
|
nRet, material_barcode = m3.GetDataObjectByKey(strLuaDEID, "Material_Barcode", "S_BARCODE", upc)
|
if (nRet ~= 0 ) then
|
if ( nRet == 1 ) then
|
if ( act_qty == 0 ) then enable = false end
|
mobox.setInfo( strLuaDEID, "条码'"..upc.."'没有对应的货品,请检查物料条码对照表!")
|
goto set_dlg_attr
|
end
|
lua.Stop( strLuaDEID, "获取【物料条码】信息失败! " .. material_barcode )
|
return
|
end
|
|
|
-- 判断扫码的货品是否是目前的入库任务
|
if ( item_code ~= material_barcode.item_code ) then
|
mobox.setInfo( strLuaDEID, "条码'"..upc.."'对应的货品编码='"..material_barcode.item_code.."不是当前入库任务中的货物!")
|
if ( act_qty == 0 ) then enable = false end
|
goto set_dlg_attr
|
end
|
act_qty = act_qty + 1
|
if ( lua.equation( act_qty, qty ) ) then
|
-- 任务完成
|
local runtime_parameter
|
nRet, runtime_parameter = m3.GetRuntimeParam(strLuaDEID)
|
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "GetRuntimeParam失败! "..runtime_parameter )
|
return
|
end
|
-- 获取【组盘输入】面板的参数
|
local parameter
|
nRet, parameter = m3.GetRuntimePanel_InputParamter( strLuaDEID, runtime_parameter.panel, "组盘输入" )
|
if ( nRet == 1 ) then
|
mobox.setInfo( strLuaDEID, "没有定义'组盘输入'面板参数!")
|
return
|
end
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), parameter ) end
|
if ( parameter == nil ) then return end
|
local id = parameter.id -- 当前点中的入库任务标识
|
local pac_no = parameter.pac_no -- 当前点中的入库任务所属组盘号
|
if ( pac_no == nil or pac_no == "") then
|
mobox.setInfo( strLuaDEID, "'组盘输入'面板必须有orgc_no参数!")
|
return
|
end
|
-- 设置【组盘明细】状态 = 2(组盘完成)
|
local strCondition = "S_ID = '"..id.."'"
|
local strUpdateSql = "N_B_STATE = 2, F_ACT_QTY = "..act_qty
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Pre_Alloc_CNTR_Detail", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "更新【组盘明细】信息失败!"..strRetInfo )
|
return
|
end
|
|
local action
|
nRet, action = prj_base.Pre_Alloc_CNTR_PostProcess( strLuaDEID, pac_no, parameter.station, parameter.cntr_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "Pre_Alloc_CNTR_PostProcess 失败!"..action )
|
return
|
end
|
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end
|
return
|
end
|
|
::set_dlg_attr::
|
local action =
|
{
|
{
|
action_type = "set_panel_dlg_attr",
|
value = {
|
panel_name = "组盘输入",
|
attrs = {
|
{
|
attr = "F_ACT_QTY",
|
value = act_qty,
|
enable = enable
|
},
|
{
|
attr = "UPC",
|
value = "",
|
prompt = "请扫商品条码..."
|
}
|
}
|
}
|
|
}
|
}
|
lua.Debug( strLuaDEID, debug.getinfo(1), "action", action )
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end
|
|
end
|