--[[
|
编码: GK-49-10
|
名称: 容器动碰生成移库单
|
作者:HAN
|
日期:2025-6-12
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: MovementCheck
|
|
功能:
|
-- 生成移库单号
|
--
|
基础算法:
|
-- 从input_parameter获取动碰的时间范围 start_time, end_time, factory, op_def_name
|
-- 从表 INV_Lock_Log 获取 这个时间点后 有变化的容器
|
|
更改记录:
|
|
--]]
|
|
wms_wh = require ("wms_wh")
|
wms_cntr = require( "wms_container" )
|
|
function MovementCheck ( strLuaDEID )
|
local nRet, strRetInfo, n
|
local log_type = "'ADJ-IN','ADJ-OUT','OUT','IN','RECEIPT-IN','RECEIPT-OUT'"
|
local strCondition, factory
|
local strOrder = ''
|
|
m3.PrintLuaDEInfo( strLuaDEID )
|
|
-- 获取输入参数
|
nRet, factory = wms_base.Get_sConst2( "WMS_Default_Factory" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "系统无法获取常量'WMS_Default_Factory'")
|
return
|
end
|
|
local end_time = os.date("%Y-%m-%d %H:%M:%S")
|
local start_time = os.date("%Y-%m-%d").." 0:0:0"
|
|
|
local op_def_name = parameter.op_def_name or ''
|
if op_def_name == '' then
|
lua.Stop( strLuaDEID, "MovementCheck 函数输入参数 parameter 中 op_def_name 必须有值!" )
|
return
|
end
|
|
strCondition = "T_CREATE >= '"..start_time.."' AND T_CREATE < '"..end_time.."' AND S_LOG_TYPE IN ("..log_type..")"
|
nRet, strRetInfo = mobox.groupDataObjAttr( strLuaDEID, "INV_TXN_Log", strCondition, "S_CNTR_CODE", strOrder )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "无法从【INV_TXN_Log】中获取信息!"..strRetInfo )
|
return
|
end
|
|
local op_def
|
nRet, op_def = wms_base.GetOpDefInfo( factory, "国科移库" )
|
if nRet ~= 0 then
|
lua.Stop( strLuaDEID, "系统无法获取名为'"..op_def_name.."'的作业类型! "..op_def )
|
return
|
end
|
|
local cntr_group = json.decode( strRetInfo )
|
local loc, container
|
|
for n = 1, #cntr_group do
|
cntr_code = cntr_group[n].value
|
nRet, container = wms_cntr.GetInfo( strLuaDEID, cntr_code )
|
if nRet == 0 then
|
nRet, loc = wms_wh.GetLocInfo( loc_code )
|
|
if nRet == 0 then
|
-- 判断库区是否在存储区,不是存储区不做动碰
|
nRet, area = wms_wh.GetAreaInfo( loc.area_code )
|
if nRet ~= 0 then
|
lua.Stop( strLuaDEID, "系统无法获取名为'"..area.."'的库区对象! "..area )
|
return
|
end
|
|
if area.type == AREA_TYPE.Storage_Area then
|
-- 创建 移库单
|
local location_trans = m3.AllocObject( strLuaDEID, "Location_Transfer" )
|
|
location_trans.op_def_code = op_def.code
|
location_trans.op_def_name = "国科移库"
|
location_trans.cntr_code = cntr_code
|
location_trans.start_wh_code = loc.wh_code
|
location_trans.start_area_code = loc.area_code
|
location_trans.start_loc_code = loc.code
|
loclocation_trans.start_loc_code = loc.codea
|
location_trans.end_wh_code = loc.wh_code
|
location_trans.factory = factory
|
|
nRet, location_trans = m3.CreateDataObj( strLuaDEID, location_trans )
|
if (nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "创建堆垛机任务失败!"..location_trans )
|
return
|
end
|
end
|
end
|
end
|
end
|
end
|