1
Jianw
2025-07-09 88e26a2a960dbbc148332772448b79b9877102d8
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
--[[
    编码: JX-01-18
    名称: 容器-全部清除编码从头开始
    作者:HAN  
    日期:2025-01-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: ResetContainer
 
    功能:
        清除所有容器和容器料格,并且编码从0001开始
 
    更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function ResetContainer( strLuaDEID )
    local nRet, strRetInfo
 
    -- 把容器编码 FB- 开始的顺序号设置为 0001
    nRet, strRetInfo = mobox.removeSerialNumber( "容器", "FB-" )    
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "removeSerialNumber() 失败! "..strRetInfo ) end 
 
    -- 把容器编码 Z- 开始的顺序号设置为 0001
    nRet, strRetInfo = mobox.removeSerialNumber( "容器", "Z-" )    
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "removeSerialNumber() 失败! "..strRetInfo ) end 
 
 
    local strCondition = ""
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Container")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Container】失败!"..strRetInfo) end
 
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Container_Cell")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Container_Cell】失败!"..strRetInfo) end    
 
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Container_Good")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Container_Good】失败!"..strRetInfo) end    
 
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "CG_Detail")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【CG_Detail】失败!"..strRetInfo) end    
 
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Loc_Container")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Loc_Container】失败!"..strRetInfo) end    
 
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Lock")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Lock】失败!"..strRetInfo) end     
    
    -- 和配盘相关
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Distribution_CNTR")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Distribution_CNTR】失败!"..strRetInfo) end    
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Distribution_CNTR_Detail")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Distribution_CNTR_Detail】失败!"..strRetInfo) end     
    
    -- 和组盘相关
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Organize_Container")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Organize_Container】失败!"..strRetInfo) end    
    nRet, strRetInfo = mobox.dbClearData(strLuaDEID, "Organize_CNTR_Detail")
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【Organize_CNTR_Detail】失败!"..strRetInfo) end         
 
    local strUpdateSql = "N_CURRENT_NUM = 0, N_LOCK_STATE = 0, S_LOCK_OP = '', S_LOCK_STATE = ''"
    local strCondition = "S_WH_CODE = 'WH01'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Location", strCondition, strUpdateSql )
    if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【货位】信息失败!"..strRetInfo ) end            
 
    local action = {}
    action[1] = {
        action_type = "refresh",
        value = ""
    }
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str( action ))
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end  
end