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
ÿþ--[[
 x: GT-40-37
  Tðy: ûN¡RŒ[b
 \O€:
 eQãSýQpeÿTaskFinish
 ŸRý€ô‹f:
    -- $R­e/f‰|™e“^؏/fö€™e“^
    -- ö€™e“^ôv¥c¾‹n\ONŒ[b ÿ‰|™e“^žX R“^X[v^îO9e™eUS¶r`:NŒ[bŒT¾‹n\ONŒ[b
 ØSôf†SòS:
 --]]
require("WMS-BASE")
wms_op = require("wms_operation")
wms_cntr = require("wms_container")
require("GT_InAndOutboundPolicies")
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.end_area_code == 'HWPFL' or task.end_area_code == 'PFL' or task.end_area_code == 'HWTFL' or task.end_area_code == 'TFL') then
        -- ¾‹n\ONŒ[b
        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
 
        -- ·ƒÖS¹[hV'ÁTfÆ~
        local cg_detail
        local strCondition = "S_CNTR_CODE = '" .. operation.cntr_code .. "'"
        nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. cg_detail) end
        -- Í‘n“^:S“^X[
        nRet,strRetInfo = wms.wms_ResetInventory("Area", task.end_area_code)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo)
        end
        -- ·ƒÖSeQ“^USncLˆáOo`
        -- local label_crad
        -- strCondition = "S_SERIAL_NO = '" .. cg_detail.serial_no .. "'"
        -- if (tonumber(cg_detail.is_tl) == 1) then
        --     nRet, label_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_ROM", strCondition, "T_CREATE DESC")
        --     if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSAm4l÷SáOo`1Y%!" .. label_crad) end
        -- else
        --     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
        -- end
 
        -- -- ·ƒÖSeQ“^USnc4YáOo`
        -- local incoming_Info
        -- strCondition = "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", strCondition, "T_CREATE DESC")
        -- if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSeQ“^USnc4YáOo`1Y%!") end
 
        -- ‚YœgeQ“^US/fKbå]U_eQ„vR
        -- if (incoming_Info.type == 'Kbå]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.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.remark3 = cg_detail.serial_no
        --     sys_record.type = "eQ“^Þ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
        -- eQ“^Ó~œgÞV O
        local data
        local source = "GTWMSeQ“^ÞV O"
        nRet, data = StorageResult(strLuaDEID, operation.code, source)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), "eQ“^Ó~œgÞV O1Y%!" .. data)
        end
        data.loc = "LK001"
        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_ASN_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
 
        -- ‚Yœg/f™eUSRîO9e™eUS¶r`:NŒ[b
        if (tonumber(cg_detail.is_tl) == 1) then
            local condition = "S_CNTR_CODE = '" .. operation.cntr_code .. "'"
            local strSetAttr = "S_STATE = 'Œ[b'"
            nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_ROM", condition, strSetAttr)
            if (nRet ~= 0) then
                lua.Error(strLuaDEID, debug.getinfo(1), "¾‹n¶r`1Y%!" .. strRetInfo)
            end
        end
    else
        -- ¾‹n\ONŒ[b
        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