Jianw
2025-05-14 29f8b36ebb718d2051bf0e7e701973ec4419ee80
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
--[[
    编码: WMS-01-09
    名称: 容器-解绑
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: Unbinding
 
    功能:
        删除容器中所有货品和容器的绑定关系,这个不是一条货品的解绑是全部解绑
        
    更改记录:
     
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
wms   = require("OILua_WMS")
m3 = require("oi_base_mobox")
 
function Unbinding ( strLuaDEID ) 
    local nRet, strRetInfo
    local row_data
    -- step1  获取当前容器编号
    nRet, row_data = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取容器对象属性失败! "..row_data ) end 
    -- 把 [{"attr":"a1","value":"xxx"},..] 的json对象转成 {"a1":"xxx","b1":"xxx"}
    
    local obj_attrs = m3.KeyValueAttrsToObjAttr( row_data.attrs )
    local cntr_code = lua.Get_StrAttrValue( obj_attrs.S_CODE )            -- 容器编码
    if ( cntr_code == '' or cntr_code == nil ) then lua.Error( strLuaDEID, debug.getinfo(1), "容器编码不能为空! " ) end 
 
    -- step2  获取容器货品明细记录
    local strCondition = "S_CNTR_CODE = '"..cntr_code.."'"
    local strOrder = ""
   
    nRet, strRetInfo = mobox.queryDataObjAttr( strLuaDEID, "CG_Detail", strCondition, strOrder, "S_ITEM_CODE" )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【容器货品明细】失败! "..strRetInfo ) end
    if ( strRetInfo == '' ) then return end
    local retObjs = json.decode( strRetInfo )
    local nCount = #retObjs
    local n
    
    for n = 1, nCount do
        nRet, strRetInfo = wms.wms_Putaway_DecAccBindingQty( strLuaDEID, retObjs[n].id, "serial" )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_Putaway_DecAccBindingQty 失败! "..strRetInfo ) end
    end
    
end