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
--[[
    编码: JX-58-13
    名称: 入库波次-强制完成(后台)
    作者:HAN    
    日期:2025-2-14
       
    入口函数: ForceFinish
 
    功能说明:
        处理后台 WFP 的入库波次强制完成
 
    更改记录:
 
--]]
 
wms_op = require( "wms_operation" )
wms_cntr = require( "wms_container" )
jx_base = require( "jx_base" )
 
function ForceFinish ( strLuaDEID ) 
    local nRet, strRetInfo
    local indound_wave = {}
    nRet, indound_wave = m3.GetSysCurEditDataObj( strLuaDEID, "Inbound_Wave" )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【入库波次】对象属性失败!"..indound_wave ) end
    
    if ( indound_wave.b_state == 0 or indound_wave.b_state == 1) then
        -- 0 未配盘 1 -- 组盘
        -- 把入库单设置为完成,并且关闭数量=入库数量
        nRet, strRetInfo = jx_base.Set_Inbound_Wave_Force_Finish( strLuaDEID, indound_wave.wave_no )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo )  end
    elseif ( indound_wave.b_state == 2 or indound_wave.b_state == 5 or indound_wave.b_state == 6 ) then
        -- 2/执行  5/暂停 6/关闭中
        -- 判断这个入库波次的作业是否还有在执行中的,如果有就不能马上关闭,只能设置为关闭中,等执行中的作业完成后才能设置为关闭,这个另外程序来处理
        -- 判断是否有存在正在执行的作业 N_B_STATE = 1
        strCondition = "S_BS_TYPE = 'Inbound_Wave' AND S_BS_NO = '"..indound_wave.wave_no.."' AND N_B_STATE = 1"
        nRet, strRetInfo = mobox.existThisData( strLuaDEID, "Operation", strCondition )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo )  end
        if ( strRetInfo == "yes" ) then 
            -- 存在正在执行的作业
            strCondition = "S_WAVE_NO = '"..indound_wave.wave_no.."'"
            strUpdateSql = "N_B_STATE = 6 "  -- 关闭中
            nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Inbound_Wave", strCondition, strUpdateSql )
            if ( nRet ~= 0 ) then  
                lua.Error( strLuaDEID, debug.getinfo(1), "更新【入库波次】信息失败!"..strRetInfo )
            end                  
        else
            -- 已经没有正在执行的作业
            nRet, strRetInfo = jx_base.Set_Inbound_Wave_Force_Finish( strLuaDEID, indound_wave.wave_no )
            if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo )  end 
        end
        -- 把作业状态 = 等待,等待前 的作业状态设置为 取消
        strCondition = "S_BS_TYPE = 'Inbound_Wave' AND S_BS_NO = '"..indound_wave.wave_no.."' AND ( N_B_STATE = 0 or N_B_STATE = 6 or N_B_STATE = 8 )"
        strUpdateSql = "N_B_STATE = 7 "
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Operation", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  
            lua.Error( strLuaDEID, debug.getinfo(1), "更新【作业】信息失败!"..strRetInfo )
        end  
    end
 
end