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
m3 = require("oi_base_mobox")
lua = require("oi_base_func")
json = require("json")
mobox = require("OILua_JavelinExt")
wms_base = require("wms_base")
wms_cntr = require("wms_container")
 
function CreateOpbyNum(strLuaDEID)
    local nRet, strRetInfo
    -- step1获取当前表头输入的数量
    nRet, strRetInfo = m3.GetSysInputParameter(strLuaDEID)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "获取当前输入面板里的属性失败! " .. strRetInfo)
    end
    
    lua.Debug(strLuaDEID, debug.getinfo(1), "strRetInfo", strRetInfo)
    local input_attr = m3.KeyValueAttrsToObjAttr(strRetInfo.attrs)
    
 
    local op_num = tonumber(input_attr.N_NUM)
    
    lua.Debug(strLuaDEID, debug.getinfo(1), "op_num", op_num)
    local cntr_code
 
    for n = 1, op_num do
        -- 申请一个托盘码
        local strHeader = "FB-"
        nRet, cntr_code = mobox.getSerialNumber("容器", strHeader, 4)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), '申请【容器】编码失败!' .. cntr_code)
        end
        
        
        -- 创建容器
        local container = m3.AllocObject(strLuaDEID, "Container")
        container.code = cntr_code                    -- 容器编码
        container.ctd_code = "CTD-001"              -- 容器编码
              
        lua.Debug(strLuaDEID, debug.getinfo(1), "container:", container)
        nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, container)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "创建容器失败!" .. strRetInfo)
        end
        
 
        -- 创建作业
        local operation = m3.AllocObject(strLuaDEID, 'Operation')
        -- operation.op_def_code = op_code -- 作业定义编码
        operation.op_type = 1
        operation.op_def_name = "货品入库" -- 作业名称
        operation.bs_state = 0 -- 状态
        operation.cntr_code = cntr_code
 
        -- 起点信息
        operation.start_wh_code = "0001" -- 仓库
        operation.start_area_code = "0001" -- 库区
        operation.start_loc_code = "" -- 货位
        -- 终点信息
        operation.end_wh_code = "0001" -- 终点仓库
        operation.end_area_code = "0001" -- 终点库区
        operation.end_loc_code = "" -- 终点货位
 
        -- operation.cntr_code = cntrcode
 
        lua.Debug(strLuaDEID, debug.getinfo(1), '作业创建前:', operation)
 
        nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, operation)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. strRetInfo)
        end
    end
end