1
Jianw
2025-07-09 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--[[
    编码: WMS-52-19
    名称: 配盘明细-数量输入变化
    作者:HAN  
    日期:2025-6-10
 
    级别:项目
    
    函数: AfterQtyChange
 
    功能:
        -- 装箱数量输入变化后
 
    更改记录:
 
--]]
 
prj_base = require( "prj_base" )
 
function AfterQtyChange ( strLuaDEID ) 
    local nRet, strRetInfo
    local runtime_parameter
    
    nRet, runtime_parameter = m3.GetRuntimeParam(strLuaDEID)
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, "GetRuntimeParam失败! "..runtime_parameter )
        return
    end
    -- 获取【组盘输入】面板的参数
    local parameter
    nRet, parameter = m3.GetRuntimePanel_InputParamter( strLuaDEID, runtime_parameter.panel, "出库分拣" )
    if ( nRet == 1 ) then 
        mobox.setInfo( strLuaDEID, "没有定义'出库分拣'面板参数!")
        return 
    end
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, parameter ) 
        return
    end 
    if ( parameter == nil ) then return end
    local id = parameter.id                 -- 当前点中的出库任务标识
    local dc_no = parameter.dc_no           -- 当前点中的出库任务所属配盘号
    if ( dc_no == nil or dc_no == "") then
        mobox.setInfo( strLuaDEID, "'出库分拣'面板必须有 dc_no 参数!")
        return         
    end
    -- 获取UPC
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "F_QTY","F_ACC_P_QTY" ) 
    if ( nRet ~= 0 )  then 
        lua.Stop( strLuaDEID, "获取当前编辑属性失败! "..strRetInfo )
        return
    end 
    local obj_attrs = json.decode( strRetInfo ) 
    local qty = lua.Get_NumAttrValue( obj_attrs[1].value )  
    local acc_p_qty = lua.Get_NumAttrValue( obj_attrs[2].value )
    
    if ( qty == 0 ) then return end
    if ( acc_p_qty >= qty ) then
        acc_p_qty = qty
        local action = {}
        -- 设置UPC这里扫码拣料箱    
        if lua.StrIsEmpty( parameter.pick_box_code ) then
            -- 分拣任务完成
            local id = parameter.id             -- 当前点中的入库任务标识
            local dc_no = parameter.dc_no       -- 当前点中的入库任务所属配盘号
            if ( dc_no == nil or dc_no == "") then
                mobox.setInfo( strLuaDEID, "'出库分拣'面板必须有配盘号参数!")
                return         
            end
        
            -- 设置【配盘明细】状态 = 2/PickingOK(完成分拣)
            local strCondition = "S_ID = '"..id.."'"
            local strUpdateSql = "N_B_STATE = "..DC_DETAIL_STATE.PickingOK..", F_ACC_P_QTY = "..acc_p_qty
            nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Distribution_CNTR_Detail", strCondition, strUpdateSql )
            if ( nRet ~= 0 ) then  
                lua.Stop( strLuaDEID, "更新【配盘明细】信息失败!"..strRetInfo )
                return
            end  
        
            nRet, action = prj_base.Distribution_CNTR_PostProcess( strLuaDEID, parameter )
            if ( nRet ~= 0 ) then
                lua.Stop( strLuaDEID, action )
                return
            end            
        else
            action = {
                {
                    action_type = "set_dlg_attr",
                    value = {  
                                { attr = "UPC", value = "", enable = true, prompt = "请扫拣货箱编码..."  },
                                { attr = "Prompt", value = "请扫拣货箱编码..." },
                                { attr = "F_ACC_P_QTY", value = qty, enable = false },
                            }       
                },
                {
                    action_type = "set_dlg_cursor",
                    value = {
                        ctrl_id = "UPC"
                    }
                }
            }
        end
        nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
        if ( nRet ~= 0 ) then 
            lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction ) 
            return
        end 
    end
end