1
Jianw
10 天以前 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
--[[ 
 编码: 
 名称: GetLocationStatusByRow 
 作者: 
 入口函数:GetLocationStatusByRow 
 功能说明: 
 变更历史: 
 --]] 
 
 
json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
wms_base = require( "wms_base" )
 
function GetLocationStatusByRow(strLuaDEID) 
        local nRet, inputData = m3.GetSysDataJson(strLuaDEID)
     if nRet ~= 0 then
         lua.Stop(strLuaDEID, "无法获取数据包!") 
         return
     end
 
     local wh_code = inputData.wh_code
     local area_code = inputData.area_code
     local row = inputData.n_row
 
     if wh_code == "" or area_code == "" then
         lua.Stop(strLuaDEID, "仓库号和库区号不能为空!") 
         return
     end
     
 
     -- 联表查询 Location 和 Container
     local strTable = "TN_Location a LEFT JOIN TN_Container b ON a.S_CODE = b.S_POSITION"
     local strAttrs = 
         "a.S_CODE, a.N_ROW, a.N_COL, a.N_LAYER, a.C_ENABLE, a.N_CURRENT_NUM, b.N_EMPTY_FULL, b.N_TYPE"                    
     local strCondition = "a.S_WH_CODE = '" .. wh_code .. "' AND a.S_AREA_CODE = '" .. area_code .. "' AND a.N_ROW = '"..row.."'"
 
     local nRet, strRetInfo = mobox.queryMultiTable(strLuaDEID, strAttrs, strTable, 100000, strCondition, "a.S_CODE")
     lua.Debug(strLuaDEID, debug.getinfo(1), "strRetInfo--->", strRetInfo )
     if nRet ~= 0 then
         lua.Stop(strLuaDEID, "查询货位和容器状态失败!")
         return
     end
 
     local queryResult = json.decode(strRetInfo)
     local result_list = {}
 
     for i = 1, #queryResult do
         local row = queryResult[i]
 
         local s_code       = row[1]
         local n_row        = tonumber(row[2])
         local n_col        = tonumber(row[3])
         local n_layer      = tonumber(row[4])
         local c_enable     = row[5]
         local n_current    = tonumber(row[6]) or 0
         local empty_full   = tonumber(row[7])
         local cntr_type    = tonumber(row[8])
 
         local loc_info = {
             code = s_code,
             pos = { n_row, n_col, n_layer },
             status = (c_enable == "Y") and 1 or 0,
             load_status = 0,
             cntr_type = ""
         }
 
         if n_current > 0 then
             -- load_status: 2 表示有货或满,1 表示空
             if empty_full == 1 or empty_full == 2 then
                 loc_info.load_status = 2
             else
                 loc_info.load_status = 1
             end
 
             if cntr_type == 1 then
                 loc_info.cntr_type = "pallet"
             elseif cntr_type == 2 then
                 loc_info.cntr_type = "normal"
             elseif cntr_type == 3 then
                 loc_info.cntr_type = "cell_box"
             elseif cntr_type == 4 then
                 loc_info.cntr_type = "picking_box"
             end
         end
 
         table.insert(result_list, loc_info)
     end
 
     mobox.returnValue(strLuaDEID, 1, lua.table2str(result_list))
end