--[[
|
编码: JX-108-25
|
名称: 巨星任务-回报失败后再次回报
|
作者:HAN
|
日期:2025-1-29
|
|
级别:项目
|
|
函数: CompletionReturn
|
|
功能:
|
-- 和JX-WMS回报失败后,通过该脚本进行再次回报
|
-- 条件是 巨星任务 的回报状态 = 2 失败
|
-- 行按钮/页面按钮触发
|
|
更改记录:
|
|
--]]
|
jx_base= require( "jx_base" )
|
jx_api = require ( "jx_external_api")
|
|
function CompletionReturn ( strLuaDEID )
|
local nRet, strRetInfo
|
-- step1 获取当前选中的巨星任务
|
local data_json, obj_attrs
|
nRet, data_json = m3.GetSysDataJson( strLuaDEID )
|
if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), data_json ) end
|
-- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
|
local nCount = #data_json
|
if ( nCount == 0 ) then return end
|
|
local id
|
local strCondition, strSetAttr
|
local jx_task
|
local curTime = os.date("%Y-%m-%d %H:%M:%S")
|
local refrush = false
|
for n = 1, #data_json do
|
id = lua.trim_guid_str( data_json[n].id )
|
strCondition = "S_ID = '"..lua.trim_guid_str( data_json[n].id ).."'"
|
nRet, jx_task = m3.GetDataObjByCondition(strLuaDEID, "JX_Task", strCondition )
|
lua.Debug(strLuaDEID, debug.getinfo(1), "jx_task", jx_task)
|
if ( nRet == 0 ) then
|
if ( jx_task.create_method == "JX-WMS" and ( jx_task.cr_state == 2 or jx_task.cr_state == 3 or jx_task.cr_state == 0 ) ) then
|
--巨星要求有一个站台搬运的类型,本质上没有变化,只是类型不同,等同于入库
|
if ( jx_task.task_type == "入库" or jx_task.task_type == "站台搬运") then
|
nRet, strRetInfo = jx_api.WMS_API_PutOn(strLuaDEID, jx_task)
|
-- MDY BY KUN 20250102
|
-- 修改了API的封装函数,状态回报,只有一个函数,8:已接受未下发,9:已接收已下发WCS,Y:完工回报,H:关闭任务
|
if (nRet == 0) then
|
nRet, strRetInfo = jx_api.WMS_API_SetPLCJobStatus(strLuaDEID, jx_task,"Y")--传Y
|
end
|
elseif ( jx_task.task_type == "出库" ) then
|
nRet, strRetInfo = jx_api.WMS_API_SetPLCJobStatus(strLuaDEID, jx_task,"Y")--传Y
|
end
|
|
-- 更新出库单的完工回报属性
|
strCondition = "S_SOURNO = '"..jx_task.sour_no.."'"
|
if ( nRet == 0 ) then
|
strSetAttr = "N_CR_STATE = 1, S_CR_ERR = '', T_CR = '"..curTime.."'"
|
else
|
lua.Debug( strLuaDEID, debug.getinfo(1), "JW-WMS SetPLCJobStatus 接口错误", strRetInfo )
|
strSetAttr = "N_CR_STATE = 2, S_CR_ERR = 'JW-WMS SetPLCJobStatus 接口错误, 详细信息看日志!', T_CR = '"..curTime.."'"
|
end
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】完工回报信息失败!"..strRetInfo ) end
|
refrush = true
|
end
|
end
|
end
|
|
if ( refrush == false ) then return end
|
|
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
|
end
|