/// <summary> /// LES-WMS-005 入库数据 WL004 // <param name="logFid"></param> public static ExecuteResultConstants SendInboundOrder (Guid logFid, InterfaceConfigInfo interfaceConfigInfo, ref string errorCode, ref string errorMsg, out string msgContent) { msgContent = string.Empty; List <WmsTranOutInfo> vmiInboundOrderInfos = new WmsTranOutBLL().GetList("[LOG_FID] = N'" + logFid + "' and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", string.Empty); if (vmiInboundOrderInfos.Count == 0) { errorCode = "MC:0x00000212";///经检测,传递数据为空,请确认 return(ExecuteResultConstants.Exception); } ///发送内容 List <BFDAVmiInboundDataInfo> bFDAVmiInboundDataInfos = new List <BFDAVmiInboundDataInfo>(); foreach (var VmiInboundDataInfo in vmiInboundOrderInfos) { bFDAVmiInboundDataInfos.Add(GetBFDAVMIInfo(VmiInboundDataInfo)); } BFDAVMISendDataInfo <BFDAVmiInboundDataInfo> sendDataInfo = new BFDAVMISendDataInfo <BFDAVmiInboundDataInfo>(); sendDataInfo.List = bFDAVmiInboundDataInfos; /// 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> /// Handler /// </summary> public void Handler() { ///WMS交易记录单次传输最大行数 string wmsTranOutDataMaxRows = new ConfigBLL().GetValueByCode("WMS_TRAN_OUT_DATA_MAX_ROWS"); ///默认为1000行 if (!int.TryParse(wmsTranOutDataMaxRows, out int maxRows)) { maxRows = 1000; } ///WMS交易记录单次传输最小行数 string wmsTranOutDataMinRows = new ConfigBLL().GetValueByCode("WMS_TRAN_OUT_DATA_MIN_ROWS"); ///默认为1000行 if (!int.TryParse(wmsTranOutDataMinRows, out int minRows)) { minRows = 20; } ///未处理数据条件 string untreatedDataCondition = "[LOG_FID] is NULL and [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + " "; /// int dataCnt = minRows + 1; while (dataCnt > minRows) { ///获取数据,TODO:考虑修改为只获取主键以提高程序执行效率 List <WmsTranOutInfo> wmsTranOutInfos = new WmsTranOutBLL().GetListByPage(untreatedDataCondition, "[ID]", 1, maxRows, out dataCnt); if (dataCnt == 0) { break; } Guid logFid = Guid.NewGuid(); ///生成发送任务 string sql = BLL.LES.CommonBLL.GetCreateOutboundLogSql("VMI", logFid, "LES-WMS-005", string.Empty, loginUser); sql += "update [LES].[TI_IFM_WMS_TRAN_OUT] " + "set [LOG_FID] = N'" + logFid + "',[MODIFY_USER] = N'" + loginUser + "',[MODIFY_DATE] = GETDATE() " + "where [ID] in (" + string.Join(",", wmsTranOutInfos.Select(d => d.Id).ToArray()) + ");"; using (var trans = new TransactionScope()) { BLL.SYS.CommonBLL.ExecuteNonQueryBySql(sql); trans.Complete(); } } }