Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: WMS-29-11
    名称: 计划盘点容器-5601-容器编码输入后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: AfterCNTRNoChange
 
    功能:
        -- 在盘点PDA界面,输入容器编号后,系统查询【计划盘点容器】及【】
    更改记录:
 
--]]
 
wms_cntr= require( "wms_container" )
 
function AfterCNTRNoChange ( strLuaDEID ) 
    local nRet, strRetInfo
    local attrs
 
    -- step1  获取5601分拣界面中表头的输入属性(容器编号/托盘号)
    nRet, attrs = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前输入面板里的属性失败! "..attrs ) end 
 
    local input_attr = m3.KeyValueAttrsToObjAttr(attrs)
    local cntr_code = input_attr.S_CNTR_CODE
    if (cntr_code == nil or cntr_code == '') then return end
    local count_no = input_attr.S_COUNT_NO
    if (count_no == nil or count_no == '') then 
        mobox.setInfo( strLuaDEID, "必须要有盘点单号!" )
        return 
    end    
 
    -- step2 判断输容器是否存在合法
    local container
    nRet, container = wms_cntr.GetInfo( strLuaDEID, cntr_code )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【容器】信息失败! " .. container) end
    if ( container == '') then lua.Error( strLuaDEID, debug.getinfo(1), "【容器】" .. cntr_code.."不存在!") end
    if ( container.virtual == 'Y' ) then lua.Error( strLuaDEID, debug.getinfo(1), "容器'" .. cntr_code.."'是一个虚拟容器!") end
 
    -- step3 查询容器是否在【盘点单】中存在
    local strCondition = "S_CNTR_CODE = '"..cntr_code.."' AND S_COUNT_NO = '"..count_no.."'"
    lua.Debug( strLuaDEID, debug.getinfo(1), "strCondition", strCondition )
    nRet, strRetInfo = mobox.existThisData(strLuaDEID, "CP_Count_Container", strCondition)
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "在检查容器是否在盘点里时失败! " .. strRetInfo) end
    if (strRetInfo ~= 'yes') then    
        mobox.setInfo( strLuaDEID, "盘点单'"..count_no.."'没有这个容器!" )
        return 
    end    
 
    -- step4 获取【Count_CG_Detail】盘点货物
    local strOrder = "S_ITEM_CODE"
    local count_cg_detail
    nRet, count_cg_detail = m3.QueryDataObject( strLuaDEID, "Count_CG_Detail", strCondition, strOrder )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【Count_CG_Detail】信息失败! " .. count_cg_detail) end
 
    -- 设置 action 
    local action_array = {}
    -- 设置[待分拣]页面信息
    local set_page_content_action = {}
    local value = {}
    set_page_content_action.action_type = "set_subtable_page_content"
    value.page_name = "盘点货物"
    value.clear = true
    value.checkbox = true
    if ( #count_cg_detail == 0 ) then
        value.content = json.decode("[]")
    else
        value.content = count_cg_detail
    end
    set_page_content_action.value = value
    action_array[1] = set_page_content_action
 
    lua.Debug( strLuaDEID, debug.getinfo(1),"action_array", action_array)
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action_array)  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
end