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
--[[
    编码: WMS-24-20
    名称: 删除
    作者:HAN    
    日期:2025-6-5
 
    入口函数: ResetState
 
    功能说明:
        把错误状态设置为 错误前的状态
 
    更改记录:
 
--]]
wms_op = require( "wms_operation" )
 
function ResetState ( strLuaDEID ) 
    local nRet, strRetInfo
    local objs
 
    -- step1  获取当前点中的作业
    nRet, objs = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then 
        lua.Stop( strLuaDEID, objs )
        return
    end  
    local nCount = #objs
    if (nCount == 0) then  return end
    local outbound_order = {}
 
    nRet, outbound_order = m3.GetDataObject( strLuaDEID, "Outbound_Order", objs[1].id ) 
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, "objAttrsToLuaJson (Outbound_Order) 返回的的JSON格式不合法 !"..outbound_order ) 
        return
    end
 
    lua.DebugEx( strLuaDEID, "outbound_order", outbound_order )
 
    -- 如果是错误状态进行重置
    local b_state
    if ( outbound_order.b_state == OUTBOUND_ORDER_STATE.Error ) then
        local strCondition = "S_NO = '"..outbound_order.no.."'"
        if outbound_order.per_b_state == OUTBOUND_ORDER_STATE.InAlloc then
            b_state = OUTBOUND_ORDER_STATE.Unalloc
        else
            b_state = outbound_order.per_b_state
        end
        local strUpdateSql = "N_B_STATE = "..b_state..", S_ERR_MSG = ''"
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Order", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  
            return 2, "更新【出库单】信息失败!"..strRetInfo
        end    
    
        local action = {
            {
                action_type = "refresh_cur_row",
                value = ""
            }
        }
        nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
        if ( nRet ~= 0 ) then 
            lua.Stop( strLuaDEID, "setAction错误: "..strRetInfo) 
            return
        end          
    end
 
end