1
Jianw
10 天以前 88e26a2a960dbbc148332772448b79b9877102d8
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
106
107
108
109
110
--[[
   编码: JX-01-25
   名称: 空料箱入库确定后
   作者:KUN
   日期:2025-03-06
 
   函数: ClickOK
   功能:
        -- 获取输入参数,查询移库单是否有记录,再查询任务池是否有记录
        -- 创建任务池
 
   更改记录:
 
--]]
 
wms_cntr = require( "wms_container" )
jx_base = require( "jx_base" )
wms_wh = require( "wms_wh" )
 
function ClickOK( strLuaDEID )
    local attrs
        -- 获取输入参数
    nRet, attrs = m3.GetSysInputParameter(strLuaDEID)
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "获取当前输入面板里的属性失败! " .. attrs)
        return
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), "attrs", attrs)
    
    local input_attr = m3.KeyValueAttrsToObjAttr(attrs)
 
    local cntr_code = input_attr.S_CODE
    local spec = input_attr.S_SPEC
    local cell_code = input_attr.cell_code
    
 
    if (cntr_code == nil or cntr_code == '') then
        mobox.setInfo(strLuaDEID, "容器编码不能为空!")
        return
    end
    
    -- 创建 JX_Task 任务池
    -- 查询该料箱是否有任务池,有则不创建
    local strCondition = "S_CNTR_CODE = '" .. cntr_code .. "' AND N_B_STATE = 0 "
    local nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JX_Task", strCondition)
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, debug.getinfo(1), "查询任务池失败! " .. data_objs)
        return
    end
    if (data_objs == '') then
        
        local now = os.date("%Y%m%d%H%M%S")
        local randomNum = math.random(1, 99999)
        local strHeader = 'RK'..os.date("%y%m%d")..'-'
        local str_no
    
        -- 获取码盘单号
        nRet, str_no = mobox.getSerialNumber( "巨星任务", strHeader, 4 )  
        if (nRet ~= 0) then 
            lua.Error( strLuaDEID, debug.getinfo(1),'申请码盘单编码失败!'..str_no) 
        end
        local jx_task = m3.AllocObject(strLuaDEID, "JX_Task")
        jx_task.cntr_code = cntr_code  -- 托盘号
        jx_task.source_sys = "巨沃入库"   -- 来源系统
        jx_task.sour_no = str_no    -- 上游任务号
        jx_task.end_area_code = wms_base.Get_sConst(strLuaDEID, "料箱库存储区")
        jx_task.task_type = "入库"   -- 作业类型
        jx_task.create_method = "JW-WMS"
        jx_task.start_wh_code = wms_base.Get_sConst(strLuaDEID, "默认仓库标识")
 
        nRet, jx_task = m3.CreateDataObj(strLuaDEID, jx_task)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1),  "创建 JX_Task 任务池记录失败! " .. jx_task)
        end
        mobox.setInfo(strLuaDEID, "创建成功!")
    else
        mobox.setInfo(strLuaDEID,  "料箱: " .. cntr_code.. "已经有任务池,不能再创建")
    end
    --  清空"料格转换"页面
    local action = {}
    action[1] = {
        action_type = "clear_subpage_rows",
        value = {
            page_name = "料箱信息"
        }
    }
    action[2] = {
        action_type = "set_dlg_attr",
        value = {
            {
                attr = "S_CODE",
                value = ""
            }
        }
    }
    
    action[3] = {
    action_type = "set_dlg_current_edit_attr",
    value = "S_CODE"
    }
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "清空页面失败! " .. strRetInfo)
        return
    end
        
 
 
end