fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
ÿþ--[[
    x: JX-300-01
     Tðy: WCS->WMS ûN¡RgbLˆåw
    \O€ÿHAN
    åegÿ2025-1-29
    §~+Rÿy˜îv
    
    ýQpeÿ TaskNotification
 
    WCS Ù¹„v“eQÂSpe
    {
        "requestPk": "pk2022120614242376",
        "contNo": "60001",
        "noticeType": "02",
        "curPos": "2F_OUT_ST21",
        "code": 0,
        "equName":"¾‹Y Tðy"
        "equNo":"¾‹Y÷S"
        "result": "success",
        "clientCode": "wcs",
        "reqTime": "2022-11-11 11:32:08"
    }
 
    ŸRý€:
        -- WCS ŠbûN¡R„vgbLˆÅ`µQ¨cÙ~ WMS 
 
    ôf9e°‹U_:
       
--]]
 
wms_task = require( "wms_task" )
wms_op = require( "wms_operation" )
 
function TaskNotification ( strLuaDEID ) 
    local nRet, strRetInfo
    local body
 
    -- ·ƒÖS¥cãS OeQ„vpenc
    nRet, body = m3.GetSysDataJson(strLuaDEID)  
    if ( nRet ~= 0 ) then
        lua.Debug( strLuaDEID, debug.getinfo(1), "¥cãS“eQÂSpe NTÕl", body )
        mobox.stopProgram( strLuaDEID, "“eQÂSpe„v<h_    g˜!" ) 
        return
    end   
    lua.Debug( strLuaDEID, debug.getinfo(1), "¥cãS“eQÂSpe", body )
    local task_code = lua.Get_StrAttrValue( body.requestPk )
    local cntr_code = lua.Get_StrAttrValue( body.contNo )
    local noticeType = lua.Get_StrAttrValue( body.noticeType )
    local curPos = lua.Get_StrAttrValue( body.curPos )
    local code = lua.Get_StrAttrValue( body.code )
    local equName = lua.Get_StrAttrValue( body.equName )
    local equNo = lua.Get_StrAttrValue( body.equNo )
 
    if ( task_code == '') then
        mobox.stopProgram( strLuaDEID, "requestPk Å_{˜    g<P!" ) 
        return
    end
    if ( cntr_code == '') then
        mobox.stopProgram( strLuaDEID, "contNo Å_{˜    g<P!" ) 
        return
    end 
    if ( noticeType == '') then
        mobox.stopProgram( strLuaDEID, "noticeType Å_{˜    g<P!" ) 
        return
    end 
    
    -- nxš[ÍSˆ™„vûN¡R/f&TX[(W
    nRet, task = wms_task.GetInfo( strLuaDEID, task_code )
    if ( nRet ~= 0 ) then
        mobox.stopProgram( strLuaDEID, "ûN¡R÷S'"..task_code.."' NX[(W!" ) 
        return
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), "task", task)
    -- 9hncûN¡R„v¶r` N T¥c6e N T„vûN¡RÍSˆ™
    -- ûN¡R:Nò]¨c¶r`
    if ( task.bs_state == 1 ) then
        -- "1" ûN¡R_ËYgbLˆ
        if ( noticeType == "1" ) then
            nRet, strRetInfo = wms_task.SetStateByCode( strLuaDEID, task_code, "ûN¡R¶r`-gbLˆ" )
            if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
            local task
            nRet, task = wms_task.GetInfo( strLuaDEID, task_code )
            lua.Debug(strLuaDEID, debug.getinfo(1), "task", task)
            -- ‚YœgûN¡R NX[(WbúQ• ÿ ÔÞV
            if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), task ) end            
            -- 2 hˆ:y¾‹Yò]Ï~_ËYgbLˆ
            nRet, strRetInfo = wms_op.SetTaskState( strLuaDEID, task.op_code, 2 )
            if ( nRet ~= 0 ) then 
                lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) 
            end   
            
            local data = {}
            data = {
                cntr_code = task.cntr_code,
                start_wh_code = task.end_wh_code,
                end_loc_code = task.end_loc_code,
                sour_no = task.bs_no,
                start_loc_code = task.start_loc_code,
                task_type = task.op_name
            }
            local serialized_data = table2str(data) 
 
            local task_action = m3.AllocObject(strLuaDEID,"Task_Action")
            task_action.task_code = task_code
            task_action.action_code = lua.StrToNumber( noticeType )
 
            task_action.data = serialized_data
            
            task_action.action = "ûN¡RgbLˆ"
            task_action.eq_code = "XXX"
            task_action.eq_type_name = "XXX"
            nRet, task_action = m3.CreateDataObj( strLuaDEID, task_action )
            if ( nRet ~= 0 ) then
                mobox.stopProgram( strLuaDEID, "ûN¡R÷S'"..task_code.."'Rú^ûN¡R;m¨R°‹U_1Y%!"..task_action ) 
                return                
            end
            
            -- MDY BY KUN 20250102
            -- îO9e$R­eagöN
            if (task.source_sys == "è]f" ) then
            -- žX RN*NTðSۏ zÞV¥b
                local add_wfp = {
                                    wfp_type = 1,                  -- æ‰ÑSpencù[aŒ‹NöNÿcš[pencù[aŒhƋ    ÿ
                                    cls = "Task_Action",
                                    obj_id = task_action.id,
                                    obj_name = "ûN¡R÷S'"..task_action.task_code.."'è]fûN¡R-->è]f¶r`ÞV¥b",
                                    trigger_event = "è]f¶r`ÞV¥b"
                                }
                nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )
                if ( nRet ~= 0 ) then 
                    lua.Error( strLuaDEID, debug.getinfo(1), "AddSysWFP1Y%!"..strRetInfo )  
                end  
                    
            end
            
        elseif ( noticeType == "2" ) then
            lua.Warning( strLuaDEID, debug.getinfo(1), "ûN¡R÷S'"..task_code.."'¡lgbLˆ1\¨cûN¡RŒ[b" )
        end
    elseif ( task.bs_state == 2 ) then
        -- "2" ûN¡RŒ[b
        if ( noticeType == "2" ) then
            -- ¾‹nûN¡RŒ[b
            nRet, strRetInfo = wms.wms_TaskFinish( strLuaDEID, task_code )
            
           
            if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "ûN¡Rx='"..task.code.."'„vûN¡R¾‹nŒ[b1Y%!"..strRetInfo ) end 
 
            local task_action = m3.AllocObject(strLuaDEID,"Task_Action")
            task_action.task_code = task_code
            task_action.action_code = lua.StrToNumber( noticeType )
            task_action.action = "ûN¡RŒ[b"
            task_action.eq_code = "XXX"
            task_action.eq_type_name = "XXX"
            nRet, strRetInfo = m3.CreateDataObj( strLuaDEID, task_action )   
            if ( nRet ~= 0 ) then
                mobox.stopProgram( strLuaDEID, "ûN¡R÷S'"..task_code.."'Rú^ûN¡R;m¨R°‹U_1Y%!" ) 
                return
            end                     
        end        
    end
    
    -- ¾‹nԏÞVÓ~œg
    local result = {
        code = 0,
        msg = "success",
        requestPk = body.requestPk
    }    
    m3.EPI_Return( strLuaDEID, result )   
end