1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
--[[
 
    编码: JX-API-OUTBOUND-01
    名称: 创建出库单及明细
    作者: 
    日期: 2025-1-29
 
    入口函数: main
    请求示例:
    {
        "taskId": "361de469-8f6b-42c8-8cf1-054a8024ea5b",
        "startLoc": "XC-01-01",
        "destLoc": "XC-05-02",
        "cid": "T001",
        "priority": 0,
        "memo": ""
    }
    响应示例:
    {
        "flag": "success",
        "code": "0",
        "message": "成功"
    }
]]--
 
json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
wms_base = require( "wms_base" )
 
function CreateAgvOperation(strLuaDEID)
 
    local nRet, strRetInfo
    local data
    local start_loc_info
    local end_loc_info
 
    -- step1 获取接口中的Data
    nRet, data = m3.GetSysDataJson(strLuaDEID) -- 获取物料信息数据包
 
    if (nRet ~= 0) then
        Error(strLuaDEID, debug.getinfo(1), '任务创建接口获取data失败!')
    end
 
    local taskNo = tostring(data.taskId) -- 任务号
    local locStart = data.startLoc -- 起点
    local locEnd = data.destLoc -- 终点
    local cntr = data.cid
    local priority = data.priority
    local memo = data.memo
 
    ---------------
    -- local cntrcode = data.cntrCode  --托盘码
 
    -- if (task_type == nil or task_type == '') then
    --     Error(strLuaDEID, debug.getinfo(1), '参数缺少任务类型!')
    -- end
 
    if (locStart == nil or locStart == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少起点!')
    end
    if (locEnd == nil or locEnd == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少终点!')
    end
    if (priority == nil or priority == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少优先级!')
    end
 
    if (taskNo == nil or taskNo == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), '参数缺少任务号!')
    end
 
    if (cntr == nil or cntr == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), '参数容器!')
    end
 
    -- -- 获取起点信息
    -- nRet, start_loc_info = WMS_GetLocInfo(locStart)
 
    -- if (nRet ~= 0) then
    --     Error(strLuaDEID, debug.getinfo(1), start_loc_info)
    -- end
    -- Debug(strLuaDEID, debug.getinfo(1), "start_loc_info", start_loc_info)
 
    -- -- 获取终点信息
    -- nRet, end_loc_info = WMS_GetLocInfo(locEnd)
    -- if (nRet ~= 0) then
    --     Error(strLuaDEID, debug.getinfo(1), end_loc_info)
    -- end
    -- Debug(strLuaDEID, debug.getinfo(1), "end_loc_info", end_loc_info)
 
 
    -- 创建作业
    local operation = m3.AllocObject(strLuaDEID, 'Operation')
 
    operation.factory = "HC" -- 工厂
    operation.op_def_name = "AGV点对点" -- 作业名称
    operation.ext_data = taskNo -- 扩展数据(任务号)
    operation.priority = priority -- 优先级
    operation.op_type = 1
    operation.bs_state = 1
    -- 起点信息
    -- operation.start_wh_code = start_loc_info.wh_code -- 仓库
    -- operation.start_area_code = start_loc_info.area_code -- 库区
    operation.start_loc_code = locStart-- 货位
    -- 终点信息
    -- operation.end_wh_code = end_loc_info.wh_code -- 终点仓库
    -- operation.end_area_code = end_loc_info.area_code -- 终点库区
    operation.end_loc_code = locEnd -- 终点货位
 
    operation.cntr_code = cntr
    operation.note = memo
 
    nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, operation)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), '创建【作业】失败!' .. strRetInfo)
    end
    -- local errMsg = "作业创建成功"
    -- mobox.returnValue(strLuaDEID, 1, errMsg)
 
    local result = '{"flag":"success","code":"0","message":"成功"}'
    mobox.returnValue(strLuaDEID, 1, result)
end