--[[
|
编码: GT-122-27
|
名称:
|
作者:
|
日期:2025-03-26
|
|
函数: ClickOk
|
功能:
|
|
更改记录:
|
|
--]]
|
wms_cntr = require("wms_container")
|
wms_wh = require("wms_wh")
|
function ClickOk(strLuaDEID)
|
local nRet, strRetInfo
|
-- 获取PDA参数
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "start_loc_code", "end_loc_code")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "调用方法GetSysDataJson出错") end
|
local obj_attrs = json.decode(strRetInfo)
|
lua.Debug(strLuaDEID, debug.getinfo(1), 'obj_attrs', obj_attrs)
|
|
|
local start_loc_code = obj_attrs[1].value
|
|
-- 获取起点容器
|
local cntr_loc
|
local strCondition = "S_LOC_CODE = '" .. start_loc_code .. "'"
|
nRet, cntr_loc = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取【货位容器】信息失败! ") end
|
|
-- 获取起点
|
local start_loc
|
nRet, start_loc = wms_wh.GetLocInfo(start_loc_code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo失败!' .. start_loc) end
|
|
-- 如果起点为内深位需要判断外深位是否上锁 上锁则报错提示,存在货品则触发被动移库
|
if (tonumber(start_loc.pos) == 2) then
|
-- 获取对应外深位
|
local new_loc_code
|
nRet, new_loc_code = OuterDeepPosition(strLuaDEID, start_loc.row_group, start_loc.code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), new_loc_code) end
|
|
-- 判断是否上锁
|
strCondition = "S_CODE = '" .. new_loc_code .. "' AND N_LOCK_STATE = 0"
|
nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Location", strCondition)
|
if (nRet == 1) then
|
mobox.setInfo(strLuaDEID, "起点对应的外深位已上锁!")
|
return
|
elseif (nRet > 1) then
|
lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
|
end
|
|
-- 判断是否存在货品,存在需要移库
|
strCondition = "S_CODE = '" .. new_loc_code .. "' AND N_CURRENT_NUM = 1"
|
nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Location", strCondition)
|
if (nRet == 1) then
|
goto back
|
elseif (nRet > 1) then
|
lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
|
end
|
|
-- 创建移库作业
|
-- 获取起点信息
|
local new_start_loc, new_end_loc
|
nRet, new_start_loc = wms_wh.GetLocInfo(new_loc_code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo失败!' .. start_loc) end
|
|
-- 获取容器信息
|
strCondition = "S_LOC_CODE = '" .. new_loc_code .. "'"
|
local new_cntr_loc
|
nRet, new_cntr_loc = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取【货位容器】信息失败! " .. new_cntr_loc) end
|
|
-- 获取货品信息
|
strCondition = "S_CNTR_CODE = '" .. new_cntr_loc.cntr_code .. "'"
|
local new_cg_detail
|
nRet, new_cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取【容器货品明细】信息失败! " .. new_cg_detail) end
|
|
-- 获取物料类型
|
local item_type, material
|
nRet, item_type, material = GT_Get_ItemType(strLuaDEID, new_cg_detail.item_code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), item_type) end
|
|
local layer = ''
|
if(item_type == '钢丝')then
|
layer = wms_base.Get_sConst(strLuaDEID, "佳通-立库钢丝货位层")
|
else
|
layer = wms_base.Get_sConst(strLuaDEID, "佳通-立库非钢丝货位层")
|
end
|
|
-- 获取终点信息
|
nRet, new_end_loc = GetEndLoc(strLuaDEID, new_start_loc.roadway,layer)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), new_end_loc) end
|
|
-- 创建佳通任务
|
local gt_task = m3.AllocObject(strLuaDEID, "GT_Task")
|
-- 起点信息
|
gt_task.start_wh_code = new_start_loc.wh_code
|
gt_task.start_area_code = new_start_loc.area_code
|
gt_task.start_loc_code = new_start_loc.code
|
-- 终点信息
|
gt_task.end_wh_code = new_end_loc.wh_code
|
gt_task.end_area_code = new_end_loc.area_code
|
gt_task.end_loc_code = new_end_loc.code
|
gt_task.type = 3 -- 1 粉料调拨搬运 2 烘胶搬运 3 同巷道移库
|
gt_task.priority = 2 -- 大的优先
|
gt_task.cntr_code = new_cntr_loc.cntr_code
|
nRet, gt_task = m3.CreateDataObj(strLuaDEID, gt_task)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '创建【佳通任务】失败!' .. gt_task) end
|
end
|
::back::
|
|
local end_loc_code = obj_attrs[2].value
|
-- 通过站台位置获取终点
|
-- end_loc_code = wms_base.Get_sConst(strLuaDEID, end_loc_code)
|
-- 获取终点
|
local end_loc
|
nRet, end_loc = wms_wh.GetLocInfo(end_loc_code)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo失败!' .. end_loc) end
|
|
-- step4: 创建搬运作业
|
local operation = m3.AllocObject(strLuaDEID, "Operation")
|
operation.start_wh_code = start_loc.wh_code
|
operation.start_area_code = start_loc.area_code
|
operation.start_loc_code = start_loc.code
|
|
-- 终点是佳通WMS传过来的
|
operation.end_wh_code = end_loc.wh_code
|
operation.end_area_code = end_loc.area_code
|
operation.end_loc_code = end_loc.code
|
|
local strCode
|
local ext_table = {}
|
local strHeader = 'TA' .. os.date("%y%m%d") .. '-'
|
nRet, strCode = mobox.getSerialNumber("任务", strHeader, 5)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '申请【任务】编码失败!' .. strCode) end
|
ext_table.task_no = strCode
|
operation.ext_data = lua.table2str(ext_table)
|
|
operation.cntr_code = cntr_loc.cntr_code
|
operation.op_def_name = "点对点出库"
|
operation.op_type = wms_base.Get_nConst(strLuaDEID, "作业类型-出库")
|
nRet, operation = m3.CreateDataObj(strLuaDEID, operation)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. operation) end
|
|
-- 起点加锁操作
|
nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.start_loc_code,
|
wms_base.Get_nConst(strLuaDEID, "锁类型-出库锁"),
|
strCode, operation.code, operation.op_def_name)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!" .. strRetInfo) end
|
|
mobox.setInfo(strLuaDEID, "操作成功!")
|
end
|