1
Jianw
2025-07-09 f6f5e6b632d6649386a380558d84003f3de7ec6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--[[
    编码: AMS-API-01
    名称: W13-SN取消
    作者:LZH
    日期: 2025-4-15
 
    入口函数: CancleStockBySN
 
    功能说明:
        供外部系统调用,对库内有SN号的料箱打上取消标记
        输入 datajson
        {
        "Name": "CancleStockBySN",
        "Source": "ERP",
        "Data": {
                "S_SN": "SNSNSNSN",
                "SourceKey": ""
            }
        }
        对CG_Detail表的SN取消状态进行更新
    变更记录:
--]] 
wms_base = require("wms_base")
function CancleStockBySN(strLuaDEID)
    -- step1 获取接口中的Data
    local nRet, item_info, id, strRetInfo
    nRet, item_info = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then
        local result = {
            SourceKey = {},
            err_code = 1,
            err_msg = "无法获取数据包!" .. item_info,
            result = nil
        }
        mobox.returnValue(strLuaDEID, 1, lua.table2str(result))
        return
    end
 
    -- 参数校验
    local SourceKey = item_info.SourceKey
    if (SourceKey == nil or SourceKey == '') then
        local result = {
            SourceKey = SourceKey,
            err_code = 1,
            err_msg = "数据传递标识不能为空!",
            result = nil
        }
        mobox.returnValue(strLuaDEID, 1, lua.table2str(result))
        return
    end
    local sn = item_info.S_SN
    if (sn == nil or sn == '') then
        local result = {
            SourceKey = SourceKey,
            err_code = 1,
            err_msg = "SN号不能为空!",
            result = nil
        }
        mobox.returnValue(strLuaDEID, 1, lua.table2str(result))
        return
    end
 
    -- 对库内SN号对应的容器货品明细打上取消标识
    local strSetAttr = "S_UDF02 = '待取消',S_UDF03 = '"..os.date("%Y-%m-%d %H:%M:%S").."'"
    local strCondition = "S_UDF01 = '" .. sn .. "'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Container", strCondition, strSetAttr)
    if (nRet ~= 0) then
        local result = {
            SourceKey = SourceKey,
            err_code = 1,
            err_msg = "更新SN状态失败!" .. strRetInfo,
            result = nil
        }
        mobox.returnValue(strLuaDEID, 1, lua.table2str(result))
        return
    end
    if (tonumber(strRetInfo) == 0) then
        local result = {
            SourceKey = SourceKey,
            err_code = 1,
            err_msg = "SN号在料箱中不存在!",
            result = nil
        }
        mobox.returnValue(strLuaDEID, 1, lua.table2str(result))
        return
    end
 
    local data = {
        SourceKey = SourceKey,
        err_code = 0,
        err_msg = "SN取消成功!",
        result = nil
    }
    mobox.returnValue(strLuaDEID, 1, lua.table2str(data))
end