--[[
|
编码: WMS-28-03
|
名称: 盘点单-创建后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterDataObjCreate
|
|
功能:
|
-- 把盘点单里的容器的货位从新刷新一下
|
--]]
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function AfterDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_COUNT_NO" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local count_code = lua.Get_StrAttrValue( obj_attrs[1].value )
|
if ( count_code == '' ) then return end
|
|
-- 获取容器所在的货位
|
local strCondition, strClsID
|
local strOrder = ''
|
strCondition = "S_CNTR_CODE IN ( Select S_CNTR_CODE From TN_CP_Count_Container Where "
|
strCondition = strCondition.." S_COUNT_NO ='"..count_code.."')"
|
|
-- 多页查询
|
nRet, strRetInfo = mobox.queryDataObjAttr2( strLuaDEID, "Loc_Container", strCondition, strOrder, 100, "S_LOC_CODE","S_CNTR_CODE" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2: "..strRetInfo) end
|
if ( strRetInfo == '' ) then return end
|
local success
|
local queryInfo
|
success, queryInfo = pcall( json.decode, strRetInfo )
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2 返回结果啊非法的JSON格式!" ) end
|
|
local queryID = queryInfo.queryID
|
local nPageCount = queryInfo.pageCount
|
local nPage = 1
|
local dataSet = queryInfo.dataSet -- 查询出来的数据集
|
local strSetAttr, loc_code, cntr_code
|
local loc
|
while (nPage <= nPageCount) do
|
|
for n = 1, #dataSet do
|
loc_code = dataSet[n].attrs[1].value
|
cntr_code = dataSet[n].attrs[2].value
|
|
nRet, loc = wms_wh.GetLocInfo( loc_code )
|
if ( nRet == 0 ) then
|
strCondition = "S_CP_NO = '"..count_plan.cp_no.."' AND S_CNTR_CODE = '"..cntr_code.."'"
|
strSetAttr = "S_LOC_CODE = '"..loc.code.."', S_WH_CODE = '"..loc.wh_code.."'"..
|
", S_AREA_CODE = '"..loc.area_code.."', N_AISLE = "..loc.aisle..",S_AISLE_CODE = '"..loc.aisle_code.."'"..
|
", N_ROW = "..loc.row..", N_COL = "..loc.col..", N_LAYER = "..loc.layer
|
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "CP_Count_Container", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition失败"..strRetInfo ) end
|
end
|
end
|
|
nPage = nPage + 1
|
if ( nPage <= nPageCount ) then
|
-- 取下一页
|
nRet, strRetInfo = mobox.queryDataObjAttr2( queryID, nPage)
|
if ( nRet ~= 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "queryDataObjAttr2失败! nPage="..nPage.." "..strRetInfo )
|
end
|
queryInfo = json.decode(strRetInfo)
|
dataSet = queryInfo.dataSet
|
end
|
end
|
end
|