ningshuxia
2024-06-06 760fa87c2f6fb9e638bba889928bdc145394a534
同段泵组合 新增
已修改8个文件
已添加3个文件
699 ■■■■ 文件已修改
IStation.Application/01-ch/01-analysis/Schedule_Controller.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Application/01-ch/03-schedule-config/ScheduleConfig_Controller.cs 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Application/IStation.Application.csproj 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Dto/01-ch/03-schedule-config/SaveChScheduleConfigOutput.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Dto/01-ch/03-schedule-config/ScheduleConfigDto.cs 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Service/00-core/ConfigHelper.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Service/01-entity/02-schedule/ScheduleRule.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Service/02-model/00-basic/02-config/ScheduleConfig.cs 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Service/07-algorithm/02-schedule/ScheduleConfigHelper.cs 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Service/07-algorithm/02-schedule/ScheduleHelper.cs 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Test/IStation.Test/Program.cs 310 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
IStation.Application/01-ch/01-analysis/Schedule_Controller.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
namespace IStation.Application
{
    /// <summary>
    /// é™ˆè¡Œè¾“水调度
    /// </summary>
    [AllowAnonymous]
    [Route("Schedule/Analysis")]
    [ApiDescriptionSettings("Schedule", Name = "输水调度", Order = 1)]
    public class Analysis_Controller : IDynamicApiController, ITransient
    {
        /// <summary>
        /// åˆå§‹åŒ–数据库
        /// </summary>
        [AllowAnonymous]
        [Route("InitDataBase")]
        [HttpGet]
        public bool InitDataBase()
        {
            IStation.Algorithm.DbInitHelper.Init();
            return true;
        }
    }
}
IStation.Application/01-ch/03-schedule-config/ScheduleConfig_Controller.cs
@@ -9,8 +9,7 @@
    public class ScheduleConfig_Controller : IDynamicApiController, ITransient
    {
        private readonly Service.ScheduleConfig _service_schedule_config = new();
        /// <summary>
        /// èŽ·å–é™ˆè¡Œè°ƒåº¦é…ç½®
        /// </summary>
@@ -32,25 +31,65 @@
        [Route("Save")]
        [HttpPost]
        [NonUnify]
        public bool Save([Required] ChScheduleConfigInput input)
        public SaveChScheduleConfigOutput Save([Required] ChScheduleConfigInput input)
        {
            if (input == null)
            {
                Yw.Dto.YOops.Oh(Yw.Dto.eResultCode.Error, Yw.Dto.InternalErrorCodes.A001, "入参不能为空!");
                return false;
                return new SaveChScheduleConfigOutput() { Result = false, Msg = "入参不能为空!" };
            }
            var receipt_time = DateTime.Now;
            var request_id = Yw.YitIdHelper.NextId();
            var request_id = Yw.YitIdHelper.NextId();
            var log_title = "调度配置";
            Log.Info(request_id, log_title, "更新配置!");
            Log.Debug(request_id, log_title, JsonHelper.Object2Json(input));
            var model = input.Adapt<ChScheduleConfigInput, Model.ChScheduleConfig>();
            var bol = _service_schedule_config.Save(model);
            Log.Info(request_id, log_title, bol.ToString());
            return bol;
            Log.Info(request_id, log_title, bol.ToString());
            return new SaveChScheduleConfigOutput() { Result = true, Msg = "保存成功!" };
        }
        /// <summary>
        /// Test
        /// </summary>
        [Route("Test")]
        [HttpGet]
        [NonUnify]
        public ChScheduleConfigDto Test()
        {
            var model = _service_schedule_config.Get();
            model.Station1.MustOpenFlagList = new List<int>() { 11, 12 };
            model.Station1.MustCloseFlagList = new List<int>() { 13 };
            model.Station1.AssociativeFlagCombineList = new List<List<int>>()
            {
                new List<int>(){14,15}
            };
            model.Station1.WaterSupplyLimitList = new List<IStation.Model.WaterSupplyLimit>()
            {
                new Model.WaterSupplyLimit()
                {
                    Min=10500,
                    Max=15000,
                    PumpCount=3
                },
                new Model.WaterSupplyLimit()
                {
                    Min=15500,
                    Max=20000,
                    PumpCount=4
                },
                new Model.WaterSupplyLimit()
                {
                    Min=20000,
                    Max=27000,
                    PumpCount=5
                },
            };
            var dto = model.Adapt<Model.ChScheduleConfig, ChScheduleConfigDto>();
            return dto;
        }
    }
}
IStation.Application/IStation.Application.csproj
@@ -57,8 +57,4 @@
        <ProjectReference Include="..\IStation.Service\IStation.Service.csproj" />
    </ItemGroup>
    <ItemGroup>
        <Folder Include="01-ch\01-analysis\" />
    </ItemGroup>
</Project>
IStation.Dto/01-ch/03-schedule-config/SaveChScheduleConfigOutput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
namespace IStation.Dto
{
    /// <summary>
    /// è°ƒåº¦é…ç½®
    /// </summary>
    public class SaveChScheduleConfigOutput
    {
        /// <summary>
        /// ç»“æžœ
        /// </summary>
        public bool Result { get; set; }
        /// <summary>
        /// ä¿¡æ¯
        /// </summary>
        public string Msg { get; set; }
    }
}
IStation.Dto/01-ch/03-schedule-config/ScheduleConfigDto.cs
@@ -5,6 +5,7 @@
    /// </summary>
    public class ScheduleConfigDto
    {
        /// <summary>
        /// å¿…开泵列表
        /// </summary>
@@ -16,14 +17,19 @@
        public List<int> MustCloseFlagList { get; set; }
        /// <summary>
        /// ç¦ç”¨æ³µç»„合
        /// ç¦ç”¨æ³µç»„合列表
        /// </summary>
        public List<List<int>> ForbiddenFlagCombineList { get; set; }
        /// <summary>
        /// å…³è”泵组合
        /// å…³è”泵组合列表
        /// </summary>
        public List<List<int>> AssociativeFlagCombineList { get; set; }
        /// <summary>
        /// åŒæ®µæ³µç»„合列表
        /// </summary>
        public List<List<int>> SameSectionFlagCombineList { get; set; }
        /// <summary>
        /// ä¾›æ°´é™åˆ¶åˆ—表
@@ -33,6 +39,7 @@
        /// <summary>
        /// é¢‘率限制列表
        /// </summary> 
        public List<FrequencyLimitDto> FrequencyLimitList { get; set; }
        public List<FrequencyLimitDto> FrequencyLimitList { get; set; }
    }
}
IStation.Service/00-core/ConfigHelper.cs
@@ -174,6 +174,12 @@
                            {
                                column.IsNullable = true;
                            }
                            //if (column.DbColumnName == "Config")
                            //{
                            //    column.DataType = StaticConfig.CodeFirst_BigString;
                            //}
                        }
                    }
                };
IStation.Service/01-entity/02-schedule/ScheduleRule.cs
@@ -28,8 +28,8 @@
        public void Reset(ScheduleRule rhs)
        {
            this.RequestID = rhs.RequestID;
            this.Station = rhs.Station;
            this.Config= rhs.Config;
            this.Station = rhs.Station;
            this.Config = rhs.Config;
        }
        /// <summary>
@@ -45,8 +45,8 @@
        /// <summary>
        /// é…ç½®Json 
        /// </summary>
        [SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
        public string Config { get; set; }
        /// <summary>
        /// 
IStation.Service/02-model/00-basic/02-config/ScheduleConfig.cs
@@ -16,11 +16,11 @@
        /// <param name="rhs"></param>
        public ScheduleConfig(ScheduleConfig rhs)
        {
            //this.PriorityOrderFlagList = rhs.PriorityOrderFlagList?.ToList();
            this.MustOpenFlagList = rhs.MustOpenFlagList?.ToList();
            this.MustCloseFlagList = rhs.MustCloseFlagList?.ToList();
            this.ForbiddenFlagCombineList = rhs.ForbiddenFlagCombineList?.ToList();
            this.AssociativeFlagCombineList = rhs.AssociativeFlagCombineList?.ToList();
            this.SameSectionFlagCombineList = rhs.SameSectionFlagCombineList?.ToList();
            this.WaterSupplyLimitList = rhs.WaterSupplyLimitList?.ToList();
            this.FrequencyLimitList = rhs.FrequencyLimitList?.ToList();
        }
@@ -30,12 +30,12 @@
        /// </summary>
        /// <param name="rhs"></param>
        public void Reset(ScheduleConfig rhs)
        {
            //this.PriorityOrderFlagList = rhs.PriorityOrderFlagList?.ToList();
        {
            this.MustOpenFlagList = rhs.MustOpenFlagList?.ToList();
            this.MustCloseFlagList = rhs.MustCloseFlagList?.ToList();
            this.ForbiddenFlagCombineList = rhs.ForbiddenFlagCombineList?.ToList();
            this.AssociativeFlagCombineList = rhs.AssociativeFlagCombineList?.ToList();
            this.SameSectionFlagCombineList = rhs.SameSectionFlagCombineList?.ToList();
            this.WaterSupplyLimitList = rhs.WaterSupplyLimitList?.ToList();
            this.FrequencyLimitList = rhs.FrequencyLimitList?.ToList();
        }
@@ -52,14 +52,19 @@
        public List<int> MustCloseFlagList { get; set; }
        /// <summary>
        /// ç¦ç”¨æ³µç»„合
        /// ç¦ç”¨æ³µç»„合列表
        /// </summary>
        public List<List<int>> ForbiddenFlagCombineList { get; set; }
        /// <summary>
        /// å…³è”泵组合
        /// å…³è”泵组合列表
        /// </summary>
        public List<List<int>> AssociativeFlagCombineList { get; set; }
        public List<List<int>> AssociativeFlagCombineList { get; set; }
        /// <summary>
        /// åŒæ®µæ³µç»„合列表
        /// </summary>
        public List<List<int>> SameSectionFlagCombineList { get; set; }
        /// <summary>
        /// ä¾›æ°´é™åˆ¶åˆ—表
@@ -71,13 +76,7 @@
        /// </summary> 
        public List<FrequencyLimit> FrequencyLimitList { get; set; }
        /// <summary>
        /// ä¼˜å…ˆåº¦æŽ’序
        /// </summary>
        // public List<int> PriorityOrderFlagList { get; set; }
        /// <summary>
        /// 
IStation.Service/07-algorithm/02-schedule/ScheduleConfigHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,107 @@
namespace IStation.Service
{
    /// <summary>
    ///
    /// </summary>
    public class ScheduleConfigHelper
    {
        /// <summary>
        /// ç”Ÿæˆ
        /// </summary>
        /// <returns></returns>
        public static Model.ChScheduleConfig Create()
        {
            var station = new IStation.Service.Station().Get();
            var chConfig = new IStation.Model.ChScheduleConfig();
            chConfig.Station1 = GetStation1(station.S1);
            chConfig.Station2 = GetStation2(station.S2);
            return chConfig;
        }
        private static IStation.Model.ScheduleConfig GetStation1(List<Model.Pump> pumps)
        {
            var model = new IStation.Model.ScheduleConfig();
            model.MustOpenFlagList = new List<int>();
            model.MustCloseFlagList = new List<int>();
            model.ForbiddenFlagCombineList = new List<List<int>>()
            {
                new List<int>(){16,17,18}
            };
            model.AssociativeFlagCombineList = new List<List<int>>();
            model.SameSectionFlagCombineList = new List<List<int>>()
            {
                new List<int>(){11,13,15,17},
                new List<int>(){12,14,16,18},
            };
            model.WaterSupplyLimitList = new List<IStation.Model.WaterSupplyLimit>();
            model.FrequencyLimitList = new List<IStation.Model.FrequencyLimit>();
            foreach (var pump in pumps)
            {
                var flag = pump.Flag;
                if (flag == 15 || flag == 16)
                    continue;
                model.FrequencyLimitList.Add(new IStation.Model.FrequencyLimit()
                {
                    Flag = pump.Flag,
                    Min = 28,
                    Max = 50
                });
            }
            return model;
        }
        private static IStation.Model.ScheduleConfig GetStation2(List<Model.Pump> pumps)
        {
            var model = new IStation.Model.ScheduleConfig();
            model.MustOpenFlagList = new List<int>();
            model.MustCloseFlagList = new List<int>()
            {
                21
            };
            model.ForbiddenFlagCombineList = new List<List<int>>()
            {
                new(){22,24,25},
            };
            model.AssociativeFlagCombineList = new List<List<int>>();
            model.SameSectionFlagCombineList = new List<List<int>>()
            {
                new(){21,22,23,24},
                new(){25,26,27},
            };
            model.WaterSupplyLimitList = new List<IStation.Model.WaterSupplyLimit>();
            model.FrequencyLimitList = new List<IStation.Model.FrequencyLimit>();
            foreach (var pump in pumps)
            {
                var flag = pump.Flag;
                if (flag == 27)
                {
                    model.FrequencyLimitList.Add(new IStation.Model.FrequencyLimit()
                    {
                        Flag = pump.Flag,
                        Min = (450 / pump.Nr * 50),
                        Max = 680 / pump.Nr * 50,
                    });
                }
                else
                {
                    model.FrequencyLimitList.Add(new IStation.Model.FrequencyLimit()
                    {
                        Flag = pump.Flag,
                        Min = 280 / pump.Nr * 50,
                        Max = 480 / pump.Nr * 50,
                    });
                }
                model.FrequencyLimitList.ForEach(x =>
                {
                    x.Min = Math.Round(x.Min, 1);
                    x.Max = Math.Round(x.Max, 1);
                });
            }
            return model;
        }
    }
}
IStation.Service/07-algorithm/02-schedule/ScheduleHelper.cs
@@ -24,6 +24,7 @@
        List<int> _must_close_flag_list = null; // å¿…关泵列表 
        List<List<int>> _forbidden_flag_combine_list = null; // ç¦ç”¨æ³µç»„合 
        List<List<int>> _associative_flag_combine_list = null; // å…³è”泵组合 
        List<List<int>> _same_section_flag_combine_list = null; // åŒæ®µæ³µç»„合
        List<Model.WaterSupplyLimit> _water_supply_limit_list = null; //供水限制列表
        List<Model.FrequencyLimit> _frequency_limit_list = null; // é¢‘率限制列表 
        //List<int> _priority_order_flag_list = null; // ä¼˜å…ˆåº¦æŽ’序 æš‚未考虑
@@ -38,22 +39,23 @@
            _must_close_flag_list = null;
            _forbidden_flag_combine_list = null;
            _associative_flag_combine_list = null;
            _same_section_flag_combine_list = null;
            _water_supply_limit_list = null;
            _frequency_limit_list = null;
            if (schedule_config!=null)
            if (schedule_config != null)
            {
                _must_open_flag_list = schedule_config.MustOpenFlagList;
                _must_close_flag_list = schedule_config.MustCloseFlagList;
                _forbidden_flag_combine_list = schedule_config.ForbiddenFlagCombineList;
                _associative_flag_combine_list = schedule_config.AssociativeFlagCombineList;
                _same_section_flag_combine_list = schedule_config.SameSectionFlagCombineList;
                _water_supply_limit_list = schedule_config.WaterSupplyLimitList;
                _frequency_limit_list = schedule_config.FrequencyLimitList;
            }
            }
           
        }
        /// <summary>
        /// è®¡ç®—
        /// </summary>
@@ -70,9 +72,9 @@
            var must_close_flag_list = _must_close_flag_list;
            var forbidden_flag_combine_list = _forbidden_flag_combine_list;
            var associative_flag_combine_list = _associative_flag_combine_list;
            var same_section_flag_combine_list = _same_section_flag_combine_list;
            var water_supply_limit_list = _water_supply_limit_list;
            var frequency_limit_list = _frequency_limit_list;
            // var priority_order_flag_list = _priority_order_flag_list;
            if (pumps == null || !pumps.Any())
            {
@@ -116,6 +118,80 @@
            var exist_associative_flag_combine_list = associative_flag_combine_list != null && associative_flag_combine_list.Count > 0;
            #endregion 
            #region å­˜åœ¨-同段泵组合
            Dictionary<int, List<int[]>> same_section_combine_dict = new();
            var exist_same_section_flag_combine_list = _same_section_flag_combine_list != null && _same_section_flag_combine_list.Count > 0;
            if (exist_same_section_flag_combine_list)
            {
                for (int pump_count = 1; pump_count <= pumps.Count; pump_count++)
                {
                    same_section_combine_dict[pump_count] = new List<int[]>();
                    switch (pump_count)
                    {
                        case 2:
                            {
                                foreach (var same_section_flag_combine in same_section_flag_combine_list)
                                {
                                    var combine_list = GetCombineList(same_section_flag_combine, 2);
                                    same_section_combine_dict[pump_count].AddRange(combine_list);
                                }
                            }
                            break;
                        case 3:
                            {
                                foreach (var same_section in same_section_flag_combine_list)
                                {
                                    var combine_list = GetCombineList(same_section, 3);
                                    same_section_combine_dict[pump_count].AddRange(combine_list);
                                }
                            }
                            break;
                        case 4:
                            {
                                foreach (var same_section in same_section_flag_combine_list)
                                {
                                    var combine_list3 = GetCombineList(same_section, 3);
                                    same_section_combine_dict[pump_count].AddRange(combine_list3);
                                    if (same_section.Count > 3)
                                    {
                                        var combine_list = GetCombineList(same_section, 4);
                                        same_section_combine_dict[pump_count].AddRange(combine_list);
                                    }
                                }
                            }
                            break;
                        case 5:
                            {
                                foreach (var same_section in same_section_flag_combine_list)
                                {
                                    if (same_section.Count > 3)
                                    {
                                        var combine_list = GetCombineList(same_section, 4);
                                        same_section_combine_dict[pump_count].AddRange(combine_list);
                                    }
                                }
                            }
                            break;
                        case 6:
                            {
                                foreach (var same_section in same_section_flag_combine_list)
                                {
                                    if (same_section.Count > 3)
                                    {
                                        var combine_list = GetCombineList(same_section, 4);
                                        same_section_combine_dict[pump_count].AddRange(combine_list);
                                    }
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            #endregion
            #region å­˜åœ¨-供水限制
@@ -175,6 +251,7 @@
                foreach (var combine in combine_list)
                {
                    double combine_merit_ratio = 1;//组合择优率
                    //必开                           
                    if (exist_must_open_flag_list)
                    {
@@ -182,6 +259,7 @@
                        if (!combine_remark.Contains(must_open_flag_list_remark))
                            continue;
                    }
                    //必关
                    if (exist_must_close_flag_list)
                    {
@@ -189,6 +267,7 @@
                        if (exist_intersected)
                            continue;
                    }
                    //禁用组合
                    if (exist_forbidden_flag_combine_list)
                    {
@@ -204,6 +283,31 @@
                        if (exist_equal)
                            continue;
                    }
                    //同段泵组合
                    if (exist_same_section_flag_combine_list)
                    {
                        var exist_equal = false;
                        foreach (var flag_list in same_section_combine_dict[pumpCount])
                        {
                            //相同
                            if (combine.SequenceEqual(flag_list))
                            {
                                exist_equal = true;
                                break;
                            }
                            //包含
                            if (flag_list.Intersect(combine).Count() == flag_list.Length)
                            {
                                exist_equal = true;
                                break;
                            }
                        }
                        if (exist_equal)
                            continue;
                    }
                    //关联组合
                    if (exist_associative_flag_combine_list)
                    {
@@ -445,6 +549,8 @@
                            }
                        }
                    }
                    if (total_flow < target_flow)
                        continue;
                    if (optimal_combine_part1 == null && optimal_combine_part2 == null)
                        continue;
@@ -503,6 +609,18 @@
            return opt;
        }
        /// <summary>
        /// èŽ·å–ç»„åˆ
        /// </summary>
        /// <param name="flags"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private List<int[]> GetCombineList(List<int> flags, int count)
        {
            var combine = IStation.Curve.PermutationAndCombination<int>.GetCombination(flags.ToArray(), count);
            return combine;
        }
        /// <summary>
        /// æ ¹æ®å·¥å†µè®¡ç®—
Test/IStation.Test/Program.cs
@@ -1,88 +1,230 @@

using IStation.Model;
//DbInitHelper.Init();
var station = new IStation.Service.Station().Get();
//var chConfig = ScheduleConfigHelper.Create();
//var bol=new IStation.Service.ScheduleConfig().Save(chConfig);
//Console.WriteLine(bol);
var chConfig = new IStation.Model.ChScheduleConfig();
chConfig.Station1 = GetStation1(station.S1);
chConfig.Station2 = GetStation2(station.S2);
using Dm;
using Yw.Untity;
using static System.Net.Mime.MediaTypeNames;
var bol=new IStation.Service.ScheduleConfig().Save(chConfig);
Console.WriteLine(bol);
var station=new IStation.Service.Station().Get();
var helper = new IStation.Algorithm.ScheduleHelper();
List<List<int>> same_section_flag_combine_list1 = new()
{
    new (){11, 13, 15, 17},
    new (){12, 14, 16 ,18},
};
List<List<int>> same_section_flag_combine_list2 = new()
{
    new (){21, 22, 23, 24},
    new (){25, 26, 27 },
};
var must_close_flag_list=new List<int>() { 25, 26, 27 , 21, 22, 23, 24 };
var combine=new List<int>() { 25, 26, 27, 21, 22, 23 };
var difC = Math.Abs(combine.Count - must_close_flag_list.Count);
var c1 = combine.Intersect(must_close_flag_list).Count() ;
var count = combine.Except(must_close_flag_list).Count();
var count2 = must_close_flag_list.Except(combine).Count();
var count3 = must_close_flag_list.Except(combine).Count();
if (count == difC)
{
}
//var same_section_flag1 = same_section_flag_combine_list[0];
//var same_section_flag2 = same_section_flag_combine_list[1];
//var same_section_flag_remark1 = IntListHelper.ToString(same_section_flag1);
//var same_section_flag_remark2 = IntListHelper.ToString(same_section_flag2);
//var pumps = station.S1;
//var pump_flag_list = pumps.Select(x => x.Flag).ToList();
//var minCombineCount = same_section_flag_combine_list.Min(x => x.Count);
//var maxCombineCount = same_section_flag_combine_list.Max(x=>x.Count);
//Test(same_section_flag_combine_list1, 8);
//Console.WriteLine($">>>>>>>>>>>>>>>>>>>");
//Console.WriteLine($">>>>>>>>>>>>>>>>>>>");
//Console.WriteLine($">>>>>>>>>>>>>>>>>>>");
//Test(same_section_flag_combine_list2, 7);
//void Test(List<List<int >> same_section_flag_combine_list, int pumpCount)
//{
//    Dictionary<int, List<int[]>> dict = new();
//    for (int pump_count = 2; pump_count <= pumpCount; pump_count++)
//    {
//        dict[pump_count] = new List<int[]>();
//        if (pump_count == 2)
//        {
//            foreach (var same_section in same_section_flag_combine_list)
//            {
//                var combine = GetCombine(same_section, 2);
//                dict[pump_count].AddRange(combine);
//            }
//        }
//        else if (pump_count == 3)
//        {
//            foreach (var same_section in same_section_flag_combine_list)
//            {
//                var combine = GetCombine(same_section, 3);
//                dict[pump_count].AddRange(combine);
//            }
//        }
//        else if (pump_count == 4)
//        {
//            foreach (var same_section in same_section_flag_combine_list)
//            {
//                var combine3 = GetCombine(same_section, 3);
//                dict[pump_count].AddRange(combine3);
//                if (same_section.Count > 3)
//                {
//                    var combine4 = GetCombine(same_section, 4);
//                    dict[pump_count].AddRange(combine4);
//                }
//            }
//        }
//        else if (pump_count == 5)
//        {
//            foreach (var same_section in same_section_flag_combine_list)
//            {
//                if (same_section.Count > 3)
//                {
//                    var combine4 = GetCombine(same_section, 4);
//                    dict[pump_count].AddRange(combine4);
//                }
//            }
//        }
//        else if (pump_count == 6)
//        {
//            foreach (var same_section in same_section_flag_combine_list)
//            {
//                if (same_section.Count > 3)
//                {
//                    var combine4 = GetCombine(same_section, 4);
//                    dict[pump_count].AddRange(combine4);
//                }
//            }
//        }
//    }
//    foreach (var item in dict)
//    {
//        Console.WriteLine($">>>>>>>>>>>>>>>>>>>{item.Key}");
//        foreach (var value in item.Value)
//        {
//            Console.WriteLine(IntListHelper.ToString(value));
//        }
//    }
//}
//List<int[]> GetCombine(List<int> flags,int count)
//{
//    var combine = IStation.Curve.PermutationAndCombination<int>.GetCombination(flags.ToArray(), count);
//    return combine;
//}
//Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>");
//Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>");
//for (int pumpCount = 2; pumpCount <= pumps.Count; pumpCount++)
//{
//    switch (pumpCount)
//    {
//        case 1:
//            {
//                Console.WriteLine("----1----");
//            }
//            break;
//        case 2:
//            {
//                Console.WriteLine("----2----");
//                var combine_list = IStation.Curve.PermutationAndCombination<int>.GetCombination(pump_flag_list.ToArray(), pumpCount);//排列组合
//                foreach (var combine in combine_list)
//                {
//                    var combine_remark = IntListHelper.ToString(combine.OrderBy(x => x));
//                    if (same_section_flag_remark1.Contains(combine_remark))
//                    {
//                        Console.WriteLine(combine_remark);
//                        continue;
//                    }
//                    if (same_section_flag_remark2.Contains(combine_remark))
//                    {
//                        Console.WriteLine(combine_remark);
//                        continue;
//                    }
//                }
//            }
//            break;
//        case 3:
//            {
//                Console.WriteLine("----3----");
//                var combine_list = IStation.Curve.PermutationAndCombination<int>.GetCombination(pump_flag_list.ToArray(), pumpCount);//排列组合
//                foreach (var combine in combine_list)
//                {
//                    var combine_remark = IntListHelper.ToString(combine.OrderBy(x => x));
//                    if (same_section_flag_remark1.Contains(combine_remark))
//                    {
//                        Console.WriteLine(combine_remark);
//                        continue;
//                    }
//                    if (same_section_flag_remark2.Contains(combine_remark))
//                    {
//                        Console.WriteLine(combine_remark);
//                        continue;
//                    }
//                }
//            }
//            break;
//        case 4:
//            {
//                Console.WriteLine("----4----");
//                var part1 = IStation.Curve.PermutationAndCombination<int>.GetCombination(same_section_flag1.ToArray(), 3);
//                part1.ForEach(x => Console.WriteLine(IntListHelper.ToString(x)));
//                var part2 = IStation.Curve.PermutationAndCombination<int>.GetCombination(same_section_flag2.ToArray(), 3);
//                part2.ForEach(x => Console.WriteLine(IntListHelper.ToString(x)));
//                Console.WriteLine(same_section_flag_remark1);
//                Console.WriteLine(same_section_flag_remark2);
//            }
//            break;
//        case 5:
//            {
//            }
//            break;
//        case 6:
//            {
//            }
//            break;
//        default:
//            {
//            }
//            break;
//    }
//}
Console.ReadKey();
IStation.Model.ScheduleConfig GetStation1(List<Pump> pumps)
{
    var model = new IStation.Model.ScheduleConfig();
    model.MustOpenFlagList = new List<int>();
    model.MustCloseFlagList = new List<int>();
    model.ForbiddenFlagCombineList = new List<List<int>>()
    {
        new List<int>(){16,17,18}
    };
    model.AssociativeFlagCombineList = new List<List<int>>();
    model.WaterSupplyLimitList = new List<IStation.Model.WaterSupplyLimit>();
    model.FrequencyLimitList = new List<IStation.Model.FrequencyLimit>();
    foreach (var pump in pumps)
    {
        var flag = pump.Flag;
        if (flag == 15 || flag == 16)
            continue;
        model.FrequencyLimitList.Add(new IStation.Model.FrequencyLimit()
        {
            Flag = pump.Flag,
            Min = 28,
            Max = 50
        });
    }
    return model;
}
IStation.Model.ScheduleConfig GetStation2(List<Pump> pumps)
{
    var model = new IStation.Model.ScheduleConfig();
    model.MustOpenFlagList = new List<int>();
    model.MustCloseFlagList = new List<int>()
    {
        21
    };
    model.ForbiddenFlagCombineList = new List<List<int>>()
    {
        new List<int>(){22,24,25},
    };
    model.AssociativeFlagCombineList = new List<List<int>>();
    model.WaterSupplyLimitList = new List<IStation.Model.WaterSupplyLimit>();
    model.FrequencyLimitList = new List<IStation.Model.FrequencyLimit>();
    foreach (var pump in pumps)
    {
        var flag = pump.Flag;
        if (flag == 27  )
        {
            model.FrequencyLimitList.Add(new IStation.Model.FrequencyLimit()
            {
                Flag = pump.Flag,
                Min = (450 / pump.Nr * 50),
                Max = 680 / pump.Nr * 50,
            });
        }
        else
        {
            model.FrequencyLimitList.Add(new IStation.Model.FrequencyLimit()
            {
                Flag = pump.Flag,
                Min = 280 / pump.Nr * 50,
                Max = 480 / pump.Nr * 50,
            });
        }
        model.FrequencyLimitList.ForEach(x =>
        {
            x.Min = Math.Round(x.Min, 1);
            x.Max = Math.Round(x.Max, 1);
        });
    }
    return model;
}