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
ÿþ--[[
 x: GT-40-21
  Tðy: \ON/T¨R
 \O€:
 eQãSýQpeÿOperationStart
 ŸRý€ô‹f: ‰|™eeQ“^ ÿ\ON/T¨R,g̑Rú^NµkûN¡R“¿~ÎNå]MO0R3|iúQ“^ãS„v\ON
 ØSôf†SòS:
 --]]
wms_op = require("wms_operation")
wms_wh = require("wms_wh")
wms_task = require("wms_task")
require("GT-Base")
require("GT_InAndOutboundPolicies")
function OperationStart(strLuaDEID)
    local nRet, strRetInfo, strErr
    -- ·ƒÖ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
    lua.Debug(strLuaDEID, debug.getinfo(1), '‰|™eeQ“^operationÂSpe!', operation)
 
    -- ã‰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
    lua.Debug(strLuaDEID, debug.getinfo(1), 'ö€™eeQ“^\ONibU\ÂSpe!', ext_data)
 
    -- ågâ‹ir™e{|‹Wô~¤bhˆ·ƒÖSir™e@b^\{|‹W
    local strCondition
    local item_type = ext_data.item_type -- ir™e{|‹W
    if (item_type == nil or item_type == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™e{|‹W Ný€:Nzz!") end
 
    -- ÇÈ~¹p$R­e¥csšãS
    local loc_code
    if (operation.end_area_code == 'HWPFL' or operation.end_area_code == 'PFL') then
        loc_code = "THREE-BGCKK-QY"
    else
        loc_code = "THREE-QGCKK-QY"
    end
 
    -- ·ƒÖSÈ~¹páOo`
    local store_loc
    nRet, store_loc = wms_wh.GetLocInfo(loc_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'WMS_GetLocInfo1Y%!' .. store_loc) end
 
    -- V1.2 $R­eå‹÷]S„vûN¡R/f&T…Ç–<P ÿ‚Yœg…ÇR\\ON¾‹n:NI{…_¶r`v^\•ï‹áOo`¾‹n0Ru˜b—
    -- ·ƒÖSÐgÍyŒ¦^{|‹W„vûN¡Rpeϑ
    strCondition = "N_SCHEDULE_TYPE = 3 AND ( N_B_STATE = " .. wms_base.Get_nConst(strLuaDEID, "ûN¡R¶r`-ò]¨c")
    strCondition = strCondition ..
        " OR N_B_STATE = " .. wms_base.Get_nConst(strLuaDEID, "ûN¡R¶r`-gbLˆ") .. ") AND N_ROADWAY =" .. store_loc.roadway
    nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, "Task", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
    if (tonumber(strRetInfo) > tonumber(wms_base.Get_sConst(strLuaDEID, "Task-g'YûN¡Rpe"))) then
        local msg
        msg = "\ONx:N=" .. operation.code .. " Rú^ûN¡R1Y%, ÷]S" .. store_loc.roadway .. "„vûN¡Rpeϑò]…Ç8^ϑg'YûN¡Rpeÿ"
        lua.Warning(strLuaDEID, debug.getinfo(1), msg)
        lua.Wait(strLuaDEID, msg)
        return
    end
 
    -- N|i‰|™eeQ“^ïSåNO(u3,4,5,6÷]S„vX›W:g,ågâ‹ûN¡Rg\„v÷]SRM‘
    local condition = "N_ROADWAY IN (SELECT N_ROADWAY FROM TN_Roadway WHERE N_ROADWAY IN(" ..
        wms_base.Get_sConst(strLuaDEID, "sO-N|i‰|™eeQ“^ïSRM‘X›W:g") .. ") AND N_LOCK_STATE = 0)"
    local tunnel_no
    nRet, tunnel_no = LeastTaskRoadway(strLuaDEID, wms_base.Get_sConst(strLuaDEID, "sO-N|i‰|™eeQ“^ïSRM‘X›W:g"))
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSûN¡Rpeg\„v÷]S1Y%! " .. tunnel_no) end
 
 
    -- Rú^Nµk å]MO0R    N|iúQ“^ãS „v,dЏûN¡R
    -- NµkûN¡R N(u R•
    local task = m3.AllocObject(strLuaDEID, "Task")
    -- Rú^“:g,dЏûN¡R
    task.op_code = operation.code    -- \ONx
    task.op_name = "‰|™eeQ“^"
    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 = store_loc.wh_code
    task.end_area_code = store_loc.area_code
    task.end_loc_code = store_loc.code
    task.schedule_type = wms_base.Get_nConst(strLuaDEID, "Œ¦^{|‹W-ýVê") -- ¾‹nŒ¦^{|‹W
    task.roadway = tunnel_no -- ûm R÷]S
    nRet, task = m3.CreateDataObj(strLuaDEID, task)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0ûN¡R01Y%!' .. task) end
 
    lua.Debug(strLuaDEID, debug.getinfo(1), 'task', task)
 
    -- Ç¹[hV·ƒÖSir™eáOo`
    local cg_detail_list, cg_detail
    nRet, cg_detail_list = wms_cntr.Get_Container_Goods(strLuaDEID, task.cntr_code)
    nRet, cg_detail = m3.ObjAttrStrToLuaObj("CG_Detail", lua.table2str(cg_detail_list[1].attrs))
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), cg_detail) end
 
    -- ·ƒÖSw¹pÑ~š[„vWCSÙz¹p
    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 start_zd = strRetInfo.name
    -- ·ƒÖSÈ~¹pÙz¹p
    condition = "S_VALUE = '" .. task.end_loc_code .. "'"
    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 end_zd = strRetInfo.name
    -- üb¥cpenc NÑSÙ~WCS
    -- Œ(uýVꁄvûN¡R NÑS¥cãS
    local strCode = lua.guid() -- u§NN*NGUIDW[&{2N
    local str_day_time = os.date("%Y-%m-%d %H:%M:%S")
    local url = wms_base.Get_sConst(strLuaDEID, "WCS-url")
    local strurl = url .. "/create"
    local strHeader = ""
    local strBody = {}
    local data = {
        req_no = strCode,
        task_type = 5, -- 1='ireQ“^ÿ2='irúQ“^ÿ3=XbØvÄ~eQ“^ÿ4=XbØvÄ~úQ“^ÿ5=ûy¨Rÿ NǏ“^MO    ÿÿ6=ûy“^
        task_no = task.code,
        tunnel_no = tunnel_no,
        from_pos = start_zd,
        to_pos = end_zd,
        mat_code = task.cntr_code,
        mat_type = cg_detail.item_code,
        mat_memo = cg_detail.item_name,
        req_time = str_day_time,
        mat_size = 3 -- ‹Oÿ1 ÿ2 ÿ3 zzXbö€™e:N1 ¢”Nir™e:N2 ‰|™e:N3
    }
    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