From c9c91ad3e3ac218d81c86809c93a35622b51a686 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周三, 17 9月 2025 16:05:05 +0800
Subject: [PATCH] 初步 增加 推送线程

---
 DEmon/iWareCc/SystemInteraction/PushMesHandler.cs |  112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 112 insertions(+), 0 deletions(-)

diff --git a/DEmon/iWareCc/SystemInteraction/PushMesHandler.cs b/DEmon/iWareCc/SystemInteraction/PushMesHandler.cs
new file mode 100644
index 0000000..59a9d63
--- /dev/null
+++ b/DEmon/iWareCc/SystemInteraction/PushMesHandler.cs
@@ -0,0 +1,112 @@
+锘縰sing Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace iWareCc
+{
+    /// <summary>
+    /// MES鎺ㄩ�佹帴鍙�
+    /// </summary>
+    public class PushMesHandler
+    {
+        public static string mes_api_url = "";// ConfigHelper.GetConfigString("MesUrl");//淇敼涓洪厤缃枃浠� 銆怑ditBy shaocx,2022-01-27銆�
+        static HTTPService mes_api = new HTTPService(mes_api_url);//mes鍩哄湴鍧�
+
+        /// <summary>
+        /// 缁橫ES鎺ㄩ�佸叆搴撲俊鎭�
+        /// </summary>
+        /// <param name="pushData"></param>
+        /// <returns></returns>
+        public static ApiResponse<string> Mes_InStockSend(List<InboundStockInfoToMes> pushData)
+        {
+            ApiResponse<string> res = null;
+            var funName = "Mes_InStockSend";
+            try
+            {
+                MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>();
+                mesRequest.Datas = pushData;
+                mesRequest.TableName = "T_WMS_Inbound_Record";
+                mesRequest.PrimaryKeys = "identifier";
+
+                string paprm = JsonConvert.SerializeObject(mesRequest);
+                //Log4NetHelper.WriteInfoLog(_logType, $"{funName},鍑嗗鍙傛暟:{paprm}");
+                Guid guid = System.Guid.NewGuid();
+
+                //妯℃嫙
+                if (1 == 2)
+                {//妯℃嫙鐜
+                    res = new ApiResponse<string>();
+                    res.Code = 500;
+                    res.Success = false;
+                    res.Message = "绯荤粺妯℃嫙瀹屾垚";
+                }
+                else
+                {
+                    var resStr = mes_api.postContentForString("", paprm, guid);
+                    //Log4NetHelper.WriteInfoLog(_logType, $"{funName},缁撴灉杩斿洖:{resStr}");
+                    res = JsonConvert.DeserializeObject<ApiResponse<string>>(resStr);
+                }
+
+                //Log4NetHelper.WriteInfoLog(_logType, $"{funName},鍙傛暟:{paprm},杩斿洖:{JsonConvert.SerializeObject(res)}");
+            }
+            catch (Exception ex)
+            {
+                //Log4NetHelper.WriteErrorLog(_logType, $"{funName},寮傚父:" + ex.Message, ex);
+                res.Code = 500;
+                res.Success = false;
+                res.Message = "wms鍙戦�佸紓甯�:" + ex.Message;
+            }
+            return res;
+
+        }
+
+
+        ///// <summary>
+        ///// 缁橫ES鎺ㄩ�佸嚭搴撲俊鎭�
+        ///// </summary>
+        ///// <param name="pushData"></param>
+        ///// <returns></returns>
+        //public static ApiResponse Mes_OutStockSend(List<InboundStockInfoToMes> pushData, LogType _logType)
+        //{
+        //    ApiResponse<string> res = null;
+        //    var funName = "Mes_OutStockSend";
+        //    try
+        //    {
+        //        MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>();
+        //        mesRequest.Datas = pushData;
+        //        mesRequest.TableName = "T_WMS_Outbound_Record";
+        //        mesRequest.PrimaryKeys = "identifier";
+
+        //        string paprm = JsonConvert.SerializeObject(mesRequest);
+        //        //Log4NetHelper.WriteInfoLog(_logType, $"{funName},鍑嗗鍙傛暟:{paprm}");
+        //        Guid guid = System.Guid.NewGuid();
+        //        //妯℃嫙
+        //        if (Form1.isvirtual)
+        //        {//妯℃嫙鐜
+        //            res = new ApiResponse<string>();
+        //            res.ErrorCode = 0;
+        //            res.ErrorMsg = "绯荤粺妯℃嫙瀹屾垚";
+        //        }
+        //        else
+        //        {
+        //            var resStr = mes_api.postContentForString("", paprm, guid);
+        //            //Log4NetHelper.WriteInfoLog(_logType, $"{funName},缁撴灉杩斿洖:{resStr}");
+        //            res = JsonConvert.DeserializeObject<ApiResponse<string>>(resStr);
+        //        }
+
+        //        //Log4NetHelper.WriteInfoLog(_logType, $"{funName},鍙傛暟:{paprm},杩斿洖:{JsonConvert.SerializeObject(res)}");
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        //Log4NetHelper.WriteErrorLog(_logType, $"{funName},寮傚父:" + ex.Message, ex);
+        //        res.ErrorCode = 4;
+        //        res.ErrorMsg = "wms鍙戦�佸紓甯�:" + ex.Message;
+        //    }
+        //    return res;
+
+        //}
+
+
+    }
+}

--
Gitblit v1.9.3