wsz
2025-06-20 19898bd66dec87b500b200d5d50961d0fb538ce5
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
--[[
    编码: JX-108-13
    名称: 巨星任务-完工回报
    作者:HAN  
    日期:2025-1-29
    级别:项目
    
    函数: CompletionReturn
 
    功能:
        需要把入库任务完成情况反馈给巨星WMS系统
 
    更改记录:
 
--]]
jx_base= require( "jx_base" )
jx_api = require ( "jx_external_api")
 
function CompletionReturn ( strLuaDEID ) 
    local nRet, strRetInfo
    local jx_task = {}
    nRet, jx_task = m3.GetSysCurEditDataObj( strLuaDEID, "JX_Task" )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【巨星任务】对象属性失败!"..jx_task ) end
    
    -- 如果已经报过完工或报工,不需要报完工,如果没完成也不需要执行后面的报告
    if ( jx_task.cr_state ~= 0 ) then return end
 
    if ( jx_task.create_method == "JX-WMS" ) then
        --巨星要求有一个站台搬运的类型,本质上没有变化,只是类型不同,等同于入库
        if ( jx_task.task_type == "入库" or jx_task.task_type == "站台搬运") then
            nRet, strRetInfo = jx_api.WMS_API_PutOn( strLuaDEID, jx_task )
            -- MDY BY KUN 20241216
            if (nRet == 0) then
                nRet, strRetInfo = jx_api.WMS_API_SetPLCJobStatus(strLuaDEID, jx_task,"Y")--传Y
            end
        elseif ( jx_task.task_type == "出库" ) then
            nRet, strRetInfo = jx_api.WMS_API_SetPLCJobStatus( strLuaDEID, jx_task,"Y")
        end
    else
        nRet = 0
    end
    -- 更新出库单的完工回报属性
    local curTime = os.date("%Y-%m-%d %H:%M:%S")
    strCondition = "S_SOURNO = '"..jx_task.sour_no.."'"
    local strSetAttr
    if ( nRet == 0 ) then
        strSetAttr = "N_CR_STATE = 1, S_CR_ERR = '', T_CR = '"..curTime.."'"
    else
        lua.Debug( strLuaDEID, debug.getinfo(1), "JW-WMS SetPLCJobStatus 接口错误", strRetInfo )
        strSetAttr = "N_CR_STATE = 2, S_CR_ERR = 'JW-WMS SetPLCJobStatus 接口错误, 详细信息看日志!', T_CR = '"..curTime.."'"
    end
    nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strSetAttr )
    if ( nRet ~= 0 ) then  lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】完工回报信息失败!"..strRetInfo ) end          
end