--[[
|
编码: JX-108-19
|
名称: 巨星任务-巨星出库后空料箱回库
|
作者:HAN
|
日期:2025-1-29
|
|
级别:项目
|
|
函数: ClickGoBack
|
|
功能:
|
-- 巨星料箱设置为空
|
-- 巨星出库任务设置=2
|
-- 创建‘巨星空料箱入库’作业
|
|
更改记录:
|
--]]
|
jx_base= require( "jx_base" )
|
wms_cntr= require( "wms_container" )
|
wms_wh = require( "wms_wh" )
|
|
function ClickGoBack ( strLuaDEID )
|
local nRet, strRetInfo
|
local strUserLogin, strUserName
|
nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前操作人员信息失败! "..strUserLogin ) end
|
|
-- 获取TOPVIEW的输入信息
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STATION_NO","S_CNTR_CODE" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local station = lua.Get_StrAttrValue( obj_attrs[1].value )
|
local cntr_code = lua.Get_StrAttrValue( obj_attrs[2].value )
|
|
if ( station == '' or cntr_code == '' ) then
|
mobox.setInfo( strLuaDEID, "输入参数不完整,无法执行入库作业!")
|
return
|
end
|
-- 检查是否有 巨星出库 任务在本站台
|
local station_loc_code = jx_base.Get_Station_Loc( strLuaDEID, station )
|
if ( station_loc_code == '' ) then
|
mobox.setInfo( strLuaDEID, "站台'"..station.."'没有定义货位!")
|
return
|
end
|
local strCondition = "N_B_STATE = 5 AND S_CNTR_CODE = '"..cntr_code.."' AND S_END_LOC = '"..station_loc_code.."' AND S_TASK_TYPE = '出库'"
|
local data_objs
|
nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JX_Task", strCondition, "S_SOURNO" )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end
|
if ( data_objs == '' ) then
|
mobox.setInfo( strLuaDEID, "容器号'"..cntr_code.."'的巨星出库任务还没到站台!")
|
return
|
elseif ( #data_objs > 1 ) then
|
mobox.setInfo( strLuaDEID, "容器号等于'"..cntr_code.."'的巨星出库到站任务有多条! 数据不合法请检查!")
|
return
|
end
|
local obj_attrs = m3.KeyValueAttrsToObjAttr(data_objs[1].attrs)
|
|
-- 更新巨星出库任务的状态,设置为 2
|
local strUpdateSql = "N_B_STATE = 2"
|
local strCondition = "S_SOURNO = '"..obj_attrs.S_SOURNO.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】状态息失败!"..strRetInfo ) end
|
-- 更新容器状态为空
|
local strUpdateSql = "N_EMPTY_FULL = 0"
|
local strCondition = "S_CODE = '"..cntr_code.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Container", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【容器】状态息失败!"..strRetInfo ) end
|
|
|
-- 获取站点货位,站点货位定义在常量中
|
local loc
|
nRet, loc = wms_wh.GetLocInfo( station_loc_code )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '获取货位信息失败! '..loc_code ) end
|
|
-- 创建一个【巨星任务】,类型(入库)
|
local jx_task = m3.AllocObject(strLuaDEID,"JX_Task")
|
jx_task.task_type = "巨星空料箱入库"
|
jx_task.b_state = 1 -- 作业启动
|
jx_task.station = station
|
jx_task.start_wh_code = loc.wh_code
|
jx_task.start_area_code = loc.area_code
|
jx_task.start_loc_code = loc_code
|
jx_task.cntr_code = cntr_code
|
jx_task.operator_name = strUserName
|
jx_task.operator = strUserLogin
|
nRet, jx_task = m3.CreateDataObj( strLuaDEID, jx_task )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '创建【巨星任务】失败!'..jx_task ) end
|
|
local operation
|
local ext_info = {
|
bs_type = "巨星任务",
|
bs_no = jx_task.sour_no
|
}
|
nRet, operation = jx_base.Create_StorageOperation( strLuaDEID, "巨星", station, cntr_code, "巨星入库", ext_info )
|
if ( nRet ~= 0 ) then
|
mobox.setInfo( strLuaDEID, operation )
|
return
|
end
|
|
strUpdateSql = "S_OP_CODE = '"..operation.code.."'"
|
strCondition = "S_SOURNO = '"..jx_task.sour_no.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】信息失败!"..strRetInfo ) end
|
|
mobox.setInfo( strLuaDEID, "系统已经成功创建了一个巨星料箱回库作业'"..operation.code.."'")
|
local action =
|
{
|
{
|
action_type = "refresh",
|
value = ""
|
}
|
}
|
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end
|
|
-- 【注意】如果上面的程序有入库作业产生需要对入库作业的终点获取加入库锁
|
nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst( strLuaDEID, "锁类型-入库锁" ),
|
"", operation.code, operation.op_def_name )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!"..strRetInfo ) end
|
end
|