--[[
|
编码: JX-16-23
|
名称: 盘点计划-盘点结果上传
|
作者:
|
日期:2025-1-19
|
|
函数: Report_Upwards
|
|
功能:
|
盘点计划完成后,把盘点结果上传给上游系统
|
(不是所有项目都需要,看项目定)
|
更改记录:
|
V2.0 HAN 20250320
|
只对货品盘点类型的盘点上传巨沃
|
--]]
|
jx_base= require( "jx_base" )
|
jx_api = require ( "jx_external_api")
|
|
function Report_Upwards( strLuaDEID )
|
local nRet, strRetInfo,objs
|
|
-- step1 获取当前点中的容器
|
nRet, objs = m3.GetSysDataJson( strLuaDEID )
|
if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end
|
-- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
|
local nCount = #objs
|
if (nCount == 0) then return end
|
|
local count_plan
|
local upward_count = 0
|
|
for n = 1, nCount do
|
nRet, count_plan = m3.GetDataObject( strLuaDEID, "Count_Plan", objs[n].id )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), count_plan ) end
|
|
-- 只有盘点计划状态=3/完成的 盘点计划才能回报, 并且回报状态不等1/完成
|
if ( count_plan.b_state == 3 and count_plan.cr_state ~= 1 and count_plan.type == wms_base.Get_nConst(strLuaDEID, "盘点类型-货品盘点") ) then
|
upward_count = upward_count + 1
|
nRet, strRetInfo = jx_api.JW_WMS_API_subStockCheck( strLuaDEID, count_plan.cp_no )
|
-- 更新盘点计划的完工回报属性
|
local curTime = os.date("%Y-%m-%d %H:%M:%S")
|
|
local strSetAttr
|
if ( nRet == 0 ) then
|
-- 盘点差异表 C_RECOUNT 设置为 N 表示不允许复盘
|
strCondition = "S_CP_NO = '"..count_plan.cp_no.."'"
|
strSetAttr = "C_RECOUNT = 'N'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Diff", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【盘点差异表】信息失败!"..strRetInfo ) end
|
strSetAttr = "N_CR_STATE = 1, S_CR_ERR = '', T_CR = '"..curTime.."'"
|
else
|
lua.Debug( strLuaDEID, debug.getinfo(1), "JW-WMS subStockCheck 接口错误", strRetInfo )
|
strSetAttr = "N_CR_STATE = 2, S_CR_ERR = 'JW-WMS subStockCheck 接口错误, 详细信息看日志!', T_CR = '"..curTime.."'"
|
end
|
-- 更新盘点计划回报状态
|
strCondition = "S_CP_NO = '"..count_plan.cp_no.."'"
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Plan", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【盘点计划】回报信息失败!"..strRetInfo ) end
|
-- 盘点计划相关的盘点单的上传状态也一起设置
|
nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Order", strCondition, strSetAttr )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【盘点单】回报信息失败!"..strRetInfo ) end
|
end
|
end
|
|
if ( upward_count == 0 ) then
|
mobox.setInfo( strLuaDEID, "选中的盘点计划条件不满足,无法上传!")
|
return
|
end
|
local action
|
if ( upward_count == 1 ) then
|
action = {
|
{
|
action_type = "refresh_cur_row",
|
value = ""
|
}
|
}
|
else
|
action = {
|
{
|
action_type = "refresh",
|
value = ""
|
}
|
}
|
end
|
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end
|
end
|