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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
ÿþ--[[
    x: WMS-38-05
     Tðy: ûN¡R-Lˆ    c®”-¾‹nûN¡RŒ[b
    \O€ÿHAN
    åegÿ2023-02-25
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ SetTaskFinish
 
    ŸRý€:
        :_6R¾‹nûN¡RŒ[b
 
    ôf9e°‹U_:
--]]
wms_task = require("wms_task")
wms_wh = require("wms_wh")
wms_cntr = require("wms_container")
function SetTaskFinish(strLuaDEID)
    local nRet, strRetInfo
 
    -- step1  ·ƒÖSS_MR¹p-N„vûN¡R
    nRet, objs = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), objs) end
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    local nCount = #objs
    if (nCount == 0) then return end
 
    local task = m3.KeyValueAttrsToObjAttr(objs[1].attrs)
 
    lua.Debug(strLuaDEID, debug.getinfo(1), 'task', task)
 
    -- ÀhågN N,g̑(u0R„vtask^\'`/f&T(Wdatajson-N ÿ¡l    g‰Ðc:yN N
    if (task.S_CODE == nil) then
        lua.Error(strLuaDEID, debug.getinfo(1), "(WûN¡R>f:yGrid-NÅ_{˜‰    gûN¡Rx^\'` S_CODE!")
    end
    if (task.S_CODE == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡Rx Ný€:Nzz!")
    end
 
    nRet, task = wms_task.GetInfo(strLuaDEID, task.S_CODE)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), task) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'task', task)
 
    -- 9hnc·ƒÖS0R„vûN¡R$R­e N T„v\ON Tðy
 
    if (tonumber(task.schedule_type) == wms_base.Get_nConst(strLuaDEID, "Œ¦^{|‹W-ýVê")) then
        if (task.op_name == 'Ëz“^úQ“^' or task.op_name == '|TëSzzXb' or task.op_name == 'Ǒ-'') then
            -- ¹[hV'MOã‰Ñ~
            nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, task.cntr_code,
                "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
        elseif (task.op_name == 'ûy“^') then
            -- ¹[hV'MOã‰Ñ~
            nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, task.cntr_code,
                "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
 
            -- ¹[hV'MOÑ~š[
            nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVÑ~š[1Y%!' .. strRetInfo) end
        else
            -- ¹[hV'MOÑ~š[
            nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVÑ~š[1Y%!' .. strRetInfo) end
        end
 
    elseif (tonumber(task.schedule_type) == wms_base.Get_nConst(strLuaDEID, "Œ¦^{|‹W-AGV")) then
        if (task.op_name == 'ûy“^') then
            -- ¹[hV'MOã‰Ñ~
            nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, task.cntr_code,
                "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
 
            -- ¹[hV'MOÑ~š[
            nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVÑ~š[1Y%!' .. strRetInfo) end
        end
        if (task.op_name == '‰|™eeQ“^') then
            nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, task.cntr_code, "Ñ~š[ã‰Ñ~¹eÕl-û|ß~", "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
        end
    end
 
    -- ¾‹nûN¡RŒ[b
    nRet, strRetInfo = wms.wms_TaskFinish(strLuaDEID, task.code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡Rx='" .. task.code .. "'„vûN¡R¾‹nŒ[b1Y%!" .. strRetInfo) end
 
    -- žX R ûN¡R¨R\O ù[aŒ
    local task_action = m3.AllocObject(strLuaDEID, "Task_Action")
    task_action.task_code = task.code
    task_action.action_code = 2
    task_action.action = ":_6RûN¡RŒ[b"
    task_action.eq_code = "system"
    task_action.eq_type_name = 'Œ[b'
    nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, task_action)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0ûN¡R¨R\O0ù[aŒ1Y%!' .. strRetInfo) end
end