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
--[[
   编码: JX-28-15
   名称: 回报失败后再次回报
   作者:KUN
   日期:2025-03-18
 
   函数: CompletionReturn
   功能:
        -- 盘点库存调整后,调接口失败,再次进行回报
        -- 条件是回报状态 = 2 失败
        -- 按钮触发
        
 
   更改记录:
 
--]]
 
jx_base = require("jx_base")
jx_api = require("jx_external_api")
 
function CompletionReturn(strLuaDEID)
    local nRet, strRetInfo
    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 nCount = #data_json
    if (nCount == 0) then 
        return 
    end
    
    lua.Debug( strLuaDEID, debug.getinfo(1), "data_json", data_json )
    
    local id
    local strCondition, strSetAttr
    local jx_task
    local curTime = os.date("%Y-%m-%d %H:%M:%S")
    local refresh = false
 
    for n = 1, #data_json do
        id = lua.trim_guid_str(data_json[n].id)
        strCondition = "S_ID = '" .. lua.trim_guid_str(data_json[n].id) .. "'"
        nRet, count_obj = m3.GetDataObjByCondition(strLuaDEID, "Count_Order", strCondition)
        
        lua.Debug(strLuaDEID, debug.getinfo(1), "count_obj", count_obj)
        
        if ( nRet == 0 ) then
            if ( count_obj.cr_state == 2 or count_obj.cr_state == 3) then
                
                nRet, strRetInfo = jx_api.JW_WMS_API_newOffShelfs( strLuaDEID, count_obj.count_no )
        
                -- 更新盘点单的差异回报属性
                local curTime = os.date("%Y-%m-%d %H:%M:%S")
                strCondition = "S_COUNT_NO = '"..count_obj.count_no.."'"
                local strSetAttr
                if ( nRet == 0 ) then
                    strSetAttr = "N_DR_STATE = 1, S_DR_ERR = '', T_CR = '"..curTime.."'"
                else
                    lua.Debug( strLuaDEID, debug.getinfo(1), "JW-WMS SetPLCJobStatus 接口错误", strRetInfo )
                    strSetAttr = "N_DR_STATE = 2, S_DR_ERR = 'JW-WMS SetPLCJobStatus 接口错误, 详细信息看日志!', T_CR = '"..curTime.."'"
                end
                nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Order", strCondition, strSetAttr )
                if ( nRet ~= 0 ) then  
                    lua.Error( strLuaDEID, debug.getinfo(1), "更新盘点单差异回报失败!"..strRetInfo )
                end   
            end
        end
 
 
    end
 
    if (refresh == false) then return 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