schangxiang@126.com
2025-09-11 e86f3bddecdc13210a546761ecf5e8550ea20799
wcs/yunneiWCS/yunneiWCS/SystemInteraction/mes2/PushMesHandler.cs
@@ -26,15 +26,16 @@
        /// </summary>
        /// <param name="pushData"></param>
        /// <returns></returns>
        public static ApiResponse<object> Mes_InStockSend(List<InboundStockInfoToMes> pushData, string _identifier, LogType _logType)
        public static mesMsg Mes_InStockSend(List<InboundStockInfoToMes> pushData, LogType _logType)
        {
            ApiResponse<object> res = null;
            mesMsg res = null;
            var funName = "Mes_InStockSend";
            try
            {
                MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>();
                mesRequest.data = pushData;
                mesRequest.identifier = _identifier;
                mesRequest.Datas = pushData;
                mesRequest.TableName = "T_WMS_Inbound_Record";
                mesRequest.PrimaryKeys = "identifier";
                string paprm = JsonConvert.SerializeObject(mesRequest);
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},准备参数:{paprm}");
@@ -43,15 +44,15 @@
                //模拟
                if (Form1.isvirtual)
                {//模拟环境
                    res = new ApiResponse<object>();
                    res.Success = true;
                    res.Message = "系统模拟完成";
                    res = new mesMsg();
                    res.ErrorCode = 0;
                    res.ErrorMsg = "系统模拟完成";
                }
                else
                {
                    var resStr = mes_api.postContentForString("T_WMS_Inbound_Record", paprm, guid);
                    var resStr = mes_api.postContentForString("", paprm, guid);
                    Log4NetHelper.WriteInfoLog(_logType, $"{funName},结果返回:{resStr}");
                    res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr);
                    res = JsonConvert.DeserializeObject<mesMsg>(resStr);
                }
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},参数:{paprm},返回:{JsonConvert.SerializeObject(res)}");
@@ -59,7 +60,8 @@
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(_logType, $"{funName},异常:" + ex.Message, ex);
                res.Message = "发送异常:" + ex.Message;
                res.ErrorCode = 4;
                res.ErrorMsg = "wms发送异常:" + ex.Message;
            }
            return res;
@@ -71,15 +73,16 @@
        /// </summary>
        /// <param name="pushData"></param>
        /// <returns></returns>
        public static ApiResponse<object> Mes_OutStockSend(List<InboundStockInfoToMes> pushData, string _identifier, LogType _logType)
        public static mesMsg Mes_OutStockSend(List<InboundStockInfoToMes> pushData, LogType _logType)
        {
            ApiResponse<object> res = null;
            mesMsg res = null;
            var funName = "Mes_OutStockSend";
            try
            {
                MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>();
                mesRequest.data = pushData;
                mesRequest.identifier = _identifier;
                mesRequest.Datas = pushData;
                mesRequest.TableName = "T_WMS_Outbound_Record";
                mesRequest.PrimaryKeys = "identifier";
                string paprm = JsonConvert.SerializeObject(mesRequest);
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},准备参数:{paprm}");
@@ -87,15 +90,15 @@
                //模拟
                if (Form1.isvirtual)
                {//模拟环境
                    res = new ApiResponse<object>();
                    res.Success = true;
                    res.Message = "系统模拟完成";
                    res = new mesMsg();
                    res.ErrorCode = 0;
                    res.ErrorMsg = "系统模拟完成";
                }
                else
                {
                    var resStr = mes_api.postContentForString("T_WMS_Outbound_Record", paprm, guid);
                    var resStr = mes_api.postContentForString("", paprm, guid);
                    Log4NetHelper.WriteInfoLog(_logType, $"{funName},结果返回:{resStr}");
                    res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr);
                    res = JsonConvert.DeserializeObject<mesMsg>(resStr);
                }
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},参数:{paprm},返回:{JsonConvert.SerializeObject(res)}");
@@ -103,7 +106,8 @@
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(_logType, $"{funName},异常:" + ex.Message, ex);
                res.Message = "发送异常:" + ex.Message;
                res.ErrorCode = 4;
                res.ErrorMsg = "wms发送异常:" + ex.Message;
            }
            return res;
@@ -115,39 +119,47 @@
        /// </summary>
        /// <param name="pushData"></param>
        /// <returns></returns>
        public static ApiResponse<object> Mes_StockSend(List<InboundStockInfoToMes> pushData, LogType _logType)
        public static mesMsg Mes_StockSend(LogType _logType, List<InboundStockInfoToMes> pushData, LogType _logTypeForInfo)
        {
            ApiResponse<object> res = null;
            mesMsg res = null;
            var funName = "Mes_StockSend";
            try
            {
                MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>();
                mesRequest.data = pushData;
                mesRequest.Datas = pushData;
                mesRequest.TableName = "T_WMS_Realtime_Data";
                mesRequest.PrimaryKeys = "serialNumber,positionName";
                string paprm = JsonConvert.SerializeObject(mesRequest);
                Guid guid = System.Guid.NewGuid();
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},准备参数:{paprm}");
                Log4NetHelper.WriteInfoLog(_logTypeForInfo, $"{funName},准备参数:{paprm}");
                var numCount = $"{pushData.Count()}条";
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},准备参数:{numCount}");
                //模拟
                if (Form1.isvirtual)
                {//模拟环境
                    res = new ApiResponse<object>();
                    res.Success = true;
                    res.Message = "系统模拟完成";
                    res = new mesMsg();
                    res.ErrorCode = 0;
                    res.ErrorMsg = "系统模拟完成";
                }
                else
                {
                    var resStr = mes_api.postContentForString("T_WMS_Realtime_Data", paprm, guid);
                    var resStr = mes_api.postContentForString("", paprm, guid);
                    Log4NetHelper.WriteInfoLog(_logTypeForInfo, $"{funName},结果返回:{resStr}");
                    Log4NetHelper.WriteInfoLog(_logType, $"{funName},结果返回:{resStr}");
                    res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr);
                    res = JsonConvert.DeserializeObject<mesMsg>(resStr);
                }
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},参数:{paprm},返回:{JsonConvert.SerializeObject(res)}");
                Log4NetHelper.WriteInfoLog(_logTypeForInfo, $"{funName},参数:{paprm},返回:{JsonConvert.SerializeObject(res)}");
                Log4NetHelper.WriteInfoLog(_logType, $"{funName},参数:{numCount},返回:{JsonConvert.SerializeObject(res)}");
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteErrorLog(_logTypeForInfo, $"{funName},异常:" + ex.Message, ex);
                Log4NetHelper.WriteErrorLog(_logType, $"{funName},异常:" + ex.Message, ex);
                res.Message = "发送异常:" + ex.Message;
                res.ErrorCode = 4;
                res.ErrorMsg = "wms发送异常:" + ex.Message;
            }
            return res;