--[[
|
编码: WMS-00-10
|
名称: 工厂-基础数据导出
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: WMS_BaseData_Export
|
|
功能:
|
-- 和WMS相关的基础数据导出
|
包括下面这些数据
|
-- 工厂,仓库,库区,货位,逻辑库区,巷道,货位组,常量,站台
|
|
更改记录:
|
|
--]]
|
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require ("oi_base_mobox")
|
|
-- 和WMS系统相关的一些仓库结构基础数据的导出
|
function WMS_BaseData_Export( strLuaDEID )
|
local nRet, strRetInfo
|
|
nRet, strRetInfo = mobox.getLuaDEInfo( strLuaDEID )
|
if (nRet ~= 0 or strRetInfo == '') then lua.Error( strLuaDEID, debug.getinfo(1), "调用 getLuaDEInfo 失败!"..strRetInfo ) end
|
local lua_info, success
|
success, lua_info = pcall( json.decode, strRetInfo)
|
if ( success == false ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "Lua数据包的JSON格式非法! 原因:"..lua_info..' --> '..strRetInfo )
|
end
|
|
local file_name = "WMSBaseDataStrut-"..lua.guid()..".json"
|
local file_path = lua_info.app_path.."\\Temp\\"..file_name
|
local fn = io.open( file_path, "a" )
|
|
-- 导出【工厂】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Factory" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Factory 时失败!"..strRetInfo ) end
|
|
-- 导出【仓库】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Warehouse" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Warehouse 时失败!"..strRetInfo ) end
|
|
-- 导出【库区】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Area" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Area 时失败!"..strRetInfo ) end
|
|
-- 导出【逻辑库区】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Zone" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Zone 时失败!"..strRetInfo ) end
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Zone_Cls" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Zone_Cls 时失败!"..strRetInfo ) end
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Zone_Link" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Zone_Link 时失败!"..strRetInfo ) end
|
|
-- 导出【货位】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Location" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Location 时失败!"..strRetInfo ) end
|
-- 导出【货位站点扩展】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Location_Ext" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Location_Ext 时失败!"..strRetInfo ) end
|
-- 导出【货位组】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Location_Group" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Location_Group 时失败!"..strRetInfo ) end
|
|
-- 导出【巷道】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Aisle" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Aisle 时失败!"..strRetInfo ) end
|
|
|
-- 导出【常量】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "WMS_Const" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 WMS_Const 时失败!"..strRetInfo ) end
|
|
-- 导出【机台】信息
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "Machine_Station" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 Machine_Station 时失败!"..strRetInfo ) end
|
nRet, strRetInfo = OI_DataObject_Export( strLuaDEID, fn, "MS_Area_Link" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "在导出 MS_Area_Link 时失败!"..strRetInfo ) end
|
|
fn:close()
|
|
mobox.setInfo( strLuaDEID, "系统导出一个名为'"..file_name.."'的WMS基础数据文件!")
|
|
-- 获取文件服务器标识
|
nRet, strRetInfo = mobox.getFileSvr(strLuaDEID)
|
if (nRet ~= 0 or strRetInfo == '') then
|
lua.Error( strLuaDEID, debug.getinfo(1), "得到文件服务标识失败!")
|
end
|
local strFileServer = strRetInfo
|
|
nRet, strRetInfo = mobox.uploadFile(strLuaDEID, strFileServer, file_path )
|
if (nRet ~= 0 or strRetInfo == '') then
|
lua.Error( strLuaDEID, debug.getinfo(1), "上传文件失败!")
|
end
|
local action = {
|
{
|
action_type = download_file,
|
value = {
|
file_svr = strFileServer,
|
file_id = strRetInfo,
|
file_name = "2.0-特征选项导出.xlsx"
|
}
|
}
|
}
|
mobox.setAction( strLuaDEID, action )
|
end
|