fy36
2025-05-30 d63516d67a13061977c1c7851f069f8c5a438466
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
--[[
    编码: JX-108-21
    名称: 巨星任务-巨星出库-输入容器变化
    作者:HAN  
    日期:2025-1-29
    级别:项目
    
    函数: AfterCNTRChange
 
    功能:
        -- 根据输入的容器号,判断在当前巨星出库任务是否已经到站台
 
    更改记录:
 
--]]
jx_base= require( "jx_base" )
 
function AfterCNTRChange ( 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 == '' or cntr_code == '' ) then return end
 
    local station_loc_code = jx_base.Get_Station_Loc( strLuaDEID, station )
    if ( station_loc_code == '' ) then
        mobox.setInfo( strLuaDEID, "站台'"..station.."'没有定义货位!")
        return
    end
 
    -- 判断 容器 是否在任务池 N_B_STATE = 0 表示待执行的任务
    local strCondition = "N_B_STATE = 5 AND S_CNTR_CODE = '"..cntr_code.."' AND S_END_LOC = '"..station_loc_code.."'"
    local data_objs
    nRet, data_objs = m3.QueryDataObject(strLuaDEID, "JX_Task", strCondition, "S_SOURNO" )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..data_objs ) end
    if ( data_objs == '' ) then 
        mobox.setInfo( strLuaDEID, "容器号'"..cntr_code.."'的巨星出库任务还没到站台!")
    elseif ( #data_objs > 1 ) then
        mobox.setInfo( strLuaDEID, "容器号等于'"..cntr_code.."'的巨星出库到站任务有多条! 数据不合法请检查!")
    else
        return
    end
 
    -- 扫码的容器没在当前站台取消容器扫码
    local action = 
    {
        {
            action_type = "set_dlg_attr",
            value = {
                {
                    attr = "S_CNTR_CODE",
                    value = ""
                }
            }            
        }
    }
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action)  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end 
 
end