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
--[[
    编码: GK-40-25
    名称: 移库作业-任务完成
    作者:HAN  
    日期:2025-1-29
 
    版本: V1.0
 
    场景:作业中的任务完成后触发这个脚本
          当前数据对象指针是 【作业】Operation
          【任务】对象属性保存在输入参数 InputParamter 
 
       
    函数: TaskFinish
 
    功能:
    
    更改记录:
 
--]]
wms_op = require( "wms_operation" )
 
function TaskFinish ( strLuaDEID ) 
    local nRet, strRetInfo
    local strErr = ''
 
    -- 获取 触发【作业】任务完成事件的场景参数
    local task
    nRet, task = m3.SysInputParamToDataObj( strLuaDEID, "Task")
    if (nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, debug.getinfo(1), task )
        return
    end 
    
    local operation
    nRet, operation = m3.GetSysCurEditDataObj( strLuaDEID, "Operation" )
    if (nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, operation ) 
        return
    end 
 
    -- 判断任务类型
    if ( task.type == TASK_TYPE.Move_Picking ) then
        local strUpdateSql, strCondition
 
        nRet, strRetInfo = wms_op.SetFinish( strLuaDEID, operation )
        if ( nRet ~= 0 ) then
            lua.Stop( strLuaDEID, "设置作业编号='"..operation.code.."' 的作业完成失败!"..strRetInfo )
            return
        end
 
        -- 更新作业的 end_loc / Pickin车的位置是由 AGV确定的
        strUpdateSql = "S_END_WH = '"..task.end_wh_code.."', S_END_AREA = '"..task.end_area_code.."', S_END_LOC = '"..task.end_loc_code.."'"
        strCondition = "S_CODE = '"..task.op_code.."'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Operation", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  
            lua.Stop( strLuaDEID, "更新【作业】信息失败!"..strRetInfo ) 
            return
        end  
  
    else
        lua.Stop( strLuaDEID, "任务编号='"..task.code.."' 的任务类型不对!" )
        return
    end
end