--[[ 编码: GT-100-08 名称: 006-出库单据取消 作者: LZH 入口函数:DeliveryCancel 功能说明: 输入数据: { "task_no": "xxx", 出库任务号 "remark1": "", -- 备注 暂未启用 "remark2": "", -- 备注 暂未启用 "remark3": "", -- 备注 暂未启用 "remark4": "" -- 备注 暂未启用 } 处理逻辑 -- step1 解析接口传递的 datajson 参数 -- step2 校验必传字段是否为空,为空则报错 -- step3 获取出库单,根据类型判断 审核状态 -》设置出库单状态为取消 执行状态 -》判断作业的状态是否为等待,如果为等待则删除作业,设置出库单状态为取消,如果作业状态不为等待则报错,无法取消 变更历史: 20250221 LZH V1.1 新增4个备用字段 --]] require("WMS-Equipment") wms_cntr = require("wms_container") wms_wh = require("wms_wh") require("GT-Base") function DeliveryCancel(strLuaDEID) local strRetInfo -- step1 获取接口数据 local 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 task_no = in_date.task_no if (task_no == nil or task_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "出库任务号不能为空!") end -- V1.1 新增备用字段 local remark1 = in_date.remark1 local remark2 = in_date.remark2 local remark3 = in_date.remark3 local remark4 = in_date.remark4 -- step3 获取出库单,根据类型判断 local stock_out nRet, stock_out = m3.GetDataObjectByKey(strLuaDEID, "GT_Stock_Out", "S_DO_NO", task_no) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取【出库单据】信息失败! " .. stock_out) end lua.Debug(strLuaDEID, debug.getinfo(1), "stock_out:", stock_out) if (stock_out.state == '审核') then local strCondition = "S_DO_NO = '" .. task_no .. "'" local strSetSQL_update = " S_STATE = '取消' " nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Stock_Out", strCondition, strSetSQL_update) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "修改出库单状态失败!" .. strRetInfo) end elseif (stock_out.state == '启用') then lua.Error(strLuaDEID, debug.getinfo(1), "出库单正在执行中,无法取消!") elseif (stock_out.state == '完成') then lua.Error(strLuaDEID, debug.getinfo(1), "出库单已完成,无法取消!") end end