1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
--[[
    编码: JX-100-01
    名称: 空料箱呼出算法
    作者:HAN  
    日期:2024-8-5
 
    级别:巨星项目定制
    
    函数:EmptyBoxCellOutPlan
 
    功能:
         空料箱呼出算法
 
    更改记录:
 
]]
 
require ("JX-EmptyBoxOutPlan")
 
function EmptyBoxCellOutPlan ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    -- step1  获取当前点中的任务
    nRet, objs = GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then Error( strLuaDEID, debug.getinfo(1), objs ) end  
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    local nCount = #objs
    if (nCount == 0) then  return end
 
    -- 获取【入库单】信息
    local obj_attrs = KeyValueAttrsToObjAttr( objs[1].attrs )
    local strOpNo = obj_attrs.S_NO
    local strCondition = "S_IO_NO = '"..obj_attrs.S_NO.."'"
    local wh_code = obj_attrs.S_WH_CODE
    local area_code = obj_attrs.S_AREA_CODE
 
    nRet, data_objs = QueryDataObject(strLuaDEID, "Inbound_Detail", strCondition, "N_ROW_NO" )
    if (nRet ~= 0) then Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end
    if ( data_objs == '' ) then return  end
    
    local n
    local item_list = {}    -- 需要入库的货品
    local obj_attrs
 
    -- 生成要入库的货品链表 item_list
    for n = 1, #data_objs do
        obj_attrs = KeyValueAttrsToObjAttr(data_objs[n].attrs)
        local item = {
            item_code = obj_attrs.S_ITEM_CODE,
            item_name = obj_attrs.S_ITEM_NAME,
            volume = StrToNumber( obj_attrs.F_VOLUME ),
            weight = StrToNumber( obj_attrs.F_WEIGHT ),
            cell_type = obj_attrs.S_CELL_TYPE,
            qty = StrToNumber( obj_attrs.F_QTY ),
            alloc_qty = 0,
            cntr_cell_list = {},
            empty_cell_type = "",
            Q = 0,
            ok = false                      -- true 表示这个货品已经分配好入库料箱
        }
        table.insert( item_list, item )
    end
 
    local station = 'A' -- 入库单测试用
 
    local ps_cntr_list = {}
    local ps_detail_list = {}
 
    nRet, strRetInfo = JX_EmptyBoxCellOutPlan( strLuaDEID, item_list, wh_code, area_code, station, "入库单", strOpNo, ps_cntr_list, ps_detail_list )
    if ( nRet ~= 0 ) then
        if (nRet == 1) then
            mobox.setInfo( strLuaDEID, strRetInfo )
            return
        end
        Error( strLuaDEID, debug.getinfo(1), "JX_EmptyBoxCellOutPlan错误: "..strRetInfo)
    end
 
    local action = {}
    action[1] =
        {
            action_type = "refresh_cur_row",
            value = ""
        }
   
    action[2] = 
        {
            action_type = "open_html_dlg",
            value = {
                dlg_name = "空料箱呼出确认",
                cls_id = "Inbound_Order",
                data_json =  {
                    cntr_count = #ps_cntr_list,
                    cntr_cell_list = ps_detail_list
                }
            }
        }        
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, table2str(action) )
    if ( nRet ~= 0 ) then Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end        
 
end