--[[
|
编码: GT-100-05
|
名称: GT-WMS
|
作者:LZH
|
入口函数: CreateLabelCrad
|
|
|
功能说明:
|
GT-WMS下发入库单据行信息给 GZ-WMS系统,GZ-WMS系统对基础数据进行新增
|
|
输入数据:
|
{
|
"delivery_no": "xxx", 收货单号
|
"delivery_row_no": "xxx", 收货单行号
|
"serial_no": "xxx", 流水号
|
"batch_no": "xxx", 批次号
|
"qty": xxx, 托盘重量
|
"item_code": "xxx", 物料编码九位码
|
"product_date": "xxx", 生产日期
|
"storage_loc": "xxx", 库位
|
"wh_code": "xxx", 仓库编号
|
"is_bonded": "xxx", 是否保税
|
"item_state": "xxx", 质量状态
|
"wheel_type_rot": "xxx", 轮型/左右旋
|
"subpool": "xxx", 子库
|
"req_no": "xxx", 唯一标识
|
"inbound_policy": "xxx", 胶料入库规则
|
"expire_date": "xxx", 到期时间
|
"palletizing": "xxx", 码盘规则
|
"dispersoid": "xxx", 散装胶标识
|
"item_code_9": "xxx", 物料编码六位码
|
"remark1": "", -- 备注 暂未启用
|
"remark2": "", -- 备注 暂未启用
|
"remark3": "", -- 备注 暂未启用
|
"remark4": "", -- 备注 暂未启用
|
"number": "", -- 只针对散装胶,散装胶的入库单据行是一车的总数量,根据 总数量/块数得到每块胶的标准重量
|
}
|
|
|
处理逻辑
|
-- step1 解析接口传递的 datajson 参数
|
-- step2 校验必传字段是否为空,为空则报错
|
-- step3 通过收货单号和收货单行号获取入库单据头信息
|
-- step4 创建入库单据行
|
|
变更记录:
|
20250221 LZH V1.1 新增4个备用字段和到期时间、散装胶标识、码盘规则
|
20250319 LZH V1.2 新增number字段
|
--]]
|
m3 = require( "oi_base_mobox" )
|
json = require("json")
|
mobox = require("OILua_JavelinExt")
|
function CreateLabelCrad(strLuaDEID)
|
local nRet, strRetInfo, in_date
|
-- step1 获取接口数据
|
nRet, in_date = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback 无法获取数据包!" .. in_date) end
|
lua.Debug(strLuaDEID, debug.getinfo(1), '入库单据行下发下发参数:', in_date)
|
|
-- step2 判断是否都有值?没值报错返回
|
local delivery_no = in_date.delivery_no
|
if (delivery_no == nil or delivery_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "收货单号不能为空!") end
|
local delivery_row_no = in_date.delivery_row_no
|
if (delivery_row_no == nil or delivery_row_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "收货单行号不能为空!") end
|
local serial_no = in_date.serial_no
|
if (serial_no == nil or serial_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "流水号不能为空!") end
|
local batch_no = in_date.batch_no
|
if (batch_no == nil or batch_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "批次号不能为空!") end
|
local qty = tonumber(in_date.qty)
|
if (qty == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "托盘重量不能为空!") end
|
local item_code = in_date.item_code
|
if (item_code == nil or item_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "物料编码不能为空!") end
|
local product_date = in_date.product_date
|
if (product_date == nil or product_date == '') then lua.Error(strLuaDEID, debug.getinfo(1), "生产日期不能为空!") end
|
local wh_code = in_date.wh_code
|
if (wh_code == nil or wh_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "仓库编号不能为空!") end
|
local is_bonded = in_date.is_bonded
|
local item_state = in_date.item_state
|
if (item_state == nil or item_state == '') then lua.Error(strLuaDEID, debug.getinfo(1), "质量状态不能为空!") end
|
local storage_loc = in_date.storage_loc
|
local wheel_type_rot = in_date.wheel_type_rot
|
local subpool = in_date.subpool
|
local req_no = in_date.req_no
|
local inbound_policy = in_date.inbound_policy
|
-- 20250221 LZH V1.1 新增4个备用字段和到期时间、散装胶标识、码盘规则
|
local expire_date = in_date.expire_date
|
local palletizing = in_date.palletizing
|
local dispersoid = in_date.dispersoid
|
local remark1 = in_date.remark1
|
local remark2 = in_date.remark2
|
local remark3 = in_date.remark3
|
local remark4 = in_date.remark4
|
-- 20250319 LZH V1.2 新增number字段
|
local number = in_date.number
|
local item_code_9 = in_date.item_code_9
|
if (item_code_9 == nil or item_code_9 == '') then lua.Error(strLuaDEID, debug.getinfo(1), "物料编码不能为空!") end
|
|
-- if(dispersoid == 'Y')then
|
-- nRet, serial_no = mobox.getSerialNumber("流水号", 'L', 7)
|
-- if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1),"申请散装胶入库单据行编码失败!" .. serial_no) end
|
-- end
|
|
-- step3 通过收货单号和收货单行号获取入库单据头信息
|
local strCondition = "S_DELIVERY_NO = '" .. delivery_no .. "' AND N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
|
nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", strCondition)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 失败!" .. strRetInfo)
|
end
|
|
local order_no = strRetInfo.order_no
|
local item_name = strRetInfo.item_name
|
|
-- 判断流水号是否存在,存在则更新
|
strCondition = "S_SERIAL_NO = '" .. serial_no .. "'"
|
nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition)
|
if (nRet == 1) then
|
-- step4 创建入库单据行
|
-- 获取一个初始的【入库单据行】数据对象
|
strRetInfo = m3.AllocObject(strLuaDEID, "GT_Label_Crad")
|
strRetInfo.delivery_no = delivery_no
|
strRetInfo.delivery_row_no = delivery_row_no
|
strRetInfo.item_code_9 = item_code
|
strRetInfo.item_name = item_name
|
strRetInfo.product_date = product_date
|
strRetInfo.batch_no = batch_no
|
strRetInfo.item_state = item_state
|
strRetInfo.qty = qty
|
strRetInfo.serial_no = serial_no
|
strRetInfo.wh_code = wh_code
|
strRetInfo.storage_loc = storage_loc
|
strRetInfo.order_no = order_no
|
strRetInfo.is_bonded = is_bonded
|
strRetInfo.wheel_type_rot = wheel_type_rot
|
strRetInfo.subpool = subpool
|
strRetInfo.req_no = req_no
|
strRetInfo.inbound_policy = inbound_policy
|
strRetInfo.expire_date = expire_date
|
strRetInfo.palletizing = palletizing
|
strRetInfo.dispersoid = dispersoid
|
strRetInfo.number = number
|
strRetInfo.item_code = item_code_9
|
nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, strRetInfo)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), 'mobox 创建【入库单据行】对象失败!' .. strRetInfo)
|
end
|
elseif (nRet == 0) then
|
local update_sql = "S_DELIVERY_NO = '" .. delivery_no .. "',N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
|
update_sql = update_sql .. ",S_item_code_9 = '" .. item_code .. "',S_ITEM_NAME = '" .. item_name .. "'"
|
update_sql = update_sql .. ",D_PRODUCT = '" .. product_date .. "',S_BATCH_NO = '" .. batch_no .. "'"
|
update_sql = update_sql .. ",S_ITEM_STATE = '" .. item_state .. "',F_QTY = '" .. qty .. "',S_WH_CODE ='" .. wh_code .. "'"
|
update_sql = update_sql .. ",S_ORDER_NO = '" .. order_no .. "'"
|
if(is_bonded ~= nil and is_bonded ~= '')then
|
update_sql = update_sql..",C_IS_BONDED = '" .. is_bonded .. "'"
|
end
|
if(storage_loc ~= nil and storage_loc ~= '')then
|
update_sql = update_sql..",S_STORAGE_LOC = '" .. storage_loc .. "'"
|
end
|
if(wheel_type_rot ~= nil and wheel_type_rot ~= '')then
|
update_sql = update_sql..",S_WHEEL_TYPE_ROT = '" .. wheel_type_rot .. "'"
|
end
|
if(subpool ~= nil and subpool ~= '')then
|
update_sql = update_sql..",S_SUBPOOL = '" .. subpool .. "'"
|
end
|
if(req_no ~= nil and req_no ~= '')then
|
update_sql = update_sql..",S_REQ_NO = '" .. req_no .. "'"
|
end
|
if(inbound_policy ~= nil and inbound_policy ~= '')then
|
update_sql = update_sql..",S_INBOUND_POLICY = '" .. inbound_policy .. "'"
|
end
|
if(expire_date ~= nil and expire_date ~= '')then
|
update_sql = update_sql..",D_EXPIRE = '" .. expire_date .. "'"
|
end
|
if(palletizing ~= nil and palletizing ~= '')then
|
update_sql = update_sql..",S_PALLETIZING = '" .. palletizing .. "'"
|
end
|
if(dispersoid ~= nil and dispersoid ~= '')then
|
update_sql = update_sql..",S_DISPERSOID = '" .. dispersoid .. "'"
|
end
|
if(number ~= nil and number ~= '')then
|
update_sql = update_sql..",S_NUMBER = '" .. number .. "'"
|
end
|
if(item_code_9 ~= nil and item_code_9 ~= '')then
|
update_sql = update_sql..",S_ITEM_CODE = '" .. item_code_9 .. "'"
|
end
|
nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Label_Crad", strCondition, update_sql)
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "修改入库单信息失败!" .. strRetInfo) end
|
else
|
lua.Error(strLuaDEID, debug.getinfo(1), 'GetDataObjByCondition失败!' .. strRetInfo)
|
end
|
end
|