1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
--[[
    编码: WMS-17-15
    名称: 计划盘点容器-盘点完成后处理
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: AfterStocktakingFinish
 
    功能:
         -- 如果计划盘点容器的盘点方法是自动搬运,需要创建一个搬运作业
 
    更改记录:
 
--]]
wms_base = require ("wms_base")
 
function AfterStocktakingFinish ( strLuaDEID ) 
    local nRet, strRetInfo
    local count_cntr = {}
    nRet, count_cntr = m3.GetCurEditDataObj( strLuaDEID )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【CP_Count_Container】对象属性失败!"..count_cntr ) end
 
    -- 检查盘点单完成盘点数量
    -- N_B_STATE = 3 已盘点 4 -- 回库
    local strCondition = "S_COUNT_NO = '"..count_cntr.count_no.."' AND N_B_STATE >= 3"
    nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "CP_Count_Container", strCondition )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "getDataObjCount失败!"..strRetInfo ) end
    local nCount = lua.StrToNumber( strRetInfo ) 
 
    -- 更新【盘点单】的状态和已完成盘点数量
    local count_order
    nRet, count_order = m3.GetDataObjectByKey( strLuaDEID, "Count_Order", "S_COUNT_NO", count_cntr.count_no )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetDataObjectByKey失败"..count_order ) end      
    local strSetAttr = ''
    if ( count_order.num == nCount ) then
        strSetAttr = "N_B_STATE = 2, N_ACC_FINISH = "..nCount
    else
        strSetAttr = "N_ACC_FINISH = "..nCount
    end
    strCondition = "S_COUNT_NO = '"..count_cntr.count_no.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Order", strCondition, strSetAttr )
    if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【Count_Order】信息失败!"..strRetInfo ) end  
 
    -- 如果有盘点计划更新盘点计划的累计盘点数量和计划状态
    if ( count_order.cp_no == '' ) then return end
 
    -- 获取盘点计划已经完成盘点的盘点容器数量
    -- N_B_STATE =3 已盘点 4 -- 回库
    local strCondition = "S_CP_NO = '"..count_order.cp_no.."' AND N_B_STATE >= 3"
    nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "CP_Count_Container", strCondition )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "getDataObjCount失败!"..strRetInfo ) end
    nCount = lua.StrToNumber( strRetInfo )
    
    -- 更新【盘点计划】的状态和已完成盘点数量
    local count_plan
    nRet, count_plan = m3.GetDataObjectByKey( strLuaDEID, "Count_Plan", "S_CP_NO", count_order.cp_no )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetDataObjectByKey失败"..count_order ) end   
    -- 如果盘点计划的计划盘点容器数量 = 已经完成盘点的容器数量,盘点计划完成   
    if ( count_plan.plan_total == nCount ) then
        -- 3 盘点计划完成
        strSetAttr = "N_B_STATE = 3, N_ACC_FINISH = "..nCount
    else
        strSetAttr = "N_ACC_FINISH = "..nCount
    end
    strCondition = "S_CP_NO = '"..count_order.cp_no.."'"
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Plan", strCondition, strSetAttr )
    if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【Count_Plan】信息失败!"..strRetInfo ) end      
end