using MaterialTraceability.Common; using MaterialTraceability.Entity.DAO; using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using MaterialTraceability.WebService.MachineIntegrationServiceService; using MaterialTraceability.WebService.MiBatchCompleteSfcAndAdujustQtyServiceService; using MaterialTraceability.WebService.MiFirstOperationForsfcServiceService; using MaterialTraceability.WebService.MiReleaseSfcWithActivityServiceService; using MaterialTraceability.WebService.ResourceSlotConfigurationSetupForJITService; using MaterialTraceability.WebService.MiSFCQueryQtyServiceService; using MaterialTraceability.WebService.MiSignOffSFCsServiceService; using MaterialTraceability.WebService.Param; using MaterialTraceability.WebService.ProcessLotServiceWSService; using MaterialTraceability.WebService.ShopOrderServiceWSService; using MaterialTraceability.WebService.WarehouseIntegrationServiceService; using System; using System.Net; using MaterialTraceability.WebService.GetParametricValueServiceService; using System.IO; using System.Collections.Generic; using System.Xml.Serialization; using System.Xml; using MaterialTraceability.Entity.DTO; using System.Windows; namespace MaterialTraceability.WebService { public class MesWebServicesImpl : IMesWebServices { private IBaseServices webServiceRequestServices = new BaseServices(); private INIFile iNIFile = new INIFile(System.Environment.CurrentDirectory + "/App.InI"); private AppConfigDto appConfig = AppConfigDto.Instance; /// /// 新自动完工接口 /// /// /// public MiBatchCompleteSfcAndAdujustQtyResponse iMiBatchCompleteSfcAndAdujustQtyServiceService(MiBatchCompleteSfcAndAdujustQtyServiceServiceParam miBatchCompleteSfcAndAdujustQtyServiceServiceParam) { try { if (StringExtension.IsBlank(miBatchCompleteSfcAndAdujustQtyServiceServiceParam.loginUser) && StringExtension.IsBlank(miBatchCompleteSfcAndAdujustQtyServiceServiceParam.password)) { miBatchCompleteSfcAndAdujustQtyServiceServiceParam.loginUser = "SUP_LYA_RF01"; miBatchCompleteSfcAndAdujustQtyServiceServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.loginUser, Password = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.password }; MiBatchCompleteSfcAndAdujustQtyServiceService.MiBatchCompleteSfcAndAdujustQtyServiceService MiBatchCompleteSfcAndAdujustQtyServiceService = new MiBatchCompleteSfcAndAdujustQtyServiceService.MiBatchCompleteSfcAndAdujustQtyServiceService(); ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; MiBatchCompleteSfcAndAdujustQtyServiceService.PreAuthenticate = true; MiBatchCompleteSfcAndAdujustQtyServiceService.Url = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.url; MiBatchCompleteSfcAndAdujustQtyServiceService.Credentials = nc; MiBatchCompleteSfcAndAdujustQtyServiceService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); MiBatchCompleteSfcAndAdujustQty MiBatchCompleteSfcAndAdujustQty = new MiBatchCompleteSfcAndAdujustQty(); MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest = new miBatchCompleteSfcAndAdujustQtyRequest(); MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.site = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.site; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.sfcPre = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.sfcPre; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.processLotPre = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.processLotPre; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.operation = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.operation; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.operationRevision = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.operationRevision; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.resource = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.resource; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.user = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.user; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.activity = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.activity; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.modeProcessSfc = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.modeProcessSfc; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.sfcList = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.sfcList; MiBatchCompleteSfcAndAdujustQty.MiBatchCompleteSfcAndAdujustQtyRequest.tailMark = miBatchCompleteSfcAndAdujustQtyServiceServiceParam.tailmark; DateTime beginTime = DateTime.Now; MiBatchCompleteSfcAndAdujustQtyResponse MiBatchCompleteSfcAndAdujustQtyResponse = MiBatchCompleteSfcAndAdujustQtyServiceService.MiBatchCompleteSfcAndAdujustQty(MiBatchCompleteSfcAndAdujustQty); //保存MES日志 WebServiceLog.saveMiBatchCompleteSfcAndAdujustQtyServiceService(miBatchCompleteSfcAndAdujustQtyServiceServiceParam, MiBatchCompleteSfcAndAdujustQtyResponse, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "MiBatchCompleteSfcAndAdujustQtyServiceService", requestState = 0, requestParam = JsonChange.ModeToJson(MiBatchCompleteSfcAndAdujustQty), responseCode = MiBatchCompleteSfcAndAdujustQtyResponse.@return.code, responseMessage = MiBatchCompleteSfcAndAdujustQtyResponse.@return.message, responseJson = JsonChange.ModeToJson(MiBatchCompleteSfcAndAdujustQtyResponse.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return MiBatchCompleteSfcAndAdujustQtyResponse; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message+" ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 首工序获取SFC接口、自动入账接口、卷绕自动上料接口 /// activity执行作业:Z_AUTO_EN530 上料功能(冷压、卷绕),默认为空,仅执行开始作业(模切) /// modeProcessSfc过账模式:MODE_RELEASE_START_SFC 冷压下达并开始SFC,MODE_START_SFC 模切开始SFC,MODE_NONE 卷绕仅上料,不执行其他作业 /// /// /// public miFirstOperationForsfcResponse iMiFirstOperationForsfcServiceService(MiFirstOperationForsfcServiceServiceParam miFirstOperationForsfcServiceServiceParam) { try { if (StringExtension.IsBlank(miFirstOperationForsfcServiceServiceParam.loginUser) && StringExtension.IsBlank(miFirstOperationForsfcServiceServiceParam.password)) { miFirstOperationForsfcServiceServiceParam.loginUser = "SUP_LYA_RF01"; miFirstOperationForsfcServiceServiceParam.password = "CA@TLmespcrf01"; } MiFirstOperationForsfcServiceService.MiFirstOperationForsfcServiceService miFirstOperationForsfcServiceService = new MiFirstOperationForsfcServiceService.MiFirstOperationForsfcServiceService(); //设置多线程数量 ServicePointManager.DefaultConnectionLimit = 32; //设置Http会话机制 ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); //设置Http双连接限制,reamrk:默认情况下,一个http客户端与服务端最多可同时建立两个TCP连接。http请求都在这两个通道中按顺序发送。调整此参数值,增加TCP连接数, ServicePointManager.DefaultConnectionLimit = 10; //调用接口服务用户预认证设置,reamrk:避免设备软件每次调用接口,系统后台会产生一条接口认证报错信息,影响系统性能,接口服务属性字段PreAuthenticate设置为:true miFirstOperationForsfcServiceService.PreAuthenticate = true; //添加认证否则调用接口报权限错误 NetworkCredential nc = new NetworkCredential { UserName = miFirstOperationForsfcServiceServiceParam.loginUser, Password = miFirstOperationForsfcServiceServiceParam.password }; miFirstOperationForsfcServiceService.Url = miFirstOperationForsfcServiceServiceParam.url; miFirstOperationForsfcServiceService.Credentials = nc; miFirstOperationForsfcServiceService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); MiFirstOperationForsfcServiceService.miFirstOperationForsfc miFirstOperationForsfc = new MiFirstOperationForsfcServiceService.miFirstOperationForsfc(); miFirstOperationForsfc.MiFirstOperationForsfcRequest = new MiFirstOperationForsfcServiceService.MiFirstOperationForsfcRequest(); miFirstOperationForsfc.MiFirstOperationForsfcRequest.site = miFirstOperationForsfcServiceServiceParam.site; miFirstOperationForsfc.MiFirstOperationForsfcRequest.sfc = miFirstOperationForsfcServiceServiceParam.sfc; miFirstOperationForsfc.MiFirstOperationForsfcRequest.processLot = miFirstOperationForsfcServiceServiceParam.processLot; miFirstOperationForsfc.MiFirstOperationForsfcRequest.operation = miFirstOperationForsfcServiceServiceParam.operation; miFirstOperationForsfc.MiFirstOperationForsfcRequest.operationRevision = miFirstOperationForsfcServiceServiceParam.operationRevision; miFirstOperationForsfc.MiFirstOperationForsfcRequest.resource = miFirstOperationForsfcServiceServiceParam.resource; miFirstOperationForsfc.MiFirstOperationForsfcRequest.user = miFirstOperationForsfcServiceServiceParam.user; if (miFirstOperationForsfcServiceServiceParam.activity == "") { miFirstOperationForsfc.MiFirstOperationForsfcRequest.activity = null; } else { miFirstOperationForsfc.MiFirstOperationForsfcRequest.activity = miFirstOperationForsfcServiceServiceParam.activity; } miFirstOperationForsfc.MiFirstOperationForsfcRequest.modeProcessSfc = miFirstOperationForsfcServiceServiceParam.modeProcessSfc; DateTime beginTime = DateTime.Now; var requestResult = miFirstOperationForsfcServiceService.miFirstOperationForsfc(miFirstOperationForsfc); //本地记录交互日志 WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "MiFirstOperationForsfcServiceService", requestState = 0, requestParam = JsonChange.ModeToJson(miFirstOperationForsfc), responseCode = requestResult.@return.code, responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 涂布工单下达接口 /// /// /// public miReleaseSfcWithActivityResponse iMiReleaseSfcWithActivityServiceService(MiReleaseSfcWithActivityServiceServiceParam miReleaseSfcWithActivityServiceServiceParam) { try { if (StringExtension.IsBlank(miReleaseSfcWithActivityServiceServiceParam.loginUser) && StringExtension.IsBlank(miReleaseSfcWithActivityServiceServiceParam.password)) { miReleaseSfcWithActivityServiceServiceParam.loginUser = "SUP_LYA_RF01"; miReleaseSfcWithActivityServiceServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = miReleaseSfcWithActivityServiceServiceParam.loginUser, Password = miReleaseSfcWithActivityServiceServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; MiReleaseSfcWithActivityServiceService.MiReleaseSfcWithActivityServiceService miReleaseSfcWithActivityServiceService = new MiReleaseSfcWithActivityServiceService.MiReleaseSfcWithActivityServiceService(); miReleaseSfcWithActivityServiceService.PreAuthenticate = true; miReleaseSfcWithActivityServiceService.Url = miReleaseSfcWithActivityServiceServiceParam.url; miReleaseSfcWithActivityServiceService.Credentials = nc; miReleaseSfcWithActivityServiceService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); MiReleaseSfcWithActivityServiceService.miReleaseSfcWithActivity miReleaseSfcWithActivity = new MiReleaseSfcWithActivityServiceService.miReleaseSfcWithActivity(); miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest = new MiReleaseSfcWithActivityServiceService.releaseSfcWithActivityRequest(); miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.site = miReleaseSfcWithActivityServiceServiceParam.site; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.user = miReleaseSfcWithActivityServiceServiceParam.user; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.operation = miReleaseSfcWithActivityServiceServiceParam.operation; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.operationRevision = miReleaseSfcWithActivityServiceServiceParam.operationRevision; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.activity = miReleaseSfcWithActivityServiceServiceParam.activityId; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.resource = miReleaseSfcWithActivityServiceServiceParam.Resource; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.sfcQty = miReleaseSfcWithActivityServiceServiceParam.sfcQty; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.processlot = miReleaseSfcWithActivityServiceServiceParam.processlot; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.modeProcessSFC = miReleaseSfcWithActivityServiceServiceParam.modeProcessSfc; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.isCarrierType = miReleaseSfcWithActivityServiceServiceParam.isCarrierType; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.ColumnOrRowFirst = miReleaseSfcWithActivityServiceServiceParam.ColumnOrRowFirst; miReleaseSfcWithActivity.ReleaseSfcWithActivityRequest.location = miReleaseSfcWithActivityServiceServiceParam.location; DateTime beginTime = DateTime.Now; var requestResult = miReleaseSfcWithActivityServiceService.miReleaseSfcWithActivity(miReleaseSfcWithActivity); WebServiceLog.saveMiReleaseSfcWithActivityServiceService(miReleaseSfcWithActivityServiceServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "MiReleaseSfcWithActivityServiceService", requestState = 0, requestParam = JsonChange.ModeToJson(miReleaseSfcWithActivity), responseCode = requestResult.@return.code, responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 获取SFC数量 /// /// /// public sfcQueryQtyResponse iMiSFCQueryQtyServiceService(MiSFCQueryQtyServiceServiceParam miSFCQueryQtyServiceServiceParam) { try { if (StringExtension.IsBlank(miSFCQueryQtyServiceServiceParam.loginUser) && StringExtension.IsBlank(miSFCQueryQtyServiceServiceParam.password)) { miSFCQueryQtyServiceServiceParam.loginUser = "SUP_LYA_RF01"; miSFCQueryQtyServiceServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = miSFCQueryQtyServiceServiceParam.loginUser, Password = miSFCQueryQtyServiceServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; MiSFCQueryQtyServiceService.MiSFCQueryQtyServiceService miSFCQueryQtyServiceService = new MiSFCQueryQtyServiceService.MiSFCQueryQtyServiceService(); miSFCQueryQtyServiceService.PreAuthenticate = true; miSFCQueryQtyServiceService.Url = miSFCQueryQtyServiceServiceParam.url; miSFCQueryQtyServiceService.Credentials = nc; miSFCQueryQtyServiceService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); MiSFCQueryQtyServiceService.sfcQueryQty sfcQueryQty = new sfcQueryQty(); sfcQueryQty.MiSFCQueryQtyRequest = new MiSFCQueryQtyServiceService.miSFCQueryQtyRequest(); sfcQueryQty.MiSFCQueryQtyRequest.site = miSFCQueryQtyServiceServiceParam.site; sfcQueryQty.MiSFCQueryQtyRequest.sfc = miSFCQueryQtyServiceServiceParam.sfc; DateTime beginTime = DateTime.Now; var requestResult = miSFCQueryQtyServiceService.sfcQueryQty(sfcQueryQty); WebServiceLog.saveMiSFCQueryQtyServiceService(miSFCQueryQtyServiceServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "MiSFCQueryQtyServiceService", requestState = 0, requestParam = JsonChange.ModeToJson(sfcQueryQty), responseCode = requestResult.@return.code, responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 注销SFC接口 /// /// /// public miSignOffSFCsResponse iMiSignOffSFCsServiceService(MiSignOffSFCsServiceServiceParam miSignOffSFCsServiceServiceParam) { try { if (StringExtension.IsBlank(miSignOffSFCsServiceServiceParam.loginUser) && StringExtension.IsBlank(miSignOffSFCsServiceServiceParam.password)) { miSignOffSFCsServiceServiceParam.loginUser = "SUP_LYA_RF01"; miSignOffSFCsServiceServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = miSignOffSFCsServiceServiceParam.loginUser, Password = miSignOffSFCsServiceServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; MiSignOffSFCsServiceService.MiSignOffSFCsServiceService miSignOffSFCsServiceService = new MiSignOffSFCsServiceService.MiSignOffSFCsServiceService(); miSignOffSFCsServiceService.PreAuthenticate = true; miSignOffSFCsServiceService.Url = miSignOffSFCsServiceServiceParam.url; miSignOffSFCsServiceService.Credentials = nc; miSignOffSFCsServiceService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); MiSignOffSFCsServiceService.miSignOffSFCs signOffSFCs = new MiSignOffSFCsServiceService.miSignOffSFCs(); signOffSFCs.SignOffSFCsRequest = new MiSignOffSFCsServiceService.signOffSFCsRequest(); signOffSFCs.SignOffSFCsRequest.site = miSignOffSFCsServiceServiceParam.site; signOffSFCs.SignOffSFCsRequest.user = miSignOffSFCsServiceServiceParam.user; signOffSFCs.SignOffSFCsRequest.operation = miSignOffSFCsServiceServiceParam.operation; signOffSFCs.SignOffSFCsRequest.operationRev = miSignOffSFCsServiceServiceParam.operationRevision; signOffSFCs.SignOffSFCsRequest.activity = miSignOffSFCsServiceServiceParam.activityId; signOffSFCs.SignOffSFCsRequest.resource = miSignOffSFCsServiceServiceParam.Resource; signOffSFCs.SignOffSFCsRequest.amount = miSignOffSFCsServiceServiceParam.amount; signOffSFCs.SignOffSFCsRequest.sfcDataArray = new string[] { miSignOffSFCsServiceServiceParam.sfc }; DateTime beginTime = DateTime.Now; var requestResult = miSignOffSFCsServiceService.miSignOffSFCs(signOffSFCs); WebServiceLog.saveMiSignOffSFCsServiceService(miSignOffSFCsServiceServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "MiSignOffSFCsServiceService", requestState = 0, requestParam = JsonChange.ModeToJson(signOffSFCs), responseCode = requestResult.@return.code, responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 托盘绑定 /// /// /// public addMemberResponse iAddMemberResponse(ProcessLotServiceWSServiceParam processLotServiceWSServiceParam) { try { if (StringExtension.IsBlank(processLotServiceWSServiceParam.loginUser) && StringExtension.IsBlank(processLotServiceWSServiceParam.password)) { processLotServiceWSServiceParam.loginUser = "SUP_LYA_RF01"; processLotServiceWSServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = processLotServiceWSServiceParam.loginUser, Password = processLotServiceWSServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; ProcessLotServiceWSService.ProcessLotServiceWSService processLotServiceWSService = new ProcessLotServiceWSService.ProcessLotServiceWSService(); processLotServiceWSService.PreAuthenticate = true; processLotServiceWSService.Url = processLotServiceWSServiceParam.url; processLotServiceWSService.Credentials = nc; processLotServiceWSService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); ProcessLotServiceWSService.addMember addMember = new ProcessLotServiceWSService.addMember(); addMember.Site = processLotServiceWSServiceParam.site; addMember.Request = new ProcessLotServiceWSService.AddMemberRequest(); addMember.Request.processLotRef = processLotServiceWSServiceParam.processlotref; addMember.Request.memberList = processLotServiceWSServiceParam.memberlist; DateTime beginTime = DateTime.Now; var requestResult = processLotServiceWSService.addMember(addMember); WebServiceLog.saveAddMemberResponse(processLotServiceWSServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "AddMemberResponse", requestState = 0, requestParam = JsonChange.ModeToJson(addMember), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 托盘解绑 /// /// /// public removeMemberResponse iRemoveMember(ProcessLotServiceWSServiceParam processLotServiceWSServiceParam) { try { if (StringExtension.IsBlank(processLotServiceWSServiceParam.loginUser) && StringExtension.IsBlank(processLotServiceWSServiceParam.password)) { processLotServiceWSServiceParam.loginUser = "SUP_LYA_RF01"; processLotServiceWSServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = processLotServiceWSServiceParam.loginUser, Password = processLotServiceWSServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; ProcessLotServiceWSService.ProcessLotServiceWSService processLotServiceWSService = new ProcessLotServiceWSService.ProcessLotServiceWSService(); processLotServiceWSService.PreAuthenticate = true; processLotServiceWSService.Url = processLotServiceWSServiceParam.url; processLotServiceWSService.Credentials = nc; processLotServiceWSService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); ProcessLotServiceWSService.removeMember removeMember = new ProcessLotServiceWSService.removeMember(); removeMember.Request = new ProcessLotServiceWSService.RemoveMemberRequest(); removeMember.Site = processLotServiceWSServiceParam.site; removeMember.Request.processLotRef = processLotServiceWSServiceParam.processlotref; removeMember.Request.memberList = processLotServiceWSServiceParam.memberlist; DateTime beginTime = DateTime.Now; removeMemberResponse requestResult = new removeMemberResponse(); requestResult = processLotServiceWSService.removeMember(removeMember); WebServiceLog.saveRemoveMember(processLotServiceWSServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "RemoveMember", requestState = 0, requestParam = JsonChange.ModeToJson(removeMember), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); //MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 极片信息返回 /// /// /// public warehouseInventoryTransferResponse iWarehouseIntegrationServiceService(WarehouseIntegrationServiceServiceParam warehouseIntegrationServiceServiceParam) { try { if (StringExtension.IsBlank(warehouseIntegrationServiceServiceParam.loginUser) && StringExtension.IsBlank(warehouseIntegrationServiceServiceParam.password)) { warehouseIntegrationServiceServiceParam.loginUser = "SUP_LYA_RF01"; warehouseIntegrationServiceServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = warehouseIntegrationServiceServiceParam.loginUser, Password = warehouseIntegrationServiceServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; WarehouseIntegrationServiceService.WarehouseIntegrationServiceService warehouseIntegrationService = new WarehouseIntegrationServiceService.WarehouseIntegrationServiceService(); warehouseIntegrationService.PreAuthenticate = true; warehouseIntegrationService.Url = warehouseIntegrationServiceServiceParam.url; warehouseIntegrationService.Credentials = nc; warehouseIntegrationService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); WarehouseIntegrationServiceService.warehouseInventoryTransfer warehouseInventory = new WarehouseIntegrationServiceService.warehouseInventoryTransfer(); warehouseInventory.Request = new WarehouseIntegrationServiceService.warehouseIntegrationrRequest(); warehouseInventory.Request.site = warehouseIntegrationServiceServiceParam.site; warehouseInventory.Request.processId = StringExtension.IsBlank(warehouseIntegrationServiceServiceParam.sfc) ? warehouseIntegrationServiceServiceParam.rfid : warehouseIntegrationServiceServiceParam.sfc; var requestResult = warehouseIntegrationService.warehouseInventoryTransfer(warehouseInventory); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "WarehouseIntegrationServiceService", requestState = 0, requestParam = JsonChange.ModeToJson(warehouseInventory), responseCode = requestResult.@return.code, responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 根据RDID获取膜卷号 /// /// /// public readProcessLotResponse readProcessLot(ProcessLotServiceWSServiceParam processLotServiceWSServiceParam) { try { if (StringExtension.IsBlank(processLotServiceWSServiceParam.loginUser) && StringExtension.IsBlank(processLotServiceWSServiceParam.password)) { processLotServiceWSServiceParam.loginUser = "SUP_LYA_RF01"; processLotServiceWSServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = processLotServiceWSServiceParam.loginUser, Password = processLotServiceWSServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; ProcessLotServiceWSService.ProcessLotServiceWSService processLotServiceWSService = new ProcessLotServiceWSService.ProcessLotServiceWSService(); processLotServiceWSService.PreAuthenticate = true; processLotServiceWSService.Url = processLotServiceWSServiceParam.url; processLotServiceWSService.Credentials = nc; processLotServiceWSService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); ProcessLotServiceWSService.readProcessLot readProcessLot = new ProcessLotServiceWSService.readProcessLot(); readProcessLot.Site = processLotServiceWSServiceParam.site; readProcessLot.Request = new ProcessLotServiceWSService.ObjectReference(); readProcessLot.Request.@ref = processLotServiceWSServiceParam.processlotref; DateTime beginTime = DateTime.Now; var requestResult = processLotServiceWSService.readProcessLot(readProcessLot); WebServiceLog.saveReadProcessLot(processLotServiceWSServiceParam, requestResult, beginTime, null); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "RemoveMember", requestState = 0, requestParam = JsonChange.ModeToJson(processLotServiceWSServiceParam), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 获取工单数量接口 /// /// /// public findShopOrderResponse findShopOrder(FindShopRequestParam findShopRequestParam) { try { if (StringExtension.IsBlank(findShopRequestParam.loginUser) && StringExtension.IsBlank(findShopRequestParam.password)) { findShopRequestParam.loginUser = "SUP_LYA_RF01"; findShopRequestParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = findShopRequestParam.loginUser, Password = findShopRequestParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; ShopOrderServiceWSService.ShopOrderServiceWSService shopOrderServiceWSService = new ShopOrderServiceWSService.ShopOrderServiceWSService(); shopOrderServiceWSService.PreAuthenticate = true; shopOrderServiceWSService.Url = findShopRequestParam.url; shopOrderServiceWSService.Credentials = nc; shopOrderServiceWSService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); ShopOrderServiceWSService.findShopOrder findShopOrder = new ShopOrderServiceWSService.findShopOrder(); findShopOrder.Site = findShopRequestParam.site; findShopOrder.Request = new ShopOrderServiceWSService.ObjectReference(); findShopOrder.Request.@ref = findShopRequestParam.shopOrder; DateTime beginTime = DateTime.Now; var requestResult = shopOrderServiceWSService.findShopOrder(findShopOrder); WebServiceLog.findShopOrder(findShopRequestParam, requestResult, beginTime, null); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "FindShopOrder", requestState = 0, requestParam = JsonChange.ModeToJson(findShopRequestParam), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), //responseCode = requestResult.@return.code, //responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.Response), }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 物料特征数据上传接口 /// /// /// public dataCollectForSfcExResponse machineIntegration(MachineIntegrationServiceParam machineIntegrationServiceParam) { try { if (StringExtension.IsBlank(machineIntegrationServiceParam.loginUser) && StringExtension.IsBlank(machineIntegrationServiceParam.password)) { machineIntegrationServiceParam.loginUser = "SUP_LYA_RF01"; machineIntegrationServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = machineIntegrationServiceParam.loginUser, Password = machineIntegrationServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; MachineIntegrationServiceService.MachineIntegrationServiceService machineIntegrationService = new MachineIntegrationServiceService.MachineIntegrationServiceService(); machineIntegrationService.PreAuthenticate = true; machineIntegrationService.Url = machineIntegrationServiceParam.url; machineIntegrationService.Credentials = nc; machineIntegrationService.Timeout = 50000; //新加参数 MachineIntegrationServiceService.dataCollectForSfcEx dataCollectForSfcEx = new MachineIntegrationServiceService.dataCollectForSfcEx(); dataCollectForSfcEx.SfcDcExRequest = new sfcDcExRequest(); dataCollectForSfcEx.SfcDcExRequest.site = machineIntegrationServiceParam.site; dataCollectForSfcEx.SfcDcExRequest.sfc = machineIntegrationServiceParam.sfc; dataCollectForSfcEx.SfcDcExRequest.user = machineIntegrationServiceParam.user; dataCollectForSfcEx.SfcDcExRequest.operation = machineIntegrationServiceParam.operation; dataCollectForSfcEx.SfcDcExRequest.operationRevision = machineIntegrationServiceParam.operationRevision; dataCollectForSfcEx.SfcDcExRequest.activityId = machineIntegrationServiceParam.activityId; dataCollectForSfcEx.SfcDcExRequest.resource = machineIntegrationServiceParam.resource; dataCollectForSfcEx.SfcDcExRequest.dcGroup = machineIntegrationServiceParam.dcGroup; dataCollectForSfcEx.SfcDcExRequest.dcGroupRevision = machineIntegrationServiceParam.dcGroupRevision; dataCollectForSfcEx.SfcDcExRequest.modeProcessSfc = machineIntegrationServiceParam.modeProcessSfc; dataCollectForSfcEx.SfcDcExRequest.parametricDataArray = machineIntegrationServiceParam.parametricArray; DateTime beginTime = DateTime.Now; var requestResult = machineIntegrationService.dataCollectForSfcEx(dataCollectForSfcEx); LogHelper.Info("MES数据上传接口返回:" + JsonChange.ModeToJson(requestResult)); //WebServiceLog.findShopOrder(machineIntegrationServiceParam, requestResult, beginTime, null); //保存Mes接口请求记录 //webServiceRequestServices.Add(new RecordMesWebServiceRequest() //{ // id = System.Guid.NewGuid().ToString(), // machineId = appConfig.machineId.ToString(), // interfaceType = "FindShopOrder", // requestState = 0, // requestParam = JsonChange.ModeToJson(machineIntegrationServiceParam), // requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), // responseCode = requestResult.@return.code, // responseMessage = requestResult.@return.message, // //responseJson = JsonChange.ModeToJson(requestResult.Response), //}); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 查询涂布数据 /// /// /// public TBParametricValueResult findTBData(TBDataServiceParam upTBDataServiceParam) { try { if (StringExtension.IsBlank(upTBDataServiceParam.loginUser) && StringExtension.IsBlank(upTBDataServiceParam.password)) { upTBDataServiceParam.loginUser = "SUP_LYA_RF01"; upTBDataServiceParam.password = "CA@TLmespcrf01"; } NetworkCredential nc = new NetworkCredential { UserName = upTBDataServiceParam.loginUser, Password = upTBDataServiceParam.password }; ServicePointManager.DefaultConnectionLimit = 32; ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); System.Net.ServicePointManager.DefaultConnectionLimit = 10; GetParametricValueServiceService.GetParametricValueServiceService getParamService = new GetParametricValueServiceService.GetParametricValueServiceService(); getParamService.PreAuthenticate = true; getParamService.Url = upTBDataServiceParam.url; getParamService.Credentials = nc; //getParamService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); //新加参数 GetParametricValueServiceService.getParametricValue datatbCollectForTB = new GetParametricValueServiceService.getParametricValue(); GetParametricValueRequest r = new GetParametricValueRequest(); r.site = upTBDataServiceParam.site; r.user = upTBDataServiceParam.loginUser; r.sfc = upTBDataServiceParam.sfc; r.parametricDataArray = upTBDataServiceParam.memberlist; datatbCollectForTB.GetParametricValueRequest = r; DateTime beginTime = DateTime.Now; TBParametricValueResult parametricValueResult = new TBParametricValueResult(); parametricValueResult.paramValues = new List(); try { System.Xml.XmlNode[] tbResponse = (System.Xml.XmlNode[])getParamService.getParametricValue(datatbCollectForTB); for (int i = 0; i < tbResponse[1].ChildNodes.Count; i++) { System.Xml.XmlNode item = tbResponse[1].ChildNodes.Item(i); var title = item.LocalName; var value = item.InnerText; if (title.Equals("code")) parametricValueResult.code = value; if (title.Equals("sfc")) parametricValueResult.sfc = value; if (title.Equals("message")) parametricValueResult.msg = value; if (title.Equals("parametricDataArray")) { TBParamValue paramValue = new TBParamValue(); for (int j = 0; j < item.ChildNodes.Count; j++) { System.Xml.XmlNode item2 = item.ChildNodes.Item(j); title = item2.LocalName; value = item2.InnerText; if (title.Equals("parameter")) paramValue.parameter = value; if (title.Equals("value")) paramValue.value = value; if (title.Equals("date")) paramValue.date = value; } parametricValueResult.paramValues.Add(paramValue); } } var result = JsonChange.ModeToJson(parametricValueResult); } catch (Exception ex) { LogHelper.Error("获取涂布数据异常", ex); LogHelper.Info("获取涂布数据异常:" + ex.Message); } return parametricValueResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); MessageBox.Show(" " + ex.Message + " ,请调大mes接口超时时间"); throw new Exception(" " + ex.Message); } } /// /// 凹版上料接口 /// /// /// /// public resourceSlotConfigurationSetupForJITServiceRequestPlanResponse resourceSlotConfigurationSetupForJITService(ResourceSlotConfigurationSetupForJITServiceParam resourceSlotConfigurationSetupForJITServiceParam) { try { if (StringExtension.IsBlank(resourceSlotConfigurationSetupForJITServiceParam.loginUser) && StringExtension.IsBlank(resourceSlotConfigurationSetupForJITServiceParam.password)) { resourceSlotConfigurationSetupForJITServiceParam.loginUser = "SUP_LYA_RF01"; resourceSlotConfigurationSetupForJITServiceParam.password = "CA@TLmespcrf01"; } ResourceSlotConfigurationSetupForJITServiceService resourceSlotConfigurationSetupForJITServiceService = new ResourceSlotConfigurationSetupForJITServiceService(); //设置多线程数量 ServicePointManager.DefaultConnectionLimit = 32; //设置Http会话机制 ServicePointManager.SetTcpKeepAlive(false, 100000, 100000); //设置Http双连接限制,reamrk:默认情况下,一个http客户端与服务端最多可同时建立两个TCP连接。http请求都在这两个通道中按顺序发送。调整此参数值,增加TCP连接数, ServicePointManager.DefaultConnectionLimit = 10; //调用接口服务用户预认证设置,reamrk:避免设备软件每次调用接口,系统后台会产生一条接口认证报错信息,影响系统性能,接口服务属性字段PreAuthenticate设置为:true resourceSlotConfigurationSetupForJITServiceService.PreAuthenticate = true; //添加认证否则调用接口报权限错误 NetworkCredential nc = new NetworkCredential { UserName = resourceSlotConfigurationSetupForJITServiceParam.loginUser, Password = resourceSlotConfigurationSetupForJITServiceParam.password }; resourceSlotConfigurationSetupForJITServiceService.Url = resourceSlotConfigurationSetupForJITServiceParam.url; resourceSlotConfigurationSetupForJITServiceService.Credentials = nc; resourceSlotConfigurationSetupForJITServiceService.Timeout = int.Parse(appConfig.MesWebServiceTimeOut); resourceSlotConfigurationSetupForJITServiceRequestPlan resourceSlotConfigurationSetupForJITService = new resourceSlotConfigurationSetupForJITServiceRequestPlan(); var Param = new resourceSlotConfigurationSetupForJITServiceRequest(); Param.site = resourceSlotConfigurationSetupForJITServiceParam.site; Param.resouce = resourceSlotConfigurationSetupForJITServiceParam.resource; Param.operation = resourceSlotConfigurationSetupForJITServiceParam.operation; Param.barcodeId = resourceSlotConfigurationSetupForJITServiceParam.barcodeId; Param.barcodeType = resourceSlotConfigurationSetupForJITServiceParam.barcodeType; Param.activityId = resourceSlotConfigurationSetupForJITServiceParam.activityId; Param.mountingPoint = resourceSlotConfigurationSetupForJITServiceParam.mountingPoint; Param.qty = null; Param.emptyTray = null; resourceSlotConfigurationSetupForJITService.resourceSlotConfigurationSetupForJITServiceRequestPlan1 = Param; DateTime beginTime = DateTime.Now; var requestResult = resourceSlotConfigurationSetupForJITServiceService.resourceSlotConfigurationSetupForJITServiceRequestPlan(resourceSlotConfigurationSetupForJITService); //本地记录交互日志 //WebServiceLog.saveMiFirstOperationForsfcServiceService(miFirstOperationForsfcServiceServiceParam, requestResult, beginTime, ""); //保存Mes接口请求记录 webServiceRequestServices.Add(new RecordMesWebServiceRequest() { id = System.Guid.NewGuid().ToString(), machineId = appConfig.machineId.ToString(), interfaceType = "ResourceSlotConfigurationSetupForJITService", requestState = 0, requestParam = JsonChange.ModeToJson(resourceSlotConfigurationSetupForJITServiceParam), responseCode = int.Parse(requestResult.@return.code), responseMessage = requestResult.@return.message, responseJson = JsonChange.ModeToJson(requestResult.@return), requestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); return requestResult; } catch (Exception ex) { LogHelper.Error("mes接口调用异常,", ex); LogHelper.Info("mes接口调用异常:" + ex.Message); throw new Exception(" " + ex.Message); } } } }