/// <summary> /// API 2,根据混兑比例和切割方案获取数据 /// </summary> /// <param name="s"></param> /// <returns></returns> private OilInfoBEntity getByRate(Specs s, BindResult pr, ref List <PropertyTable> result) { var r = pr.GetResult <FittingResult>(); if (r != null) { var oilApplyBll = new OilApplyAPIBll(); //切割比率 var cutOilRates = new List <CutOilRateEntity>(); foreach (var l in r.Specs) { cutOilRates.Add(new CutOilRateEntity() { crudeIndex = l.Spec.UUID, rate = (float)(l.Rate * 100) }); } var cuts = new List <CutMothedAPIEntity>(); foreach (var t in this._initP) { if (t.Table == PropertyType.NIR) { continue; } cuts.Add(new CutMothedAPIEntity() { ICP = (int)t.BoilingStart, ECP = (int)t.BoilingEnd, Name = this.convertEnum(t.Table) }); } try { log.Info(string.Join(";", cutOilRates.Select(d => string.Format("{0},{1}", d.crudeIndex, d.rate)))); log.Info(string.Join(";", cuts.Select(d => string.Format("ICP={0},ECP={1},Name={2}", d.ICP, d.ECP, d.Name)))); var oil = oilApplyBll.GetCutResultAPI(cutOilRates, cuts); if (oil != null) { var lst = oil.OilDataTableBAPIEntityList; convertEntity(lst, ref result, IntegrateModel.GetConfidence(r.TQ, r.MinTQ, r.SQ, r.MinSQ)); } return(oil); } catch (Exception ex) { log.Error(ex.ToString()); } } return(null); }
/// <summary> /// API 1,根据原油名称的切割方案获取数据 /// </summary> /// <param name="s"></param> /// <returns></returns> private OilInfoBEntity getByName(Specs s, BindResult pr, ref List <PropertyTable> result) { var r = pr.GetResult <IdentifyResult>(); if (r != null) { OilInfoBEntity oil = new OilInfoBEntity(); //新建一条原油 var oilApplyBll = new OilApplyAPIBll(); var cuts = new List <CutMothedAPIEntity>(); foreach (var t in this._initP) { if (t.Table == PropertyType.NIR) { continue; } cuts.Add(new CutMothedAPIEntity() { ICP = (int)t.BoilingStart, ECP = (int)t.BoilingEnd, Name = this.convertEnum(t.Table) }); } try { log.Info(r.Items.First().Spec.UUID); log.Info(string.Join(";", cuts.Select(d => string.Format("ICP={0},ECP={1},Name={2}", d.ICP, d.ECP, d.Name)))); oil = oilApplyBll.GetCutResultAPI(r.Items.First().Spec.UUID, cuts); if (oil != null) { var lst = oil.OilDataTableBAPIEntityList; convertEntity(lst, ref result, IntegrateModel.GetConfidence(r.Items.First().TQ, r.MinTQ, r.Items.First().SQ, r.MinSQ)); //写入值信度 } else { log.ErrorFormat("GetCutResultAPI({0})", r.Items.First().Spec.UUID); } return(oil); } catch (Exception ex) { log.Error(ex.ToString()); } } return(null); }
public static void GetNIRData(Specs s, OilInfoBEntity oil, ref List <PropertyTable> lst) { if (s == null || s.Spec == null || s.Spec.Components == null) { return; } var cmps = s.Spec.Components; var t = lst.Where(d => d.Table == PropertyType.NIR).FirstOrDefault(); if (t != null) { if (oil != null) { t.OilInfoDetail = new OilInfo() { CrudeIndex = oil.crudeIndex, CrudeName = oil.crudeName } } ; double confidence = double.NaN; List <IntegrateResultItem> itgResult = null; switch (s.ResultObj.MethodType) { case PredictMethod.Identify: var r1 = s.ResultObj.GetResult <IdentifyResult>(); confidence = IntegrateModel.GetConfidence(r1.Items.First().TQ, r1.MinTQ, r1.Items.First().SQ, r1.MinSQ); break; case PredictMethod.Fitting: var r2 = s.ResultObj.GetResult <FittingResult>(); confidence = IntegrateModel.GetConfidence(r2.TQ, r2.MinTQ, r2.SQ, r2.MinSQ); break; case PredictMethod.PLSBind: confidence = 90; break; case PredictMethod.Integrate: itgResult = s.ResultObj.GetResult <List <IntegrateResultItem> >(); break; } foreach (var c in cmps) { var item = t.Datas.Where(d => d.Name == c.Name).FirstOrDefault(); if (item != null) { item.Value = c.PredictedValue; if (s.ResultObj.MethodType == PredictMethod.Integrate) { var itgitem = itgResult.Where(d => d.Comp.Name == c.Name).FirstOrDefault(); if (itgResult != null) { item.Confidence = itgitem.ConfidenceOutter; } } else { item.Confidence = confidence; } } } } }