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
ÿþ--[[
    x: GT-40-37
     Tðy: \ON-Ëz“^eQ“^-ûN¡RŒ[b
    \O€ÿLZH
    åegÿ2024-12-24
    Hr,g: V1.0
    :Wofÿ\ON-N„vûN¡RŒ[bTæ‰ÑSُ*N,g
    ýQpeÿ TaskFinish
    ŸRý€:
        -- Ëz“^,dЏeQ“^ûN¡RŒ[bsSïS¤‹:N\ONŒ[b
 
    ôf9e°‹U_ÿ
 
--]]
wms_op = require("wms_operation")
wms_cntr = require("wms_container")
require("GT_InAndOutboundPolicies")
wms_op = require("wms_operation")
function TaskFinish(strLuaDEID)
    local nRet, strRetInfo
 
    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
 
    -- ·ƒÖSub \ONöe ÿÝOX[(WÓbU\W[µk̑„v)Y6qö€W[µk
    local ext_data   = json.decode(operation.ext_data)
    local abnormal   = ext_data.abnormal
 
    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
 
    if (tonumber(cg_detail.is_fj) == 0) then
        -- Í‘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 .. "'"
        nRet, label_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition, "T_CREATE DESC")
        if (nRet == 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
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSeQ“^USncLˆáOo`1Y%!" .. label_crad)
        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
    else
        -- îO9e¹[hV'ÁTfÆ~„vhƋ:N YÀhúQ“^
        local condition = "S_CNTR_CODE = '" .. operation.cntr_code .. "'"
        local strSetSQL_update = "N_IS_FJ = 0"
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "CG_Detail", condition, strSetSQL_update)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9e¹[hV'ÁTfÆ~1Y%ÿ" .. 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
end