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
ÿþ--[[
   x: GT-122-24
    Tðy:
   \O€ÿ
   åegÿ2025-03-14
 
   ýQpeÿ AfterClickOk
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
json  = require("json")
mobox = require("OILua_JavelinExt")
m3    = require("oi_base_mobox")
require("GT-Base")
wms_wh = require("wms_wh")
function AfterClickOk(strLuaDEID)
    local nRet, strRetInfo
    -- ·ƒÖSÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_LOC_CODE", "S_VERIFY_LOC", "S_AREA","S_ITEM_CODE","S_BATCH_NO")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local loc_code = obj_attrs[1].value
    local verify_loc = obj_attrs[2].value
    local area = obj_attrs[3].value
    local item_code = obj_attrs[4].value
    local batch_no = obj_attrs[5].value
 
    -- $RzzŒT!hŒš
    if (verify_loc == nil or verify_loc == '') then
        mobox.setInfo(strLuaDEID, "!hŒš'MO Ný€:Nzz!")
        return
    end
    if (loc_code ~= verify_loc) then
        mobox.setInfo(strLuaDEID, "!hŒš'MO Ncknx,÷‹ŒšÁ‹!")
        return
    end
    -- ·ƒÖS0¹[hV'MO0ù[aŒ
    local strCondition = "S_LOC_CODE  = '" .. loc_code .. "'"
    local loc_cntr
    nRet, loc_cntr = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition, "T_CREATE")
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "å‹'MO¡l    gÑ~š[¹[hV!")
        return
    end
    local cntr_code = loc_cntr.cntr_code
 
    -- 'MO¹[hVã‰Ñ~
    nRet, strRetInfo = wms_wh.Loc_Container_Unbinding(strLuaDEID, loc_code, cntr_code, "Ñ~š[ã‰Ñ~¹eÕl-û|ß~", ":_6RŒ[b")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), ''MO¹[hVã‰Ñ~1Y%!' .. strRetInfo) end
 
    -- ³xў“^„vXbØv/fZ†ßb„v,úQ“^Œ[‰ Rd–¹[hV
    if (area == '³xў') then
        strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'"
        nRet, strRetInfo = mobox.deleteDataObject(strLuaDEID, "Container", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
    end
 
    -- ·ƒÖSúQ“^USncáOo`
    local stock_out
    strCondition = "S_ITEM_CODE = '" .. item_code .. "' AND S_BATCH_NO = '" .. batch_no .."' AND S_STATE = '/T(u'"
    nRet, stock_out = m3.GetDataObjByCondition(strLuaDEID, "GT_Stock_Out", strCondition,"T_CREATE")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. stock_out)
    end
 
    -- ¾‹núQ“^US¶r`:NŒ[b
    strCondition = "S_DO_NO = '" .. stock_out.delivery_no .. "'"
    local strSetSQL_update = " S_STATE = 'Œ[b'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition(strLuaDEID, "GT_Stock_Out", strCondition, strSetSQL_update)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "îO9eúQ“^USnc¶r`1Y%ÿ" .. strRetInfo) end
 
    -- ·ƒÖS¹[hV'ÁTáOo`
    local cg_detail
    strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'"
    nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. cg_detail) end
 
    -- ·ƒÖSeQ“^USncLˆáOo`
    local label_crad
    strCondition = "S_SERIAL_NO = '" .. cg_detail.serial_no .. "'"
    nRet, label_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition, "T_CREATE DESC")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSeQ“^USncLˆáOo`1Y%!" .. label_crad) end
 
    -- ·ƒÖSeQ“^USnc4YáOo`
    local incoming_Info
    strCondition = "S_ORDER_NO = '" .. label_crad.order_no .. "'"
    nRet, incoming_Info = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", strCondition, "T_CREATE DESC")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSeQ“^USnc4YáOo`1Y%!" .. incoming_Info) end
 
    -- úQ“^Ó~œgÞV O
    local data = {
        wh_code = "wmwhse1",
        task_no = stock_out.delivery_no,
        batch_no = cg_detail.batch_no,
        sku = cg_detail.item_code,
        qty = cg_detail.qty,
        rfid = cg_detail.cntr_code,
        number_no = label_crad.serial_no,
        supplier = incoming_Info.vendor,
        grade = incoming_Info.level,
        subloc = label_crad.subpool
    }
    local source = "GTWMSúQ“^ÞV O"
 
    -- Œ(uGT-WMS„vÞV O¥cãS
    local url = wms_base.Get_sConst(strLuaDEID, "GTWMS-url")
    local strurl = url
    local strHeader = ""
    local strBody = {
        application = "GITI",
        code = "WCS_SO_WMS",
        data = data
    }
    nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, strBody, "GTWMS", source)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "Œ(uWCS¥cãS1Y%!" .. strRetInfo)
    end
 
    -- ¹[hV'ÁT Rd–
    strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'"
    nRet, strRetInfo = wms_cntr.Delete_CG_Detail(strLuaDEID, cntr_code, strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
 
    mobox.setInfo(strLuaDEID, "úQ“^bŸR!")
end