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
ÿþ--[[
 x: GT-100-23
  Tðy: NotifyDeviceSignal
 \O€: LZH
 eQãSýQpeÿNotifyDeviceSignal
 ŸRý€ô‹f: 004-¾‹YáO÷SÍSˆ™,S_WCS_8^öeŒ(u ÿ NÑSNµkagvûN¡RÉb0R_8^:S
 ØSôf†SòS:
 --]]
wms_task = require("wms_task")
require("WMS-Equipment")
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
require("GT_InAndOutboundPolicies")
function notifyDeviceSignal(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), "àeÕl·ƒÖSpencS!" .. in_date) end
    lua.Debug(strLuaDEID, debug.getinfo(1), '004-¾‹YáO÷SÍSˆ™ÂSpe:', in_date)
 
    -- step2 $R­e Å_kXy˜ /f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local loc_code = in_date.loc    -- 'MO
    local cntr_code = in_date.cntr_code  -- ¹[hV
    -- local extData = in_date.extData
    -- if (type(extData) ~= 'table') then
    --     lua.Error(strLuaDEID, debug.getinfo(1), "ibU\ÂSpe N/fRhˆ!")
    -- end
    local signalType = lua.StrToNumber(in_date.signalType)  -- 1: N¿~÷‹Bl ÿ2ÿëS™e÷‹Bl 3ÿû‹x÷‹Bl ÿ4: N¿~°‹U_ ÿ5ÿ_8^3u÷‹ÿúVš[ O3    ÿ
    if (loc_code == nil or loc_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "Ùz¹p Ný€:Nzz!") end
    if (cntr_code == nil or cntr_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "FRID Ný€:Nzz!") end
    if (signalType == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "{|‹W Ný€:Nzz!") end
    local flag = lua.StrToNumber(in_date.extData)  -- ibU\ÂSpe  0ck8^ 1_8^
    if (flag == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "ibU\ÂSpe Ný€:Nzz!") end
 
    if (signalType ~= 3) then
        lua.Error(strLuaDEID, debug.getinfo(1), signalType .. "*g/T(u„v÷‹Bl{|‹W!")
    end
    
 
    -- $R­eWCSÍSˆ™ck8^؏/f_8^
    if (tonumber(flag) == 1) then
        lua.Debug(strLuaDEID, debug.getinfo(1), '222:', 222)
        -- ûN¡R_8^R NÑSagvûN¡RÉb0R_8^:S
        local strCode
        local strHeader = 'TA' .. os.date("%y%m%d") .. '-'
        nRet, strCode = mobox.getSerialNumber("ûN¡R", strHeader, 5)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '3u÷‹0ûN¡R0x1Y%!' .. strCode) end
        -- ·ƒÖSÙzðSw¹p
        loc_code = wms_base.Get_sConst(strLuaDEID, loc_code)
        local start_loc
        nRet, start_loc = wms_wh.GetLocInfo(loc_code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo1Y%!' .. start_loc) end
 
        -- 9hncw¹pÙzðS·ƒÖSù[”^„v_8^“^:S
        -- _8^“^:S TWO-BGYCKQ,TWO-QGYCKQ,THREE-BGYCKQ,THREE-QGYCKQ
        local area_info
        local strCondition = "S_CODE = '"..start_loc.area_code.."'"
        nRet, area_info = m3.GetDataObjByCondition(strLuaDEID, "Area", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS“^:SáOo`1Y%!" .. area_info) end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'area_info:', area_info)
 
        local yc_area = ''
        if(tonumber(area_info.floor) == 2)then
            lua.Debug(strLuaDEID, debug.getinfo(1), "333!",3333)
            if(area_info.note == 'JS¢”')then
                yc_area = "BGYCQ"
            elseif(area_info.note == 'hQ¢”')then
                yc_area = "QGYCQ"
            else
                lua.Error(strLuaDEID, debug.getinfo(1), "*gš[INå‹Ùz¹p„v“^:SÏcð/f^\ŽNJS¢”؏/fhQ¢”!")
            end
        elseif(tonumber(area_info.floor) == 3)then
            if(area_info.note == 'JS¢”')then
                yc_area = "THREE-BGYCQ"
            elseif(area_info.note == 'hQ¢”')then
                yc_area = "THREE-QGYCQ"
            else
                lua.Error(strLuaDEID, debug.getinfo(1), "*gš[INå‹Ùz¹p„v“^:SÏcð/f^\ŽNJS¢”؏/fhQ¢”!")
            end
        else
            lua.Error(strLuaDEID, debug.getinfo(1),"å‹|iB\*gš[IN_8^“^:S!")
        end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'yc_area:', yc_area)
 
        -- ·ƒÖS_8^:SÈ~¹p
        local end_loc
        nRet, end_loc = wms_base.GetAreaAvaliableLoc(strLuaDEID, yc_area)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_base.GetAreaAvaliableLoc 1Y%! " .. end_loc) end
        nRet, end_loc = wms_wh.GetLocInfo(end_loc.loc_code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo1Y%!' .. end_loc) end
        lua.Debug(strLuaDEID, debug.getinfo(1), 'end_loc:', end_loc)
        -- Rú^\ON
        local operation           = m3.AllocObject(strLuaDEID, "Operation")
        operation.start_wh_code   = start_loc.wh_code
        operation.start_area_code = start_loc.area_code
        operation.start_loc_code  = start_loc.code
 
        -- È~¹páOo`
        operation.end_wh_code     = end_loc.wh_code
        operation.end_area_code   = end_loc.area_code
        operation.end_loc_code    = end_loc.code
 
        operation.op_type         = wms_base.Get_nConst(strLuaDEID, "\ON{|‹W-eQ“^")
        local ext_table           = {
            task_no = strCode
        }
        operation.op_def_name     = "AGV“^…Q,dЏ"
        operation.cntr_code       = cntr_code
        operation.ext_data        = lua.table2str(ext_table)
 
        nRet, operation           = m3.CreateDataObj(strLuaDEID, operation)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0\ON01Y%!' .. operation) end
        lua.Debug(strLuaDEID, debug.getinfo(1), "\ONRú^TáOo`", operation)
    elseif(tonumber(flag) == 0)then
        
        -- ·ƒÖSÙzðSw¹p
        loc_code = wms_base.Get_sConst(strLuaDEID, loc_code)
        -- ã‰•'MO
        nRet, strRetInfo = wms.wms_UnlockByTask(strLuaDEID,cntr_code)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_UnlockLocation 1Y%! " .. strRetInfo) end
    end
end