private MeasurementTestResult Calculate(Guid specItemID, out WorkInfoSpecItem item) { item = MeasurementJob.SpecData.WorkInfoSpecItems.FirstOrDefault(q => q.SpecItemID == specItemID); if (item == null) { return(new MeasurementTestResult() { Result = -1, Message = "规格异常", Data = 0D }); } var testResult = MeasuringManager.Calculate( MeasurementJob.ReferenceData, TestData, item.SystemTypeID, item.TestGroupTestType, item.TestTemp, item.PortSetting, item.TestSetting ); if (testResult.Result < 1) { return(testResult); } if (testResult.Data == double.MinValue) { testResult.Result = -1; testResult.Message = "计算结果出错"; return(testResult); } testResult.Result = 0; foreach (var resultSetting in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult.OrderBy(q => q.ResultID)) { ComputeSettingItem computeItem = default(ComputeSettingItem); if (!item.ComputeSetting.TryGetValue(resultSetting.ResultID, out computeItem)) { testResult.Result = -1; testResult.Message = "规格判断标准设置错误"; return(testResult); } if (string.IsNullOrEmpty(computeItem.ComputeValue)) { continue; } if (OperatorManager.GetOperator(computeItem.ComputeSign).GetComputeResult(computeItem.ComputeValue, testResult.Data)) { testResult.Result = resultSetting.ResultID; testResult.Message = $"{item.ItemName} 通过"; } else { testResult.Message = "结果不符合规格"; } } return(testResult); }
private string GetTagValue(string tag) { var temp = 0; var round = -1; var port = int.MinValue; var dataType = 0; var tagString = tag; var stringTemp = ""; tagString = GetRound(tagString, out round); tagString = GetTemperature(tagString, out temp); tagString = GetPort(tagString, out port); tagString = GetDataType(tagString, out dataType); if (dataType == int.MinValue) { return(tagString); } if (temp > tempSetting.Length) { return(""); } else if (temp >= 0) { stringTemp = tempSetting[temp]; } //测试项目有相同项目 var testedData = testInfo.TestItems.Where( q => q.ItemName == tagString && (string.IsNullOrEmpty(stringTemp) || q.TestTemp == stringTemp) && (port == int.MinValue || BaseSettingsManager.Get <SystemGroupSetting>().GetTestSystemItem(q.SystemID).PortSetting == port) ).ToList(); if (testedData.Count > 0) { return(GetTestValue(testedData, dataType, round)); } var setting = ""; var tagItem = GetSetting(tagString, out setting); var testSystem = BaseSettingsManager.Get <SystemGroupSetting>().GetTestSystemItem(classID, tagItem, port); if (testSystem == null) { return(""); } //测试项目设置符合条件 testedData = testInfo.TestItems.Where( q => q.SystemID == testSystem.SystemID && (string.IsNullOrEmpty(setting) || q.TestInfo == setting) && (string.IsNullOrEmpty(stringTemp) || q.TestTemp == stringTemp)).ToList(); if (testedData != null) { return(GetTestValue(testedData, dataType, round)); } //重新计算结果 try { var testGroup = BaseSettingsManager.Get <SystemGroupSetting>().GetTestSystemGroup(testSystem.TestGroupID); if (testGroup == null) { return(""); } var value = MeasuringManager.Calculate(referenceData, collection, testSystem.SystemTypeID, testGroup.TestGroupTestType, stringTemp, testSystem.PortSetting, setting); if (value.Result > -1 && value.Data != double.MinValue) { return(round < 0 ? value.Data.ToString() : Math.Round(value.Data, round).ToString()); } } catch (Exception ex) { Incht.Common.Log.LogHelper.WriteLog("TemplateData", ex); } return(""); }