lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
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
ÿþ--[[
   x: GT-40-58
    Tðy:
   \O€ÿ
   åegÿ2025-02-24
 
   ýQpeÿ TaskFinish
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
wms_op = require("wms_operation")
wms_wh = require("wms_wh")
wms_task = require("wms_task")
require("GT-Base")
function TaskFinish(strLuaDEID)
    local nRet, strRetInfo
 
    -- ·ƒÖSS_MR\ONù[aŒ
    local operation
    nRet, operation = m3.GetSysCurEditDataObj(strLuaDEID, "Operation")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), operation) end
 
    -- ·ƒÖSûN¡Rù[aŒ
    local task
    nRet, task = m3.SysInputParamToDataObj(strLuaDEID, "Task")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), task) end
 
    if (task.type == wms_base.Get_nConst(strLuaDEID, "ûN¡R{|‹W-Ëz“^úQ“^,dЏ")) then
        -- Rú^ AGV ,dЏûN¡R
        local new_task = m3.AllocObject(strLuaDEID, "Task")
        new_task.op_code = operation.code    -- \ONx
        new_task.op_name = operation.op_def_name
        new_task.factory = operation.factory -- å]‚S
        new_task.type = wms_base.Get_nConst(strLuaDEID, "ûN¡R{|‹W-AGVúQ“^,dЏ")
        new_task.cntr_code = operation.cntr_code
        -- w¹p
        new_task.start_wh_code = task.end_wh_code
        new_task.start_area_code = task.end_area_code
        new_task.start_loc_code = task.end_loc_code
        -- È~¹p
        new_task.end_wh_code = operation.end_wh_code
        new_task.end_area_code = operation.end_area_code
        new_task.end_loc_code = operation.end_loc_code
        new_task.schedule_type = wms_base.Get_nConst(strLuaDEID, "Œ¦^{|‹W-AGV") -- ¾‹nŒ¦^{|‹W
 
        lua.Debug(strLuaDEID, debug.getinfo(1), "ûN¡RRú^MRáOo`", new_task)
 
        nRet, new_task = m3.CreateDataObj(strLuaDEID, new_task)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "Rú^AGVeQ“^ûN¡R1Y%!" .. new_task)
        end
 
        -- Ç¹[hV·ƒÖSir™eáOo`
        local cg_detail_list, cg_detail
        nRet, cg_detail_list = wms_cntr.Get_Container_Goods(strLuaDEID, task.cntr_code)
        nRet, cg_detail = m3.ObjAttrStrToLuaObj("CG_Detail", lua.table2str(cg_detail_list[1].attrs))
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), cg_detail) end
        -- üb¥cpenc NÑSAGVûN¡R
        local data = {
            taskNum = new_task.code,
            pickStation = new_task.start_loc_code,
            dropStation = new_task.end_loc_code
        }
        --  NÑSûN¡RÙ~AGV
        local strurl = wms_base.Get_sConst(strLuaDEID, "AGV-url1")
        local strHeader = ""
        local strBody = data
        nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, strBody, "AGV", "¹pù[¹pûN¡RRú^")
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¥cãS1Y%!" .. strRetInfo)
        end
    else
        nRet, strRetInfo = wms_op.SetFinish( strLuaDEID, operation.code )
        if ( nRet ~= 0 ) then
            lua.Error( strLuaDEID, debug.getinfo(1), "¾‹n\ON÷S='"..operation.code.."' „v\ONŒ[b1Y%!"..strRetInfo )
        end
    end
end