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
81
82
83
84
--[[
    编码: WMS-56-14
    名称: 组盘明细-3055-顶部窗口站台变化后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: AfterStationChange
 
    功能:
        -- 根据输入的容器号,判断在当前工作台是否有该容器号的 组盘明细 ,有显示在 当前任务 页签
        -- 如果当前到站台的入库任务中的容器号和扫码输入的容器号不相等报错
 
 
    更改记录:
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function AfterStationChange ( strLuaDEID ) 
    local nRet, strRetInfo
 
    -- 获取站台编码
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STATION_NO","S_CNTR_CODE" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local station = lua.Get_StrAttrValue( obj_attrs[1].value )  
    local cntr_code = lua.Get_StrAttrValue( obj_attrs[2].value )  
    
    if ( station == '' ) then return end
 
    local strCondition, nCount
    -- N_B_STATE = 0  未执行任务
    strCondition = "S_STATION_NO = '"..station.."' AND N_B_STATE = 0"        
    nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "Pre_Alloc_CNTR_Detail", strCondition )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),  strRetInfo ) end 
    nCount = lua.StrToNumber( strRetInfo )    
    local action =  {
        {
            action_type = "set_dlg_attr",
            value = {
                { attr = "TaskCount", value = nCount, enable = false }
            }
        },
        {
            action_type = "set_query_condition",
            value = {
                condition = strCondition,
                order = "S_SET_CODE",
                page_name = "未执行任务"
            }            
        }
    }
 
    -- 判断 容器 是否已经搬运到入库站台
    --   Organize_Container中的 N_B_STATE = 2
    if ( cntr_code ~= '' ) then
        strCondition = "S_STATION_NO = '"..station.."' AND N_B_STATE = 2 AND S_CNTR_CODE = '"..cntr_code.."'"
        nRet, strRetInfo = mobox.existThisData( strLuaDEID, "Pre_Alloc_Container", strCondition )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo )  end
        -- 如果该车辆编码的动作已经在队列,返回,不做处理
        if ( strRetInfo ~= "yes" ) then 
            mobox.setInfo( strLuaDEID, "料箱'"..cntr_code.."'没有到达站台"..station)
        end
    else
        strCondition = "S_STATION_NO = '"..station.."' AND N_B_STATE = 1 AND S_CNTR_CODE = '"..cntr_code.."'"
        action [3] = 
            {
                action_type = "set_query_condition",
                value = {
                    condition = strCondition,
                    order = "S_SET_CODE",
                    page_name = "当前任务"
                }            
            }
    end
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action)  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end 
 
end