lzh
2025-06-19 3a6436e0c88042c6ce8dca2fe8adb0109f0ad9e4
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
json     = require("json")
mobox    = require("OILua_JavelinExt")
m3       = require("oi_base_mobox")
wms_task = require("wms_task")
function test(strLuaDEID)
  -- 获取作业信息
  local condition = "S_CODE = ''"
  nRet, operation = m3.GetDataObjByCondition(strLuaDEID, "Operation", condition)
  if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), operation) end
  -- 获取扩展数据参数
  local ext_data    = json.decode(operation.ext_data)
  local delivery_no = ext_data.delivery_no -- 业务单号为 出库单号
  --获取出库单信息
  local stock_out
  condition         = "S_DO_NO = '" .. delivery_no .. "'"
  nRet, stock_out   = m3.GetDataObjByCondition(strLuaDEID, "GT_Stock_Out", condition)
  if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), stock_out) end
  -- 获取容器货品明细
  local cg_detail
  condition       = "S_CNTR_CODE = '" .. operation.cntr_code .. "'"
  nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", condition)
  if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), cg_detail) end
  -- 获取入库单据行信息
  local label_crad
  local strCondition = "S_SERIAL_NO = '" .. cg_detail.serial_no .. "'"
  if (tonumber(cg_detail.is_tl) == 1) then
    nRet, label_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_ROM", strCondition, "T_CREATE DESC")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取流水号信息失败!" .. label_crad) end
  else
    nRet, label_crad = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition, "T_CREATE DESC")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取流水号信息失败!" .. label_crad) end
  end
  -- 获取入库单据头信息
  local incoming_Info
  condition = "S_DELIVERY_NO = '" ..
      label_crad.delivery_no .. "' AND N_DELIVERY_ROW_NO = '" .. label_crad.delivery_row_no .. "'"
  nRet, incoming_Info = m3.GetDataObjByCondition(strLuaDEID, "GT_Incoming_Info", condition, "T_CREATE DESC")
  if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取入库单据头信息失败!" .. incoming_Info) end
 
  -- 出库结果回传
  local data
  local source = "GTWMS出库回传"
  nRet, data   = StorageResult(strLuaDEID, operation.code, source)
  if (nRet ~= 0) then
    lua.Error(strLuaDEID, debug.getinfo(1), "出库结果回传失败!" .. data)
  end
  lua.Debug(strLuaDEID, debug.getinfo(1), 'data', data)
 
  -- 调用GT-WMS的回传接口
  local url = wms_base.Get_sConst(strLuaDEID, "GTWMS-url")
  local strurl = url
  local strHeader = ""
  local strBody = {
    application = "GITI",
    code = "WCS_SO_WMS",
    data = data
  }
  nRet, strRetInfo = CreateInterfaceExc(strLuaDEID, strurl, strHeader, strBody, "GTWMS", source)
  if (nRet ~= 0) then
    lua.Error(strLuaDEID, debug.getinfo(1), "调用接口失败!" .. strRetInfo)
  end
end