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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
ÿþ--[[
    x: GT-100-05
     Tðy: GT-WMS
    \O€ÿLZH
    eQãSýQpeÿ CreateLabelCrad
 
 
    ŸRý€ô‹f:
        GT-WMS NÑSeQ“^USncLˆáOo`Ù~ GZ-WMSû|ß~ ÿGZ-WMSû|ß~ù[úW@xpencۏLˆ°ežX
 
        “eQpencÿ                                                                                        
        {    
        "delivery_no": "xxx",    6e'US÷S
        "delivery_row_no": "xxx",    6e'USLˆ÷S
        "serial_no": "xxx",    Am4l÷S
        "batch_no": "xxx",    yb!k÷S
        "qty": xxx,    XbØv͑ϑ
        "item_code": "xxx",    ir™ex]NMOx
        "product_date": "xxx",    u§Nåeg
        "storage_loc": "xxx",    “^MO
        "wh_code": "xxx",    ÓN“^÷S
        "is_bonded": "xxx",    /f&TÝOz
        "item_state": "xxx",    (Ï‘¶r`
        "wheel_type_rot": "xxx",    n‹W/æ]óSËe
        "subpool": "xxx",    P[“^
        "req_no": "xxx",    /UNhƋ
        "inbound_policy": "xxx",    ö€™eeQ“^ĉR
        "expire_date": "xxx",   0Rgöeô•
        "palletizing": "xxx",   xØvĉR
        "dispersoid": "xxx",   ceňö€hƋ
        "Item_code_9": "xxx",   ir™exmQMOx
        "remark1": "",  -- Yèl ‚f*g/T(u
        "remark2": "",  -- Yèl ‚f*g/T(u
        "remark3": "",  -- Yèl ‚f*g/T(u
        "remark4": "",   -- Yèl ‚f*g/T(u
        "number": "",   -- êSˆ”ù[ceňö€ ÿceňö€„veQ“^USncLˆ/fNf„v;`peϑ ÿ9hnc ;`peϑ/WWpe—_0RÏkWWö€„vhÆQ͑ϑ
        }    
 
 
        Yt;‘
        -- step1 ã‰g¥cãS O„v datajson ÂSpe
        -- step2 !hŒšÅ_ OW[µk/f&T:Nzz ÿ:NzzR¥b•
        -- step3 Ç6e'US÷SŒT6e'USLˆ÷S·ƒÖSeQ“^USnc4YáOo`
        -- step4 Rú^eQ“^USncLˆ
                                                                    
    ØSôf°‹U_:
    20250221 LZH V1.1 °ežX4*NY(uW[µkŒT0Rgöeô•0ceňö€hƋ0xØvĉR
    20250319 LZH V1.2 °ežXnumberW[µk
--]]
m3 = require( "oi_base_mobox" )
json  = require("json")
mobox = require("OILua_JavelinExt")
function CreateLabelCrad(strLuaDEID)
    local nRet, strRetInfo, in_date
    -- step1 ·ƒÖS¥cãSpenc
    nRet, in_date = m3.GetSysDataJson(strLuaDEID)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "WCStoreCallback àeÕl·ƒÖSpencS!" .. in_date) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'eQ“^USncLˆ NÑS NÑSÂSpe:', in_date)
 
    -- step2 $R­e/f&Tý    g<Pÿ¡l<P¥b•ԏÞV
    local delivery_no = in_date.delivery_no
    if (delivery_no == nil or delivery_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "6e'US÷S Ný€:Nzz!") end
    local delivery_row_no = in_date.delivery_row_no
    if (delivery_row_no == nil or delivery_row_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "6e'USLˆ÷S Ný€:Nzz!") end
    local serial_no = in_date.serial_no
    if (serial_no == nil or serial_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "Am4l÷S Ný€:Nzz!") end
    local batch_no = in_date.batch_no
    if (batch_no == nil or batch_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S Ný€:Nzz!") end
    local qty = tonumber(in_date.qty)
    if (qty == nil) then lua.Error(strLuaDEID, debug.getinfo(1), "XbØv͑ϑ Ný€:Nzz!") end
    local item_code = in_date.item_code
    if (item_code == nil or item_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™ex Ný€:Nzz!") end
    local product_date = in_date.product_date
    if (product_date == nil or product_date == '') then lua.Error(strLuaDEID, debug.getinfo(1), "u§Nåeg Ný€:Nzz!") end
    local wh_code = in_date.wh_code
    if (wh_code == nil or wh_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ÓN“^÷S Ný€:Nzz!") end
    local is_bonded = in_date.is_bonded
    local item_state = in_date.item_state
    if (item_state == nil or item_state == '') then lua.Error(strLuaDEID, debug.getinfo(1), "(Ï‘¶r` Ný€:Nzz!") end
    local storage_loc = in_date.storage_loc
    local wheel_type_rot = in_date.wheel_type_rot
    local subpool = in_date.subpool
    local req_no = in_date.req_no
    local inbound_policy = in_date.inbound_policy
    -- 20250221 LZH V1.1 °ežX4*NY(uW[µkŒT0Rgöeô•0ceňö€hƋ0xØvĉR
    local expire_date = in_date.expire_date
    local palletizing = in_date.palletizing
    local dispersoid = in_date.dispersoid
    local remark1 = in_date.remark1
    local remark2 = in_date.remark2
    local remark3 = in_date.remark3
    local remark4 = in_date.remark4
    -- 20250319 LZH V1.2 °ežXnumberW[µk
    local number = in_date.number
    local Item_code_9 = in_date.item_code_9
    if (Item_code_9 == nil or Item_code_9 == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™ex Ný€:Nzz!") end
    
    -- if(dispersoid == 'Y')then
    --     nRet, serial_no = mobox.getSerialNumber("Am4l÷S", 'L', 7)
    --     if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1),"3u÷‹ceňö€eQ“^USncLˆx1Y%!" .. serial_no) end
    -- end
 
    -- step3 Ç6e'US÷SŒT6e'USLˆ÷S·ƒÖSeQ“^USnc4YáOo`
    local strCondition = "S_DELIVERY_NO = '" .. delivery_no .. "' AND N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", strCondition)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. strRetInfo)
    end
 
    local order_no = strRetInfo.order_no
    local item_name = strRetInfo.item_name
 
    -- $R­eAm4l÷S/f&TX[(W,X[(WRôf°e
    strCondition = "S_SERIAL_NO = '" .. serial_no .. "'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition)
    if (nRet == 1) then
        -- step4 Rú^eQ“^USncLˆ
        -- ·ƒÖSN*NRËY„v0eQ“^USncLˆ0pencù[aŒ
        strRetInfo = m3.AllocObject(strLuaDEID, "GT_Label_Crad")
        strRetInfo.delivery_no = delivery_no
        strRetInfo.delivery_row_no = delivery_row_no
        strRetInfo.item_code_9 = item_code
        strRetInfo.item_name = item_name
        strRetInfo.product_date = product_date
        strRetInfo.batch_no = batch_no
        strRetInfo.item_state = item_state
        strRetInfo.qty = qty
        strRetInfo.serial_no = serial_no
        strRetInfo.wh_code = wh_code
        strRetInfo.storage_loc = storage_loc
        strRetInfo.order_no = order_no
        strRetInfo.is_bonded = is_bonded
        strRetInfo.wheel_type_rot = wheel_type_rot
        strRetInfo.subpool = subpool
        strRetInfo.req_no = req_no
        strRetInfo.inbound_policy = inbound_policy
        strRetInfo.expire_date = expire_date
        strRetInfo.palletizing = palletizing
        strRetInfo.dispersoid = dispersoid
        strRetInfo.number = number
        strRetInfo.item_code = Item_code_9
        nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, strRetInfo)
        if (nRet ~= 0) then
            lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0eQ“^USncLˆ0ù[aŒ1Y%!' .. strRetInfo)
        end
    elseif (nRet == 0) then
        local update_sql = "S_DELIVERY_NO = '" .. delivery_no .. "',N_DELIVERY_ROW_NO = '" .. delivery_row_no .. "'"
        update_sql = update_sql .. ",S_ITEM_CODE_9 = '" .. item_code .. "',S_ITEM_NAME = '" .. item_name .. "'"
        update_sql = update_sql .. ",D_PRODUCT = '" .. product_date .. "',S_BATCH_NO = '" .. batch_no .. "'"
        update_sql = update_sql .. ",S_ITEM_STATE = '" .. item_state .. "',F_QTY = '" .. qty .. "',S_WH_CODE ='" .. wh_code .. "'"
        update_sql = update_sql .. ",S_ORDER_NO = '" .. order_no .. "'"
        if(is_bonded ~= nil and is_bonded ~= '')then
            update_sql = update_sql..",C_IS_BONDED = '" .. is_bonded .. "'"
        end
        if(storage_loc ~= nil and storage_loc ~= '')then
            update_sql = update_sql..",S_STORAGE_LOC = '" .. storage_loc .. "'"
        end
        if(wheel_type_rot ~= nil and wheel_type_rot ~= '')then
            update_sql = update_sql..",S_WHEEL_TYPE_ROT = '" .. wheel_type_rot .. "'"
        end
        if(subpool ~= nil and subpool ~= '')then
            update_sql = update_sql..",S_SUBPOOL = '" .. subpool .. "'"
        end
        if(req_no ~= nil and req_no ~= '')then
            update_sql = update_sql..",S_REQ_NO = '" .. req_no .. "'"
        end
        if(inbound_policy ~= nil and inbound_policy ~= '')then
            update_sql = update_sql..",S_INBOUND_POLICY = '" .. inbound_policy .. "'"
        end
        if(expire_date ~= nil and expire_date ~= '')then
            update_sql = update_sql..",D_EXPIRE = '" .. expire_date .. "'"
        end
        if(palletizing ~= nil and palletizing ~= '')then
            update_sql = update_sql..",S_PALLETIZING = '" .. palletizing .. "'"
        end
        if(dispersoid ~= nil and dispersoid ~= '')then
            update_sql = update_sql..",S_DISPERSOID = '" .. dispersoid .. "'"
        end
        if(number ~= nil and number ~= '')then
            update_sql = update_sql..",S_NUMBER = '" .. number .. "'"
        end
        if(Item_code_9 ~= nil and Item_code_9 ~= '')then
            update_sql = update_sql..",S_ITEM_CODE = '" .. Item_code_9 .. "'"
        end
        nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Label_Crad", strCondition, update_sql)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eeQ“^USáOo`1Y%ÿ" .. strRetInfo) end
    else
        lua.Error(strLuaDEID, debug.getinfo(1), 'GetDataObjByCondition1Y%!' .. strRetInfo)
    end
end