--[[
|
编码: WMS-32-10
|
名称: 巷道-数据重置
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: ResetZoneCodeOPNum
|
|
功能:
|
-- 根据巷道定义信息匹配逻辑库区,如果有设备编码匹配一下任务数量
|
--]]
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function ResetZoneCodeOPNum ( 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 strCondition
|
local strOrder = 'S_CODE'
|
strCondition = "S_AREA_CODE = '"..factory.."'"
|
nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" )
|
if (nRet ~= 0) then error( "获取【仓库】信息失败! " .. strRetInfo) end
|
if ( strRetInfo ~= '' ) then
|
local warehouse = {}
|
local n, nCount
|
local success
|
local attrs
|
success, warehouse = pcall( json.decode, strRetInfo)
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! 非法的JSON格式!"..warehouse ) end
|
|
nCount = #warehouse
|
-- 组织下拉列表选项
|
|
for n = 1, nCount do
|
attrs = warehouse[n].attrs
|
choic_items = choic_items..'"'..attrs[1].value..'",'
|
end
|
choic_items = lua.trim_laster_char( choic_items )
|
-- 如果只有一个仓库,那么就默认选这个仓库
|
if ( nCount == 1) then wh_code = attrs[1].value end
|
end
|
|
local aisle = {}
|
for n = 1, nCount do
|
nRet, aisle = m3.ObjAttrStrToLuaObj( "Aisle", lua.table2str(objs[n].attrs) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "m3.ObjAttrStrToLuaObj(Aisle) 失败! "..aisle ) end
|
|
-- 获取巷道逻辑库区
|
|
end
|
|
local strAction = '[{"action_type":"refresh","value":""}]'
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end
|
end
|