--[[
|
编码: WMS-52-17
|
名称: 出库分拣-条码输入变化后
|
作者:HAN
|
日期:2025-1-29
|
级别:固定
|
函数:AfterUPCChange
|
功能:
|
- 根据输入的条码校验是否属于拣货箱编码
|
- 校验通过后更新分拣任务状态并绑定货品
|
--]]
|
|
prj_base = require("prj_base")
|
wms_out = require("wms_outbound")
|
|
function main(strLuaDEID)
|
local nRet, strRetInfo
|
|
-- 1. 获取当前编辑属性(UPC、货品编码、分拣数量等)
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "UPC", "S_ITEM_CODE", "F_ACC_P_QTY", "F_QTY", "TaskFinish")
|
if nRet ~= 0 then
|
lua.Stop(strLuaDEID, "获取当前编辑属性失败! " .. strRetInfo)
|
return
|
end
|
|
local obj_attrs = json.decode(strRetInfo)
|
local upc = lua.Get_StrAttrValue(obj_attrs[1].value) -- 当前扫描的UPC
|
local item_code = lua.Get_StrAttrValue(obj_attrs[2].value) -- 货品编码
|
local acc_p_qty = lua.Get_NumAttrValue(obj_attrs[3].value) -- 已分拣累计数量
|
local qty = lua.Get_NumAttrValue(obj_attrs[4].value) -- 分拣数量
|
local task_finish = lua.Get_NumAttrValue(obj_attrs[5].value) -- 任务强制完成标志
|
local str_prompt = "请扫拣货箱编码..."
|
local qty_input_enable = false -- 分拣数量输入框是否可以输入
|
|
if upc == '' then return end
|
|
-- 2. 获取运行时参数
|
local runtime_parameter
|
nRet, runtime_parameter = m3.GetRuntimeParam(strLuaDEID)
|
if nRet ~= 0 then
|
mobox.setInfo(strLuaDEID, "GetRuntimeParam失败! " .. runtime_parameter)
|
return
|
end
|
|
-- 3. 获取面板参数
|
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.Stop(strLuaDEID, parameter)
|
return
|
end
|
if parameter == nil then return end
|
|
-- 4. 查询出库订单
|
local bs_no = parameter.bs_no
|
local strCondition = "S_NO = '" .. bs_no .. "'"
|
nRet, transfer = m3.GetDataObjByCondition(strLuaDEID, "Outbound_Order", strCondition)
|
if nRet ~= 0 then
|
mobox.setInfo(strLuaDEID, "查询Outbound_Order表失败: " .. transfer)
|
return
|
end
|
|
-- 5. 解析并校验UPC
|
local box_code = json.decode(transfer.pick_box_code)
|
local found = false
|
for _, code in ipairs(box_code) do
|
if upc == code then
|
found = true
|
break
|
end
|
end
|
|
local id
|
local dc_no
|
local strCondition
|
local strUpdateSql
|
local action
|
|
-- 6. UPC校验失败处理
|
if not found then
|
mobox.setInfo(strLuaDEID, "UPC校验失败: upc=" .. upc .. " 不在 box_code 中")
|
goto set_dlg_attr
|
|
else
|
-- 7. 校验通过后的业务逻辑
|
id = parameter.id -- 当前点中的入库任务标识
|
dc_no = parameter.dc_no -- 当前点中的入库任务所属配盘号
|
if dc_no == nil or dc_no == "" then
|
mobox.setInfo(strLuaDEID, "'出库分拣'面板必须有配盘号参数!")
|
return
|
end
|
|
-- 8. 更新配盘明细状态为"分拣完成"
|
strCondition = "S_ID = '" .. id .. "'"
|
strUpdateSql = "N_B_STATE = " .. DC_DETAIL_STATE.PickingOK .. ", F_ACC_P_QTY = " .. acc_p_qty
|
nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Distribution_CNTR_Detail", strCondition, strUpdateSql)
|
if nRet ~= 0 then
|
lua.Stop(strLuaDEID, "更新【配盘明细】信息失败!" .. strRetInfo)
|
return
|
end
|
|
-- 9. 创建拣料箱绑定记录
|
if upc ~= '' and upc ~= nil and acc_p_qty > 0 then
|
nRet, pc_detail_data = wms_out.Creat_Picking_CNTR_Detail(strLuaDEID, id, acc_p_qty, upc)
|
if nRet ~= 0 then
|
lua.Stop(strLuaDEID, '创建拣料箱CG_Detail时失败!' .. pc_detail_data)
|
return
|
end
|
end
|
|
-- 10. 执行后续处理
|
|
nRet, action = prj_base.Distribution_CNTR_PostProcess(strLuaDEID, parameter)
|
if nRet ~= 0 then
|
lua.Stop(strLuaDEID, action)
|
return
|
end
|
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if nRet ~= 0 then
|
lua.Stop(strLuaDEID, "setAction失败! " .. strRetInfo)
|
return
|
end
|
return
|
end
|
|
::set_dlg_attr::
|
-- 11. 界面重置逻辑
|
local action = {
|
{
|
action_type = "set_panel_dlg_attr",
|
value = {
|
panel_name = "出库分拣",
|
attrs = {
|
{
|
attr = "F_ACC_P_QTY",
|
value = acc_p_qty,
|
enable = qty_input_enable
|
},
|
{
|
attr = "UPC",
|
value = "",
|
prompt = str_prompt
|
},
|
{
|
attr = "Prompt",
|
value = str_prompt
|
}
|
}
|
}
|
}
|
}
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if nRet ~= 0 then
|
lua.Stop(strLuaDEID, "setAction失败! " .. strRetInfo)
|
return
|
end
|
end
|