fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
--[[
    编码: JX-105-11
    名称: 出库波次-创建空料箱出库作业
    作者:HAN  
    日期: 2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: CreateOutOperation
 
    功能:
        -- 适用于行、页面按钮调用
        -- 获取【出库波次】中的配盘数据对象,
        -- 每个配盘对象创建一个{货品出库}作业,容器加出库锁
 
    更改记录:
 
--]]
 
wms_wh = require( "wms_wh" )
jx_base= require( "jx_base" )
 
function CreateOutOperation( strLuaDEID )
    local nRet, strRetInfo, n, m
    local data_json, obj_attrs
 
    nRet, data_json = m3.GetSysDataJson( strLuaDEID )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), data_json ) end
 
    local strCondition, strUpdateSql
    local distribution_objs, distribution
 
    for n = 1, #data_json do
        obj_attrs = m3.KeyValueAttrsToObjAttr( data_json[1].attrs )
 
        strCondition = "S_BS_NO = '"..obj_attrs.S_WAVE_NO.."'"
        nRet, distribution_objs = m3.QueryDataObject(strLuaDEID, "Distribution_CNTR", strCondition, "" )
        if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1),"QueryDataObject失败!"..distribution_objs ) end
    
        -- 根据每个配盘生成出库作业
        for m = 1, #distribution_objs do
            distribution = m3.KeyValueAttrsToObjAttr(distribution_objs[m].attrs)   
            nRet, strRetInfo = jx_base.Create_Distribution_OutOperation ( strLuaDEID, distribution )
            if ( nRet ~= 0 ) then
                mobox.stopProgram( strLuaDEID, strRetInfo )
                return
            end
        end   
        
        -- 更新出库波次的状态 N_B_STATE = 3 表示已经创建作业
        strUpdateSql = "N_B_STATE = 3"
        strCondition = "S_WAVE_NO = '"..obj_attrs.S_WAVE_NO.."'"
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Wave", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【出库波次】状态失败!"..strRetInfo ) end  
        
        -- 更新出库单状态为 作业中3
        nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Order", strCondition, strUpdateSql )
        if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【出库单】状态失败!"..strRetInfo ) end          
        
    end
 
    local action = {
            {
                action_type = "refresh",
                value = ""
            }
        }
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str( action ))
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end      
end