using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; using IStation.Calculation.DispatchAna.Model; namespace IStation.Calculation.DispatchAna { /// /// 陈行一输调度方案计算器(最优方案) /// public class Calculator_OptAna_SHYS_陈行一输: CalculatorBase_SHYS_陈行一输, IOptAnaCalc { List _allMachineList = null; #region 计算 最优方案 /// /// 计算 最优方案 /// /// /// /// /// /// public List CalcSchemes( IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras, IStation.Calculation.DispatchAna.Model.EtaAnaRecord4Station eta_ana_records, IStation.Calculation.DispatchAna.Model.MachineRunPara machine_run_status, out string error_info) { this._corpID = complex_request_paras.CorpID; this._stationID = complex_request_paras.StationID; var isUsePress = complex_request_paras.PressValueType == Model.RequestParasComplex.ePressValueType.压力 ? true : false; if (isUsePress) return CalcSchemes压力(complex_request_paras, machine_run_status, out error_info); else return CalcSchemes扬程(complex_request_paras, machine_run_status, out error_info); } /// /// /// /// /// /// /// protected override List CalcSchemes压力( IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras, IStation.Calculation.DispatchAna.Model.MachineRunPara machine_run_status, out string error_info) { error_info = ""; if (complex_request_paras == null) { error_info = "ERROR 30"; return null; } if (complex_request_paras.OutletPipePara == null || complex_request_paras.OutletPipePara.Count < 3) { error_info = "ERROR 35,陈行一输需要3个出口管路的流量"; return null; } double water_level1 = 0, water_level2 = 0, water_level3 = 0; if (complex_request_paras.InletPipePara != null && complex_request_paras.InletPipePara.Count > 0) { if (complex_request_paras.InletPipePara.Count >= 1) { water_level1 = complex_request_paras.InletPipePara[0].Value; } if (complex_request_paras.InletPipePara.Count >= 2) { water_level2 = complex_request_paras.InletPipePara[1].Value; } if (complex_request_paras.InletPipePara.Count >= 3) { water_level3 = complex_request_paras.InletPipePara[2].Value; } } double pipe1_TargetFlow = complex_request_paras.OutletPipePara[0].TargetFlow; double pipe2_TargetFlow = complex_request_paras.OutletPipePara[1].TargetFlow; double pipe3_TargetFlow = complex_request_paras.OutletPipePara[2].TargetFlow; if (pipe1_TargetFlow < 50 && pipe2_TargetFlow < 50 && pipe3_TargetFlow < 50) {//都关机 error_info = "ERROR 35,陈行一输需要3个出口管路的流量都为0"; return null; } double pipe1_TargetPess = complex_request_paras.OutletPipePara[0].TargetPress; double pipe2_TargetPess = complex_request_paras.OutletPipePara[1].TargetPress; double pipe3_TargetPess = complex_request_paras.OutletPipePara[2].TargetPress; if (pipe1_TargetFlow > 50) { if (pipe1_TargetPess < water_level1 / 102 + 0.01) { error_info = "ERROR 35,陈行一输需要一号管压力未赋值"; return default; } } if (pipe2_TargetFlow > 50) { if (pipe2_TargetPess < water_level2 / 102 + 0.01) { error_info = "ERROR 35,陈行一输需要二号管压力未赋值"; return default; } } if (pipe3_TargetFlow > 50) { if (pipe3_TargetPess < water_level3 / 102 + 0.01) { error_info = "ERROR 35,陈行一输需要三号管压力未赋值"; return default; } } //机泵信息 if (_allMachineList == null) { if (!BuildMachineList( out _allMachineList, out error_info)) { error_info = "机泵组无法构建,ERROR 70,错误信息:" + error_info; return null; } } Common.DispatchAnaGeneralHelper压力 calc_pipe1_helper = new Common.DispatchAnaGeneralHelper压力(); Common.DispatchAnaGeneralHelper压力 calc_pipe2_helper = new Common.DispatchAnaGeneralHelper压力(); Common.DispatchAnaGeneralHelper压力 calc_pipe3_helper = new Common.DispatchAnaGeneralHelper压力(); double totalQ = 0, totalH = 0, totalP = 0; int pipe_count = 0; IStation.Calculation.DispatchAna.Model.AnaScheme pipe1_result = null; List pipe1_results = null; if (pipe1_TargetFlow > 50) { calc_pipe1_helper.InitialParas( pipe1_TargetFlow, water_level1 ,true , pipe1_TargetPess,false, null, null, (from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(), machine_run_status == null ? null : machine_run_status.MachineRunFilter, out error_info); pipe1_results = calc_pipe1_helper.CalcOptList(complex_request_paras.SchemeSortType, 3); if (pipe1_results == null || pipe1_results.Count() == 0) { error_info = String.Format("管路一调度方案无法计算,请确认数据是否合理,进口液位:{0} ,出口压力:{1}MPa, 流量要求:{2}", Math.Round(water_level1, 4), Math.Round(pipe1_TargetPess,4), pipe1_TargetFlow); return null; } pipe1_result = pipe1_results[0]; totalQ += pipe1_result.TotalWrkQ; totalP += pipe1_result.TotalWrkP; totalH += pipe1_result.TotalWrkH; pipe_count++; } IStation.Calculation.DispatchAna.Model.AnaScheme pipe2_result = null; List pipe2_results = null; if (pipe2_TargetFlow > 50) { calc_pipe2_helper.InitialParas( pipe2_TargetFlow, water_level2, true, pipe2_TargetPess,false , null, null, (from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(), machine_run_status == null ? null : machine_run_status.MachineRunFilter, out error_info); pipe2_results = calc_pipe2_helper.CalcOptList(complex_request_paras.SchemeSortType, 3); if (pipe2_results == null || pipe2_results.Count() == 0) { error_info = String.Format("管路2调度方案无法计算,请确认数据是否合理,进口液位:{0} ,出口压力:{1}MPa,流量要求:{2}", Math.Round(water_level1, 4), Math.Round(pipe2_TargetPess, 4), pipe2_TargetFlow); return null; } pipe2_result = pipe2_results[0]; totalQ += pipe2_result.TotalWrkQ; totalP += pipe2_result.TotalWrkP; totalH += pipe2_result.TotalWrkH; pipe_count++; } IStation.Calculation.DispatchAna.Model.AnaScheme pipe3_result = null; List pipe3_results = null; if (pipe3_TargetFlow > 50) { calc_pipe3_helper.InitialParas( pipe3_TargetFlow, water_level3,true , pipe3_TargetPess,false , null, null, (from x in _allMachineList where pipe3_machineIds.Contains(x.MachineID) select x).ToList(), machine_run_status == null ? null : machine_run_status.MachineRunFilter, out error_info); pipe3_results = calc_pipe3_helper.CalcOptList(complex_request_paras.SchemeSortType, 3); if (pipe3_results == null || pipe3_results.Count() == 0) { error_info = String.Format("管路3调度方案无法计算,请确认数据是否合理,进口液位:{0} ,出口压力:{1}MPa,流量要求:{2}", Math.Round(water_level3, 4), Math.Round(pipe3_TargetPess, 4), pipe3_TargetFlow); return null; } pipe3_result = pipe3_results[0]; totalQ += pipe3_result.TotalWrkQ; totalP += pipe3_result.TotalWrkP; totalH += pipe3_result.TotalWrkH; pipe_count++; } var plan = new Model.AnaScheme(); plan.ID = 1; plan.TotalWrkQ = Math.Round(totalQ, 1); plan.TotalWrkH = Math.Round(totalH / pipe_count, 2); plan.TotalWrkP = Math.Round(totalP, 1); plan.TotalWrkE = CalcConnectPipeEta(new List() { pipe1_result, pipe2_result, pipe3_result }); plan.UWP = CalculateUWP(plan.TotalWrkP, plan.TotalWrkQ, plan.TotalWrkH); plan.WP = CalculateWP(plan.TotalWrkP, plan.TotalWrkQ); plan.Items = new List(); if (pipe1_result.Items != null && pipe1_result.Items.Count > 0) plan.Items.AddRange(pipe1_result.Items); if (pipe2_result.Items != null && pipe2_result.Items.Count > 0) plan.Items.AddRange(pipe2_result.Items); if (pipe3_result.Items != null && pipe3_result.Items.Count > 0) plan.Items.AddRange(pipe3_result.Items); return new List() { plan }; } private List CalcSchemes扬程( IStation.Calculation.DispatchAna.Model.RequestParasComplex complex_request_paras, IStation.Calculation.DispatchAna.Model.MachineRunPara machine_run_status, out string error_info) { error_info = ""; if (complex_request_paras == null) { error_info = "ERROR 30"; return null; } if (complex_request_paras.OutletPipePara == null || complex_request_paras.OutletPipePara.Count < 2) { error_info = "ERROR 35,陈行一输需要两个管路的流量"; return null; } double pipe1_TargetFlow = complex_request_paras.OutletPipePara[0].TargetFlow; double pipe2_TargetFlow = complex_request_paras.OutletPipePara[1].TargetFlow; double pipe3_TargetFlow = complex_request_paras.OutletPipePara[2].TargetFlow; if (pipe1_TargetFlow < 50 && pipe2_TargetFlow < 50 && pipe3_TargetFlow < 50) {//都关机 error_info = "ERROR 35,陈行一输需要两个管路的流量 都为0"; return null; } double pipe1_TargetHead = complex_request_paras.OutletPipePara[0].TargetPress; double pipe2_TargetHead = complex_request_paras.OutletPipePara[1].TargetPress; double pipe3_TargetHead = complex_request_paras.OutletPipePara[2].TargetPress; if (pipe1_TargetFlow > 50) { if (pipe1_TargetHead < 0.01) { error_info = "ERROR 35,陈行一输需要一号管压力未赋值"; return default; } } if (pipe2_TargetFlow > 50) { if (pipe2_TargetHead < 0.01) { error_info = "ERROR 35,陈行一输需要二号管压力未赋值"; return default; } } if (pipe3_TargetFlow > 50) { if (pipe3_TargetHead < 0.01) { error_info = "ERROR 35,陈行一输需要3号管压力未赋值"; return default; } } //机泵信息 if (_allMachineList == null) { if (!BuildMachineList( out _allMachineList, out error_info)) { error_info = "机泵组无法构建,ERROR 70,错误信息:" + error_info; return null; } } Common.DispatchAnaGeneralHelper扬程 calc_pipe1_helper = new Common.DispatchAnaGeneralHelper扬程(); Common.DispatchAnaGeneralHelper扬程 calc_pipe2_helper = new Common.DispatchAnaGeneralHelper扬程(); Common.DispatchAnaGeneralHelper扬程 calc_pipe3_helper = new Common.DispatchAnaGeneralHelper扬程(); double totalQ = 0, totalH = 0, totalP = 0; int pipe_count = 0; IStation.Calculation.DispatchAna.Model.AnaScheme pipe1_result = null; List pipe1_results = null; if (pipe1_TargetFlow > 50) { calc_pipe1_helper.InitialParas( pipe1_TargetFlow, pipe1_TargetHead, null, null, (from x in _allMachineList where pipe1_machineIds.Contains(x.MachineID) select x).ToList(), machine_run_status == null ? null : machine_run_status.MachineRunFilter); pipe1_results = calc_pipe1_helper.CalcOptList(complex_request_paras.SchemeSortType, 3); if (pipe1_results == null || pipe1_results.Count() == 0) { error_info = String.Format("管路一调度方案无法计算,请确认数据是否合理,扬程要求:{0}m,流量要求:{1}", pipe1_TargetHead, pipe1_TargetFlow); return null; } pipe1_result = pipe1_results[0]; totalQ += pipe1_result.TotalWrkQ; totalP += pipe1_result.TotalWrkP; totalH += pipe1_result.TotalWrkH; pipe_count++; } IStation.Calculation.DispatchAna.Model.AnaScheme pipe2_result = null; List pipe2_results = null; if (pipe2_TargetFlow > 50) { calc_pipe2_helper.InitialParas( pipe2_TargetFlow, pipe2_TargetHead, null, null, (from x in _allMachineList where pipe2_machineIds.Contains(x.MachineID) select x).ToList(), machine_run_status == null ? null : machine_run_status.MachineRunFilter); pipe2_results = calc_pipe2_helper.CalcOptList(complex_request_paras.SchemeSortType, 3); if (pipe2_results == null || pipe2_results.Count() == 0) { error_info = String.Format("管路一调度方案无法计算,请确认数据是否合理,扬程要求:{0}m,流量要求:{1}", pipe2_TargetHead, pipe1_TargetFlow); return null; } pipe2_result = pipe2_results[0]; totalQ += pipe2_result.TotalWrkQ; totalP += pipe2_result.TotalWrkP; totalH += pipe2_result.TotalWrkH; pipe_count++; } IStation.Calculation.DispatchAna.Model.AnaScheme pipe3_result = null; List pipe3_results = null; if (pipe3_TargetFlow > 50) { calc_pipe3_helper.InitialParas( pipe3_TargetFlow, pipe3_TargetHead, null, null, (from x in _allMachineList where pipe3_machineIds.Contains(x.MachineID) select x).ToList(), machine_run_status == null ? null : machine_run_status.MachineRunFilter); pipe3_results = calc_pipe3_helper.CalcOptList(complex_request_paras.SchemeSortType, 3); if (pipe3_results == null || pipe3_results.Count() == 0) { error_info = String.Format("管路一调度方案无法计算,请确认数据是否合理,扬程要求:{0}m,流量要求:{1}", pipe3_TargetHead, pipe3_TargetFlow); return null; } pipe3_result = pipe3_results[0]; totalQ += pipe3_result.TotalWrkQ; totalP += pipe3_result.TotalWrkP; totalH += pipe3_result.TotalWrkH; pipe_count++; } var plan = new Model.AnaScheme(); plan.ID = 1; plan.TotalWrkQ = Math.Round(totalQ, 1); plan.TotalWrkH = Math.Round(totalH / pipe_count, 2); plan.TotalWrkP = Math.Round(totalP, 1); plan.TotalWrkE = CalcConnectPipeEta(new List() { pipe1_result, pipe2_result, pipe3_result }); plan.UWP = CalculateUWP(plan.TotalWrkP, plan.TotalWrkQ, plan.TotalWrkH); plan.WP = CalculateWP(plan.TotalWrkP, plan.TotalWrkQ); plan.Items = new List(); if (pipe1_result.Items != null && pipe1_result.Items.Count > 0) plan.Items.AddRange(pipe1_result.Items); if (pipe2_result.Items != null && pipe2_result.Items.Count > 0) plan.Items.AddRange(pipe2_result.Items); if (pipe3_result.Items != null && pipe3_result.Items.Count > 0) plan.Items.AddRange(pipe3_result.Items); return new List() { plan }; } #endregion } }