| | |
| | | <!--æ¯å¦æ¯èæä»¿ç模å¼,true:æ¯ï¼falseï¼å¦ãç产ç¯å¢è¦é
置为false ãEditBy shaocx,2022-01-27ã--> |
| | | <add key="IsVirtualMode" value="true"/> |
| | | <!--MESå°å ãEditBy shaocx,2025-08-27ã--> |
| | | <add key="MesUrl" value="http://192.168.6.47:8000/api/Save/"/> |
| | | <add key="MesUrl" value="http://192.168.6.47:8000/api/Save"/> |
| | | </appSettings> |
| | | |
| | | <system.serviceModel> |
| | |
| | | <!--æ¯å¦æ¯èæä»¿ç模å¼,true:æ¯ï¼falseï¼å¦ãç产ç¯å¢è¦é
置为false ãEditBy shaocx,2022-01-27ã--> |
| | | <add key="IsVirtualMode" value="false"/> |
| | | <!--MESå°å ãEditBy shaocx,2025-08-27ã--> |
| | | <add key="MesUrl" value="http://192.168.6.47:8000/api/Save/"/> |
| | | <add key="MesUrl" value="http://192.168.6.47:8000/api/Save"/> |
| | | </appSettings> |
| | | <system.serviceModel> |
| | | |
| | |
| | | <!--æ¯å¦æ¯èæä»¿ç模å¼,true:æ¯ï¼falseï¼å¦ãç产ç¯å¢è¦é
置为false ãEditBy shaocx,2022-01-27ã--> |
| | | <add key="IsVirtualMode" value="true"/> |
| | | <!--MESå°å ãEditBy shaocx,2025-08-27ã--> |
| | | <add key="MesUrl" value="http://192.168.6.47:8000/api/Save/"/> |
| | | <add key="MesUrl" value="http://192.168.6.47:8000/api/Save"/> |
| | | </appSettings> |
| | | |
| | | <system.serviceModel> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //using iWareCommon.Utils; |
| | | //using Newtonsoft.Json; |
| | | //using System; |
| | | //using System.Collections.Generic; |
| | | //using System.Linq; |
| | | //using System.Net; |
| | | //using System.Text; |
| | | //using System.Threading.Tasks; |
| | | //using yunneiWCS.EnumDefine; |
| | | //using yunneiWCS.ExtendFunction; |
| | | //using yunneiWCS.SystemInteraction.mes2.dto; |
| | | //using static WZ.Useful.Commons.NativeMethods; |
| | | |
| | | //namespace yunneiWCS.mes |
| | | //{ |
| | | // /// <summary> |
| | | // /// MESæ¨éæ¥å£ |
| | | // /// </summary> |
| | | // public class PushMesHandler |
| | | // { |
| | | // public static string mes_api_url = ConfigHelper.GetConfigString("MesUrl");//ä¿®æ¹ä¸ºé
ç½®æä»¶ ãEditBy shaocx,2022-01-27ã |
| | | // static HTTPService mes_api = new HTTPService(mes_api_url);//mesåºå°å |
| | | |
| | | // /// <summary> |
| | | // /// ç»MESæ¨éå
¥åºä¿¡æ¯ |
| | | // /// </summary> |
| | | // /// <param name="pushData"></param> |
| | | // /// <returns></returns> |
| | | // public static ApiResponse<object> Mes_InStockSend(List<InboundStockInfoToMes> pushData, string _identifier, LogType _logType) |
| | | // { |
| | | // ApiResponse<object> res = null; |
| | | // var funName = "Mes_InStockSend"; |
| | | // try |
| | | // { |
| | | // MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>(); |
| | | // mesRequest.data = pushData; |
| | | // mesRequest.identifier = _identifier; |
| | | |
| | | // string paprm = JsonConvert.SerializeObject(mesRequest); |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},åå¤åæ°:{paprm}"); |
| | | // Guid guid = System.Guid.NewGuid(); |
| | | |
| | | // //模æ |
| | | // if (Form1.isvirtual) |
| | | // {//模æç¯å¢ |
| | | // res = new ApiResponse<object>(); |
| | | // res.Success = true; |
| | | // res.Message = "ç³»ç»æ¨¡æå®æ"; |
| | | // } |
| | | // else |
| | | // { |
| | | // var resStr = mes_api.postContentForString("T_WMS_Inbound_Record", paprm, guid); |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},ç»æè¿å:{resStr}"); |
| | | // res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr); |
| | | // } |
| | | |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},åæ°:{paprm},è¿å:{JsonConvert.SerializeObject(res)}"); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(_logType, $"{funName},å¼å¸¸:" + ex.Message, ex); |
| | | // res.Message = "åéå¼å¸¸:" + ex.Message; |
| | | // } |
| | | // return res; |
| | | |
| | | // } |
| | | |
| | | |
| | | // /// <summary> |
| | | // /// ç»MESæ¨éåºåºä¿¡æ¯ |
| | | // /// </summary> |
| | | // /// <param name="pushData"></param> |
| | | // /// <returns></returns> |
| | | // public static ApiResponse<object> Mes_OutStockSend(List<InboundStockInfoToMes> pushData, string _identifier, LogType _logType) |
| | | // { |
| | | // ApiResponse<object> res = null; |
| | | // var funName = "Mes_OutStockSend"; |
| | | // try |
| | | // { |
| | | // MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>(); |
| | | // mesRequest.data = pushData; |
| | | // mesRequest.identifier = _identifier; |
| | | |
| | | // string paprm = JsonConvert.SerializeObject(mesRequest); |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},åå¤åæ°:{paprm}"); |
| | | // Guid guid = System.Guid.NewGuid(); |
| | | // //模æ |
| | | // if (Form1.isvirtual) |
| | | // {//模æç¯å¢ |
| | | // res = new ApiResponse<object>(); |
| | | // res.Success = true; |
| | | // res.Message = "ç³»ç»æ¨¡æå®æ"; |
| | | // } |
| | | // else |
| | | // { |
| | | // var resStr = mes_api.postContentForString("T_WMS_Outbound_Record", paprm, guid); |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},ç»æè¿å:{resStr}"); |
| | | // res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr); |
| | | // } |
| | | |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},åæ°:{paprm},è¿å:{JsonConvert.SerializeObject(res)}"); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(_logType, $"{funName},å¼å¸¸:" + ex.Message, ex); |
| | | // res.Message = "åéå¼å¸¸:" + ex.Message; |
| | | // } |
| | | // return res; |
| | | |
| | | // } |
| | | |
| | | |
| | | // /// <summary> |
| | | // /// ç»MESæ¨éåºåä¿¡æ¯ |
| | | // /// </summary> |
| | | // /// <param name="pushData"></param> |
| | | // /// <returns></returns> |
| | | // public static ApiResponse<object> Mes_StockSend(List<InboundStockInfoToMes> pushData, LogType _logType) |
| | | // { |
| | | // ApiResponse<object> res = null; |
| | | // var funName = "Mes_StockSend"; |
| | | // try |
| | | // { |
| | | // MesRequest<List<InboundStockInfoToMes>> mesRequest = new MesRequest<List<InboundStockInfoToMes>>(); |
| | | // mesRequest.data = pushData; |
| | | |
| | | // string paprm = JsonConvert.SerializeObject(mesRequest); |
| | | // Guid guid = System.Guid.NewGuid(); |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},åå¤åæ°:{paprm}"); |
| | | // //模æ |
| | | // if (Form1.isvirtual) |
| | | // {//模æç¯å¢ |
| | | // res = new ApiResponse<object>(); |
| | | // res.Success = true; |
| | | // res.Message = "ç³»ç»æ¨¡æå®æ"; |
| | | // } |
| | | // else |
| | | // { |
| | | // var resStr = mes_api.postContentForString("T_WMS_Realtime_Data", paprm, guid); |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},ç»æè¿å:{resStr}"); |
| | | // res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr); |
| | | // } |
| | | |
| | | |
| | | // Log4NetHelper.WriteInfoLog(_logType, $"{funName},åæ°:{paprm},è¿å:{JsonConvert.SerializeObject(res)}"); |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // Log4NetHelper.WriteErrorLog(_logType, $"{funName},å¼å¸¸:" + ex.Message, ex); |
| | | // res.Message = "åéå¼å¸¸:" + ex.Message; |
| | | // } |
| | | // return res; |
| | | |
| | | // } |
| | | // } |
| | | //} |
| | |
| | | /// </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}"); |
| | |
| | | //模æ |
| | | 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)}"); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(_logType, $"{funName},å¼å¸¸:" + ex.Message, ex); |
| | | res.Message = "åéå¼å¸¸:" + ex.Message; |
| | | res.ErrorCode = 4; |
| | | res.ErrorMsg = "wmsåéå¼å¸¸:" + ex.Message; |
| | | } |
| | | return res; |
| | | |
| | |
| | | /// </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}"); |
| | |
| | | //模æ |
| | | 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)}"); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(_logType, $"{funName},å¼å¸¸:" + ex.Message, ex); |
| | | res.Message = "åéå¼å¸¸:" + ex.Message; |
| | | res.ErrorCode = 4; |
| | | res.ErrorMsg = "wmsåéå¼å¸¸:" + ex.Message; |
| | | } |
| | | return res; |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="pushData"></param> |
| | | /// <returns></returns> |
| | | public static ApiResponse<object> Mes_StockSend(List<InboundStockInfoToMes> pushData, LogType _logType) |
| | | public static mesMsg Mes_StockSend(List<InboundStockInfoToMes> pushData, LogType _logType) |
| | | { |
| | | 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(); |
| | |
| | | //模æ |
| | | 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(_logType, $"{funName},ç»æè¿å:{resStr}"); |
| | | res = JsonConvert.DeserializeObject<ApiResponse<object>>(resStr); |
| | | res = JsonConvert.DeserializeObject<mesMsg>(resStr); |
| | | } |
| | | |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | Log4NetHelper.WriteErrorLog(_logType, $"{funName},å¼å¸¸:" + ex.Message, ex); |
| | | res.Message = "åéå¼å¸¸:" + ex.Message; |
| | | res.ErrorCode = 4; |
| | | res.ErrorMsg = "wmsåéå¼å¸¸:" + ex.Message; |
| | | } |
| | | return res; |
| | | |
| | |
| | | public class InboundStockInfoToMes |
| | | { |
| | | /// <summary> |
| | | /// å¯ä¸æ è¯ç¬¦ |
| | | /// </summary> |
| | | public string identifier { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 产ååç§° |
| | | /// </summary> |
| | | public string productName { get; set; } |
| | |
| | | /// æºå |
| | | /// </summary> |
| | | public string version { get; set; } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// æ°æ® |
| | | /// </summary> |
| | | public T data { get; set; } |
| | | /// <summary> |
| | | /// æ¨é人 |
| | | /// </summary> |
| | | public string Creator { get; set; } = "wms"; // å建人ï¼å¦ "wms" |
| | | public T Datas { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¨éæ¶é´ |
| | | /// ç³»ç»ç±»å |
| | | /// </summary> |
| | | public string Timestamp { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // æ¶é´æ³ï¼å¦ "2022-03-15 06:43:15" |
| | | public string SystemType { get; set; } = "ERP"; |
| | | /// <summary> |
| | | /// Secret |
| | | /// </summary> |
| | | public string Secret { get; set; } = "HJY^*HGYIIY"; |
| | | |
| | | |
| | | /// <summary> |
| | | /// å¯ä¸æ è¯ç¬¦ |
| | | /// 表å |
| | | /// </summary> |
| | | public string identifier { get; set; } |
| | | public string TableName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | public string PrimaryKeys { get; set; } |
| | | } |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | ApiResponse<object> ret = null; |
| | | mesMsg ret = null; |
| | | |
| | | //è·åä¿¡æ¯æç» |
| | | var details = mod.Wms_outInStockRecord_Details_V2_Mes.Where(x => x.mainId == itemTask.ID).ToList(); |
| | |
| | | { |
| | | pushData.Add(new InboundStockInfoToMes() |
| | | { |
| | | identifier = de.ID.ToString(), |
| | | containerCode = itemTask.containerCode, |
| | | createTime = itemTask.CreateTime?.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | materialCode = de.productCode, |
| | |
| | | switch (itemTask.outInFlag) |
| | | { |
| | | case (int)OutInFlag.å
¥åº: |
| | | ret = PushMesHandler.Mes_InStockSend(pushData, itemTask.ID.ToString(), _logType); |
| | | ret = PushMesHandler.Mes_InStockSend(pushData, _logType); |
| | | break; |
| | | case (int)OutInFlag.åºåº: |
| | | ret = PushMesHandler.Mes_OutStockSend(pushData, itemTask.ID.ToString(), _logType); |
| | | ret = PushMesHandler.Mes_OutStockSend(pushData, _logType); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | SystemWarningMsg.msg_mesDataTranfficForRealMes = $"{MyExtend.MsgTimeStr()},å·²æ¨éç»æï¼è¿å:{JsonConvert.SerializeObject(ret)}"; |
| | | if (ret.Success) |
| | | if (ret.ErrorCode == 0) |
| | | { |
| | | itemTask.isSendToMes = 1; |
| | | } |
| | |
| | | itemTask.isSendToMes = 0; |
| | | } |
| | | itemTask.SendToMesTime = DateTime.Now; |
| | | itemTask.MesRet = ret.Message; |
| | | itemTask.MesRet = ret.ErrorMsg; |
| | | itemTask.SendToMesCount = (itemTask.SendToMesCount ?? 0) + 1; |
| | | mod.SaveChanges(); |
| | | |
| | |
| | | if (sendMesData.Count > 0) |
| | | { |
| | | SystemWarningMsg.mesStockDataForRealMes = $"{MyExtend.MsgTimeStr()},è¦æ¨é{sendMesData.Count()}æ¡!"; |
| | | ApiResponse<object> ret = null; |
| | | mesMsg ret = null; |
| | | List<InboundStockInfoToMes> pushData = new List<InboundStockInfoToMes>(); |
| | | foreach (var itemTask in sendMesData) |
| | | { |
| | | pushData.Add(new InboundStockInfoToMes() |
| | | { |
| | | identifier=Yitter.IdGenerator.YitIdHelper.NextId().ToString(), |
| | | containerCode = itemTask.containerCode, |
| | | createTime = itemTask.createTime?.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | materialCode = itemTask.productCode, |
| | |
| | | <Compile Include="SystemInteraction\mes2\dto\ApiResponse.cs" /> |
| | | <Compile Include="SystemInteraction\mes2\dto\MesRequest.cs" /> |
| | | <Compile Include="SystemInteraction\mes2\dto\InboundStockInfoToMes.cs" /> |
| | | <Compile Include="SystemInteraction\mes2\PushMesHandler - å¤å¶.cs" /> |
| | | <Compile Include="SystemInteraction\mes2\PushMesHandler.cs" /> |
| | | <Compile Include="SystemInteraction\tianyong\TianYongSystem.cs" /> |
| | | <Compile Include="TestForm.cs"> |