--[[
|
编码: JX-60-15
|
名称: 出库波次-强制完成
|
作者:HAN
|
日期:2025-2-20
|
|
入口函数: ForceFinish
|
|
功能说明:
|
出库波次强制完成
|
-- 首先判断只有 未配货/配货完成/执行/错误/暂停 状态的出库波次才能做 强制完成操作
|
不同状态的出库波次 强制完成的处理逻辑不一样
|
0 -- 未配货
|
-- +(波次明细)关闭数量
|
-- 状态设置为关闭
|
1 -- 配货完成/暂停/错误
|
-- 配盘容器状态设置=取消,释放货品的分配量
|
-- +(波次明细)关闭数量
|
-- 状态设置为关闭
|
2 -- 执行
|
-- 检测所以目前该波次创建的作业是否有在执行的,有设置波次状态 = 关闭中 需要等待这些作业完成后才能关闭
|
等这个出库波次正在执行的作业都完成后,出库波次状态自动该为 关闭
|
-- 取消等待启动中的作业(状态设置为取消)
|
-- 配盘容器状态设置=取消,释放货品的分配量
|
-- +(波次明细)关闭数量
|
-- 状态设置为关闭
|
|
-- 触发出库波次进行完工回报
|
|
更改记录:
|
|
--]]
|
|
wms_op = require( "wms_operation" )
|
wms_cntr = require( "wms_container" )
|
jx_base = require( "jx_base" )
|
|
function ForceFinish ( strLuaDEID )
|
local nRet, strRetInfo
|
local objs
|
|
m3.PrintLuaDEInfo( strLuaDEID )
|
|
-- step1 获取当前点中的作业
|
nRet, objs = m3.GetSysDataJson( strLuaDEID )
|
if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end
|
-- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
|
local nCount = #objs
|
if (nCount == 0) then return end
|
|
local strObjJson, data_objs
|
local n, data_attrs
|
local strCondition
|
local success
|
local outbound_wave = {}
|
for n = 1, nCount do
|
nRet, outbound_wave = m3.ObjAttrStrToLuaObj( "Outbound_Wave", lua.table2str( objs[n].attrs ) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "objAttrsToLuaJson (Outbound_Wave) 返回的的JSON格式不合法 !"..outbound_wave ) end
|
|
if ( outbound_wave.b_state == 0 or outbound_wave.b_state == 2) then
|
-- 0 未配货 2 -- 配货完成
|
-- 把出库波次设置为完成,并且关闭数量=出库数量
|
nRet, strRetInfo = jx_base.Set_Outbound_Wave_Force_Finish( strLuaDEID, outbound_wave.wave_no )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
|
elseif ( outbound_wave.b_state == 3 or outbound_wave.b_state == 7 ) then
|
-- 3/执行 7/暂停
|
-- 判断这个出库波次的作业是否还有在执行中的,如果有就不能马上关闭,只能设置为关闭中,等执行中的作业完成后才能设置为关闭,这个另外程序来处理
|
-- 判断是否有存在正在执行的作业 N_B_STATE = 1
|
strCondition = "S_BS_TYPE = 'Outbound_Wave' AND S_BS_NO = '"..outbound_wave.wave_no.."' AND N_B_STATE = 1"
|
nRet, strRetInfo = mobox.existThisData( strLuaDEID, "Operation", strCondition )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
|
if ( strRetInfo == "yes" ) then
|
-- 存在正在执行的作业
|
strCondition = "S_WAVE_NO = '"..outbound_wave.wave_no.."'"
|
strUpdateSql = "N_B_STATE = 8 " -- 关闭中
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Wave", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "更新【出库波次】信息失败!"..strRetInfo )
|
end
|
else
|
-- 已经没有正在执行的作业
|
nRet, strRetInfo = jx_base.Set_Outbound_Wave_Force_Finish( strLuaDEID, outbound_wave.wave_no )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
|
end
|
-- 把作业状态 = 等待,等待前 的作业状态设置为 取消
|
strCondition = "S_BS_TYPE = 'Outbound_Wave' AND S_BS_NO = '"..outbound_wave.wave_no.."' AND ( N_B_STATE = 0 or N_B_STATE = 6 or N_B_STATE = 8 )"
|
strUpdateSql = "N_B_STATE = 7 "
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Operation", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "更新【作业】信息失败!"..strRetInfo )
|
end
|
end
|
end
|
|
local action = {}
|
if ( nCount == 1 ) then
|
-- 如果就是一行刷新当前行
|
action = {
|
{
|
action_type = "refresh_cur_row", value = ""
|
}
|
}
|
else
|
action = {
|
{
|
action_type = "refresh", value = ""
|
}
|
}
|
end
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end
|
end
|