/// <summary> /// 接口配置信息数据新增或修改方法 /// </summary> /// <param name="entity"></param> /// <param name="mode"></param> public void AddOrUpdateInterfaceConfigInfo(IDbCommand icmd, InterfaceConfigInfo entity, ModifierType mode) { icmd.Parameters.Clear(); MySqlCommand cmd = icmd as MySqlCommand; cmd.CommandType = CommandType.Text; if (mode == ModifierType.Add) { string sql = @"insert into interfaceconfiginfo(Id,InterfaceName,ApplicationName,ServerAddress, ServerUser,UserPwd,PersonInChargeName,PersonInChargePhone,ConnectedTimeout, DocumentHelpPath,Description,CreateTime,urlAddress,exeptionlevel,affectProduction,type,appid) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8},'{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}')"; cmd.CommandText = string.Format(sql, entity.Id, entity.InterfaceName, entity.ApplicationName, entity.ServerAddress, entity.ServerUser, entity.UserPwd, entity.PersonOfChargeName, entity.PersonOfChargePhone, entity.ConnectedTimeout, entity.DocumentHelpPath, entity.Description, entity.CreateTime, entity.UrlAddress, entity.Exeptionlevel, entity.AffectProduction, entity.Type, entity.appid); } else if (mode == ModifierType.Update) { string sql = @"update interfaceconfiginfo set InterfaceName = '{0}', ApplicationName = '{1}', ServerAddress = '{2}', ServerUser = '******', UserPwd = '{4}', PersonInChargeName = '{5}', PersonInChargePhone = '{6}', ConnectedTimeout = {7}, DocumentHelpPath = '{8}', Description = '{9}', CreateTime = '{10}', urlAddress = '{12}', exeptionlevel = '{13}', affectProduction = '{14}', type = '{15}', appid = '{16}' where Id = '{11}'"; cmd.CommandText = string.Format(sql, entity.InterfaceName, entity.ApplicationName, entity.ServerAddress, entity.ServerUser, entity.UserPwd, entity.PersonOfChargeName, entity.PersonOfChargePhone, entity.ConnectedTimeout, entity.DocumentHelpPath, entity.Description, entity.CreateTime, entity.Id, entity.UrlAddress, entity.Exeptionlevel, entity.AffectProduction, entity.Type, entity.appid); } cmd.ExecuteNonQuery(); }
/// <summary> /// LES-SRM-005 物料拉动单 /// </summary> /// <param name="logFid"></param> public static ExecuteResultConstants Send(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { /// msgContent = string.Empty; /// List <SrmPullingOrderInfo> srmPullingOrderInfos = new SrmPullingOrderBLL().GetList("" + "[LOG_FID] = N'" + logFid + "' and " + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (srmPullingOrderInfos.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///发送内容 List <BFDAPullingOrderInfo> srmVmiPullingOrderInfos = new List <BFDAPullingOrderInfo>(); foreach (var srmPullingOrderInfo in srmPullingOrderInfos) { srmVmiPullingOrderInfos.Add(GetSrmPullingOrderInfo(srmPullingOrderInfo)); } BFDASRMSendDataInfo <BFDAPullingOrderInfo> sendDataInfo = new BFDASRMSendDataInfo <BFDAPullingOrderInfo>(); sendDataInfo.List = srmVmiPullingOrderInfos; /// MaterialPullService_pttClient client = new MaterialPullService_pttClient(); client.Endpoint.Address = new EndpointAddress(interfaceConfigInfo.CallUrl); ///数据发送 msgContent = new XmlWrapper().ObjectToXmlByEncoding(sendDataInfo, Encoding.UTF8, false); msgContent = msgContent.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", ""); string result = client.MaterialPullService(msgContent, out errorCode, out errorMsg); if (result == Convert.ToString((int)OutboundReturnStateConstants.FAILURE)) { return(ExecuteResultConstants.Error); } return(ExecuteResultConstants.Success); }
/// <summary> /// 根据Id编号获取接口配置信息 /// </summary> /// <param name="icmd"></param> /// <param name="id"></param> /// <returns></returns> public InterfaceConfigInfo GetInterfaceConfigInfoById(IDbCommand icmd, Guid id) { icmd.Parameters.Clear(); MySqlCommand cmd = icmd as MySqlCommand; cmd.CommandType = CommandType.Text; string sql = @"select Id,InterfaceName,ApplicationName,ServerAddress,ServerUser,UserPwd,PersonInChargeName,PersonInChargePhone,ConnectedTimeout,DocumentHelpPath,Description,CreateTime,urlAddress,exeptionlevel,affectProduction,type,appid from interfaceconfiginfo where Id = '{0}'"; cmd.CommandText = string.Format(sql, id); InterfaceConfigInfo entity = null; DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); if (dt.Rows.Count > 0) { entity = new InterfaceConfigInfo(); entity.AllParse(dt.Rows[0]); } return(entity); }
/// <summary> /// 发送 /// </summary> /// <param name="logFid"></param> /// <param name="interfaceConfigInfo"></param> /// <param name="errorCode"></param> /// <param name="errorMsg"></param> /// <param name="msgContent"></param> /// <returns></returns> public static ExecuteResultConstants Send(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { /// msgContent = string.Empty; /// List <SrmSupplyPlanInfo> srmSupplyPlanInfos = new SrmSupplyPlanBLL().GetList("" + "[LOG_FID] = N'" + logFid + "' and " + "[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (srmSupplyPlanInfos.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///发送内容 List <BFDASupplyPlanInfo> list = new List <BFDASupplyPlanInfo>(); foreach (var srmSupplyPlanInfo in srmSupplyPlanInfos) { list.Add(GetSrmSupplyPlanInfo(srmSupplyPlanInfo)); } /////数据发送 msgContent = new XmlWrapper().ObjectToXmlByEncoding(list, Encoding.UTF8, true); msgContent = msgContent.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", ""); SRMSupplierPlanWSDL.SupplierPlanService_pttClient Client = new SRMSupplierPlanWSDL.SupplierPlanService_pttClient(); Client.Endpoint.Address = new System.ServiceModel.EndpointAddress(interfaceConfigInfo.CallUrl); /// string result = Client.SupplierPlanService(msgContent, out errorCode, out errorMsg); Log.WriteLogToFile(logFlag, interfaceCode + "--Return:dataCnt:" + result + "Content:" + msgContent + "\r", AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); if (result == Convert.ToString((int)OutboundReturnStateConstants.FAILURE)) { return(ExecuteResultConstants.Error); } return(ExecuteResultConstants.Success); }
/// <summary> /// 获取接口配置信息列表(带分页) /// </summary> /// <param name="icmd"></param> /// <param name="fields"></param> /// <param name="whereCondition"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public List <InterfaceConfigInfo> GetInterfaceConfigInfoPageList(IDbCommand icmd, string fields, string whereCondition, int startIndex, int pageSize) { icmd.Parameters.Clear(); MySqlCommand cmd = icmd as MySqlCommand; cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(fields)) { sb.AppendFormat("select {0} from interfaceconfiginfo ", fields); } if (!string.IsNullOrEmpty(whereCondition)) { sb.AppendFormat("{0} ", whereCondition); } sb.AppendFormat("limit {0},{1} ", startIndex, pageSize); cmd.CommandText = sb.ToString(); List <InterfaceConfigInfo> list = new List <InterfaceConfigInfo>(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); if (dt.Rows.Count > 0) { InterfaceConfigInfo obj = null; foreach (DataRow dr in dt.Rows) { obj = new InterfaceConfigInfo(); obj.AllParse(dr); if (null != obj) { list.Add(obj); } } } return(list); }
/// <summary> /// 接口配置信息添加测试 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button5_Click(object sender, EventArgs e) { #region 接口配置添加测试 InterfaceConfigInfo entity = new InterfaceConfigInfo(); entity.Id = new Guid("ad6fb4e4-96c0-4e15-a072-dd921bcac243"); entity.InterfaceName = "InterfaceMonitor.Frameworks.Logical.InterfaceConfigInfoOperation"; entity.ApplicationName = "测试接口"; entity.ServerAddress = "192.168.1.100"; entity.ServerUser = "******"; entity.UserPwd = "test123"; entity.PersonOfChargeName = "json"; entity.PersonOfChargePhone = "13812345678"; entity.ConnectedTimeout = 200; entity.DocumentHelpPath = "../root/test.pdf"; entity.Description = "不拉不拉不拉"; entity.CreateTime = DateTime.Now; InterfaceConfigInfoOperation.AddOrUpdateInterfaceConfigInfo(entity, ModifierType.Add); #endregion #region 接口配置更新测试 //InterfaceConfigInfo entity2 = new InterfaceConfigInfo(); //entity2.Id = new Guid("BB71F8EB-1C7C-4E88-8FA5-EC76FF9F5189"); //entity2.InterfaceName = "InterfaceMonitor.Frameworks.Dal.InterfaceConfigInfoDal"; //entity2.ApplicationName = "测试接口2"; //entity2.ServerAddress = "192.168.1.80"; //entity2.ServerUser = "******"; //entity2.UserPwd = "test123"; //entity2.PersonOfChargeName = "json"; //entity2.PersonOfChargePhone = "13812345678"; //entity2.ConnectedTimeout = 200; //entity2.DocumentHelpPath = "../root/test2.pdf"; //entity2.Description = "不拉不拉不拉呜呜呜呜"; //entity.CreateTime = DateTime.Now; //InterfaceConfigInfoOperation.AddOrUpdateInterfaceConfigInfo(entity2, ModifierType.Update); #endregion }
/// <summary> /// Handler /// </summary> public void Handler() { List <InterfaceConfigInfo> interfaceConfigInfos = new InterfaceConfigBLL().GetList("[SYS_NAME] = N'" + targetSystem + "'", string.Empty); if (interfaceConfigInfos.Count == 0) { return; } ///接口配置 InterfaceConfigInfo interfaceConfigInfo = null; ///WMS-LES-002,WMS库存交易记录 interfaceConfigInfo = interfaceConfigInfos.FirstOrDefault(d => d.InterfaceCode.ToUpper() == "WMS-LES-002"); if (interfaceConfigInfo != null) { SyncWmsVmiTranDetailBLL.Sync(loginUser); } ///WMS-LES-006,WMS送货单 interfaceConfigInfo = interfaceConfigInfos.FirstOrDefault(d => d.InterfaceCode.ToUpper() == "WMS-LES-006"); if (interfaceConfigInfo != null) { SyncWmsVmiAsnRunsheetBLL.Sync(loginUser); } }
/// <summary> /// LES-SAP-015 断点替换记录 /// </summary> /// <param name="logFid"></param> public static ExecuteResultConstants SendBreakpointReplaceData(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { msgContent = string.Empty; List <SapBreakpointReplaceInfo> sapSendInfos = new SapBreakpointReplaceBLL().GetList("[LOG_FID] = N'" + logFid + "' and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (sapSendInfos.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///发送消息 Zsles006[] Itab = new Zsles006[sapSendInfos.Count]; for (int i = 0; i < sapSendInfos.Count; i++) { Zsles006 zles006 = new Zsles006(); zles006.Aufnr = sapSendInfos[i].Aufnr; ///生产订单 zles006.Nmatnr = sapSendInfos[i].Nmatnr; ///新物料号 zles006.Omatnr = sapSendInfos[i].Omatnr; ///旧物料号 zles006.Menge = sapSendInfos[i].Menge.GetValueOrDefault(); ///数量 zles006.Vlsch = sapSendInfos[i].Vlsch; ///工位 zles006.Rdate = sapSendInfos[i].Rdate.GetValueOrDefault().ToString(sapDateFormat); ///替换日期 Itab[i] = zles006; } ZLES006Client client = new ZLES006Client(); client.Endpoint.Address = new EndpointAddress(interfaceConfigInfo.CallUrl); ///1标识成功、0标识失败 //long tenantId = 89; //if (!long.TryParse(interfaceConfigInfo.Param2, out tenantId)) //{ // errorCode = "MC:3x00000021";///接口配置错误 // return ExecuteResultConstants.Exception; //} ///返回对象 Zfles006[] retu006 = new Zfles006[0]; ///1标识成功、0标识失败 string result; ///返回信息提示 string msg; ///影响数据行数 int dataCnt = client.Zles006(ref Itab, ref retu006, out result, out msg); Log.WriteLogToFile("LES-SAP-015 断点替换记录.return:dataCnt:" + dataCnt, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); ///失败时的ERROR_CODE中是对方系统的ERROR_MSG if (result == "0") { errorMsg = msg; for (int i = 0; i < retu006.Count(); i++) { errorMsg += "; "; errorMsg += retu006[i].Nmatnr + ":" + retu006[i].Mess; } Log.WriteLogToFile(errorMsg, AppDomain.CurrentDomain.BaseDirectory + @"\Error_Log\", DateTime.Now.ToString("yyyyMMddHH")); return(ExecuteResultConstants.Error); } msgContent = GetMsgContent(sapSendInfos); Log.WriteLogToFile("result:" + result + " | Content:" + msgContent, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); return(ExecuteResultConstants.Success); }
/// <summary> /// LES-WMS-008 VMI供应商物料关系 LW005 /// </summary> /// <param name="logFid"></param> public static ExecuteResultConstants SendSupplierMaterialRelationship(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { msgContent = string.Empty; List <WmsVmiSupplierPartInfo> vmiSupplierParts = new WmsVmiSupplierPartBLL().GetList("[LOG_FID] = N'" + logFid + "' and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (vmiSupplierParts.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///转换发送内容 List <BFDAVmiSupplierPartInfo> fDAVmiSupplierPartInfos = new List <BFDAVmiSupplierPartInfo>(); foreach (var vmiSupplierPartInfo in vmiSupplierParts) { fDAVmiSupplierPartInfos.Add(GetBFDAVMIInfo(vmiSupplierPartInfo)); } BFDAVMISendDataInfo <BFDAVmiSupplierPartInfo> sendDataInfo = new BFDAVMISendDataInfo <BFDAVmiSupplierPartInfo>(); sendDataInfo.List = fDAVmiSupplierPartInfos; ///调用 WsProcessServiceClient client = new WsProcessServiceClient(); client.Endpoint.Address = new EndpointAddress(interfaceConfigInfo.CallUrl); ///1标识成功、0标识失败 long tenantId = 89; if (!long.TryParse(interfaceConfigInfo.Param2, out tenantId)) { errorCode = "MC:3x00000021";///接口配置错误 return(ExecuteResultConstants.Exception); } ///数据发送 msgContent = new XmlWrapper().ObjectToXml(sendDataInfo, false); Log.WriteLogToFile(msgContent, AppDomain.CurrentDomain.BaseDirectory + @"\logContent\", DateTime.Now.ToString("yyyyMMddHHmm") + interfaceConfigInfo.SysMethodName); string result = client.runProcessWithAction(interfaceConfigInfo.Param1, tenantId, interfaceConfigInfo.SysMethodName, msgContent); BFDAVMIResultInfo resultInfo = new XmlWrapper(result, LoadType.FromString).XmlToObject("/Result", typeof(BFDAVMIResultInfo)) as BFDAVMIResultInfo; // throw new Exception(resultInfo.Status); TDD: delete ///成功后更新中间表数据处理状态 if (resultInfo.Status.ToLower() == "error") { errorCode = resultInfo.ErrorCode; errorMsg = resultInfo.ErrorMsg; return(ExecuteResultConstants.Error); } Log.WriteLogToFile("END: " + ExecuteResultConstants.Success, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHHmm")); return(ExecuteResultConstants.Success); }
/// <summary> /// 物料移动数据发送至SAP /// </summary> /// <param name="logFid"></param> public static ExecuteResultConstants SendMaterialMoveData(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { msgContent = string.Empty; List <SapTranOutInfo> sapTranOutInfos = new SapTranOutBLL().GetList("[LOG_FID] = N'" + logFid + "' and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (sapTranOutInfos.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///发送消息 Zsles002[] Itab = new Zsles002[sapTranOutInfos.Count]; for (int i = 0; i < sapTranOutInfos.Count; i++) { Zsles002 zsles002 = new Zsles002(); ///匹配字段 zsles002.Id = sapTranOutInfos[i].Fid.GetValueOrDefault().ToString(); ///唯一值 zsles002.Matnr = sapTranOutInfos[i].Matnr; ///物料 zsles002.Menge = sapTranOutInfos[i].Menge.GetValueOrDefault(); ///数量 (检查传值时候, 小数的位数) zsles002.Rsnum = sapTranOutInfos[i].Rsnum; ///预留号 zsles002.Bwart = sapTranOutInfos[i].Bwart; ///移动类型 zsles002.Kostl = sapTranOutInfos[i].Kostl; ///成本中心 zsles002.Budat = sapTranOutInfos[i].Budat.GetValueOrDefault().ToString(sapDateFormat); ///日期 zsles002.Lgort = sapTranOutInfos[i].Lgort; ///发出库存地点 zsles002.Umlgo = sapTranOutInfos[i].Umlgo; ///接收库存地点 zsles002.Werks = sapTranOutInfos[i].Werks; ///发出工厂 zsles002.Unwrk = sapTranOutInfos[i].Unwrk; ///收货工厂 zsles002.Ebelp = sapTranOutInfos[i].Ebelp.GetValueOrDefault().ToString(); ///采购订单行号 zsles002.Ebeln = sapTranOutInfos[i].Ebeln; ///采购订单号 zsles002.Lifnr = sapTranOutInfos[i].Lifnr; ///供应商 //zsles002.Aufnr = string.Empty; ///生产订单号 ///已经撤销 //zsles002.Kosrt = string.Empty; ///成本中心 ///已经撤销 //zsles002.Rspos = string.Empty; ///预留行号 ///已经撤销 Itab[i] = zsles002; } ZLES002Service service = new ZLES002Service(); service.Url = interfaceConfigInfo.CallUrl; ///1标识成功、0标识失败 string sapResult; ///影响数据行数 int dataCnt = service.Zles002(ref Itab, out errorMsg, out sapResult); Log.WriteLogToFile(logFlag, "Return:dataCnt:" + dataCnt, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHHmm")); ///失败时的ERROR_CODE中是对方系统的ERROR_MSG if (sapResult == "0") { return(ExecuteResultConstants.Error); } msgContent = GetMsgContent(sapTranOutInfos); return(ExecuteResultConstants.Success); }
/// <summary> /// Handler /// </summary> public void Handler() { List <InterfaceConfigInfo> interfaceConfigInfos = new InterfaceConfigBLL().GetList("[SYS_NAME] = N'" + targetSystem + "'", string.Empty); if (interfaceConfigInfos.Count == 0) { return; } ///发送消息前需要获取执行结果⑨为10.submit、60.submit的数据,逐条按methodCode④提交到不同的业务处理函数内 List <SapOutboundLogInfo> sapOutboundLogInfos = new SapOutboundLogBLL().GetListForUnsend(); if (sapOutboundLogInfos.Count == 0) { return; } foreach (SapOutboundLogInfo sapOutboundLogInfo in sapOutboundLogInfos) { ///业务处理函数开始处理之前需要根据logFid更新executeResult⑧为20.processing ///executeStartTime为当前数据库时间 ///在BLL.LES.CommonBll提供UpdateProcessingLog函数,参数为Guid logFid BLL.LES.CommonBLL.UpdateProcessingLog(targetSystem, sapOutboundLogInfo.Id, loginUser); ///处理结果 ExecuteResultConstants executeResult = ExecuteResultConstants.Processing; ///错误代码 string errorCode = string.Empty; ///报文内容 string msgContent = null; ///错误消息 string errorMsg = string.Empty; InterfaceConfigInfo interfaceConfigInfo = interfaceConfigInfos.FirstOrDefault(d => d.InterfaceCode.ToLower() == sapOutboundLogInfo.MethodCode.ToLower()); if (interfaceConfigInfo == null) { errorCode = "MC:3x00000021";///接口配置错误 executeResult = ExecuteResultConstants.Exception; } else { /// switch (sapOutboundLogInfo.MethodCode.ToLower().Trim()) { ///物料移动数据发送至SAP TI_IFM_SAP_TRAN_OUT case "les-sap-009": executeResult = BFDAMaterialMoveBLL.SendMaterialMoveData(sapOutboundLogInfo.Fid, interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-SAP-017 缺件影响生产订单范围 TI_IFM_SAP_PRODUCTION_ORDER_LACK_MATERIAL case "les-sap-017": executeResult = BFDAProductionOrderLackMaterialBLL.SendLackMaterialData(sapOutboundLogInfo.Fid, interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-SAP-015 断点替换记录 TI_IFM_SAP_BREAKPOINT_REPLACE case "les-sap-015": executeResult = BFDASAPBreakpointReplaceBLL.SendBreakpointReplaceData(sapOutboundLogInfo.Fid, interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-SAP-012 发送盘点报告 TI_IFM_SAP_INVENTORY_CHECK_REPORT case "les-sap-012": executeResult = BFDASAPInventoryCheckReportBLL.SendInventoryCheckReportData(sapOutboundLogInfo.Fid, interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; } } if (!string.IsNullOrEmpty(errorCode)) { errorMsg = GetMessage(ref errorCode); } ///更新任务状态 BLL.LES.CommonBLL.UpdateResultLog(targetSystem, sapOutboundLogInfo.Id, executeResult, msgContent, errorCode, errorMsg, loginUser); } }
/// <summary> /// Handler /// </summary> public void Handler() { List <InterfaceConfigInfo> interfaceConfigInfos = new InterfaceConfigBLL().GetList("[SYS_NAME] = N'" + targetSystem + "'", string.Empty); if (interfaceConfigInfos.Count == 0) { return; } ///发送消息前需要获取执行结果⑨为10.submit、60.submit的数据,逐条按methodCode④提交到不同的业务处理函数内 List <MesOutboundLogInfo> vmiOutboundLogInfos = new MesOutboundLogBLL().GetListForUnsend(); // List<SrmOutboundLogInfo> vmiOutboundLogInfos = new SrmOutboundLogBLL().GetListForUnsend(); if (vmiOutboundLogInfos.Count == 0) { return; } foreach (MesOutboundLogInfo srmOutboundInfo in vmiOutboundLogInfos) { ///业务处理函数开始处理之前需要根据logFid更新executeResult⑧为20.processing ///executeStartTime为当前数据库时间 ///在BLL.LES.CommonBll提供UpdateProcessingLog函数,参数为Guid logFid BLL.LES.CommonBLL.UpdateProcessingLog(targetSystem, srmOutboundInfo.Id, loginUser); ///处理结果 ExecuteResultConstants executeResult = ExecuteResultConstants.Processing; ///错误代码 string errorCode = string.Empty; ///报文内容 string msgContent = null; ///错误消息 string errorMsg = string.Empty; InterfaceConfigInfo interfaceConfigInfo = interfaceConfigInfos.FirstOrDefault(d => d.InterfaceCode.ToLower() == srmOutboundInfo.MethodCode.ToLower()); if (interfaceConfigInfo == null) { errorCode = "MC:3x00000021";///接口配置错误 executeResult = ExecuteResultConstants.Exception; } else { /// Log.WriteLogToFile("The switch|" + srmOutboundInfo.MethodCode, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHHmm")); switch (srmOutboundInfo.MethodCode.ToLower()) { ///LES-MES-002 缺件影响订单 case "les-mes-002": executeResult = BFDAMesMissingpartsInfluenceOrderscopeBLL.SendQmisAsnPullSheet(srmOutboundInfo.Fid, interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-MES-005 断点替换信息 case "les-mes-005": executeResult = BFDAMesBreakpointReplacementRecordBLL.SendQmisAsnPullSheet(srmOutboundInfo.Fid, interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; default: break; } } if (!string.IsNullOrEmpty(errorCode)) { errorMsg = GetMessage(ref errorCode); } ///更新任务状态 BLL.LES.CommonBLL.UpdateResultLog(targetSystem, srmOutboundInfo.Id, executeResult, msgContent, errorCode, errorMsg, loginUser); } }
/// <summary> /// Handler /// </summary> public void Handler() { List <InterfaceConfigInfo> interfaceConfigInfos = new InterfaceConfigBLL().GetList("[SYS_NAME] = N'" + targetSystem + "'", string.Empty); if (interfaceConfigInfos.Count == 0) { return; } ///发送消息前需要获取执行结果⑨为10.submit、60.submit的数据,逐条按methodCode④提交到不同的业务处理函数内 List <SrmOutboundLogInfo> vmiOutboundLogInfos = new SrmOutboundLogBLL().GetListForUnsend(); if (vmiOutboundLogInfos.Count == 0) { return; } foreach (SrmOutboundLogInfo srmOutboundInfo in vmiOutboundLogInfos) { ///业务处理函数开始处理之前需要根据logFid更新executeResult⑧为20.processing ///executeStartTime为当前数据库时间 ///在BLL.LES.CommonBll提供UpdateProcessingLog函数,参数为Guid logFid BLL.LES.CommonBLL.UpdateProcessingLog(targetSystem, srmOutboundInfo.Id, loginUser); ///处理结果 ExecuteResultConstants executeResult = ExecuteResultConstants.Processing; ///错误代码 string errorCode = string.Empty; ///报文内容 string msgContent = null; ///错误消息 string errorMsg = string.Empty; InterfaceConfigInfo interfaceConfigInfo = interfaceConfigInfos.FirstOrDefault(d => d.InterfaceCode.ToLower() == srmOutboundInfo.MethodCode.ToLower()); if (interfaceConfigInfo == null) { executeResult = ExecuteResultConstants.Exception; errorCode = "3x00000021";///接口配置错误 errorMsg = GetMessage(ref errorCode); BLL.LES.CommonBLL.UpdateResultLog(targetSystem, srmOutboundInfo.Id, executeResult, msgContent, errorCode, errorMsg, loginUser); continue; } /// switch (srmOutboundInfo.MethodCode.ToLower()) { ///LES-SRM-001 VMI供应商物料关系 √ case "les-srm-001": executeResult = BFDAVmiSupplierPartBLL.Send(srmOutboundInfo.Fid.GetValueOrDefault(), interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-SRM-002 供货计划 √ TI_IFM_SRM_SUPPLY_PLAN case "les-srm-002": executeResult = BFDASupplyPlanBLL.Send(srmOutboundInfo.Fid.GetValueOrDefault(), interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-WMS-004 JIS 拉动单 (排序拉动单) √ TI_IFM_SRM_JIS_PULL_ORDER case "les-srm-004": executeResult = BFDAJisPullOrderBLL.Send(srmOutboundInfo.Fid.GetValueOrDefault(), interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; /// LES-SRM-005 物料拉动单 √ TI_IFM_SRM_PULLING_ORDER case "les-srm-005": executeResult = BFDAPullingOrderBLL.Send(srmOutboundInfo.Fid.GetValueOrDefault(), interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; ///LES-SRM-008 入库数据 √ TI_IFM_SRM_TRAN_OUT case "les-srm-008": executeResult = BFDATranOutBLL.Send(srmOutboundInfo.Fid.GetValueOrDefault(), interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; /// LES-SRM-009 物料退货单 TI_IFM_SRM_PART_RETURN_SHEET case "les-srm-009": executeResult = BFDAPartReturnSheetBLL.Send(srmOutboundInfo.Fid.GetValueOrDefault(), interfaceConfigInfo, ref errorCode, ref errorMsg, out msgContent); break; } errorMsg = GetMessage(ref errorCode); Log.WriteLogToFile(logFlag, srmOutboundInfo.MethodCode + ":Handler:msgContent:" + msgContent, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); ///更新任务状态 BLL.LES.CommonBLL.UpdateResultLog(targetSystem, srmOutboundInfo.Id, executeResult, msgContent, errorCode, errorMsg, loginUser); } }
/// <summary> /// LES-SAP-012 盘点计划报告 /// </summary> /// <param name="logFid"></param> public static ExecuteResultConstants SendInventoryCheckReportData(Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { msgContent = string.Empty; List <SapInventoryCheckReportInfo> sapInventoryCheckReportInfos = new SapInventoryCheckReportBLL().GetList("[LOG_FID] = N'" + logFid + "' and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (sapInventoryCheckReportInfos.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///发送消息 Zsles008[] Itab = new Zsles008[sapInventoryCheckReportInfos.Count]; for (int i = 0; i < sapInventoryCheckReportInfos.Count; i++) { Zsles008 zfles008 = new Zsles008(); zfles008.Iblnr = sapInventoryCheckReportInfos[i].Iblnr; ///库存盘点凭证 zfles008.Matnr = sapInventoryCheckReportInfos[i].Matnr; ///物料号 ///zfles008.Werks = sapInventoryCheckReportInfos[i].; ///工厂 zfles008.Lgort = sapInventoryCheckReportInfos[i].Lgort; ///库存地点 zfles008.Menge = Convert.ToDecimal(sapInventoryCheckReportInfos[i].Menge.GetValueOrDefault()); ///数量 zfles008.Aqty = Convert.ToDecimal(sapInventoryCheckReportInfos[i].Aqty.GetValueOrDefault()); ///实盘数量 zfles008.Dqty = Convert.ToDecimal(sapInventoryCheckReportInfos[i].Dqty.GetValueOrDefault()); ///差异数量 zfles008.Gidat = sapInventoryCheckReportInfos[i].Zldat.GetValueOrDefault().ToString(sapDateFormat); ///库存盘点计划日期 Itab[i] = zfles008; } msgContent = new XmlWrapper().ObjectToXml(Itab, false); Log.WriteLogToFile("LES-SAP-012 盘点报告.return:Count:" + sapInventoryCheckReportInfos.Count + "/r" + msgContent, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); ZLES008Client client = new ZLES008Client(); client.Endpoint.Address = new EndpointAddress(interfaceConfigInfo.CallUrl); ///返回对象 Zfles008[] retu008 = new Zfles008[0]; ///1标识成功、0标识失败 int result; ///返回信息提示 string msg; ///影响数据行数 string dataCnt = client.Zles008(ref Itab, ref retu008, out result, out msg); Log.WriteLogToFile("LES-SAP-012 盘点报告.return:dataCnt:" + dataCnt, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); ///失败时的ERROR_CODE中是对方系统的ERROR_MSG if (result == 0) { errorMsg = msg; for (int i = 0; i < retu008.Count(); i++) { errorMsg += "; "; errorMsg += retu008[i].Msg + ":" + retu008[i].Iblnr; } Log.WriteLogToFile(errorMsg, AppDomain.CurrentDomain.BaseDirectory + @"\Error_Log\", DateTime.Now.ToString("yyyyMMddHH")); return(ExecuteResultConstants.Error); } msgContent = GetMsgContent(sapInventoryCheckReportInfos); Log.WriteLogToFile("result:" + result + " | Content:" + msgContent, AppDomain.CurrentDomain.BaseDirectory + @"\log\", DateTime.Now.ToString("yyyyMMddHH")); return(ExecuteResultConstants.Success); }
public object AddApplicationInterfaceRelation(string appid, string appname, string interfaceid, string interfacename, string destinappid, string destinappname, string fatherid, string fathername) { try { SystemSettingBase settings = SystemSettingBase.CreateInstance(); if (settings.SysMySqlDB != null) { ConnString.MySqldb = settings.SysMySqlDB.ConnectionString; } if (null == ApplicationInterfaceRelationOperation.GetApplicationInterfaceRelation(new Guid(appid), new Guid(interfaceid), new Guid(destinappid))) { ApplicationInterfaceRelation info = new ApplicationInterfaceRelation() { Id = Guid.NewGuid(), appId = new Guid(appid), appname = appname, interfaceId = new Guid(interfaceid), interfacename = interfacename, destinappid = new Guid(destinappid), destinappname = destinappname, updatetime = DateTime.Now }; ApplicationInterfaceRelationOperation.AddOrUpdateApplicationInterfaceRelation(info, ModifierType.Add); if (null == ApplicationRelationOperation.GetApplicationRelationById(new Guid(appid))) { ApplicationRelation relation = new ApplicationRelation() { appId = new Guid(appid), appName = appname, fatherId = new Guid(fatherid), fatherName = fathername, childId = new Guid(destinappid), childName = destinappname }; ApplicationRelationOperation.AddOrUpdateApplicationRelation(relation, ModifierType.Add); } //更新接口配置表接口配置中接口所属系统信息 InterfaceConfigInfo interfaceConfig = InterfaceConfigInfoOperation.GetInterfaceConfigInfoById(new Guid(interfaceid)); if (null != interfaceConfig) { interfaceConfig.ApplicationName = appname; interfaceConfig.CreateTime = DateTime.Now; InterfaceConfigInfoOperation.AddOrUpdateInterfaceConfigInfo(interfaceConfig, ModifierType.Update); } //更新接口实时信息表中接口所属系统信息 InterfaceRealtimeInfo realtimeInfo = InterfaceRealtimeInfoOperation.GetInterfaceRealtimeInfo(new Guid(interfaceid)); if (null != realtimeInfo) { realtimeInfo.ApplicationName = appname; realtimeInfo.UpdateTime = DateTime.Now; InterfaceRealtimeInfoOperation.AddOrUpdateInterceRealtimeInfo(realtimeInfo, ModifierType.Update); } return(string.Format("添加【{0},{1},{2}】关联关系成功!", appname, interfacename, destinappname)); } else { return(string.Format("系统已存在【{0},{1},{2}】该关联关系!", appname, interfacename, destinappname)); } } catch (Exception ex) { return(string.Format("添加【{0},{1},{2}】关联关系失败!异常信息如下:{3}", appname, interfacename, destinappname, ex.Message)); } }