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
ÿþ--[[
 x: GT-40-46
  Tðy: \ON/T¨R
 \O€: LZH
 eQãSýQpeÿOperationStart
 ŸRý€ô‹f:
    Rú^NµkAGVûN¡R,ÎN\ONw¹p0RÞV“^¥csšMOv^Œ(uAGV„vûN¡R NÑS¥cãS
 ØSôf†SòS:
 --]]
require("WMS-BASE")
wms_op = require("wms_operation")
wms_wh = require("wms_wh")
wms_task = require("wms_task")
require("GT-Base")
function OperationStart(strLuaDEID)
    local nRet, strRetInfo
    -- ·ƒÖS\ONù[aŒ, ÎN\ONù[aŒ-N·ƒÖS{ibU\penc}, ÎN{ibU\penc}·ƒÖS¿~SO¾‹Yx
    local operation
    nRet, operation = m3.GetSysCurEditDataObj(strLuaDEID, "Operation")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS\ONù[aŒ^\'`1Y%!" .. operation)
    end
 
    -- ·ƒÖSw¹páOo`
    local loc_start
    nRet, loc_start = wms_wh.Location_GetInfo(strLuaDEID, operation.start_loc_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WMS_Location_GetInfo1Y%! " .. loc_start) end
 
    -- ·ƒÖSw¹p“^:SáOo`
    local area
    local strCondition = "S_CODE = '" .. loc_start.area_code .. "'"
    nRet, area = m3.GetDataObjByCondition(strLuaDEID, "Area", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. area) end
 
    -- Ç|iB\ + “^:SMOn ¡‹—{AGV„vÈ~¹p:NêT*NÞV“^ãS“^:S
    -- “^:S„vYèl:N JS¢”/hQ¢”
    strCondition = "N_FLOOR = '" .. area.floor .. "' AND S_NAME LIKE '%" .. area.note .. "ÞV“^ãS%'"
    nRet, area = m3.GetDataObjByCondition(strLuaDEID, "Area", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. area) end
 
    -- ·ƒÖSÈ~¹p¥csšMO
    local end_loc_list
    local end_loc_code = ''
    strCondition = "N_LOCK_STATE = 0 AND S_AREA_CODE = '" .. area.code .. "'"
    nRet, end_loc_list = m3.QueryDataObject(strLuaDEID, "Location", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'ågâ‹'MO1Y%!' .. end_loc_list) end
    for i = 1, #end_loc_list do
        local attrs = end_loc_list[i].attrs
        attrs = m3.KeyValueAttrsToObjAttr(attrs)
        if (attrs == nil) then goto coroutine end
        end_loc_code = attrs.S_CODE
        ::coroutine::
    end
 
    if (end_loc_code == '') then
        local msg
        msg = "\ONx:N=" .. operation.code .. " Rú^ûN¡R1Y%, ¡l    gïS(u¥csšMO!"
        lua.Warning(strLuaDEID, debug.getinfo(1), msg)
        lua.Wait(strLuaDEID, msg)
        return
    end
 
    -- ·ƒÖSÈ~¹p¥csšMO
    local loc_end
    nRet, loc_end = wms_wh.Location_GetInfo(strLuaDEID, end_loc_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WMS_Location_GetInfo1Y%! " .. loc_end) end
 
    -- ôf°e\ONÈ~¹p'MOáOo`
    nRet, strRetInfo = wms_op.SetEndLoc(strLuaDEID, operation.code, loc_end.code, loc_end.area_code,
        loc_end.wh_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "ôf°e\ONÈ~¹p1Y%! " .. strRetInfo) end
 
    -- Rú^ AGV ,dЏûN¡R
    local task = m3.AllocObject(strLuaDEID, "Task")
    task.op_code = operation.code    -- \ONx
    task.op_name = operation.op_def_name
    task.factory = operation.factory -- å]‚S
    task.type = wms_base.Get_nConst(strLuaDEID, "ûN¡R{|‹W-AGVeQ“^,dЏ")
    task.cntr_code = operation.cntr_code
    -- w¹p
    task.start_wh_code = operation.start_wh_code
    task.start_area_code = operation.start_area_code
    task.start_loc_code = operation.start_loc_code
    -- È~¹p
    task.end_wh_code = loc_end.wh_code
    task.end_area_code = loc_end.area_code
    task.end_loc_code = loc_end.code
    task.schedule_type = wms_base.Get_nConst(strLuaDEID, "Œ¦^{|‹W-AGV") -- ¾‹nŒ¦^{|‹W
    task.roadway = loc_end.roadway
    nRet, task = m3.CreateDataObj(strLuaDEID, task)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Rú^AGVeQ“^ûN¡R1Y%!" .. task)
    end
 
    -- ‚Yœg/fŒN|iÞV“^ãS„v݋ ÿ—‰Ù~ÞV“^ãS'MO
N• ÿ(WýVêÔÞV >e'Œ[bAQ¸‹»y_ ¶r`öe㉕'MO
    if (tonumber(area.floor) == 2) then
        nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, loc_end.code,
            wms_base.Get_nConst(strLuaDEID, "•{|‹W-eQ“^•"),
            operation.cntr_code, operation.cntr_code, operation.op_def_name)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "wms_LockLocation 1Y%!" .. strRetInfo) end
    end
 
    -- ¾‹n¶r`*g¨c
    wms_task.SetStateByCode(strLuaDEID, task.code, "ûN¡R¶r`-ò]¨c")
 
    local data = {
        taskData = {
            taskNum = task.code,
            pickStation = task.start_loc_code,
            dropStation = task.end_loc_code,
            taskType = 2,
            carrierType = 1,
            priority = 1,
            wmsTaskNo = "",                 -- úQ“^MbÙ~
            level = "",                     -- eQ“^I{§~/f؞¤‹„v
            produceTime = "",
            tyreType = "",
            supplier = "",
            receiveLot = "",
            subpool = "",
            source = "YCL"
        },
        partData = {
            rfid = task.cntr_code,
            lotNumber = nil,
            partNumber = "KT",
            partDesc = "zzXb",
            partType = nil,
            weight = nil,
            unit = nil,
            maturityTime = nil,
            productionTime = nil,
            stewingTime = nil,
            overdueTime = nil
        }
    }
 
    local url = wms_base.Get_sConst(strLuaDEID, "AGV-url")
    local strurl = url .. "/CreateTask"
    local strBody = data
    local strHeader = ""
    nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, strBody, "AGV", "ûN¡RRú^")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¥cãS1Y%!" .. strRetInfo)
    end
end