fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
111
--[[
    编码: JX-108-11
    名称: 巨星任务-TOPVIEW-IN-点入库
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: ClickRun
 
    功能:
        -- 根据输入的容器号,任务号,如果有值说明有可执行的任务
        -- 创建‘巨星入库’作业
 
    更改记录:
        V2.0 HAN 20241115 作业创建集成在函数 jx_base.Create_StorageOperation
--]]
jx_base= require( "jx_base" )
wms_wh = require( "wms_wh" )
 
function ClickRun ( strLuaDEID ) 
    local nRet, strRetInfo
 
    local strUserLogin, strUserName
    nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前操作人员信息失败! "..strUserLogin ) end
 
    -- 获取TOPVIEW的输入信息
    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 
        mobox.setInfo( strLuaDEID, "输入参数不完整,无法执行入库作业!")
        return 
    end
 
    -- 判断容器的位置可以为空,可以在入库理货,不能在存储区或堆垛机的出入缓存区
    local loc_code = wms_wh.GetLocCodeByCNTR( strLuaDEID, cntr_code )
    local loc
    if  ( loc_code ~= '' ) then
        nRet, loc = wms_wh.GetLocInfo( loc_code )
        if ( loc.area_code ~= wms_base.Get_sConst( strLuaDEID,"料箱库理货区" ) and loc.area_code ~= wms_base.Get_sConst( strLuaDEID,"料箱库理货区1" ) and loc.area_code ~= wms_base.Get_sConst( strLuaDEID,"料箱库理货区2" )) then
            mobox.setInfo( strLuaDEID, "容器'"..cntr_code.."'目前所在区域为'"..loc.area_code.."'不能进行入库操作!, 建议清除该料箱的绑定记录!")
            return             
        end
    end
 
    -- 获取站点货位,站点货位定义在常量中
    loc_code = jx_base.Get_Station_Loc( strLuaDEID, station )
    nRet, loc = wms_wh.GetLocInfo( loc_code )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '获取货位信息失败! '..loc_code ) end  
 
    -- 创建【巨星任务】
    local jx_task = m3.AllocObject(strLuaDEID,"JX_Task")
    jx_task.task_type = "入库"
    jx_task.b_state = 1                     -- 作业启动
    jx_task.station = station
    jx_task.start_wh_code = loc.wh_code
    jx_task.start_area_code = loc.area_code
    jx_task.start_loc_code = loc_code
    jx_task.cntr_code = cntr_code
    jx_task.operator_name = strUserName
    jx_task.operator = strUserLogin
    jx_task.create_method = "JX-WMS"
    nRet, jx_task = m3.CreateDataObj( strLuaDEID, jx_task )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '创建【巨星任务】失败!'..jx_task ) end 
 
    -- 巨星料箱 的空满状态设置为 2/满
    local strUpdateSql = "N_EMPTY_FULL = 2"
    local strCondition = "S_CODE = '"..cntr_code.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Container", strCondition, strUpdateSql )
    if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【容器】状态息失败!"..strRetInfo ) end  
    
    local operation
    local ext_info = {}
    
    ext_info.bs_type = "巨星任务"
    ext_info.bs_no = jx_task.sour_no
    nRet, operation = jx_base.Create_StorageOperation( strLuaDEID, "巨星", station, cntr_code, "巨星入库", ext_info )
    if ( nRet ~= 0 ) then
        mobox.setInfo( strLuaDEID, operation )
        return
    end   
 
    strUpdateSql = "S_OP_CODE = '"..operation.code.."'"
    strCondition = "S_SOURNO = '"..jx_task.sour_no.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql )
    if ( nRet ~= 0 ) then  
        lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】信息失败!"..strRetInfo ) 
    end   
    mobox.setInfo( strLuaDEID, "系统已经成功创建了一个巨星如库作业'"..operation.code.."'")         
    local action = 
    {
        {
            action_type = "refresh",
            value = ""   
        }
    }
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action)  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end 
 
    -- 【注意】如果上面的程序有入库作业产生需要对入库作业的终点获取加入库锁
    nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, operation.end_loc_code, wms_base.Get_nConst( strLuaDEID, "锁类型-入库锁" ),
                                            "", operation.code, operation.op_def_name )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_LockLocation 失败!"..strRetInfo ) end     
 
end