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-34
  Tðy: \ON/T¨R
 \O€: LZH
 eQãSýQpeÿOperationStart
 ŸRý€ô‹f:
    Rú^NµkýVêûN¡R,ÎN\ONw¹p0RËz“^v^Œ(uýVꁄvûN¡R NÑS¥cãS
 ØSôf†SòS:
    V1.1 LZH 20241223 S_Ùz¹p:Næ]§O zz}wQ/JS™eÞV“^ãS öe,È~¹pêSý€eQ506÷]S
 --]]
require("WMS-BASE")
wms_op = require("wms_operation")
wms_wh = require("wms_wh")
wms_task = require("wms_task")
require("GT_InAndOutboundPolicies")
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
 
    -- ã‰g\ON-N„vibU\ÂSpe
    local ext_data, success
    success, ext_data = pcall(json.decode, operation.ext_data)
    if (success == false) then
        lua.Error(strLuaDEID, debug.getinfo(1), "operation_obj.ext_data -N…Q¹[JSON<h_ NTÕl!")
    end
    local rowday = ext_data.roadway_inventory
    lua.Debug(strLuaDEID, debug.getinfo(1), 'ö€™eeQ“^\ONibU\ÂSpe!', ext_data)
 
    -- ¡‹—{ÞV“^ãSÈ~¹p,‚YœgÞV“^ãS¡l    gïSeQ“^'MORۏeQI{…_¶r`
    local loc_code
    -- V1.1 LZH S_Ùz¹p:Næ]§O zz}wQ/JS™eÞV“^ãS ŒT    N|iÞV“^ãSöe,È~¹pêSý€eQ3\4÷]S
    if (operation.start_loc_code == wms_base.Get_sConst(strLuaDEID, "KL_ReturnRgvStation1") or
            operation.start_loc_code == wms_base.Get_sConst(strLuaDEID, "F3L_InWeight1") or
            operation.start_loc_code == wms_base.Get_sConst(strLuaDEID, "F3R_InWeight1")) then
        local roadway_list = lua.split(rowday, ",")
        local str = ''          -- (uegüb¥c÷]Sågâ‹agöNW[&{2N
        for i = 1, #roadway_list do
            if (roadway_list[i] == '3' or roadway_list[i] == '4') then
                str = str .. roadway_list[i] .. ","
            end
        end
        if(str == '') then lua.Error(strLuaDEID, debug.getinfo(1), "¡l    gïSeQ“^÷]S!") end
        -- »Sd–gTN*N,
        str = lua.trim_laster_char(str)
        -- ïS(u÷]SÌ‘b—êSý€eQ304÷]S
        nRet, loc_code = Empty_StorageTactics(strLuaDEID, operation.cntr_code, str)
        lua.Debug(strLuaDEID, debug.getinfo(1), 'loc_code', loc_code)
    else
        nRet, loc_code = Empty_StorageTactics(strLuaDEID, operation.cntr_code, rowday)
        lua.Debug(strLuaDEID, debug.getinfo(1), 'loc_code', loc_code)
    end
 
    lua.Debug(strLuaDEID, debug.getinfo(1), 'loc_code', loc_code)
 
    if (nRet ~= 0) then
        local msg
        msg = "\ONx:N=" .. operation.code .. " Rú^ûN¡R1Y%, ·ƒÖSÈ~¹p1Y%!" .. loc_code
        lua.Warning(strLuaDEID, debug.getinfo(1), msg)
        lua.Wait(strLuaDEID, msg)
        return
    end
 
    local loc_end
    nRet, loc_end = wms_wh.Location_GetInfo(strLuaDEID, 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
 
    local strHeader = 'TA' .. os.date("%y%m%d") .. '-'
    local strCode
    nRet, strCode = mobox.getSerialNumber("ûN¡R", strHeader, 5)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), '3u÷‹0ûN¡R0x1Y%!' .. strCode) end
 
    -- Rú^ ýVꁠ,dЏûN¡R
    local task = m3.AllocObject(strLuaDEID, "Task")
    task.code = strCode               -- ûN¡Rx
    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-Ëz“^eQ“^,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-ýVê") -- ¾‹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
    -- È~¹p R•Íd\O(w¹p:NÙz¹p    gWCS¡{§c)
    nRet, strRetInfo = wms.wms_LockLocation(strLuaDEID, task.end_loc_code, wms_base.Get_nConst(strLuaDEID, "•{|‹W-eQ“^•"),
        task.code,
        task.op_code, task.op_name)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1),
            "wms_LockLocation 1Y%! 'MO='" .. task.end_loc_code .. "'  " .. strRetInfo)
    end
 
    -- úQ“^ Ncš[wQSOÈ~¹p,    gWCSÍSˆ™È~¹p,·ƒÖSúQ“^ãS“^:SÑ~š[„vWCSÙz¹p
    local condition = "S_VALUE = '" .. task.start_loc_code .. "' AND S_NOTE LIKE '%eQ“^ÙzðS%'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "WMS_Const", condition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS08^ϑ0áOo`1Y%! " .. strRetInfo) end
    local loc_code_zd = strRetInfo.name
 
    --  NÑSûN¡RÙ~ýVê
    local data = {}
    local strGUID = lua.guid()
    data.req_no = strGUID
    data.task_type = 3
    data.task_no = task.code
    data.tunnel_no = loc_end.roadway
    data.from_pos = loc_code_zd
    data.to_pos = task.end_loc_code
    data.mat_code = task.cntr_code
    data.req_time = os.date("%Y-%m-%d %H:%M:%S")
    data.mat_size = 1  -- zzXbԏÞV1
    lua.Debug(strLuaDEID, debug.getinfo(1), 'data', data)
 
    -- Œ(uýVꁄvûN¡R NÑS¥cãS
    local url = wms_base.Get_sConst(strLuaDEID, "WCS-url")
    local strurl = url .. "/create"
    local strHeader = ""
    local strBody = {}
    strBody[1] = data
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strBody', strBody)
    nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, strBody, "WCS", "ûN¡RRú^")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Œ(uWCS¥cãS1Y%!" .. strRetInfo)
    end
 
    -- ¾‹n¶r`*g¨c
    wms_task.SetStateByCode(strLuaDEID, task.code, "ûN¡R¶r`-ò]¨c")
end