| | |
| | | namespace IStation.Application |
| | | using IStation.Curve; |
| | | using IStation.Model; |
| | | using SqlSugar; |
| | | |
| | | namespace IStation.Application |
| | | { |
| | | /// <summary> |
| | | /// 输水调度 |
| | |
| | | private static readonly Service.ScheduleConfig _service_schedule_config = new(); |
| | | |
| | | private static readonly Service.AnalysisDeviation _service_analysis_deviation = new(); |
| | | private static readonly Service.FlowDeviation _service_flow_deviation = new(); |
| | | |
| | | /// <summary> |
| | | /// 计算 |
| | |
| | | var is_monitor_record_debug = false; |
| | | #if DEBUG |
| | | is_monitor_record_debug = true; |
| | | #endif |
| | | #endif |
| | | |
| | | |
| | | log_title = "实时ZyScada请求"; |
| | | var get_msg = GlobalHelper.GetMonitorRecordList(receipt_time, out List<Model.MonitorRecord> monitor_record_list, is_monitor_record_debug); |
| | |
| | | var analysis_deviation_list = _service_analysis_deviation.GetList(); |
| | | |
| | | GlobalHelper.GetStationOpenFlagList(monitor_record_list, out List<int> station1_open_flag_list, out List<int> station2_open_flag_list); |
| | | GlobalHelper.GetStationFlagStateList(monitor_record_list, out List<int> station1_flag_maintenance_list, out List<int> station2_maintenance_flag_list, out List<int> station1_priority_flag_list, out List<int> station2_priority_flag_list); |
| | | GlobalHelper.GetStationFlagStateList(monitor_record_list, out List<int> station1_maintenance_flag_list, out List<int> station2_maintenance_flag_list, out List<int> station1_priority_flag_list, out List<int> station2_priority_flag_list); |
| | | GlobalHelper.GetFlagInletWaterLevelDict(monitor_record_list, out Dictionary<int, double> station1_flag_inlet_water_level_dict, out Dictionary<int, double> station2_flag_inlet_water_level_dict); |
| | | |
| | | station1_schedule_config.MaintenanceFlagList = new List<int>(); |
| | | station2_schedule_config.MaintenanceFlagList = new List<int>(); |
| | | station1_schedule_config.PriorityOpenFlagList = new List<int>(); |
| | | station2_schedule_config.PriorityOpenFlagList = new List<int>(); |
| | | log_title = "机泵检修"; |
| | | if (station1_flag_maintenance_list != null && station1_flag_maintenance_list.Any()) |
| | | if (station1_maintenance_flag_list != null && station1_maintenance_flag_list.Any()) |
| | | { |
| | | ScheduleLog.Info(request_id, log_title, $"1输水:{Yw.Untity.IntListHelper.ToString(station1_flag_maintenance_list)}"); |
| | | station1_schedule_config.MustCloseFlagList.AddRange(station1_flag_maintenance_list); |
| | | ScheduleLog.Info(request_id, log_title, $"1输水:{Yw.Untity.IntListHelper.ToString(station1_maintenance_flag_list)}"); |
| | | station1_schedule_config.MaintenanceFlagList.AddRange(station1_maintenance_flag_list); |
| | | } |
| | | if (station2_maintenance_flag_list != null && station2_maintenance_flag_list.Any()) |
| | | { |
| | | ScheduleLog.Info(request_id, log_title, $"2输水:{Yw.Untity.IntListHelper.ToString(station2_maintenance_flag_list)}"); |
| | | station2_schedule_config.MustCloseFlagList.AddRange(station2_maintenance_flag_list); |
| | | station2_schedule_config.MaintenanceFlagList.AddRange(station2_maintenance_flag_list); |
| | | } |
| | | |
| | | log_title = "机泵优先"; |
| | |
| | | station2_schedule_config.PriorityOpenFlagList.AddRange(station2_priority_flag_list); |
| | | } |
| | | |
| | | log_title = "供水限制"; |
| | | var limit_info= VerifyWaterSupplyLimit(station1_schedule_config.WaterSupplyLimitList,station1_open_flag_list, target_flow1); |
| | | if (!string.IsNullOrEmpty(limit_info)) |
| | | { |
| | | ScheduleLog.Info(request_id, log_title, $"1输水:{limit_info}"); |
| | | } |
| | | |
| | | log_title = "调度返回"; |
| | | var msg = "计算结束!"; |
| | | var helper = new Service.ScheduleHelper(); |
| | | limit_info = VerifyWaterSupplyLimit(station2_schedule_config.WaterSupplyLimitList, station2_open_flag_list, target_flow2); |
| | | if (!string.IsNullOrEmpty(limit_info)) |
| | | { |
| | | ScheduleLog.Info(request_id, log_title, $"2输水:{limit_info}"); |
| | | } |
| | | |
| | | log_title = "流量补差"; |
| | | var helper = new Service.ScheduleHelper(); |
| | | helper.Initial(station1_open_flag_list, station1_schedule_config, analysis_deviation_list); |
| | | var optimal_combine1 = helper.GetOptAnaCombine(station1, station1_flag_inlet_water_level_dict, target_flow1, target_pressure1); |
| | | |
| | | |
| | | helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list); |
| | | var station2_target_flow_diff=_service_flow_deviation.GetFlowDiff(target_pressure2); |
| | | ScheduleLog.Info(request_id, log_title, $"2输水:{station2_target_flow_diff:N1}"); |
| | | helper.Initial(station2_open_flag_list, station2_schedule_config, analysis_deviation_list,station2_target_flow_diff); |
| | | var optimal_combine2 = helper.GetOptAnaCombine(station2, station2_flag_inlet_water_level_dict, target_flow2, target_pressure2); |
| | | |
| | | |
| | | log_title = "调度返回"; |
| | | var msg = "计算结束!"; |
| | | var schedule_request = new Model.ScheduleRequest |
| | | { |
| | | ID = request_id, |
| | |
| | | }; |
| | | schedule_pump_list1 = new List<Model.SchedulePump>(); |
| | | |
| | | output.objects["1输水总流量"] = optimal_combine1.TotalFlow; |
| | | output.objects["1输水总压力"] = Math.Round(Curve.PumpCalculateHelper.M2Mpa(optimal_combine1.TotalPressure), 4); |
| | | // 20250422 修改原因,水中心直接拿我的理论值套到调度上了,我返回原值给他们 |
| | | output.objects["1输水总流量"] = target_flow1; |
| | | output.objects["1输水总压力"] = target_mpa_pressure1; |
| | | output.objects["1输水总功率"] = optimal_combine1.TotalPower; |
| | | output.objects["1输水总效率"] = optimal_combine1.TotalEfficiency; |
| | | output.objects["1输水总千吨能耗"] = optimal_combine1.WP; |
| | |
| | | } |
| | | else |
| | | { |
| | | output.objects["1输水总流量"] = target_flow1; |
| | | output.objects["1输水总压力"] = target_mpa_pressure1; |
| | | msg += $" 1输水调度计算失败,无法满足目标流量:{target_flow1},目标压力:{target_mpa_pressure1}!"; |
| | | } |
| | | |
| | |
| | | }; |
| | | schedule_pump_list2 = new List<Model.SchedulePump>(); |
| | | |
| | | output.objects["2输水总流量"] = optimal_combine2.TotalFlow; |
| | | output.objects["2输水总压力"] = Math.Round(Curve.PumpCalculateHelper.M2Mpa(optimal_combine2.TotalPressure), 4); |
| | | output.objects["2输水总流量"] = target_flow2; |
| | | output.objects["2输水总压力"] = target_mpa_pressure2; |
| | | output.objects["2输水总功率"] = optimal_combine2.TotalPower; |
| | | output.objects["2输水总效率"] = optimal_combine2.TotalEfficiency; |
| | | output.objects["2输水总千吨能耗"] = optimal_combine2.WP; |
| | |
| | | } |
| | | else |
| | | { |
| | | output.objects["2输水总流量"] = target_flow2; |
| | | output.objects["2输水总压力"] = target_mpa_pressure2; |
| | | msg += $" 2输水调度计算失败,无法满足目标流量:{target_flow2},目标压力:{target_mpa_pressure2}!"; |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | private static string VerifyWaterSupplyLimit(List<WaterSupplyLimit> waterSupplyLimits, List<int> station_open_flag_list, double targetFlow) |
| | | { |
| | | if (waterSupplyLimits != null && waterSupplyLimits.Any()) |
| | | { |
| | | if (station_open_flag_list != null && station_open_flag_list.Any()) |
| | | { |
| | | var pumpCount = station_open_flag_list.Count; |
| | | var exist_limit = waterSupplyLimits.Find(x => x.PumpCount == pumpCount); |
| | | if (exist_limit != null) |
| | | { |
| | | if (targetFlow < exist_limit.Min || targetFlow > exist_limit.Max) |
| | | { |
| | | var flags = Yw.Untity.IntListHelper.ToString(station_open_flag_list); |
| | | return $"[{flags}]:目标流量:{targetFlow},供水限制:{exist_limit.Min}-{exist_limit.Max}"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | |
| | | } |