--[[
|
编码: JX-20-28
|
名称: 入库单刷新
|
作者:KUN
|
日期:2025-3-14
|
|
级别:项目
|
|
函数: Refresh
|
功能: 刷新入库单明细的体积和重量
|
|
更改记录:
|
--]]
|
|
jx_base = require("jx_base")
|
wms_count = require("wms_count")
|
|
function Refresh(strLuaDEID)
|
local nRet, obj
|
|
-- 获取传入的数据包
|
nRet, obj = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "无法获取数据包!" .. obj)
|
return
|
end
|
lua.Debug(strLuaDEID, debug.getinfo(1), "obj", obj)
|
|
local nCount = #obj
|
if (nCount == 0) then
|
return
|
end
|
|
local qty, volume, weight
|
-- 遍历每条入库单
|
for i = 1, #obj do
|
local item = obj[i]
|
local obj_attrs = m3.KeyValueAttrsToObjAttr(item.attrs)
|
|
-- 根据入库单号查询入库单明细
|
local strCondition = "S_IO_NO = '" .. obj_attrs.S_NO .. "'"
|
nRet, inbound_order = m3.QueryDataObject(strLuaDEID, "Inbound_Detail", strCondition)
|
if (nRet ~= 0 or inbound_order == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), '无法查询入库单明细!' .. inbound_order)
|
end
|
|
-- 遍历每条入库单明细
|
for n = 1, #inbound_order do
|
local inbound_detail = inbound_order[n]
|
local inbound_attrs = m3.KeyValueAttrsToObjAttr(inbound_detail.attrs)
|
|
-- 获取物料编码
|
local item_code = inbound_attrs.S_ITEM_CODE
|
if (item_code == nil or item_code == '') then
|
lua.Error(strLuaDEID, debug.getinfo(1), "物料编码为空!")
|
end
|
|
-- 根据物料编码查询物料表
|
local strCondition = "S_ITEM_CODE = '" .. item_code .. "'"
|
nRet, material = m3.GetDataObjByCondition(strLuaDEID, "Material", strCondition)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "获取物料信息失败,商品编码:" .. item.inco)
|
end
|
|
-- 计算总体积和总重量
|
qty = tonumber(inbound_attrs.F_QTY)
|
volume = material.volume
|
weight = material.weight
|
|
|
local strUpdateSql = "F_WEIGHT = '"..weight.."', F_VOLUME = '"..volume.."', S_CELL_TYPE = '"..material.cell_type.."' "
|
local strCondition = "S_IO_NO = '" .. obj_attrs.S_NO .. "' AND S_ITEM_CODE = '" .. item_code.. "'"
|
|
local nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Inbound_Detail", strCondition, strUpdateSql)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, "更新 Inbound_Detail 表失败: " .. strRetInfo)
|
end
|
|
end
|
end
|
mobox.setInfo(strLuaDEID, "更新成功!")
|
|
end
|