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
ÿþ--[[
   x: 
    Tðy: 
   \O€ÿ
   åegÿ2024-11-19
 
   ýQpeÿ AfterSerialNoInput
   Ÿ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, "task_no", "batch_no", "item_code", "loc_code", "new_qty","cntr_qty")
    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 task_no = obj_attrs[1].value
    local batch_no = obj_attrs[2].value
    local item_code = obj_attrs[3].value
    local loc_code = obj_attrs[4].value
    local qty = tonumber(obj_attrs[5].value)
    local cntr_qty = tonumber(obj_attrs[6].value)
    
    -- Xbpeò]úQŒ[ R NYt;‘
    if(qty == 0) then return end
    
    -- ·ƒÖS0¹[hV'MO0ù[aŒ
    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
    
    -- ·ƒÖS0'MO0ù[aŒ
    local loc_info
    nRet, loc_info = wms_wh.Location_GetInfo(strLuaDEID, loc_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0'MO0áOo`1Y%! " .. loc_info) end
    
    
    -- $RzzŒT!hŒš
    if (task_no == nil or task_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡R÷S Ný€:Nzz! ") end
    if (batch_no == nil or batch_no == '') then lua.Error(strLuaDEID, debug.getinfo(1), "yb!k÷S Ný€:Nzz! ") end
    if (item_code == nil or item_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ir™e÷S Ný€:Nzz! ") end
    if (loc_code == nil or loc_code == '') then lua.Error(strLuaDEID, debug.getinfo(1), "'MO Ný€:Nzz! ") end
    if (qty == nil or qty <= 0 or qty ~= math.floor(qty)) then
        return
        -- lua.Error(strLuaDEID, debug.getinfo(1), "Xbpe Ný€:Nzzb\peŒTpe! ")
    end
    
    -- '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
 
    -- ¹[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
 
    -- “^X[7R°e
    nRet = wms.wms_ResetInventory( "Area", loc_info.area_code )
    
    -- strCondition = "S_LOC_CODE IN (SELECT S_CODE FROM TN_Location WHERE S_AREA_CODE = '"..loc_info.area_code.."')"
    -- strCondition = strCondition .. " AND S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_CG_Detail WHERE S_ITEM_CODE = '"..item_code.."' AND S_BATCH_NO = '"..batch_no.."')"
    strCondition = " S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_CG_Detail WHERE S_ITEM_CODE = '"..item_code.."' AND S_BATCH_NO = '"..batch_no.."')"
    nRet, loc_cntr = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition,"T_CREATE")
    if (nRet ~= 0) then 
        -- lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0'MO¹[hV0áOo`1Y%! " .. loc_cntr)
        mobox.setInfo(strLuaDEID,"ò]hQèúQ“^Œ[bÿ")
        return
        end
    local loc_code = loc_cntr.loc_code
    
    qty = tonumber(qty - 1) -- Xbpe
    cntr_qty = tonumber(cntr_qty - 1) --“^X[Xbpe
    -- ¾‹nMRïzaction
    local setAttr = '[{"attr":"new_qty","value":"' .. qty .. '"},{"attr":"cntr_qty","value":"'..cntr_qty..'"},{"attr":"loc_code","value":"'..loc_code..'"}]'
    local action1 = {}
    action1.action_type = "set_dlg_attr"
    action1.value = json.decode(setAttr)
    
    setAttr = '[{"attr":"new_qty","show": true}]'
    local action2 = {}
    action2.action_type = "set_dlg_attr_show"
    action2.value = json.decode(setAttr)
 
    setAttr = '[{"attr":"qtys","show": false}]'
    local action3 = {}
    action3.action_type = "set_dlg_attr_show"
    action3.value = json.decode(setAttr)
    
    nRet, strRetInfo = mobox.setAction(strLuaDEID, '[' .. lua.table2str(action1) .. ','.. lua.table2str(action2) ..','.. lua.table2str(action3)..']')
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "setAction1Y%! " .. strRetInfo) end
    
  
      -- ·ƒÖS0úQ“^USncù[aŒ0ù[aŒ
    -- 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 
 
end