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
61
62
63
64
65
66
--[[
    编码: JX-28-13
    名称: 盘点单-盘点差异转移
    作者:HAN  
    日期:2025-3-6
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: CountOrder_DiffTransfer
 
    功能:
        根据点中的盘点单把盘点单相关的盘点差异进行盘点差异处理
        -- 把盘点差异上传巨沃(只上传盘亏)
        -- 调整WMS的库存量
 
    更改记录:
 
--]]
wms_count= require( "wms_count" )
jx_base = require( "jx_base" )
 
function CountOrder_DiffTransfer( strLuaDEID ) 
    local nRet, strRetInfo, n
    local count_order
 
    m3.PrintLuaDEInfo( strLuaDEID )
 
    -- step1  获取当前点中的[盘点单]
    nRet, objs = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end  
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    local nCount = #objs
    if (nCount == 0) then  return end
 
    -- 获取盘点单对象
    local msg = ""
    for n = 1, nCount do
        strCondition = "S_ID = '"..lua.trim_guid_str( objs[n].id ).."'"
        nRet, count_order = m3.GetDataObjByCondition(strLuaDEID, "Count_Order", strCondition )
        if ( nRet ~= 0 ) then return 2, "m3.ObjAttrStrToLuaObj(Count_Order) 失败! "..count_order end
 
        -- 如果是货物盘点需要判断盘点单是否已经上传巨沃 cr_state = 1 表示成功上传
        if ( count_order.cr_state ~= 1 and count_order.count_type == wms_base.Get_nConst( strLuaDEID, "盘点类型-货品盘点")) then
            msg = msg.."盘点单'"..count_order.count_no.."'盘点结果还没有上传巨沃,无法做差异转移!\r\n"
        else
            nRet, strRetInfo = jx_base.CountOrder_Transfter ( strLuaDEID, count_order ) 
            -- 返回2说明是致命错误
            if ( nRet ~= 0 ) then
                if ( nRet == 2 ) then return 2, strRetInfo end
                msg = msg..strRetInfo.."\r\n"
            end
        end
    end
    if ( msg ~= '' ) then
        mobox.setInfo(  strLuaDEID, msg )
    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