Jianw
2025-05-14 29f8b36ebb718d2051bf0e7e701973ec4419ee80
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
--[[
    编码: WMS-15-03
    名称: 收货单-检入前
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCheckIn
 
    功能:
        1)如果有ASN需要判断一下 收货单的数量是否超过 预收货单 中的数量
 
    更改记录:
     
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
wms = require("OILua_WMS")
 
m3 = require("oi_base_mobox")
 
function BeforeDataObjCheckIn ( strLuaDEID )
    local   nRet, strRetInfo
 
    -- 获取 S_NO
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_NO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
 
    local obj_attrs = json.decode( strRetInfo ) 
    local receipt_no = obj_attrs[1].value                -- 收货单编号
 
    if ( receipt_no ~= "" ) then
        nRet,strRetInfo = wms.wms_CheckAccumQty( strLuaDEID, "Receipt_Order", receipt_no ) 
        -- 返回 { "result": true/false, "cause": [ "[xxxx]的可收货数量是58, 不能收货 100", ... ] }
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end 
        -- 根据返回值判断是否检测通过, 如果 strRetInfo == '' 说明没预收货单
        if ( strRetInfo ~= '') then
            local check_result = json.decode( strRetInfo )
            if ( check_result.result == false ) then
                -- 告知前端有错误,程序执行终止
                mobox.stopProgram( strLuaDEID, lua.table2str(check_result.cause))
                return
            end
        end
    end
end