duheng
2025-03-28 b825d70578b0ddf6d479569887c194f919795dad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections.Generic;
using System.Linq;
 
namespace PBS.WinFrmUI.Hydro.Dispatch.Model
{
    /// <summary>
    /// 组合运行判断
    /// </summary>
    public class CombineRunJudge
    {
        private CombineRunJudge() { }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids_list">所有ID</param>
        /// <param name="index_list">禁止只开机index组合列表</param>
        public static CombineRunJudge BuildByOpenMachineIndex(List<long> ids_list, params int[] index_list)
        {
            CombineRunJudge c1 = new CombineRunJudge();
 
            var must_open_machine_array = new List<long>();
            for (int index = 0; index < ids_list.Count(); index++)
            {
                if (index_list.Contains(index))
                {
                    must_open_machine_array.Add(ids_list[index]);
                }
            }
            must_open_machine_array.Sort();
            c1.open_machine_id_join_string = string.Join(",", must_open_machine_array);
            return c1;
        }
        private string open_machine_id_join_string = null;
 
 
        /// <summary>
        /// 符合就true, 不满足就false
        /// </summary>
        /// <param name="open_machine_id_array"></param>
        /// <returns></returns>
        public bool Judgement(List<long> open_machine_id_array)
        {
            if (!string.IsNullOrEmpty(open_machine_id_join_string))
            {
                open_machine_id_array.Sort();
                if (open_machine_id_join_string == string.Join(",", open_machine_id_array))
                    return true;
            }
 
            return false;
        }
    }
 
}