fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
96
97
98
99
100
101
102
103
104
105
--[[
     项目中Lua调用外部 API 
     更新记录:
--]]
 
wms_base = require( "wms_base" )
 
local external_api = {_version = "0.1.1"}
 
--[[
    1# Task_Cancel              通知WCS任务取消
    2# Get_DEV_State            获取设备的状态
]]
 
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-- 通过WCS的接口,获取设备状态
-- reqDev 设备号, readingBit -- 读码位
function external_api.Get_DEV_State( strLuaDEID, reqDev )
    local dev_state = {
        {DVC_NO = "ZD01", IS_USE = 1},
        {DVC_NO = "ZD02", IS_USE = 1},
        {DVC_NO = "ZD03", IS_USE = 0},
        {DVC_NO = "ZD04", IS_USE = 1}
    }
    return 0, dev_state
end
--[[    
    local nRet, strRetInfo
    local now = os.date("%Y%m%d%H%M%S")  
    local randomNum = math.random(1, 99999)  
    local requestPk = "PK"..now..randomNum
    local wcs_url
    nRet, wcs_url = wms_base.Get_sConst2( strLuaDEID, "WCS服务地址")
    if ( nRet ~= 0 ) then
        return 1, "系统无法获取常量'WCS服务地址'"
    end      
    local strurl =  wcs_url..'/wcs-admin/api/dvc-state'
 
    local body = {
                    requestPk = requestPk,
                    reqDvc = reqDvc,
                }
    lua.Debug( strLuaDEID, debug.getinfo(1), "调WCS接口-->", strurl )                     
    lua.Debug( strLuaDEID, debug.getinfo(1), "body", body )
 
 
    nRet, strRetInfo = mobox.sendHttpRequest( strurl, "", lua.table2str(body) )
    if ( nRet ~= 0 or strRetInfo == '' ) then 
        lua.Error( strLuaDEID, debug.getinfo(1), "调用WCS /wcs-admin/api/receive 接口失败! "..strRetInfo ) 
    end  
 
    lua.Debug( strLuaDEID, debug.getinfo(1), "strRetInfo", strRetInfo )
    
    local ret_info = json.decode(strRetInfo)
    return 0, ret_info.data
 
end
]]
 
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--Task_Cancel 取消任务
--cntr_code 容器号, task_code 任务号
function external_api.Task_Cancel(strLuaDEID, cntr_code, task_code)
    return 0, ""
end
--[[
    local nRet, strRetInfo,n
    -- local now = os.date("%Y%m%d%H%M%S")  
    -- local randomNum = math.random(1, 99999)  
    -- local requestPk = "PK"..now..randomNum
    local wcs_url
    nRet, wcs_url = wms_base.Get_sConst2( strLuaDEID, "WCS服务地址")
    if ( nRet ~= 0 ) then
        return 1, "系统无法获取常量'WCS服务地址'"
    end  
 
    local strurl =  wcs_url..'/wcs-admin/api/cancel'
    local body = {
                    requestPk = task_code,
                    contNo = cntr_code,
                    clientCode = wms,
                    reqTime = 2022-11-11
                }
    lua.Debug( strLuaDEID, debug.getinfo(1), "调WCS接口-->", strurl )                     
    lua.Debug( strLuaDEID, debug.getinfo(1), "body", body )
 
 
    nRet, strRetInfo = mobox.sendHttpRequest( strurl, "",lua.table2str(body) )
    if ( nRet ~= 0 or strRetInfo == '' ) then 
        lua.Error( strLuaDEID, debug.getinfo(1), "调用WCS /wcs-admin/api/receive 接口失败! "..strRetInfo ) 
    end  
 
    lua.Debug( strLuaDEID, debug.getinfo(1), "strRetInfo", strRetInfo )
    
    local ret_info = json.decode(strRetInfo)
    return 0, ret_info.msg
end
]]
 
 
 
return external_api