--[[
|
编码: GK-24-17
|
名称: 点出库按钮后
|
作者:HAN
|
日期:2025-7-2
|
|
级别:项目
|
|
函数: ClickOutButton
|
|
功能:
|
-- 点击选中的出库单进行出库
|
|
更改记录:
|
|
--]]
|
wms_out = require( "wms_outbound" )
|
wms_station = require( "wms_station" )
|
|
function ClickOutButton ( strLuaDEID )
|
local nRet, strRetInfo, n
|
local data_json
|
|
-- 在此操作的数据对象主体 是【出库单】数据对象, data_json 是出库单
|
nRet, data_json = m3.GetSysDataJson( strLuaDEID )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), data_json ) end
|
-- nCount 出库单数量
|
local nCount = #data_json
|
if ( nCount == 0 ) then
|
mobox.setInfo( strLuaDEID, "必须选中一个出库单!" )
|
return
|
end
|
-- 获取输入界面中的工作台属性
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STATION_NO" )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo )
|
end
|
|
local input_value = json.decode( strRetInfo )
|
local station = lua.Get_StrAttrValue( input_value[1].value )
|
if ( station == '' or input_value == nil ) then
|
mobox.setInfo( strLuaDEID, "必须选择一个工作站!" )
|
return
|
end
|
local strUserLogin, strUserName
|
nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID )
|
if ( nRet ~= 0 ) then return 2, "获取当前操作人员信息失败! "..strUserLogin end
|
|
local outbound_obj = {}
|
local strUpdateSql, strCondition
|
local num = 0
|
|
for n = 1, nCount do
|
nRet, outbound_obj = m3.GetDataObject( strLuaDEID, "Outbound_Order", data_json[n].id )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, outbound_obj )
|
return
|
end
|
if outbound_obj.b_state == OUTBOUND_ORDER_STATE.Unalloc then
|
|
-- 自动配盘用到的参数
|
local paramter = {
|
station = station,
|
login = strUserLogin,
|
user_name = strUserName,
|
outbound_order_no = outbound_obj.no,
|
shortage_handling = "", -- 缺件处理
|
cntr_out_op_def = "国科出库",
|
cntr_back_op_def = "国科入库"
|
}
|
|
-- call_back 主要给后台配盘脚本,在错误的时候调用
|
local call_back = {
|
cls_id = "Outbound_Order", obj_id = data_json[n].id,
|
event_name = "自动配盘回调"
|
}
|
-- '自动配盘'脚本需要后台线程进行排队处理
|
nRet, strRetInfo = mobox.addBackendScriptProc( "Outbound_Order","自动配盘", lua.table2str( paramter ), lua.table2str( call_back ) )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, strRetInfo )
|
return
|
end
|
num = num + 1
|
-- 出库单的状态改为 配货中
|
strUpdateSql = "N_B_STATE = "..OUTBOUND_ORDER_STATE.InAlloc
|
strCondition = "S_NO = '"..outbound_obj.no.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Order", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "更新【出库单】信息失败!"..strRetInfo )
|
return
|
end
|
end
|
end
|
|
if num > 0 then
|
mobox.setInfo( strLuaDEID, "有"..num.."个出库单提交配盘申请!")
|
local action = {
|
{
|
action_type = "refresh_selected_row",
|
value = ""
|
}
|
}
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "setAction错误: "..strRetInfo)
|
return
|
end
|
end
|
|
end
|