--[[
|
编码: JX-40-29
|
名称: 作业-待启动前作业处理
|
作者:HAN
|
日期:2025-1-29
|
|
版本: V1.0
|
|
场景:查询业务状态=8的作业,判断一下作业的终点位置的任务作业数量,如果大于一定值就不设置为 待启动
|
|
|
函数: ProStartOperation
|
|
功能:
|
|
|
更改记录:
|
|
--]]
|
wms_op = require( "wms_operation" )
|
wms_cntr = require( "wms_container" )
|
wms_wh = require( "wms_wh" )
|
|
local STATION_MAX_TASK_NUM = 15 --站台最大任务数量
|
|
local function get_end_loc_task_num( loc_code, end_loc_task_set )
|
local n
|
for n = 1, #end_loc_task_set do
|
if ( end_loc_task_set[n].loc_code == loc_code ) then
|
return true, end_loc_task_set[n].task_num
|
end
|
end
|
return false, 0
|
end
|
|
local function set_end_loc_task_num( loc_code, end_loc_task_set, task_num )
|
local n
|
for n = 1, #end_loc_task_set do
|
if ( end_loc_task_set[n].loc_code == loc_code ) then
|
end_loc_task_set[n].task_num = task_num
|
return
|
end
|
end
|
|
end
|
|
function ProStartOperation ( strLuaDEID )
|
local nRet, strRetInfo, data_objs
|
-- 对待启动前的出库作业
|
local strCondition = "N_B_STATE = 8 AND N_TYPE = "..wms_base.Get_nConst(strLuaDEID, "作业类型-出库")
|
|
nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Operation", strCondition, "S_CODE" )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), '查询【作业】失败!'..data_objs ) end
|
if ( data_objs == '' ) then return end
|
|
local n, data_attrs
|
local find, task_num, can_usedin_op
|
local end_loc_task_set = {}
|
local strUpdateSql
|
local cntr_loc_code, cntr_loc
|
local container
|
|
for n = 1, #data_objs do
|
data_attrs = m3.KeyValueAttrsToObjAttr(data_objs[n].attrs)
|
|
-- 如果该容器还有在作业中,不能设置为待启动
|
nRet, can_usedin_op = wms_cntr.CanUsedInOperation( strLuaDEID, data_attrs.S_CNTR_CODE )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, can_usedin_op )
|
return
|
end
|
if ( can_usedin_op == false ) then goto continue end
|
|
-- 判断容器所在的货位是否是存储类型,如果不是存储类型也不能设置为待启动
|
nRet, container = wms_cntr.GetInfo( strLuaDEID, data_attrs.S_CNTR_CODE )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_cntr.GetInfo 失败!"..container ) end
|
cntr_loc_code = lua.Get_StrAttrValue( container.position )
|
if ( cntr_loc_code == '' ) then goto continue end
|
nRet, cntr_loc = wms_wh.GetLocInfo( cntr_loc_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "GetLocInfo 失败!"..cntr_loc )
|
return
|
end
|
-- 如果货位的用途不是存储,说明该容器还没回库 purpose = 1 说明是存储用途
|
if ( cntr_loc.purpose ~= 1 ) then goto continue end
|
|
find, task_num = get_end_loc_task_num( data_attrs.S_END_LOC, end_loc_task_set )
|
if ( find ) then
|
if ( task_num >= STATION_MAX_TASK_NUM ) then goto continue end
|
else
|
strCondition = "S_END_LOC = '"..data_attrs.S_END_LOC.."' AND N_B_STATE IN (0,1,5,6)"
|
nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "Operation", strCondition )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "getDataObjCount失败!"..strRetInfo ) end
|
task_num = lua.StrToNumber( strRetInfo )
|
local end_loc_task = {
|
loc_code = data_attrs.S_END_LOC, task_num = task_num
|
}
|
table.insert( end_loc_task_set, end_loc_task )
|
if ( task_num >= STATION_MAX_TASK_NUM ) then goto continue end
|
end
|
|
task_num = task_num + 1
|
set_end_loc_task_num( data_attrs.S_END_LOC, end_loc_task_set, task_num )
|
-- 设置作业状态为 0/待启动
|
strUpdateSql = "N_B_STATE = 0"
|
strCondition = "S_CODE = '"..data_attrs.S_CODE.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Operation", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "更新【作业】信息失败!"..strRetInfo )
|
end
|
::continue::
|
end
|
end
|