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-24-22
    名称: 出库单-回报失败后再次回报
    作者: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 outound_order
    local curTime = os.date("%Y-%m-%d %H:%M:%S")
    local refrush = false
    local err_msg = ""
    for n = 1, #data_json do
        strCondition = "S_ID = '"..lua.trim_guid_str( data_json[n].id ).."'"
        nRet, outound_order = m3.GetDataObjByCondition(strLuaDEID, "Outbound_Order", strCondition )
        if ( nRet == 0 ) then
            if ( outound_order.create_method == "JW-WMS" and ( outound_order.cr_state == 2 or outound_order.cr_state == 3 ) ) then
                nRet, strRetInfo = jx_api.JW_WMS_API_subPickDown( strLuaDEID, outound_order.no )
                -- 更新出库单的完工回报属性
                strCondition = "S_NO = '"..outound_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 subPickDown 接口错误", strRetInfo )
                    err_msg = "JW-WMS subPickDown 接口错误! --> "..lua.FormatSQLString( strRetInfo )
                    strSetAttr = "N_CR_STATE = 2, S_CR_ERR = '"..err_msg.."', T_CR = '"..curTime.."'"
                    mobox.setInfo(strLuaDEID, "重推失败!错误信息: " .. strRetInfo)
                end
                nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_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 = ""
        }
    }
    mobox.setInfo( strLuaDEID, "重推成功!" )  
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str( action ))
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end          
end