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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
ÿþ--[[
 x: GT-100-14
  Tðy: AGVûN¡RÞV¥b
 \O€: LZH
 eQãSýQpeÿTaskStatus
 ŸRý€ô‹f: ¥c6eAGV„vûN¡RԏÞV¶r`
    “eQpencÿ                                                                                        
    {
    "taskNum": "ûN¡R÷S",
    "taskStatus": ¢‹US¶r`ÿ1 _ËYgbLˆ ÿ2 ûN¡RŒ[b  ÿ3 _ËYÖS' ÿ4 ÖS'Œ[b ÿ5 _ËY>e' ÿ6 >e'Œ[b ,7 ûN¡RÖSˆm ÿ8 :_6RŒ[b
    }
 
    Yt;‘
    -- step1 ã‰g¥cãS O„v datajson ÂSpe
    -- step2 !hŒšÅ_ OW[µk/f&T:Nzz ÿ:NzzR¥b•
    -- step3 ÍSˆ™{|‹W 2 ¾‹nûN¡RŒ[b 4 ¹[hV'ÁTã‰Ñ~ 6 ¹[hV'ÁTÑ~š[
 ØSôf†SòS:
    V1.1 LZH 20250506 Ëz“^úQ“^ŒT‰|™eúQ“^AGVÖS'Œ[bKNTôv¥cÞV OGTWMS
 --]]
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
wms_task = require("wms_task")
function AGVTaskStatus(strLuaDEID)
    local nRet, in_date, strRetInfo
    -- step1 ·ƒÖS¥cãSpenc
    nRet, in_date = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback àeÕl·ƒÖSpencS!" .. in_date) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'AGVûN¡RÞV¥bÂSpe:', in_date)
 
    -- step2 $R­e Å_kXy˜ /f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local task_no = in_date.taskNum
    if (task_no == nil or task_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡R÷S Ný€:Nzz!") end
    local feed_type = tonumber(in_date.taskStatus)
    if (feed_type == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "ÍSˆ™{|‹W Ný€:Nzz!") end
 
    -- ·ƒÖSûN¡RáOo`
    local task, operation
    nRet, task = wms_task.GetInfo(strLuaDEID, task_no)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), task) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'task:', task)
    -- ·ƒÖS\ONáOo`
    local condition = "S_CODE = '" .. task.op_code .. "'"
    nRet, operation = m3.GetDataObjByCondition(strLuaDEID, "Operation", condition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), operation) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'operation:', operation)
 
    -- ÍSˆ™{|‹W 2 ¾‹nûN¡RŒ[b 4 ¹[hV'ÁTã‰Ñ~ 6 ¹[hV'ÁTÑ~š[
    if (feed_type == 2) then
        lua.Debug(strLuaDEID, debug.getinfo(1), '111:', 1111)
        -- ¾‹nûN¡RŒ[b
        nRet, strRetInfo = wms.wms_TaskFinish(strLuaDEID, task_no)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡Rx='" .. task_no .. "'„vûN¡R¾‹nŒ[b1Y%!") end
        lua.Debug(strLuaDEID, debug.getinfo(1), '222:', 222)
        -- žX R ûN¡R¨R\O ù[aŒ
        local task_action = m3.AllocObject(strLuaDEID, "Task_Action")
        task_action.task_code = task_no
        task_action.action_code = 2
        task_action.action = "AGV,dЏŒ[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%!') end
        lua.Debug(strLuaDEID, debug.getinfo(1), '333:', 333)
    elseif (feed_type == 4) then
        -- V1.1 LZH 20250506 Ëz“^úQ“^ŒT‰|™eúQ“^AGVÖS'Œ[bKNTôv¥cÞV OGTWMS
        -- Ëz“^úQ“^„vŒNµkAGVûN¡R/fXbØv»y_'MORcbd–“^X[
        if (task.op_name == 'Ëz“^úQ“^' or task.op_name == '‰|™eúQ“^') then
            if (task.op_name == '‰|™eúQ“^') then
                nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, task.start_loc_code, operation.cntr_code,
                    "Ñ~š[ã‰Ñ~¹eÕl-û|ß~",
                    "Œ[b")
                if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
            end
            -- ·ƒÖSibU\pencÂSpe
            local ext_data    = json.decode(operation.ext_data)
            local delivery_no = ext_data.delivery_no -- N¡RUS÷S:N úQ“^US÷S
            --·ƒÖSúQ“^USáOo`
            local stock_out
            condition         = "S_DO_NO = '" .. delivery_no .. "'"
            nRet, stock_out   = m3.GetDataObjByCondition(strLuaDEID, "GT_Stock_Out", condition)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), stock_out) end
            -- ·ƒÖS¹[hV'ÁTfÆ~
            local cg_detail
            condition       = "S_CNTR_CODE = '" .. operation.cntr_code .. "'"
            nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", condition)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), cg_detail) end
            
            -- local label_crad
            -- if(tonumber(cg_detail) == 1)then
            -- end
            -- -- ·ƒÖSeQ“^USncLˆáOo`
            -- local strCondition = "S_SERIAL_NO = '" .. cg_detail.serial_no .. "'"
            -- nRet, label_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition, "T_CREATE DESC")
            -- if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1),"·ƒÖSAm4l÷SáOo`1Y%!" .. label_crad) end
            -- -- ·ƒÖSeQ“^USnc4YáOo`
            -- local incoming_Info
            -- condition = "S_DELIVERY_NO = '" ..
            -- label_crad.delivery_no .. "' AND N_DELIVERY_ROW_NO = '" .. label_crad.delivery_row_no .. "'"
            -- nRet, incoming_Info = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", condition, "T_CREATE DESC")
            -- if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSeQ“^USnc4YáOo`1Y%!" .. incoming_Info) end
 
            -- if (stock_out.type == 'ºNå]U_eQ') then
            --     -- Rú^0GTWMS Tek°‹U_0
            --     local sys_record = m3.AllocObject(strLuaDEID, "GTWMS_SYNC_RECORD")
            --     sys_record.delivery_no = incoming_Info.delivery_no
            --     sys_record.delivery_row_no = incoming_Info.delivery_row_no
            --     sys_record.task_no = delivery_no
            --     sys_record.lpn = cg_detail.serial_no
            --     sys_record.rfid = operation.cntr_code
            --     sys_record.lpnweight = cg_detail.qty
            --     sys_record.sku = cg_detail.item_code
            --     sys_record.batch_no = cg_detail.batch_no
            --     sys_record.grade = incoming_Info.level
            --     sys_record.type = "úQ“^ÞV O"
            --     lua.Debug(strLuaDEID, debug.getinfo(1), 'sys_record', sys_record)
            --     nRet, sys_record = m3.CreateDataObj(strLuaDEID, sys_record)
            --     if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0GTWMS Tek°‹U_0ù[aŒ1Y%!' .. sys_record) end
            -- else
                -- úQ“^Ó~œgÞV O
                local data
                local source = "GTWMSúQ“^ÞV O"
                nRet, data   = StorageResult(strLuaDEID, operation.code, source)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), "úQ“^Ó~œgÞV O1Y%!" .. data)
                end
                lua.Debug(strLuaDEID, debug.getinfo(1), 'data', data)
 
                -- Œ(uGT-WMS„vÞV O¥cãS
                local url = wms_base.Get_sConst(strLuaDEID, "GTWMS-url")
                local strurl = url
                local strHeader = ""
                local strBody = {
                    application = "GITI",
                    code = "WCS_SO_WMS",
                    data = data
                }
                nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, strBody, "GTWMS", source)
                if (nRet ~= 0) then
                    lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¥cãS1Y%!" .. strRetInfo)
                end
            -- end
        end
    elseif (feed_type == 6) then
        if (task.op_name == '‰|™eeQ“^') then
            nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, operation.cntr_code,
                "Ñ~š[ã‰Ñ~¹eÕl-û|ß~", "Œ[b")
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
        elseif(task.op_name == '™eeQ“^')then
            if(task.end_area_code == 'HWPFL' or task.end_area_code == 'PFL' or task.end_area_code == 'HWTFL' or task.end_area_code == 'TFL')then
                nRet, strRetInfo = wms_wh.Loc_Container_Binding(strLuaDEID, task.end_loc_code, operation.cntr_code,
                    "Ñ~š[ã‰Ñ~¹eÕl-û|ß~", "Œ[b")
                if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
            end
        end
    elseif (feed_type == 7) then
        if (task.op_name == 'AGVzzXbÞV“^') then
            -- Ù~ÖSˆm„vûN¡R㉕
            nRet, strRetInfo = wms.wms_UnlockByTask(strLuaDEID, task_no)
            if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_UnlockByTask 1Y%! " .. strRetInfo) end
            -- ¾‹nûN¡R¶r`:NÖSˆm
            local condition = "S_CODE = '" .. task_no .. "'"
            local strSetAttr = "N_B_STATE = " .. wms_base.Get_nConst(strLuaDEID, "ûN¡R¶r`-ÖSˆm") .. ", S_B_STATE = 'ÖSˆm'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Task", condition, strSetAttr)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "¾‹nûN¡R¶r`1Y%!" .. strRetInfo)
            end
            -- ¾‹n\ON¶r`:NÖSˆm
            local condition = "S_CODE = '" .. task.op_code .. "'"
            strSetAttr = "N_B_STATE = " .. wms_base.Get_nConst(strLuaDEID, "\ON¶r`-ÖSˆm") .. ", S_B_STATE = 'ÖSˆm'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "Operation", condition, strSetAttr)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "¾‹n\ON¶r`1Y%!" .. strRetInfo)
            end
            --  Rd–¹[hV'ÁTfÆ~
            nRet, strRetInfo = mobox.deleteDataObject(strLuaDEID, "CG_Detail", "S_CNTR_CODE = '" .. operation.cntr_code .. "'")
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1)," Rd–¹[hV'ÁTfÆ~1Y%!" .. strRetInfo)
            end
        end
    end
end