1
Jianw
10 天以前 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
--[[
    编码: GK-56-24
    名称: 预分配容器明细-入库任务界面-任务取消
    作者:HAN  
    日期:2025-6-26
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: TaskFinish
 
    功能:
        -- 入库数量不对报错
        -- 灭灯
        -- 入库任务状态设置为完成
        -- 创建入库作业
 
    更改记录:
 
 
--]]
wms_base = require( "wms_base" )
wms_ptl = require( "wms_ptl" )
gk_base = require( "gk_base" )
 
function TaskFinish ( strLuaDEID ) 
    local nRet, strRetInfo
 
    m3.PrintLuaDEInfo( strLuaDEID )
 
    -- 获取扫码方式
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "F_QTY", "F_ACT_QTY") 
    if ( nRet ~= 0 )  then 
        lua.Stop( strLuaDEID, "获取当前编辑属性失败! "..strRetInfo ) 
        return
    end 
    local obj_attrs = json.decode( strRetInfo ) 
    local qty = lua.Get_NumAttrValue( obj_attrs[1].value ) 
    local act_qty = lua.Get_NumAttrValue( obj_attrs[2].value )  
 
    if ( lua.equation( act_qty, qty ) ) then
        -- 任务完成
        local parameter
        nRet, parameter = m3.Get_3053_PanelParameter( strLuaDEID, "组盘输入" )
        if nRet ~= 0 then
            wms_base.Notice_Audio( strLuaDEID, parameter, "error.mp3" ) 
            return        
        end
 
        local id = parameter.id               -- 当前点中的入库任务标识
        local pac_no = parameter.pac_no       -- 当前点中的入库任务所属组盘号
        if ( pac_no == nil or pac_no == "") then
            wms_base.Notice_Audio( strLuaDEID, "'组盘输入'面板必须有orgc_no 参数!", "error.mp3" )             
            return         
        end  
        local groupID = "Station:"..parameter.station  
        
        -- 设置【预分配容器明细】状态 = 2/PalletizingOK(码盘完成)
        local strCondition = "S_ID = '"..id.."'"
        local strUpdateSql = "N_B_STATE =  "..PAC_DETAIL_STATE.PalletizingOK..", F_ACT_QTY = "..act_qty
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Pre_Alloc_CNTR_Detail", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  
            wms_base.Error_Audio( strLuaDEID,  "更新【预分配容器明细】信息失败!"..strRetInfo )
            return
        end  
 
        -- 更新 GK_IN_TASK_Detail 中的 F_ACC_B_QTY
        strCondition = "S_IO_NO = '"..parameter.bs_no.."' AND N_ROW_NO = "..parameter.bs_row_no
        strUpdateSql = "F_ACC_B_QTY = F_ACC_B_QTY + "..act_qty
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "GK_IN_TASK_Detail", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  
            wms_base.Error_Audio( strLuaDEID,  "更新【国科入库任务明细】信息失败!"..strRetInfo )
            return
        end  
 
        local action
        nRet, action = gk_base.Pre_Alloc_CNTR_PostProcess( strLuaDEID, pac_no, parameter.station, parameter.cntr_code )
        if ( nRet ~= 0 ) then 
            wms_base.Error_Audio( strLuaDEID,  "Pre_Alloc_CNTR_PostProcess 失败!"..action )
            return
        end
        if not lua.isTableEmpty( action ) then
            nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
            if ( nRet ~= 0 ) then 
                wms_base.Error_Audio( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction ) 
                return
            end  
        end
        mobox.removeCacheGroup( groupID )
    else
        wms_base.Notice_Audio( strLuaDEID,  "上架数量不够,无法完成当前入库任务!" )
        return        
    end        
 
end