ningshuxia
2025-04-16 ed113213fc94c3d9886ea08dfddd09d08d9ba7d5
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
namespace IStation.Test
{
    internal class Program
    {
 
        //static BLL.StationSignalRecordPacket bll = new BLL.StationSignalRecordPacket();
        //static long projectId = 661070185922629;
        //static long monitorDataSourcesId = 606203941007429;
        //static DateTime dateStart = new DateTime(2024, 1, 1);
        //static DateTime dateEnd = new DateTime(2025, 1, 1);
        //static Dictionary<int, long> stationDict = new Dictionary<int, long>
        //    {
        //        { 1, 462958406303813 },
        //        { 2, 462958422204485 }
        //    };
 
        //// 过滤无效数据
        //// 1输模型修正
        //// 2输数据修正
        //// 修正组合偏差
        //static void Main(string[] args)
        //{
 
 
        //    IStation.SettingsD.Project.ID = projectId;
 
        //    var ptList = new List<PointViewModel>();
        //    var ptFilterList = new List<PointViewModel>();
        //    foreach (var station in stationDict)
        //    {
        //        var stationIndex = station.Key;
        //        var stationId = station.Value;
        //        var packets = bll.Get(monitorDataSourcesId, stationId);
        //        var list = new List<PointViewModel>();
 
        //        var records = packets.SelectMany(x => x.StationSignalRecords).ToList();
        //        foreach (var x in records)
        //        {
        //            //if (x.TotalPressure > 0 && x.TotalFlow > 0)
        //            //{ 
        //            //    if (stationIndex == 2 && x.DiffFlow > 0)
        //            //    {
        //            //        continue;
        //            //    }
        //            //    ptList.Add(new PointViewModel(x.Time, x.TotalFlow, x.TotalPressure, x.DiffFlow, stationIndex));
        //            //}
        //            if (x.TotalPressure < 0 || x.TotalPressure > 40)
        //            {
        //                continue;
        //            }
        //            if (x.TotalFlow < 1000)
        //            {
        //                continue;
        //            }
        //            if (x.TotalPressure < 13 && stationIndex == 1)
        //            {
        //                continue;
        //            }
        //            if (stationIndex == 2 && Math.Abs(x.DiffFlow) > 3500)
        //            {
        //                continue;
        //            }
        //            list.Add(new PointViewModel(x.Time, x.TotalFlow, x.TotalPressure, x.DiffFlow, stationIndex));
        //        }
 
 
        //        ptList.AddRange(list);
        //        var newPtList = DynamicThresholdProcessorHelper.Filter(list);
        //        ptFilterList.AddRange(newPtList);
        //    }
 
        //    var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "csv");
        //    if (!Directory.Exists(fullPath))
        //    {
        //        Directory.CreateDirectory(fullPath);
        //    }
 
        //    var recordFilterList = GetRecordList(ptFilterList, Path.Combine(fullPath, "allFilter.csv"));
        //    var recordList = GetRecordList(ptList, Path.Combine(fullPath, "all.csv"));
 
        //    var fc = recordFilterList.Count;
        //    var c=recordList.Count;
        //    Console.WriteLine($"recordFilterList:{fc} recordList:{c} diff:{c-fc}");
        //    Console.WriteLine("ok");
        //    Console.ReadKey();
 
        //}
 
 
        //static List<RecordViewModel> GetRecordList(List<PointViewModel> list,string filePath)
        //{
        //    var recordList = new List<RecordViewModel>();
        //    var timeGroup = list.GroupBy(x => x.Time);
        //    foreach (var group in timeGroup)
        //    {
        //        if (group.Count() < 2)
        //            continue;
        //        var record = new RecordViewModel
        //        {
        //            Time = group.Key
        //        };
        //        foreach (var item in group)
        //        {
        //            if (item.Index == 1)
        //            {
        //                record.Flow1 = item.X;
        //                record.Pressure1 = item.Y;
        //            }
        //            else
        //            {
        //                record.Flow2 = item.X;
        //                record.Pressure2 = item.Y;
        //                record.FlowDiff2 = item.Diff;
        //            }
        //        }
 
        //        recordList.Add(record);
        //    }
 
        //    { 
        //        using StreamWriter writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8); 
        //        writer.WriteLine($"Time,Flow1,Pressure1,Flow2,Pressure2,FlowDiff2");
 
        //        foreach (var record in recordList)
        //        {
        //           writer.WriteLine($"{record.Time},{record.Flow1},{record.Pressure1},{record.Flow2:N3},{record.Pressure2:N5},{record.FlowDiff2}");
        //           //  writer.WriteLine($"{record.Time},{record.Flow1},{record.Pressure1},{record.Flow2},{record.Pressure2},{Math.Abs(record.FlowDiff2)}");
        //        }
 
        //    }
        //    return recordList;
 
        //}
 
 
        // 过滤无效数据
        // 1输模型修正
        // 2输数据修正
        // 修正组合偏差
        static void Main(string[] args)
        {
            Station2Helper.Start();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("ok");
            Console.ReadKey();
        }
 
 
 
    }
 
}