zoulei 11 kuukautta sitten
vanhempi
commit
6184c47d83

+ 10 - 0
Service/CgDbScan/CgDbScan.csproj

@@ -90,6 +90,16 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Dbsacn\Cluster.cs" />
+    <Compile Include="Dbsacn\ClusterSet.cs" />
+    <Compile Include="Dbsacn\Dbscan.cs" />
+    <Compile Include="Dbsacn\DistanceFunction.cs" />
+    <Compile Include="Dbsacn\DistanceFunctions.cs" />
+    <Compile Include="Dbsacn\IPointData.cs" />
+    <Compile Include="Dbsacn\ISpatialIndex.cs" />
+    <Compile Include="Dbsacn\ListSpatialIndex.cs" />
+    <Compile Include="Dbsacn\Point.cs" />
+    <Compile Include="Dbsacn\PointInfo.cs" />
     <Compile Include="DBSCAN.cs" />
     <Compile Include="LogHelper.cs" />
     <Compile Include="Program.cs" />

+ 17 - 0
Service/CgDbScan/Dbsacn/Cluster.cs

@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+
+namespace Dbscan
+{
+
+	/// <summary>
+	/// A collection of items that have been clustered by the algorithm.
+	/// </summary>
+	/// <typeparam name="T">The type of elements in the cluster.</typeparam>
+	public class Cluster<T>
+	{
+		/// <summary>
+		/// The items that have been clustered.
+		/// </summary>
+		public IReadOnlyList<T> Objects { get; set; }
+	}
+}

+ 22 - 0
Service/CgDbScan/Dbsacn/ClusterSet.cs

@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+
+namespace Dbscan
+{
+
+	/// <summary>
+	/// The result of running the DBSCAN algorithm on a set of data.
+	/// </summary>
+	/// <typeparam name="T">The type of elements in the cluster.</typeparam>
+	public class ClusterSet<T>
+	{
+		/// <summary>
+		/// A list of the clusters that have been identified.
+		/// </summary>
+		public IReadOnlyList<Cluster<T>> Clusters { get; set; }
+
+		/// <summary>
+		/// A list of the items that were not identified as being part of a cluster.
+		/// </summary>
+		public IReadOnlyList<T> UnclusteredObjects { get; set; }
+	}
+}

+ 94 - 0
Service/CgDbScan/Dbsacn/Dbscan.cs

@@ -0,0 +1,94 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Dbscan
+{
+
+	/// <summary>
+	/// Contains static methods to run the DBSCAN algorithm.
+	/// </summary>
+	public static class Dbscan
+	{
+		/// <summary>
+		/// Run the DBSCAN algorithm on a collection of points, using the default index
+		/// (<see cref="T:Dbscan.ListSpatialIndex`1" />).
+		/// </summary>
+		/// <typeparam name="T">The type of elements to cluster.</typeparam>
+		/// <param name="data">The collection of elements to cluster.</param>
+		/// <param name="epsilon">The epsilon parameter to use in the algorithm; used to determine the radius of the circle to find neighboring points.</param>
+		/// <param name="minimumPointsPerCluster">The minimum number of points required to create a cluster or to add additional points to the cluster.</param>
+		/// <returns>A <see cref="T:Dbscan.ClusterSet`1" /> containing the list of <see cref="T:Dbscan.Cluster`1" />s and a list of unclustered points.</returns>
+		/// <remarks>This method is an O(N^2) operation, where N is the Length of the dataset</remarks>
+		public static ClusterSet<T> CalculateClusters<T>(IEnumerable<T> data, double epsilon, int minimumPointsPerCluster) where T : IPointData
+		{
+			return CalculateClusters(new ListSpatialIndex<PointInfo<T>>(data.Select((T p) => new PointInfo<T>(p)).ToList()), epsilon, minimumPointsPerCluster);
+		}
+
+		/// <summary>
+		/// Run the DBSCAN algorithm on a collection of points, the specified pre-filled <see cref="T:Dbscan.ISpatialIndex`1" />.
+		/// </summary>
+		/// <typeparam name="T">The type of elements to cluster.</typeparam>
+		/// <param name="index">The collection of elements to cluster.</param>
+		/// <param name="epsilon">The epsilon parameter to use in the algorithm; used to determine the radius of the circle to find neighboring points.</param>
+		/// <param name="minimumPointsPerCluster">The minimum number of points required to create a cluster or to add additional points to the cluster.</param>
+		/// <returns>A <see cref="T:Dbscan.ClusterSet`1" /> containing the list of <see cref="T:Dbscan.Cluster`1" />s and a list of unclustered points.</returns>
+		public static ClusterSet<T> CalculateClusters<T>(ISpatialIndex<PointInfo<T>> index, double epsilon, int minimumPointsPerCluster) where T : IPointData
+		{
+			List<PointInfo<T>> list = index.Search().ToList();
+			List<Cluster<T>> list2 = new List<Cluster<T>>();
+			foreach (PointInfo<T> item in list)
+			{
+				if (!item.Visited)
+				{
+					item.Visited = true;
+					IPointData p2 = item;
+					IReadOnlyList<PointInfo<T>> readOnlyList = index.Search(in p2, epsilon);
+					if (readOnlyList.Count >= minimumPointsPerCluster)
+					{
+						list2.Add(BuildCluster(index, item, readOnlyList, epsilon, minimumPointsPerCluster));
+					}
+				}
+			}
+			return new ClusterSet<T>
+			{
+				Clusters = list2,
+				UnclusteredObjects = (from p in list
+									  where !p.Clustered
+									  select p.Item).ToList()
+			};
+		}
+
+		private static Cluster<T> BuildCluster<T>(ISpatialIndex<PointInfo<T>> index, PointInfo<T> point, IReadOnlyList<PointInfo<T>> neighborhood, double epsilon, int minimumPointsPerCluster) where T : IPointData
+		{
+			List<T> list = new List<T> { point.Item };
+			point.Clustered = true;
+			Queue<PointInfo<T>> queue = new Queue<PointInfo<T>>(neighborhood);
+			while (queue.Any())
+			{
+				PointInfo<T> pointInfo = queue.Dequeue();
+				if (!pointInfo.Visited)
+				{
+					pointInfo.Visited = true;
+					IPointData p = pointInfo;
+					IReadOnlyList<PointInfo<T>> readOnlyList = index.Search(in p, epsilon);
+					if (readOnlyList.Count >= minimumPointsPerCluster)
+					{
+						foreach (PointInfo<T> item in readOnlyList)
+						{
+							queue.Enqueue(item);
+						}
+					}
+				}
+				if (!pointInfo.Clustered)
+				{
+					pointInfo.Clustered = true;
+					list.Add(pointInfo.Item);
+				}
+			}
+			return new Cluster<T>
+			{
+				Objects = list
+			};
+		}
+	}
+}

+ 11 - 0
Service/CgDbScan/Dbsacn/DistanceFunction.cs

@@ -0,0 +1,11 @@
+namespace Dbscan
+{
+
+    /// <summary>
+    /// Represents a method that calculates the distance between two <see cref="T:Dbscan.IPointData" /> objects.
+    /// </summary>
+    /// <param name="p1">An object representing the first point.</param>
+    /// <param name="p2">An object representing the second point.</param>
+    /// <returns>The distance between points <paramref name="p1" /> and <paramref name="p2" />.</returns>
+    public delegate double DistanceFunction(in IPointData p1, in IPointData p2);
+}

+ 15 - 0
Service/CgDbScan/Dbsacn/DistanceFunctions.cs

@@ -0,0 +1,15 @@
+using System;
+
+namespace Dbscan
+{
+
+	internal static class DistanceFunctions
+	{
+		public static double EuclideanDistance(in IPointData a, in IPointData b)
+		{
+			double num = b.Point.X - a.Point.X;
+			double num2 = b.Point.Y - a.Point.Y;
+			return Math.Sqrt(num * num + num2 * num2);
+		}
+	}
+}

+ 14 - 0
Service/CgDbScan/Dbsacn/IPointData.cs

@@ -0,0 +1,14 @@
+namespace Dbscan
+{
+
+	/// <summary>
+	/// Exposes a <see cref="P:Dbscan.IPointData.Point" /> that identifies where an object is.
+	/// </summary>
+	public interface IPointData
+	{
+		/// <summary>
+		/// The location of the current object.
+		/// </summary>
+		Point Point { get; }
+	}
+}

+ 33 - 0
Service/CgDbScan/Dbsacn/ISpatialIndex.cs

@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+
+namespace Dbscan
+{
+
+	/// <summary>
+	/// Provides the base interface for the abstraction of
+	/// an index to find points.
+	/// </summary>
+	/// <typeparam name="T">The type of elements in the index.</typeparam>
+	public interface ISpatialIndex<out T>
+	{
+		/// <summary>
+		/// Get all of the elements within the current <see cref="T:Dbscan.ISpatialIndex`1" />.
+		/// </summary>
+		/// <returns>
+		/// A list of every element contained in the <see cref="T:Dbscan.ISpatialIndex`1" />.
+		/// </returns>
+		IReadOnlyList<T> Search();
+
+		/// <summary>
+		/// Get all of the elements from this <see cref="T:Dbscan.ISpatialIndex`1" />
+		/// within a circle centered at the point <see cref="P:Dbscan.IPointData.Point" />
+		/// with a radius of <paramref name="epsilon" />.
+		/// </summary>
+		/// <param name="p">The center of the search circle.</param>
+		/// <param name="epsilon">The radius of the search circle.</param>
+		/// <returns>
+		/// A list of the points that are within the search area.
+		/// </returns>
+		IReadOnlyList<T> Search(in IPointData p, double epsilon);
+	}
+}

+ 83 - 0
Service/CgDbScan/Dbsacn/ListSpatialIndex.cs

@@ -0,0 +1,83 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Dbscan
+{
+
+	/// <summary>
+	/// An implementation of the <see cref="T:Dbscan.ISpatialIndex`1" /> using a simple <see cref="T:System.Collections.Generic.List`1" />
+	/// to hold the elements and a linear search of all items to <see cref="M:Dbscan.ListSpatialIndex`1.Search(Dbscan.IPointData@,System.Double)" />
+	/// for nearby items.
+	/// </summary>
+	/// <typeparam name="T">The type of items in the index.</typeparam>
+	public class ListSpatialIndex<T> : ISpatialIndex<T> where T : IPointData
+	{
+		private readonly IReadOnlyList<T> _list;
+
+		private readonly DistanceFunction _distanceFunction;
+
+		/// <summary>
+		/// Initializes a <see cref="T:Dbscan.ListSpatialIndex`1" /> with a collection of data, using the
+		/// Euclidean distance between two points as the distance function to search for points 
+		/// in a given neighborhood.
+		/// </summary>
+		/// <param name="data">The collection of data to put into the index</param>
+		public ListSpatialIndex(IEnumerable<T> data)
+			: this(data, (DistanceFunction)DistanceFunctions.EuclideanDistance)
+		{
+		}
+
+		/// <summary>
+		/// Initializes a <see cref="T:Dbscan.ListSpatialIndex`1" /> with a collection of data, using the
+		/// specified distanct function to search for points in a given neighborhood.
+		/// </summary>
+		/// <param name="data">The collection of data to put into the index</param>
+		/// <param name="distanceFunction">The function used to determine if a point is within a specified distance of a given point.</param>
+		public ListSpatialIndex(IEnumerable<T> data, DistanceFunction distanceFunction)
+		{
+			_list = data.ToList();
+			_distanceFunction = distanceFunction;
+		}
+
+		/// <summary>
+		/// Get all of the elements within the current <see cref="T:Dbscan.ListSpatialIndex`1" />.
+		/// </summary>
+		/// <returns>
+		/// A list of every element contained in the <see cref="T:Dbscan.ListSpatialIndex`1" />.
+		/// </returns>
+		public IReadOnlyList<T> Search()
+		{
+			return _list;
+		}
+
+		/// <summary>
+		/// Get all of the elements from this <see cref="T:Dbscan.ListSpatialIndex`1" />
+		/// within a circle centered at the point <see cref="P:Dbscan.IPointData.Point" />
+		/// with a radius of <paramref name="epsilon" />.
+		/// </summary>
+		/// <param name="p">The center of the search circle.</param>
+		/// <param name="epsilon">The radius of the search circle.</param>
+		/// <returns>
+		/// A list of the points that are within the search area.
+		/// </returns>
+		public IReadOnlyList<T> Search(in IPointData p, double epsilon)
+		{
+			List<T> list = new List<T>();
+			foreach (T item in _list)
+			{
+				DistanceFunction distanceFunction = _distanceFunction;
+				IPointData p2 = item;
+				if (distanceFunction(in p, in p2) < epsilon)
+				{
+					list.Add(item);
+				}
+			}
+			return list;
+		}
+
+		IReadOnlyList<T> ISpatialIndex<T>.Search(in IPointData p, double epsilon)
+		{
+			return Search(in p, epsilon);
+		}
+	}
+}

+ 108 - 0
Service/CgDbScan/Dbsacn/Point.cs

@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using System.Text;
+
+namespace Dbscan
+{
+
+    /// <summary>
+    /// A point on the 2-d plane.
+    /// </summary>
+    /// <param name="X">The x-coordinate of the point.</param>
+    /// <param name="Y">The y-coordinate of the point.</param>
+    public struct Point : IEquatable<Point>
+    {
+        /// <summary>The x-coordinate of the point.</summary>
+        public double X { get; set; }
+
+        /// <summary>The y-coordinate of the point.</summary>
+        public double Y { get; set; }
+
+        /// <summary>
+        /// A point on the 2-d plane.
+        /// </summary>
+        /// <param name="X">The x-coordinate of the point.</param>
+        /// <param name="Y">The y-coordinate of the point.</param>
+        public Point(double X, double Y)
+        {
+            this.X = X;
+            this.Y = Y;
+        }
+
+        [CompilerGenerated]
+        public override string ToString()
+        {
+            StringBuilder stringBuilder = new StringBuilder();
+            stringBuilder.Append("Point");
+            stringBuilder.Append(" { ");
+            if (PrintMembers(stringBuilder))
+            {
+                stringBuilder.Append(' ');
+            }
+            stringBuilder.Append('}');
+            return stringBuilder.ToString();
+        }
+
+        [CompilerGenerated]
+        private bool PrintMembers(StringBuilder builder)
+        {
+            builder.Append("X = ");
+            builder.Append(X.ToString());
+            builder.Append(", Y = ");
+            builder.Append(Y.ToString());
+            return true;
+        }
+
+        [CompilerGenerated]
+        public static bool operator !=(Point left, Point right)
+        {
+            return !(left == right);
+        }
+
+        [CompilerGenerated]
+        public static bool operator ==(Point left, Point right)
+        {
+            return left.Equals(right);
+        }
+
+        [CompilerGenerated]
+        public override int GetHashCode()
+        {
+            return EqualityComparer<double>.Default.GetHashCode(X) * -1521134295 + EqualityComparer<double>.Default.GetHashCode(Y);
+        }
+
+        [CompilerGenerated]
+        public override bool Equals(object obj)
+        {
+            if (obj is Point)
+            {
+                return Equals((Point)obj);
+            }
+            return false;
+        }
+
+        [CompilerGenerated]
+        public bool Equals(Point other)
+        {
+            if (EqualityComparer<double>.Default.Equals(X, other.X))
+            {
+                return EqualityComparer<double>.Default.Equals(Y, other.Y);
+            }
+            return false;
+        }
+
+        [CompilerGenerated]
+        public void Deconstruct(out double X, out double Y)
+        {
+            X = this.X;
+            Y = this.Y;
+        }
+    }
+
+    public class Data : IPointData
+    {
+        public long ID { get; set; }
+        public Point Point { get; set; }
+    }
+}

+ 39 - 0
Service/CgDbScan/Dbsacn/PointInfo.cs

@@ -0,0 +1,39 @@
+namespace Dbscan
+{
+
+	/// <summary>
+	/// A holding class for algorithm related information about a point.
+	/// </summary>
+	/// <typeparam name="T">The type of the element this object is holding.</typeparam>
+	public class PointInfo<T> : IPointData where T : IPointData
+	{
+		/// <summary>
+		/// The object being held by this holder
+		/// </summary>
+		public T Item { get; }
+
+		/// <summary>
+		/// Whether or not this point has been clustered
+		/// </summary>
+		public bool Clustered { get; set; }
+
+		/// <summary>
+		/// Whether or not this point has been visited
+		/// </summary>
+		public bool Visited { get; set; }
+
+		/// <summary>
+		/// The location of this point
+		/// </summary>
+		public Point Point => Item.Point;
+
+		/// <summary>
+		/// Initializes a new <see cref="T:Dbscan.PointInfo`1" /> with the object it is holding.
+		/// </summary>
+		/// <param name="item"></param>
+		public PointInfo(T item)
+		{
+			Item = item;
+		}
+	}
+}

+ 91 - 2
Service/CgDbScan/MainForm.cs

@@ -102,6 +102,9 @@ namespace CheckServer
                 ModuleType = EnumModuleType.Soft,
                 ModuleState = EnumModuleState.正常,
             });
+
+            Do();
+
             bool preSucceed = false;
             long id = 0;
             while (!this.Disposing)
@@ -189,7 +192,6 @@ namespace CheckServer
         {
             try
             {
-                var port = Convert.ToInt32(ConfigurationManager.AppSettings["LocalHttpPort"].Trim());
                 var svrID = ConfigurationManager.AppSettings["SvrID"].Trim();
                 var posPlatformAddr = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim();
                 string url;
@@ -202,7 +204,6 @@ namespace CheckServer
                     SvrID = svrID,
                     SvrType = svrType,
                     ReportType = 1,
-                    BaseHttpAddr = $"http://{IpHelper.GetLocalIp()}:{port}",
                     DevId = ConfigurationManager.AppSettings["DevID"].Trim(),
                     ModuleType = EnumModuleType.Soft,
                     ModuleState = EnumModuleState.Error,
@@ -214,5 +215,93 @@ namespace CheckServer
                 _ = LogHelper.Error("服务状态上报异常", ex);
             }
         }
+
+        private void Do()
+        {
+            Task.Run(async () =>
+            {
+                while (true)
+                {
+                    try
+                    {
+                        string baseurl = ConfigurationManager.AppSettings["PosPlatformAddr"].Trim() + "/api/";
+                        var taskRsp = await HttpHelper.PostRequestAsync<List<TaskQueryResDto>>(baseurl + "Result/GetRunningTasks", null);
+                        if (taskRsp.code != 200)
+                        {
+                            await LogHelper.Error($"查询执行中的任务失败.{taskRsp.msg}");
+                            await Task.Delay(10000);
+                            continue;
+                        }
+                        var taskIds = taskRsp.data.Select(p => p.TaskID).ToList();
+                        if (!taskIds.Any())
+                        {
+                            await Task.Delay(10000);
+                            continue;
+                        }
+                        foreach (var taskId in taskIds)
+                        {
+                            var taskFreqsRsp = await HttpHelper.PostRequestAsync<List<TaskFreqResDto>>(baseurl + "Result/GetTaskFreqs", new TaskFreqQueryDto()
+                            {
+                                TaskInfoID = taskId
+                            });
+                            if (taskFreqsRsp.code != 200)
+                            {
+                                await LogHelper.Error($"查询任务频点信息失败.{taskFreqsRsp.msg},任务ID={taskId}");
+                                continue;
+                            }
+                            foreach (var item in taskFreqsRsp.data)
+                            {
+                                var cgResRsp = await HttpHelper.PostRequestAsync<List<CgResDto>>(baseurl + "Result/GetNoneDbScanCgRes", new DbsacnCgResQueryDto()
+                                {
+                                    TaskInfoID = taskId,
+                                    TarFrequpHz = item.FreqUpHz,
+                                });
+                                if (cgResRsp.code != 200)
+                                {
+                                    await LogHelper.Error($"查询未编批的参估结果信息失败.{taskFreqsRsp.msg},任务ID={taskId},上行频点={item.FreqUpHz}");
+                                    continue;
+                                }
+                                var cgRes = cgResRsp.data;
+
+                                var groupByData = cgRes.GroupBy(p => p.SigTime);
+
+                                //重复时间的数据只取一条
+                                List<CgResDto> listDto = new List<CgResDto>();
+                                foreach (var groupByItem in groupByData)
+                                {
+                                    listDto.Add(groupByItem.First());
+                                }
+                                if (listDto.Count < 10) continue;//至少10条记录时开始编批
+                                var firstTime = listDto.First().SigTime;
+                                double t1 = (firstTime - new DateTime(2020, 1, 1, 0, 0, 0)).TotalSeconds;
+                                //将参估结果组装为编批结构
+                                List<Dbscan.Data> list = new List<Dbscan.Data>();
+                                foreach (var cgItem in listDto)
+                                {
+                                    Dbscan.Data data = new Dbscan.Data()
+                                    {
+                                        ID = cgItem.ID,
+                                        Point = new Dbscan.Point(t1 + (cgItem.SigTime - firstTime).TotalSeconds, cgItem.Dto1.Value * 100 + cgItem.Dto2.Value)
+                                    };
+                                    list.Add(data);
+                                }
+                                var clusters = Dbscan.Dbscan.CalculateClusters(
+                                    list,
+                                    epsilon: 100,//邻域半径(需要根据实际情况调整)
+                                    minimumPointsPerCluster: 1);//每个聚合最少个数
+                            }
+                        }
+
+                        await Task.Delay(5000);
+                    }
+                    catch (Exception ex)
+                    {
+                        await LogHelper.Error($"参估编批处理异常", ex);
+                        await Task.Delay(30000);
+                        continue;
+                    }
+                }
+            });
+        }
     }
 }

+ 35 - 0
Service/ClearServiceData/Program.cs

@@ -7,10 +7,45 @@ using System.Threading.Tasks;
 
 namespace ClearServiceData
 {
+    public class AdFile
+    {
+        /// <summary>
+        /// 文件(含路径)
+        /// </summary>
+        public string File { get; set; }
+
+        /// <summary>
+        /// 采集时刻
+        /// </summary>
+        public DateTime AdTime { get; set; }
+
+        /// <summary>
+        /// 通道号
+        /// </summary>
+        public int ChNo { get; set; }
+    }
     internal class Program
     {
+        private static AdFile StringToAdFile(string file)
+        {
+            //20240409094240_ADC_ch02.dat
+            var name = Path.GetFileNameWithoutExtension(file).ToUpper();
+            var arr = name.Split(new string[] { "_", "CH" }, StringSplitOptions.RemoveEmptyEntries);
+            var time = DateTime.ParseExact(arr[0], "yyyyMMddHHmmss", null);
+            AdFile adFile = new AdFile()
+            {
+                File = file,
+                AdTime = time,
+                ChNo = Convert.ToInt32(arr[2]),
+            };
+            return adFile;
+        }
         static void Main(string[] args)
         {
+           var files= Directory.EnumerateFiles("F:\\", "*.dat", SearchOption.TopDirectoryOnly);
+            Console.WriteLine(files.Count());
+            Console.ReadLine();
+            return;
             Console.WriteLine("程序将删除平台及服务的日志文件、wwwroot中上传的临时文件,按Y继续");
             var str= Console.ReadLine();
             if (str.Trim().ToLower() != "y") return;

+ 1 - 0
Service/X1LeoTaskServer54/MainForm.Designer.cs

@@ -47,6 +47,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(705, 338);
             this.Controls.Add(this.listBox1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
             this.Name = "MainForm";
             this.Text = "两星一地离线数据处理服务";
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);

+ 1 - 1
Service/X2D1TaskServer54/AddIns/时隙获取/SlotHelper.cs

@@ -31,12 +31,12 @@ namespace X2D1NoRefTaskServer54
             int multi = 0, slotscount = 0;
             IntPtr slotst, slotle;
             var ret = GetFileSlots(file, timeData, ref frequenceM, ref fsampleM, ref multi, ref slotscount, out slotst, out slotle);
+            res.AdTime = new DateTime(2000 + timeData[0], timeData[1], timeData[2], timeData[3], timeData[4], timeData[5]);
             if (ret == 0)
             {
                 res.FrequenceM = (float)((long)((decimal)frequenceM * 1000000) / 1e6);
                 res.FsampleM = fsampleM;
                 res.Multi = multi;
-                res.AdTime = new DateTime(2000 + timeData[0], timeData[1], timeData[2], timeData[3], timeData[4], timeData[5]);
                 float[] startsF = new float[slotscount];
                 float[] lenF = new float[slotscount];
                 Marshal.Copy(slotst, startsF, 0, slotscount);

+ 1 - 0
Service/X2D1TaskServer54/MainForm.Designer.cs

@@ -47,6 +47,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(705, 338);
             this.Controls.Add(this.listBox1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
             this.Name = "MainForm";
             this.Text = "两星一地离线数据处理服务";
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);

+ 42 - 10
Service/X2D1TaskServer54/Service/TaskService.cs

@@ -117,21 +117,27 @@ namespace X2D1NoRefTaskServer54.Service
                                 idx++;
                                 if (slotsInfo.Slots.Any())
                                     listSlotsInfo.Add(slotsInfo);
-                                else
-                                    File.Delete(item.File);//删除没有信号的检测引导文件
+
+                                if (CapDir.StartsWith("F:"))
+                                    File.Delete(item.File);//删除检测引导文件
                             }
-                            var adFiles = Directory.EnumerateFiles(CapDir, "*.dat", SearchOption.TopDirectoryOnly).Select(p => StringToAdFile(p))
-                                .Where(p => p.AdTime == listSlotsInfo.First().AdTime);
                             if (!listSlotsInfo.Any())
                             {
-                                //没有突发信号,删除所有对应时刻的采集文件
-                                foreach (var item in adFiles)
+                                continue;
+                            }
+                            var delAdFiles = Directory.EnumerateFiles(CapDir, "*.dat", SearchOption.TopDirectoryOnly).Select(p => StringToAdFile(p))
+                                .Where(p => p.AdTime < adTime);
+                            foreach (var item in delAdFiles)
+                            {
+                                try
                                 {
                                     File.Delete(item.File);
                                 }
-                                continue;
+                                catch
+                                { }
                             }
-
+                            var adFiles = Directory.EnumerateFiles(CapDir, "*.dat", SearchOption.TopDirectoryOnly).Select(p => StringToAdFile(p))
+                                .Where(p => p.AdTime == listSlotsInfo.First().AdTime);
                             if (adFiles.Count() != 3)
                             {
                                 await LogHelper.Warning($"【任务{dto.ID}】{adTime:yyyyMMddHHmmss}时刻原始AD文件个数不为3,跳过此组文件");
@@ -140,6 +146,7 @@ namespace X2D1NoRefTaskServer54.Service
                                 {
                                     File.Delete(item.File);
                                 }
+
                                 continue;
                             }
                             var first = listSlotsInfo.First();
@@ -155,6 +162,16 @@ namespace X2D1NoRefTaskServer54.Service
                                 {
                                     var ddcRes = DDCHelper.DDC(adFile.File, adFile.AdTime, adFile.ChNo, (long)(first.FsampleM * 1e6), (long)(227 * 1e6), "DdcDir", sigs);
                                     chDDCFiles.AddRange(StringToDDCFile(ddcRes));
+                                    if (adFile.File.StartsWith("F:"))
+                                    {
+                                        try
+                                        {
+                                            File.Delete(adFile.File);
+                                        }
+                                        catch
+                                        {
+                                        }
+                                    }
                                 }, cts.Token);
                                 listTask.Add(task);
                             }
@@ -201,6 +218,21 @@ namespace X2D1NoRefTaskServer54.Service
                                     string mainFile = await HttpHelper.UploadFileAsync(ch0File.File, baseUrl, token: cts.Token);//主星文件
                                     string adja1File = await HttpHelper.UploadFileAsync(ch1File.File, baseUrl, token: cts.Token);//邻1星文件
                                     string cdbFile = await HttpHelper.UploadFileAsync(ch2File.File, baseUrl, token: cts.Token);//地面信号文件
+                                    try
+                                    {
+
+                                        try
+                                        {
+                                            File.Delete(ch0File.File);
+                                            File.Delete(ch1File.File);
+                                            File.Delete(ch2File.File);
+                                        }
+                                        catch
+                                        {
+                                        }
+                                    }
+                                    catch
+                                    { }
                                     var smpPositions = sig.Slots.Slots.Select(p => new SmpPosition() { TimeSeconds = p.TimeSeconds, smpStart = p.StartPoint, smpCount = p.Len }).ToList();
                                     var cgDto = new CpuCgMultiDto()
                                     {
@@ -366,8 +398,8 @@ namespace X2D1NoRefTaskServer54.Service
                                                     TsCount = data1.Count,
                                                     PosType = 3,
                                                     ModRate = signalResult.data[i].Rate,
-                                                    CdbLon=posDto.CdbTxLon,
-                                                    CdbLat=posDto.CdbTxLat,
+                                                    CdbLon = posDto.CdbTxLon,
+                                                    CdbLat = posDto.CdbTxLat,
                                                 };
                                                 await HttpHelper.PostRequestAsync(baseUrl + "Result/WritePosResToFile", wDto);
                                             }

+ 1 - 0
Service/X2LeoTaskServer54/MainForm.Designer.cs

@@ -47,6 +47,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(705, 338);
             this.Controls.Add(this.listBox1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
             this.Name = "MainForm";
             this.Text = "两星一地离线数据处理服务";
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);

+ 1 - 1
Service/X3LeoTaskServer54/App.config

@@ -14,7 +14,7 @@
 		<add key="PosPlatformAddr" value="http://127.0.0.1:8091" />
 
 		<!--采集数据目录-->
-		<add key="CapDir" value="E:\data10\低轨三星仿真数据"/>
+		<add key="CapDir" value="D:\data10\低轨三星仿真数据"/>
 
 		<!--卫星及星历-->
 		<add key ="MainSatInfo" value="39206,-41891185.7993,-2303482.9121,-1007186.7852"/>

+ 1 - 0
Service/X3LeoTaskServer54/MainForm.Designer.cs

@@ -47,6 +47,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(705, 338);
             this.Controls.Add(this.listBox1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
             this.Name = "MainForm";
             this.Text = "两星一地离线数据处理服务";
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);

+ 1 - 0
Service/X3TaskServer54/MainForm.Designer.cs

@@ -47,6 +47,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(705, 338);
             this.Controls.Add(this.listBox1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
             this.Name = "MainForm";
             this.Text = "三星离线数据处理服务";
             this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);

+ 57 - 9
XdCxRhDW.App/Controllers/ResultController.cs

@@ -108,6 +108,51 @@ namespace XdCxRhDW.App.Controllers
             }
         }
 
+        /// <summary>
+        /// 获取未编批的参估结果(该方法只返回部分数据)
+        /// </summary>
+        /// <param name="dto"><see cref="DbsacnCgResQueryDto"/>查询参数</param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        [HttpPost]
+        public async Task<AjaxResult<List<CgResDto>>> GetNoneDbScanCgRes(DbsacnCgResQueryDto dto)
+        {
+            List<CgResDto> cgList = new List<CgResDto>();
+            try
+            {
+                var dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DbPart");
+                var files = Directory.EnumerateFiles(dir, "*.db", SearchOption.AllDirectories).OrderBy(p => Convert.ToInt32(Path.GetFileNameWithoutExtension(p))).ToList();
+                List<CgRes> list = new List<CgRes>();
+                foreach (var item in files)
+                {
+                    using (RHDWPartContext db = RHDWPartContext.GetContext(item))
+                    {
+                        var res = await db.CgRes.Where(p => p.TaskID == dto.TaskInfoID && p.TarFreqUp == dto.TarFrequpHz && p.SigNo == 0 && p.Snr1 > 0 && p.Snr2 > 0).OrderBy(p => p.SigTime).Take(1000).ToListAsync();
+                        list.AddRange(res);
+                    }
+                    if (list.Count >= 1000) break;//每次取1000个点编批
+                }
+                if (list.Count > 1000)
+                {
+                    list = list.Take(1000).ToList();
+                }
+                return Success(MapCgDto(list, false));
+            }
+            catch (TaskCanceledException)
+            {
+                string msg = $"查询未编批的参估结果超时.任务ID={dto.TaskInfoID},FrequpHz={dto.TarFrequpHz}";
+                await LogHelper.Error(msg);
+                return Error<List<CgResDto>>("参估结果时间范围查询超时");
+            }
+            catch (Exception ex)
+            {
+                string msg = $"查询未编批的参估异常.任务ID= {dto.TaskInfoID} ,FrequpHz= {dto.TarFrequpHz}";
+                await LogHelper.Error(msg, ex);
+                return Error<List<CgResDto>>("查询未编批的参估异常");
+            }
+        }
+
+
         /// <summary>
         /// 获取指定任务的所有上行频点
         /// </summary>
@@ -466,7 +511,7 @@ namespace XdCxRhDW.App.Controllers
             };
         }
 
-        private List<CgResDto> MapCgDto(List<CgRes> listCg)
+        private List<CgResDto> MapCgDto(List<CgRes> listCg, bool needStationRes = true)
         {
             List<CgResDto> list = new List<CgResDto>();
             foreach (CgRes cgRes in listCg)
@@ -523,16 +568,19 @@ namespace XdCxRhDW.App.Controllers
                     Adja2Vx = cgRes.Adja2Vx,
                     Adja2Vy = cgRes.Adja2Vy,
                     Adja2Vz = cgRes.Adja2Vz,
-                    SatTxLon = cgRes.StationRes.SatTxLon,
-                    SatTxLat = cgRes.StationRes.SatTxLat,
-                    CdbTxLon = cgRes.StationRes.CdbTxLon,
-                    CdbTxLat = cgRes.StationRes.CdbTxLat,
-                    CxLon = cgRes.StationRes.CxLon,
-                    CxLat = cgRes.StationRes.CxLat,
-                    RefLon = cgRes.StationRes.RefLon,
-                    RefLat = cgRes.StationRes.RefLat,
                     CreateTime = cgRes.CreateTime,
                 };
+                if (needStationRes)
+                {
+                    dto.SatTxLon = cgRes.StationRes.SatTxLon;
+                    dto.SatTxLat = cgRes.StationRes.SatTxLat;
+                    dto.CdbTxLon = cgRes.StationRes.CdbTxLon;
+                    dto.CdbTxLat = cgRes.StationRes.CdbTxLat;
+                    dto.CxLon = cgRes.StationRes.CxLon;
+                    dto.CxLat = cgRes.StationRes.CxLat;
+                    dto.RefLon = cgRes.StationRes.RefLon;
+                    dto.RefLat = cgRes.StationRes.RefLat;
+                }
                 list.Add(dto);
             }
             return list;

+ 1 - 4
XdCxRhDW.App/MainForm.cs

@@ -326,10 +326,7 @@ namespace XdCxRhDW
                      {
                          LogHelper.Error("端口状态上报异常", ex).Wait(5000);
                      }
-                     double.TryParse(ConfigurationManager.AppSettings["StateRptDelay"].Trim(), out double delay);
-                     if (delay == 0)
-                         delay = 5000;
-                     await Task.Delay((int)delay);
+                     await Task.Delay(10000);
                  }
              });
 

+ 20 - 0
XdCxRhDW.App/UserControl/CtrlSvrs.cs

@@ -36,6 +36,7 @@ namespace XdCxRhDW.App.UserControl
         {
             gridSvrs.UseDefault(list).UseGroup().UseRowNumber().UseNullValueText();
             gridView1.ShowingEditor += GridView1_ShowingEditor;
+            gridView1.CustomColumnDisplayText += GridView1_CustomColumnDisplayText;
             gridSvrs.UseEdit();
             var linkEdit = new DevExpress.XtraEditors.Repository.RepositoryItemHyperLinkEdit();
             this.gridSvrs.RepositoryItems.Add(linkEdit);
@@ -52,6 +53,25 @@ namespace XdCxRhDW.App.UserControl
 
         }
 
+        private void GridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
+        {
+            if (e.Column.FieldName == nameof(ModelSvr.DevID))
+            {
+                if (e.Value != null && e.Value.ToString().StartsWith("1"))
+                {
+                    e.DisplayText = $"{e.Value}(采集设备)";
+                }
+                if (e.Value != null && e.Value.ToString().StartsWith("2"))
+                {
+                    e.DisplayText = $"{e.Value}(参估设备)";
+                }
+                if (e.Value != null && e.Value.ToString().StartsWith("3"))
+                {
+                    e.DisplayText = $"{e.Value}(定位设备)";
+                }
+            }
+        }
+
         private void GridView1_ShowingEditor(object sender, CancelEventArgs e)
         {
             var cellValue = gridView1.GetFocusedRowCellValue(nameof(ModelSvr.SwaggerAddr));

+ 17 - 0
XdCxRhDw.Dto/CgResQueryDto.cs

@@ -53,5 +53,22 @@ namespace XdCxRhDW.Dto
         }
     }
 
+    /// <summary>
+    /// 未编批的参估结果查询模型
+    /// </summary>
+    public class DbsacnCgResQueryDto
+    {
+        /// <summary>
+        /// 任务编号
+        /// </summary>
+        [RangeInt(0)]
+        public int TaskInfoID { get; set; }
+
+        /// <summary>
+        /// 目标上行频点(Hz)
+        /// </summary>
+        public long TarFrequpHz { get; set; }
+    }
+
     
 }