Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: JX-105-14
    名称: 出库波次-重置错误
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: Reset
 
    功能:
        把错误状态的出库波次重新进行自动配盘
    更改记录:
 
--]]
wms_base = require ("wms_base")
 
function Reset ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    -- step1  获取当前点中的容器
    nRet, objs = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end  
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    local nCount = #objs
    if (nCount == 0) then  return end
    local outbound_wave
    nRet, outbound_wave = m3.GetDataObject( strLuaDEID, "Outbound_Wave", objs[1].id ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), outbound_wave ) end 
 
    if ( outbound_wave.b_state ~= 5 ) then
        mobox.stopProgram( strLuaDEID, "只能设置错误状态的出库单波次!")
        return        
    end
 
    local pre_b_state = outbound_wave.per_b_state
 
    local strUpdateSql = "N_B_STATE = "..pre_b_state..", S_ERR_MSG = ''"
    local strCondition = "S_WAVE_NO = '"..outbound_wave.wave_no.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Wave", strCondition, strUpdateSql )
    if ( nRet ~= 0 ) then  
        lua.Error( strLuaDEID, debug.getinfo(1), "更新【Outbound_Wave】信息失败!"..strRetInfo ) 
    end   
 
    if ( 1 == pre_b_state ) then
        -- 触发自动配盘
        local add_wfp = {
            wfp_type = 1,                  -- 触发数据对象事件(指定数据对象标识)
            cls = "Outbound_Wave",
            obj_id = outbound_wave.id,
            obj_name = "波次号'"..outbound_wave.wave_no.."'-->自动配盘",
            trigger_event = "自动配盘"
        }
        nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp )
        if ( nRet ~= 0 ) then 
            lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo )  
        end           
    end
    local action = {
        {
            action_type = "refresh_cur_row",
            value = ""
        }
    }
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end      
 
end