--[[
|
编码: JX-58-12
|
名称: 入库波次-强制完成
|
作者:HAN
|
日期:2025-2-14
|
|
入口函数: 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
|
|
-- 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 indound_wave = {}
|
for n = 1, nCount do
|
nRet, indound_wave = m3.ObjAttrStrToLuaObj( "Inbound_Wave", lua.table2str( objs[n].attrs ) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "objAttrsToLuaJson (Inbound_Wave) 返回的的JSON格式不合法 !"..indound_wave ) end
|
if ( indound_wave.b_state == 0 or indound_wave.b_state == 1) then
|
-- 0 未配盘 1 -- 组盘
|
-- 把入库单设置为完成,并且关闭数量=入库数量
|
nRet, strRetInfo = jx_base.Set_Inbound_Wave_Force_Finish( strLuaDEID, indound_wave.wave_no )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
|
elseif ( indound_wave.b_state == 2 or indound_wave.b_state == 5 ) then
|
-- 2/执行 5/暂停
|
-- 判断这个入库波次的作业是否还有在执行中的,如果有就不能马上关闭,只能设置为关闭中,等执行中的作业完成后才能设置为关闭,这个另外程序来处理
|
-- 判断是否有存在正在执行的作业 N_B_STATE = 1
|
strCondition = "S_BS_TYPE = 'Inbound_Wave' AND S_BS_NO = '"..indound_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 = '"..indound_wave.wave_no.."'"
|
strUpdateSql = "N_B_STATE = 6 " -- 关闭中
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Inbound_Wave", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "更新【入库波次】信息失败!"..strRetInfo )
|
end
|
else
|
-- 已经没有正在执行的作业
|
nRet, strRetInfo = jx_base.Set_Inbound_Wave_Force_Finish( strLuaDEID, indound_wave.wave_no )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
|
end
|
-- 把作业状态 = 等待,等待前 的作业状态设置为 取消
|
strCondition = "S_BS_TYPE = 'Inbound_Wave' AND S_BS_NO = '"..indound_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
|