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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--[[
    编码: WMS-20-25
    名称: 入库单-回报失败后再次回报
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: CompletionReturn
 
    功能:
        -- 和JW-WMS回报失败后,通过该脚本进行再次回报
        -- 条件是 巨星任务 的回报状态 = 2 失败
        -- 行按钮/页面按钮触发
 
    更改记录:
 
--]]
jx_base= require( "jx_base" )
jx_api = require ( "jx_external_api")
 
function CompletionReturn ( strLuaDEID ) 
    local nRet, strRetInfo
    -- step1  获取当前选中的巨星任务
    local data_json, obj_attrs
    nRet, data_json = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), data_json ) end  
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    local nCount = #data_json
    if ( nCount == 0 ) then  return end
    
    local strCondition, strSetAttr
    local inbound_order
    local curTime = os.date("%Y-%m-%d %H:%M:%S")
    local refrush = false
    for n = 1, #data_json do
        strCondition = "S_ID = '"..lua.trim_guid_str( data_json[n].id ).."'"
        nRet, inbound_order = m3.GetDataObjByCondition(strLuaDEID, "Inbound_Order", strCondition )
        if ( nRet == 0 ) then
            if ( inbound_order.create_method == "JW-WMS" and ( inbound_order.cr_state == 2 or inbound_order.cr_state == 3 ) ) then
                nRet, strRetInfo = jx_api.JW_WMS_API_newTrans( strLuaDEID, inbound_order.no )
                -- 更新出库单的完工回报属性
                strCondition = "S_NO = '"..inbound_order.no.."'"
                if ( nRet == 0 ) then
                    strSetAttr = "N_CR_STATE = 1, S_CR_ERR = '', T_CR = '"..curTime.."'"
                else
                    lua.Debug( strLuaDEID, debug.getinfo(1), "JW-WMS newTrans接口错误", strRetInfo )
                    strSetAttr = "N_CR_STATE = 2, S_CR_ERR = 'JW-WMS newTrans 接口错误, 详细信息看日志!', T_CR = '"..curTime.."'"
                end
                nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Inbound_Order", strCondition, strSetAttr )
                if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【入库单】完工回报信息失败!"..strRetInfo ) end   
                refrush = true                
            end
        end
    end
    
    if ( refrush == 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