From a2861d59d2245b349ded89a6afe8249dd96c52e1 Mon Sep 17 00:00:00 2001 From: fy36 <1046342473@qq.com> Date: 星期一, 09 六月 2025 20:58:05 +0800 Subject: [PATCH] 1. 国科盘点信息同步功能代码校验 2. 小件收货信息同步 3. 完善SKU同步Grid料箱 --- lua_code/Lua/Receipt_Sync.lua | 51 ++++++++++++++++++++++++++++++++------------------- 1 files changed, 32 insertions(+), 19 deletions(-) diff --git a/lua_code/Lua/Receipt_Sync.lua b/lua_code/Lua/Receipt_Sync.lua index 8abe6e7..8305e15 100644 --- a/lua_code/Lua/Receipt_Sync.lua +++ b/lua_code/Lua/Receipt_Sync.lua @@ -80,10 +80,16 @@ xml = require("oi_base_xml") mobox = require("OILua_JavelinExt") m3 = require("oi_base_mobox") +function Create_result(flag, code, msg) + return { + flag = flag or "success", + code = code or "0", + message = msg or "" + } +end function Receipt_Sync(strLuaDEID) -- 鍒濆鍖栨渶缁堢粨鏋� local FinalRes = Create_result() - -- 1. 鑾峰彇 xml 鏁版嵁鍖� local nRet, soap_xml = mobox.getCurEditDataPacket(strLuaDEID) if nRet ~= 0 then @@ -99,7 +105,7 @@ -- 2. 瑙f瀽 xml local nRet, parsed_data = xml.parse(soap_xml) if nRet ~= 0 then - FinalRes = Create_result("failure", "202", "xml 鏍煎紡闈炴硶") + FinalRes = Create_result("failure", "202", "xml 鏍煎紡闈炴硶" .. parsed_data) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) lua.Stop(strLuaDEID, "xml鏍煎紡闈炴硶", parsed_data) @@ -126,16 +132,26 @@ end -- 5. 鑾峰彇绯荤粺甯搁噺 - local RetWH_COE, CONST_WH = wms_base.Get_sConst2(strLuaDEID, "GK_Default_Warehouse") - local RetFAC_COE, CONST_FACTORY = wms_base.Get_sConst2(strLuaDEID, "GK_Default_Factory") - if (RetWH_COE ~= 0 or RetFAC_COE ~= 0) then - FinalRes = Create_result("failure", "204", "鑾峰彇浠撳簱/宸ュ巶甯搁噺澶辫触") + local RetWH_COE, CONST_WH = wms_base.Get_sConst2("GK_Default_Warehouse") + local RetFAC_COE, CONST_FACTORY = wms_base.Get_sConst2("GK_Default_Factory") + + -- 浠撳簱甯搁噺寮傚父鎹曡幏 + if (RetWH_COE ~= 0) then + FinalRes = Create_result("failure", "204", "鑾峰彇浠撳簱甯搁噺澶辫触" .. CONST_WH) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) - lua.Stop(strLuaDEID, "鑾峰彇绯荤粺甯搁噺澶辫触", xml_result) + lua.Stop(strLuaDEID, "鑾峰彇绯荤粺甯搁噺锛欸K_Default_Warehouse 澶辫触", xml_result) return end + -- 宸ュ巶甯搁噺寮傚父鎹曡幏 + if (RetFAC_COE ~= 0) then + FinalRes = Create_result("failure", "204", "鑾峰彇宸ュ巶甯搁噺澶辫触" .. CONST_FACTORY) + local xml_result = xml.json_to_xml(FinalRes, "response") + mobox.returnValue(strLuaDEID, 0, xml_result, 0) + lua.Stop(strLuaDEID, "鑾峰彇绯荤粺甯搁噺锛欸K_Default_Factory澶辫触", xml_result) + return + end -- 6. 閬嶅巻鎵�湁鏀惰揣鍗� for i = 1, #receipt_headers do local header = receipt_headers[i] @@ -147,8 +163,7 @@ if nRet == 0 then -- 鏌ヨ鎴愬姛涓旀壘鍒拌褰曪紝璇存槑鏀惰揣鍗曞凡瀛樺湪 lua.DebugEx(strLuaDEID, "鏌ヨ鎴愬姛锛屾敹璐у崟宸插瓨鍦�, retReceipt) - FinalRes = Create_result("failure", "1", "鏀惰揣鍗曞凡瀛樺湪", - "鏀惰揣鍗昜" .. header.orderNo .. "]宸插瓨鍦�) + FinalRes = Create_result("failure", "1", "鏀惰揣鍗昜" .. header.orderNo .. "]宸插瓨鍦�) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) lua.Stop(strLuaDEID, "鏀惰揣鍗曞凡瀛樺湪", retReceipt) @@ -156,7 +171,7 @@ elseif nRet ~= 1 then -- 鏌ヨ鍑洪敊 lua.DebugEx(strLuaDEID, "鏌ヨ鍑洪敊", retReceipt) - FinalRes = Create_result("failure", "206", "妫�煡鏀惰揣鍗曟槸鍚﹀瓨鍦ㄦ椂鍑洪敊", + FinalRes = Create_result("failure", "206", "妫�煡鏀惰揣鍗昜" .. header.orderNo .. "]鏃跺嚭閿� " .. retReceipt) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) @@ -181,10 +196,9 @@ -- 鍐嶆妫�煡鏄惁鐪熺殑瀛樺湪 local nRetCheck, retReceiptCheck = m3.GetDataObjByCondition(strLuaDEID, "Receipt_Order", strCondition) if nRetCheck == 0 then - FinalRes = Create_result("failure", "205", "鏀惰揣鍗曞凡瀛樺湪", - "鏀惰揣鍗昜" .. header.orderNo .. "]宸插瓨鍦�) + FinalRes = Create_result("failure", "205", "鏀惰揣鍗昜" .. header.orderNo .. "]宸插瓨鍦�) else - FinalRes = Create_result("failure", "207", "鍒涘缓鏀惰揣鍗曚富琛ㄥけ璐�, + FinalRes = Create_result("failure", "207", "鏀惰揣鍗昜" .. header.orderNo .. "]鍒涘缓澶辫触: " .. ret_info) end local xml_result = xml.json_to_xml(FinalRes, "response") @@ -196,8 +210,7 @@ -- 妫�煡鏄庣粏鏁版嵁鏄惁瀛樺湪 if header.SmallPiece_TB_ITEM == nil then lua.DebugEx(strLuaDEID, "璀﹀憡锛氭敹璐у崟 " .. header.orderNo .. " 鏃犳槑缁嗘暟鎹�) - FinalRes = Create_result("failure", "208", "鏀惰揣鍗曟棤鏄庣粏鏁版嵁", - "鏀惰揣鍗昜" .. header.orderNo .. "]鏃犳槑缁嗘暟鎹�) + FinalRes = Create_result("failure", "208", "鏀惰揣鍗昜" .. header.orderNo .. "]鏃犳槑缁嗘暟鎹�) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) lua.Stop(strLuaDEID, "鏀惰揣鍗曟棤鏄庣粏鏁版嵁", xml_result) @@ -220,15 +233,15 @@ if (nRet ~= 0) then lua.DebugEx(strLuaDEID, "SKU鏌ヨ鍑洪敊", "ITEM_CODE: " .. item.skuId .. ", 閿欒淇℃伅: " .. receiptInfo) - FinalRes = Create_result("failure", "207", "妫�煡 SKU 鏄惁瀛樺湪鏃跺嚭閿�, - "SKU ID: " .. item.skuId .. ", 閿欒: " .. receiptInfo) + FinalRes = Create_result("failure", "207", + "妫�煡 SKU 鏄惁瀛樺湪鏃跺嚭閿�SKU ID涓�" .. item.skuId .. ", 閿欒: " .. receiptInfo) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) lua.Stop(strLuaDEID, "鏌ヨ澶辫触", xml_result) return elseif (receiptInfo == "") then lua.DebugEx(strLuaDEID, "鏌ヨ涓虹┖", "ITEM_CODE:" .. item.skuId) - FinalRes = Create_result("failure", "208", "鏌ヨ鏁版嵁涓虹┖", "ITEM_CODE : " .. item.skuId) + FinalRes = Create_result("failure", "208", "鏌ヨ鏁版嵁涓虹┖锛欼TEM_CODE : " .. item.skuId) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) lua.Stop(strLuaDEID, "鐗╂枡鏁版嵁涓嶅瓨鍦�, xml_result) @@ -261,7 +274,7 @@ lua.DebugEx(strLuaDEID, "鍒涘缓鏄庣粏鏁版嵁:", receipt_detail) local nRet, ret_info = m3.CreateDataObj(strLuaDEID, receipt_detail) if nRet ~= 0 then - FinalRes = Create_result("failure", "208", "鍒涘缓鏀惰揣鏄庣粏澶辫触", "鍒涘缓澶辫触: " .. ret_info) + FinalRes = Create_result("failure", "208", "鍒涘缓鏀惰揣鏄庣粏澶辫触: " .. ret_info) local xml_result = xml.json_to_xml(FinalRes, "response") mobox.returnValue(strLuaDEID, 0, xml_result, 0) lua.DebugEx(strLuaDEID, "鍒涘缓鏀惰揣鏄庣粏澶辫触", xml_result) -- Gitblit v1.9.1