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
ÿþ--[[
 x:
  Tðy: LocState
 \O€:
 eQãSýQpeÿLocState
 ŸRý€ô‹f:
 ØSôf†SòS:
 --]]
require("WMS-Equipment")
wms_cntr = require("wms_container")
wms_wh = require("wms_wh")
require("GT-Base")
require("GT_InAndOutboundPolicies")
function LocState(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), ''MO/f&TïS(uÂSpe:', in_date)
 
    -- step2 $R­e Å_kXy˜ /f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local loc_code = in_date.loc_code              -- w¹pMOn
    local type = lua.StrToNumber(in_date.type)     -- 1 ÷‹BlÖS' 2 ÷‹Bl>e' 3 ÖS'Œ[b 4 >e'Œ[b
    local req_no = lua.StrToNumber(in_date.req_no) -- /UNx
    if (loc_code == nil or loc_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "Ùz¹p Ný€:Nzz!") end
    if (type == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "{|‹W Ný€:Nzz!") end
 
    -- ·ƒÖSWCSÙz¹p
    local condition = "S_VALUE = '" .. loc_code .. "' AND S_NOTE NOT LIKE '%ؚ¦^ĉ<hÙ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
 
 
    -- Œ(uWCS„v‰[hQ¤N’N¥cãS
    local url = wms_base.Get_sConst(strLuaDEID, "WCS-url")
    local strurl = url .. "/LocState"
    local strHeader = ""
    local data = {
        loc_code = loc_code_zd,
        type = type, -- 1 ÷‹BlÖS' 2 ÷‹Bl>e' 3 ÖS'Œ[b 4 >e'Œ[b
        req_no = req_no
    }
    nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, data, "WCS", "'MO/f&TïS(u")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¥cãS1Y%!" .. strRetInfo)
    end
 
    -- žX R ûN¡R¨R\O ù[aŒ
    local task_action = m3.AllocObject(strLuaDEID, "Task_Action")
    local task
    if (type == 1) then
        -- Ùz¹p:Nw¹p,ûN¡R¶r`:Nò]¨c
        condition = "S_START_LOC = '" ..
            loc_code ..
            "' AND N_B_STATE = 1 AND S_CODE NOT IN (SELECT S_TASK_CODE FROM TN_Task_Action WHERE N_ACTION_CODE = " ..
            wms_base.Get_nConst(strLuaDEID, "AGV¶r`x-÷‹BlÖS'") .. ")"
        nRet, task = m3.GetDataObjByCondition(strLuaDEID, "Task", condition, "T_CREATE")
        if (nRet == 1) then
            return
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0ûN¡R0áOo`1Y%! " .. strRetInfo)
        end
 
        task_action.task_code = task.code
        task_action.action_code = wms_base.Get_nConst(strLuaDEID, "AGV¶r`x-÷‹BlÖS'")
        task_action.action = "÷‹BlÖS'"
        task_action.eq_code = "system"
        task_action.eq_type_name = '÷‹BlÖS''
    elseif (type == 2) then
        -- Ùz¹p:NÈ~¹p,ûN¡R¶r`:Nò]¨c
        condition = "S_END_LOC = '" ..
            loc_code ..
            "' AND N_B_STATE = 1 AND S_CODE NOT IN (SELECT S_TASK_CODE FROM TN_Task_Action WHERE N_ACTION_CODE = " ..
            wms_base.Get_nConst(strLuaDEID, "AGV¶r`x-÷‹Bl>e'") .. ")"
        nRet, task = m3.GetDataObjByCondition(strLuaDEID, "Task", condition, "T_CREATE")
        if (nRet == 1) then
            return
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0ûN¡R0áOo`1Y%! " .. strRetInfo)
        end
 
        task_action.task_code = task.code
        task_action.action_code = wms_base.Get_nConst(strLuaDEID, "AGV¶r`x-÷‹Bl>e'")
        task_action.action = "÷‹Bl>e'"
        task_action.eq_code = "system"
        task_action.eq_type_name = '÷‹Bl>e''
    elseif (type == 3) then
        -- Ùz¹p:Nw¹p,ûN¡R¶r`:Nò]¨c
        condition = "S_START_LOC = '" ..
            loc_code ..
            "' AND N_B_STATE = 1 AND S_CODE NOT IN (SELECT S_TASK_CODE FROM TN_Task_Action WHERE N_ACTION_CODE = " ..
            wms_base.Get_nConst(strLuaDEID, "AGV¶r`x-ÖS'Œ[b") .. ")"
        nRet, task = m3.GetDataObjByCondition(strLuaDEID, "Task", condition, "T_CREATE")
        if (nRet == 1) then
            return
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0ûN¡R0áOo`1Y%! " .. strRetInfo)
        end
 
        task_action.task_code = task.code
        task_action.action_code = wms_base.Get_nConst(strLuaDEID, "AGV¶r`x-ÖS'Œ[b")
        task_action.action = "ÖS'Œ[b"
        task_action.eq_code = "system"
        task_action.eq_type_name = 'ÖS'Œ[b'
    elseif (type == 4) then
        -- Ùz¹p:NÈ~¹p,ûN¡R¶r`:Nò]¨c
        condition = "S_END_LOC = '" ..
            loc_code ..
            "' AND N_B_STATE = 1 AND S_CODE NOT IN (SELECT S_TASK_CODE FROM TN_Task_Action WHERE N_ACTION_CODE = " ..
            wms_base.Get_nConst(strLuaDEID, "AGV¶r`x->e'Œ[b") .. ")"
        nRet, task = m3.GetDataObjByCondition(strLuaDEID, "Task", condition, "T_CREATE")
        if (nRet == 1) then
            return
        elseif (nRet > 1) then
            lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0ûN¡R0áOo`1Y%! " .. strRetInfo)
        end
 
        task_action.task_code = task.code
        task_action.action_code = wms_base.Get_nConst(strLuaDEID, "AGV¶r`x->e'Œ[b")
        task_action.action = ">e'Œ[b"
        task_action.eq_code = "system"
        task_action.eq_type_name = '>e'Œ[b'
    end
    nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, task_action)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'Rú^0ûN¡R¨R\O0ù[aŒ1Y%!' .. strRetInfo) end
end