--[[
|
编码: JX-24-22
|
名称: 出库单-回报失败后再次回报
|
作者:HAN
|
日期:2025-1-29
|
|
级别:项目
|
|
函数: CompletionReturn
|
|
功能:
|
-- 和JW-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 strCondition, strSetAttr
|
local outound_order
|
local curTime = os.date("%Y-%m-%d %H:%M:%S")
|
local refrush = false
|
local err_msg = ""
|
for n = 1, #data_json do
|
strCondition = "S_ID = '"..lua.trim_guid_str( data_json[n].id ).."'"
|
nRet, outound_order = m3.GetDataObjByCondition(strLuaDEID, "Outbound_Order", strCondition )
|
if ( nRet == 0 ) then
|
if ( outound_order.create_method == "JW-WMS" and ( outound_order.cr_state == 2 or outound_order.cr_state == 3 ) ) then
|
nRet, strRetInfo = jx_api.JW_WMS_API_subPickDown( strLuaDEID, outound_order.no )
|
-- 更新出库单的完工回报属性
|
strCondition = "S_NO = '"..outound_order.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 subPickDown 接口错误", strRetInfo )
|
err_msg = "JW-WMS subPickDown 接口错误! --> "..lua.FormatSQLString( strRetInfo )
|
strSetAttr = "N_CR_STATE = 2, S_CR_ERR = '"..err_msg.."', T_CR = '"..curTime.."'"
|
mobox.setInfo(strLuaDEID, "重推失败!错误信息: " .. strRetInfo)
|
end
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Order", 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 = ""
|
}
|
}
|
mobox.setInfo( strLuaDEID, "重推成功!" )
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str( action ))
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end
|
end
|