Jelajahi Sumber

修改有固定站,两星一地有参定位

wyq 8 bulan lalu
induk
melakukan
33771f79e3

+ 0 - 4
Service/X2D1TaskServer/HistoryFile.cs

@@ -1,8 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace X2D1TaskServer
 {

+ 0 - 1
Service/X2D1TaskServer/LogHelper.cs

@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Diagnostics;
 using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
 using XdCxRhDW.Dto;
 

+ 0 - 3
Service/X2D1TaskServer/MainForm.cs

@@ -1,13 +1,10 @@
 using System;
-using System.Collections.Generic;
-using System.Configuration;
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Reflection;
 using System.Threading.Tasks;
 using System.Windows.Forms;
-using X2D1TaskServer.Service;
 using XdCxRhDW.Dto;
 using XdCxRhDW.Framework;
 using XdCxRhDW.WebApi;

+ 0 - 1
Service/X2D1TaskServer/MySqlTools.cs

@@ -1,5 +1,4 @@
 using MySql.Data.MySqlClient;
-using System;
 using System.Data;
 
 namespace X2D1TaskServer

+ 0 - 5
Service/X2D1TaskServer/Program.cs

@@ -1,16 +1,11 @@
 using Serilog;
 using System;
 using System.Collections.Generic;
-using System.Configuration;
 using System.Diagnostics;
 using System.IO;
-using System.Linq;
 using System.Reflection;
 using System.Security.Principal;
-using System.Threading.Tasks;
 using System.Windows.Forms;
-using XdCxRhDW.Framework;
-using static Org.BouncyCastle.Math.EC.ECCurve;
 
 namespace X2D1TaskServer
 {

+ 0 - 1
Service/X2D1TaskServer/Properties/AssemblyInfo.cs

@@ -1,5 +1,4 @@
 using System.Reflection;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 // 有关程序集的一般信息由以下

+ 1 - 5
Service/X2D1TaskServer/Service/BaseParamInfo.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Linq;
 using XdCxRhDW.Dto;
 
 namespace X2D1TaskServer

+ 1 - 5
Service/X2D1TaskServer/Service/BaseTaskI.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
 using XdCxRhDW.Dto;
 
 namespace X2D1TaskServer

+ 0 - 2
Service/X2D1TaskServer/Service/TaskHistoryService.cs

@@ -1,10 +1,8 @@
 using System;
 using System.Collections.Generic;
-using System.Configuration;
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
-using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using XdCxRhDW.Dto;

+ 2 - 5
Service/X2D1TaskServer/Service/TaskRealService.cs

@@ -1,14 +1,11 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
 using System.Linq;
-using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
-using static Org.BouncyCastle.Math.EC.ECCurve;
 using XdCxRhDW.Dto;
-using System.Configuration;
-using System.Diagnostics;
-using System.IO;
 
 namespace X2D1TaskServer.Service
 {

+ 23 - 3
Service/X2D1TaskServer/Service/TaskService.cs

@@ -1,12 +1,10 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Configuration;
 using System.Diagnostics;
 using System.Globalization;
 using System.IO;
 using System.Linq;
-using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using XdCxRhDW.Dto;
@@ -567,6 +565,7 @@ namespace X2D1TaskServer.Service
 
         private async Task DoX2D1NoParPosAsync(X2D1TaskHandleDto dto, BaseParamInfo paramInfo, List<DetectResDto> deteRes, List<CpuCgResDto> data1, List<CpuCgResDto> data2, CancellationTokenSource cts, string msg, int fixedStationId, bool beFindRef = false)
         {
+            List<X2D1NoXlNoParlPosDto> list = new List<X2D1NoXlNoParlPosDto>();
             for (int i = 0; i < data1.Count; i++)
             {
                 try
@@ -628,7 +627,11 @@ namespace X2D1TaskServer.Service
                             x2D1.XdSnr = data1[i].Snr;
                         }
                     }
-
+                    if (beFindRef)
+                    {
+                        list.Add(x2D1);
+                        continue;
+                    }
                     var result = await HttpHelper.PostRequestAsync<PosResDto>(_config.baseUrl + "Pos/PosX2D1NoXlNoParAsync", x2D1);
                     if (result.code != 200)
                     {
@@ -640,6 +643,23 @@ namespace X2D1TaskServer.Service
                     await LogHelper.Error($"{msg},{paramInfo.Minfo.CapTime:yyyyMMddHHmmss}时刻时隙位置{data1[i].Smpstart}定位异常", ex);
                 }
             }
+            try
+            {
+                if (beFindRef)
+                {
+                    var result = await HttpHelper.PostRequestAsync<PosResDto>(_config.baseUrl + "Pos/PosX2D1BeFindRefListAsync", list);
+                    if (result.code != 200)
+                    {
+                        await LogHelper.Error($"{msg},{paramInfo.Minfo.CapTime:yyyyMMddHHmmss}时刻找参考定位定位异常.{result.msg}");
+                    }
+
+                }
+            }
+            catch (Exception ex)
+            {
+                await LogHelper.Error($"{msg},{paramInfo.Minfo.CapTime:yyyyMMddHHmmss}时刻找参考定位异常", ex);
+            }
+
             await LogHelper.Info($"{msg},{paramInfo.Minfo.CapTime:yyyyMMddHHmmss}时刻定位完成");
         }
 

+ 1 - 7
Service/X2D1TaskServer/Service/TaskSvrConfig.cs

@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace X2D1TaskServer.Service
+namespace X2D1TaskServer.Service
 {
     public class TaskSvrConfig
     {

+ 88 - 7
XdCxRhDW.App/Controllers/PosController.cs

@@ -449,7 +449,7 @@ namespace XdCxRhDW.App.Controllers
                     return Error<PosResDto>($"推算卫星{dto.AdjaCode}的ECEF星历出错");
                 }
 
-                //#warning 测试代码
+                 //#warning 测试代码
                 //var tarEcef = PhysicsHelper.GeoToEcef((110, 17, 0));
                 //var ecefXl1 = (ephMain.data.X, ephMain.data.Y, ephMain.data.Z);
                 //var ecefXl2 = (ephAdja.data.X, ephAdja.data.Y, ephAdja.data.Z);
@@ -706,6 +706,93 @@ namespace XdCxRhDW.App.Controllers
 
         Random r = new Random();
 
+        /// <summary>
+        /// 两星一地无参定位(无星历)
+        /// </summary>
+        /// <returns>返回定位结果ID</returns>
+        [HttpPost]
+        public async Task<AjaxResult<PosResDto>> PosX2D1BeFindRefListAsync(List<X2D1NoXlNoParlPosDto> dtos)
+        {
+            var dto = dtos.First();
+            try
+            {
+                TaskInfo runTask;
+                using (RHDWContext db = new RHDWContext())
+                {
+                    if (dto.TaskID == null)
+                    {
+                        runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.TaskType == EnumTaskType.Group
+                        && p.PosType == EnumPosType.X2D1 && p.TaskState == EnumTaskState.Running);
+                        if (runTask == null)
+                        {
+                            Serilog.Log.Warning($"接收到两星一地无参定位(无星历)参数,由于找不到执行中的任务忽略本次定位");
+                            return Error<PosResDto>($"多模式融合定位平台没有启动两星一地定位任务");
+                        }
+                    }
+                    else
+                    {
+                        runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.ID == dto.TaskID);
+                        if (runTask == null)
+                        {
+                            Serilog.Log.Warning($"找不到任务,ID={dto.TaskID}");
+                            return Error<PosResDto>($"找不到ID={dto.TaskID}的任务");
+                        }
+                    }
+                }
+                var xl1 = await XlRepository.GetLatest2Async(dto.MainCode, dto.SigTime);
+                if (xl1 == null)
+                {
+                    Serilog.Log.Error($"系统缺少编号{dto.MainCode}卫星的星历!");
+                    return Error<PosResDto>($"系统缺少编号{dto.MainCode}卫星的星历!");
+                }
+                Serilog.Log.Information($"卫星{dto.MainCode}使用发布时刻为{xl1.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
+                var xl2 = await XlRepository.GetLatest2Async(dto.AdjaCode, dto.SigTime);
+                if (xl2 == null)
+                {
+                    Serilog.Log.Error($"系统缺少编号{dto.AdjaCode}卫星的星历!");
+                    return Error<PosResDto>($"系统缺少编号{dto.AdjaCode}卫星的星历!");
+                }
+
+
+
+                Serilog.Log.Information($"卫星{dto.AdjaCode}使用发布时刻为{xl2.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
+                //dto.SigTime = new DateTime(2023, 12, 24, 18, 0, 0);
+                //dto.CdbTxLon = 45;
+                //dto.CdbTxLat = 20;
+                //dto.SatTxLon = 45;
+                //dto.SatTxLat = 20;
+                var XlCalcDto = new XlCalcDto() { tleStr = xl1.TwoLine, SigTime = dto.SigTime };
+                var ephMain = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto);
+                if (ephMain.code != 200)
+                {
+                    Serilog.Log.Error($"推算卫星{dto.MainCode}的ECEF星历出错.{ephMain.msg}");
+                    return Error<PosResDto>($"推算卫星{dto.MainCode}的ECEF星历出错");
+                }
+                var XlCalcDto2 = new XlCalcDto() { tleStr = xl2.TwoLine, SigTime = dto.SigTime };
+                var ephAdja = await HttpHelper.PostRequestAsync<SatEphResDto>(SysConfig.GetUrl("Xl/Calc"), XlCalcDto2);
+                if (ephAdja.code != 200)
+                {
+                    Serilog.Log.Error($"推算卫星{dto.AdjaCode}的ECEF星历出错.{ephAdja.msg}");
+                    return Error<PosResDto>($"推算卫星{dto.AdjaCode}的ECEF星历出错");
+                }
+
+                X2D1PosRefService.Instance.AddPosDto(dtos);
+                PosRes posRes = new PosRes();
+                return Success(MapDto(posRes));
+
+            }
+            catch (DbUpdateException)
+            {
+                using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
+                {
+                    if (!db.IsTableFieldSync())
+                        throw new Exception("表结构不一致,本次定位异常,已自动同步结构");
+                    else
+                        throw;
+                }
+            }
+        }
+
         /// <summary>
         /// 两星一地无参定位(无星历)
         /// </summary>
@@ -789,12 +876,6 @@ namespace XdCxRhDW.App.Controllers
                 //dto.SxDto = dto1 * 1e6 + r.Next(-10, 10) + Math.Round(r.NextDouble(), 3);
                 //dto.XdDto = dto2 * 1e6 + r.Next(-10, 10) + Math.Round(r.NextDouble(), 3);
 
-                if (dto.BeFindRef)
-                {
-                    X2D1PosRefService.Instance.AddPosDto(dto);
-                    PosRes posRes = new PosRes();
-                    return Success(MapDto(posRes));
-                }
                 using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
                 {
                     var StationRes = db.StationRes.Add(new StationRes()

+ 175 - 93
XdCxRhDW.App/X2D1PosRef/X2D1PosHandle.cs

@@ -1,4 +1,5 @@
 using DevExpress.Utils.About;
+using DevExpress.XtraTreeList;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -17,15 +18,17 @@ namespace XdCxRhDW.App
 
     public class X2D1PosItem
     {
-        public X2D1PosItem(X2D1NoXlNoParlPosDto x2D1)
+        public X2D1PosItem(X2D1NoXlNoParlPosDto x2D1, DateTime date)
         {
             this.Dto = x2D1;
-            this.CreateTime = DateTime.Now;
+            this.CreateTime = date;
+            this.IsDw = false;
 
         }
         public X2D1NoXlNoParlPosDto Dto { get; set; }
 
         public DateTime CreateTime { get; set; }
+        public bool IsDw { get; set; }
 
     }
     /// <summary>
@@ -40,7 +43,7 @@ namespace XdCxRhDW.App
 
         private bool isRuning = true;
 
-        BlockingCollection<X2D1PosItem> posItems = new BlockingCollection<X2D1PosItem>();
+        BlockingCollection<List<X2D1PosItem>> posItems = new BlockingCollection<List<X2D1PosItem>>();
         public X2D1PosHandle(int taskId, double takeRefTime)
         {
             takeRefTimeSeconds = takeRefTime * 60;//秒
@@ -57,99 +60,117 @@ namespace XdCxRhDW.App
                 {
                     try
                     {
-                        var posItem = posItems.Take();
-                        var dto = posItem.Dto;
+                        var X2D1PosItems = posItems.Take();
+
+                        var firstdto = X2D1PosItems.First().Dto;
                         FixedStation fixedStation;
-                        int fixedStationId = dto.FixedStationId.HasValue ? dto.FixedStationId.Value : 0;
+                        int fixedStationId = firstdto.FixedStationId.HasValue ? firstdto.FixedStationId.Value : 0;
                         using (RHDWContext db = new RHDWContext())
                         {
                             fixedStation = await db.FixedStation.FirstOrDefaultAsync(f => f.ID == fixedStationId);
                         }
-                        if (fixedStation == null)//没有固定站
-                        {
-                            SendX2D1NoXlNoParAsync(dto);
-                            continue;
-                        }
-                        using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
-                        {
-                            DateTime min = dto.SigTime.AddSeconds(-takeRefTimeSeconds);
-                            DateTime max = dto.SigTime.AddSeconds(takeRefTimeSeconds);
-                            //获取设定分钟之内的固定站数据
-                            var cgResRefs = await db.CgRes.Where(m => m.TaskID == dto.TaskID && m.FixedStationID == dto.FixedStationId && m.SigTime >= min && m.SigTime <= max).OrderBy(d => d.SigTime).ToListAsync();
 
-                            List<CgRes> matchCgList = new List<CgRes>();
-                            cgResRefs.ForEach(c =>
-                            {
-                                if ((dto.SigTime - c.SigTime).TotalSeconds <= takeRefTimeSeconds)
-                                {
-                                    matchCgList.Add(c);
-                                }
-                            });
-                            var cgOrderList = matchCgList.OrderBy(d => d.SigTime).ToList();
-                            var point1 = cgOrderList.Where(c => c.SigTime <= dto.SigTime).FirstOrDefault();
-                            var point2 = cgOrderList.Where(c => c.SigTime >= dto.SigTime).FirstOrDefault();
+                        List<X2D1NoXlNoParlPosDto> listNoRef = new List<X2D1NoXlNoParlPosDto>();
+                        List<X2D1NoXlPosDto> listRef = new List<X2D1NoXlPosDto>();
 
-                            if (point1 == null || point2 == null)//若参考频点未出结果,查找目标信号出
+                        foreach (var posItem in X2D1PosItems)
+                        {
+                            try
                             {
-                                bool isTarAny = await db.CgRes.AnyAsync(m => m.TaskID == dto.TaskID && !m.FixedStationID.HasValue && m.TarFreqUp.HasValue && m.TarFreqUp.Value == fixedStation.FreqUpHz && m.SigTime >= dto.SigTime);
-                                if (!isTarAny && (DateTime.Now - posItem.CreateTime).TotalMinutes < 2)//目标未出结果
+                                var dto = posItem.Dto;
+                                if (fixedStation == null)//没有固定站
                                 {
-                                    Serilog.Log.Information($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}目标未出结果");
-                                    posItems.Add(posItem);
+                                    posItem.IsDw = true;
+                                    listNoRef.Add(dto);
                                     continue;
                                 }
-                                else if (!isTarAny && (DateTime.Now - posItem.CreateTime).TotalMinutes >= 2)//目标两分钟之内未出结果走无参
+                                using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
                                 {
-                                    Serilog.Log.Information($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}目标未出结果超时");
-                                    SendX2D1NoXlNoParAsync(dto);
-                                    continue;
+                                    DateTime min = dto.SigTime.AddSeconds(-takeRefTimeSeconds);
+                                    DateTime max = dto.SigTime.AddSeconds(takeRefTimeSeconds);
+                                    //获取设定分钟之内的固定站数据
+                                    var cgResRefs = await db.CgRes.Where(m => m.TaskID == dto.TaskID && m.FixedStationID == dto.FixedStationId && m.SigTime >= min && m.SigTime <= max).OrderBy(d => d.SigTime).ToListAsync();
+
+                                    List<CgRes> matchCgList = new List<CgRes>();
+                                    cgResRefs.ForEach(c =>
+                                    {
+                                        if ((dto.SigTime - c.SigTime).TotalSeconds <= takeRefTimeSeconds)
+                                        {
+                                            matchCgList.Add(c);
+                                        }
+                                    });
+                                    var cgOrderList = matchCgList.OrderBy(d => d.SigTime).ToList();
+                                    var point1 = cgOrderList.Where(c => c.SigTime <= dto.SigTime).FirstOrDefault();
+                                    var point2 = cgOrderList.Where(c => c.SigTime >= dto.SigTime).FirstOrDefault();
+
+                                    if (point1 == null || point2 == null)//若参考频点未出结果,查找目标信号出
+                                    {
+                                        if ((DateTime.Now - posItem.CreateTime).TotalMinutes >= 2)//两分钟之内未出结果走无参
+                                        {
+                                            await LogHelper.Warning($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}参考未出结果超时");
+                                            posItem.IsDw = true;
+                                            listNoRef.Add(dto);
+                                            continue;
+                                        }
+                                        bool isTarAny = await db.CgRes.AnyAsync(m => m.TaskID == dto.TaskID && !m.FixedStationID.HasValue && m.TarFreqUp.HasValue && m.TarFreqUp.Value == fixedStation.FreqUpHz && m.SigTime >= dto.SigTime);
+                                        if (!isTarAny && (DateTime.Now - posItem.CreateTime).TotalMinutes < 2)//目标未出结果
+                                        {
+                                            posItem.IsDw = false;
+                                            continue;
+                                        }
+                                       
+                                    }
+                                    if (point1 != null && point2 != null)
+                                    {
+                                        posItem.IsDw = true;
+                                        //通过双星时差及超短波时差怎么计算参考信息的时差
+                                        double refDto = LinearInterpolation.CalSigTimeDto(dto.SigTime, point1.SigTime, point2.SigTime, point1.Dto1.Value, point2.Dto1.Value);
+                                        double refDtoCdb = LinearInterpolation.CalSigTimeDto(dto.SigTime, point1.SigTime, point2.SigTime, point1.DtoCdb.Value, point2.DtoCdb.Value);
+
+                                        //执行两星一地有参定位
+                                        X2D1NoXlPosDto X2D1NoXlPosDto = new X2D1NoXlPosDto()
+                                        {
+                                            SigTime = dto.SigTime,
+                                            MainCode = dto.MainCode,
+                                            AdjaCode = dto.AdjaCode,
+                                            SxDto = dto.SxDto,
+                                            XdDto = dto.XdDto,
+                                            MainYbDto = refDto,
+                                            AdjaYbDto = refDtoCdb,
+                                            SatTxLon = dto.SatTxLon,
+                                            SatTxLat = dto.SatTxLat,
+                                            CdbTxLon = dto.CdbTxLon,
+                                            CdbTxLat = dto.CdbTxLat,
+                                            RefLon = fixedStation.Lon,
+                                            RefLat = fixedStation.Lat,
+                                            FreqDown = dto.FreqDown,
+                                            FreqUp = dto.FreqUp,
+                                            XdDfo = dto.XdDfo,
+                                            XdSnr = dto.XdSnr,
+                                            SxDfo = dto.SxDfo,
+                                            SxSnr = dto.SxSnr,
+                                            CalcConfidence = true,
+                                            TheoryDfoCalc = true,
+                                            TaskID = dto.TaskID,
+                                            CheckRes = dto.CheckRes,
+                                        };
+                                        listRef.Add(X2D1NoXlPosDto);
+                                    }
                                 }
                             }
-                            if (point1 != null && point2 != null)
+                            catch (Exception ex)
                             {
-                                //通过双星时差及超短波时差怎么计算参考信息的时差
-                                double refDto = LinearInterpolation.CalSigTimeDto(dto.SigTime, point1.SigTime, point2.SigTime, point1.Dto1.Value, point2.Dto1.Value);
-                                double refDtoCdb = LinearInterpolation.CalSigTimeDto(dto.SigTime, point1.SigTime, point2.SigTime, point1.DtoCdb.Value, point2.DtoCdb.Value);
-
-                                //执行两星一地有参定位
-                                X2D1NoXlPosDto X2D1NoXlPosDto = new X2D1NoXlPosDto()
-                                {
-                                    SigTime = dto.SigTime,
-                                    MainCode = dto.MainCode,
-                                    AdjaCode = dto.AdjaCode,
-                                    SxDto = dto.SxDto,
-                                    XdDto = dto.XdDto,
-                                    MainYbDto = refDto,
-                                    AdjaYbDto = refDtoCdb,
-                                    SatTxLon = dto.SatTxLon,
-                                    SatTxLat = dto.SatTxLat,
-                                    CdbTxLon = dto.CdbTxLon,
-                                    CdbTxLat = dto.CdbTxLat,
-                                    RefLon = fixedStation.Lon,
-                                    RefLat = fixedStation.Lat,
-                                    FreqDown = dto.FreqDown,
-                                    FreqUp = dto.FreqUp,
-                                    XdDfo = dto.XdDfo,
-                                    XdSnr = dto.XdSnr,
-                                    SxDfo = dto.SxDfo,
-                                    SxSnr = dto.SxSnr,
-                                    CalcConfidence = true,
-                                    TheoryDfoCalc = true,
-                                    TaskID = dto.TaskID,
-                                };
-                                var result = await HttpHelper.PostRequestAsync<PosResDto>(SysConfig.GetUrl("Pos/PosX2D1NoXlAsync"), X2D1NoXlPosDto);
-                                if (result.code != 200)
-                                {
-                                    Serilog.Log.Information($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地定位失败{result.msg}");
-                                }
-                                else
-                                {
-                                    Serilog.Log.Information($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地定位完成{result.msg}");
-                                }
+                                posItem.IsDw = false;
+                                await LogHelper.Error($"【取参考信号流程异常{ex.Message}", ex);
                             }
 
-
                         }
+                        var poslist = X2D1PosItems.Where(x => !x.IsDw);
+                        if (poslist.Count() > 0)
+                        {
+                            posItems.Add(poslist.ToList());
+                        }
+                        SendPos(listNoRef, listRef);
                     }
                     catch (Exception ex)
                     {
@@ -160,32 +181,93 @@ namespace XdCxRhDW.App
             });
         }
 
+
+        private void SendPos(List<X2D1NoXlNoParlPosDto> listNoRef, List<X2D1NoXlPosDto> listRef)
+        {
+            SendX2D1NoXlNoParAsync(listNoRef);
+            SendX2D1RefAsync(listRef);
+
+        }
         /// <summary>
         /// 发送两星一地无参定位
         /// </summary>
-        /// <param name="dto"></param>
-        private async void SendX2D1NoXlNoParAsync(X2D1NoXlNoParlPosDto dto)
+        /// <param name="dtos"></param>
+        private void SendX2D1NoXlNoParAsync(List<X2D1NoXlNoParlPosDto> dtos)
         {
-            dto.BeFindRef = false;
-            dto.FixedStationId = null;
-            var result = await HttpHelper.PostRequestAsync<PosResDto>(SysConfig.GetUrl("Pos/PosX2D1NoXlNoParAsync"), dto);
-            if (result.code != 200)
+            Task.Run(async () =>
             {
-                Serilog.Log.Information($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位失败{result.msg}");
+                foreach (var dto in dtos)
+                {
+                    try
+                    {
+                        dto.BeFindRef = false;
+                        dto.FixedStationId = null;
+                        var result = await HttpHelper.PostRequestAsync<PosResDto>(SysConfig.GetUrl("Pos/PosX2D1NoXlNoParAsync"), dto);
+                        if (result.code != 200)
+                        {
+                            await LogHelper.Error($"找参考任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位失败{result.msg}");
 
-            }
-            else
+                        }
+                        else
+                        {
+                            await LogHelper.Info($"找参考任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位完成{result.msg}");
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        await LogHelper.Error($"找参考任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位失败{ex.Message}");
+                    }
+
+                }
+            });
+
+        }
+
+        /// <summary>
+        /// 发送两星一地无参定位
+        /// </summary>
+        /// <param name="dtos"></param>
+        private void SendX2D1RefAsync(List<X2D1NoXlPosDto> dtos)
+        {
+            Task.Run(async () =>
             {
-                Serilog.Log.Information($"任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地无参定位完成{result.msg}");
-            }
+                foreach (var dto in dtos)
+                {
+                    try
+                    {
+                        var result = await HttpHelper.PostRequestAsync<PosResDto>(SysConfig.GetUrl("Pos/PosX2D1NoXlAsync"), dto);
+                        if (result.code != 200)
+                        {
+                            await LogHelper.Error($"找参考任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地定位失败{result.msg}");
+                        }
+                        else
+                        {
+                            await LogHelper.Info($"找参考任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地定位完成{result.msg}");
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        await LogHelper.Error($"找参考任务{dto.TaskID}-{dto.SigTime:yyyy-MM-dd HH:mm:ss}两星一地定位失败{ex.Message}");
+                    }
+
+                }
+            });
+
         }
-        public void Append(X2D1NoXlNoParlPosDto dto)
+        public void Append(List<X2D1NoXlNoParlPosDto> dtos)
         {
-            X2D1PosItem posItem = new X2D1PosItem(dto);
-            bool ret = posItems.TryAdd(posItem);
+            DateTime dt = DateTime.Now;
+            List<X2D1PosItem> list = new List<X2D1PosItem>();
+            foreach (var dtoitem in dtos)
+            {
+                X2D1PosItem posItem = new X2D1PosItem(dtoitem, dt);
+                list.Add(posItem);
+            }
+
+            bool ret = posItems.TryAdd(list);
             if (!ret)
             {
-                Serilog.Log.Information($"【任务{dto.TaskID}】添加取参考Dto");
+                LogHelper.Warning($"【任务{dtos.First().TaskID}】添加取参考Dto").GetAwaiter();
             }
         }
 

+ 8 - 6
XdCxRhDW.App/X2D1PosRef/X2D1PosRefService.cs

@@ -30,7 +30,7 @@ namespace XdCxRhDW.App
         }
         public void StartMonitor()
         {
-            Task.Run(() =>
+            Task.Run(async () =>
             {
                 while (true)
                 {
@@ -64,31 +64,33 @@ namespace XdCxRhDW.App
                     }
                     catch (Exception ex)
                     {
-                        Serilog.Log.Error(ex, $"【监视取参考任务运行状态异常,{ex.Message}");
+                       await LogHelper.Error($"【监视取参考任务运行状态异常,{ex.Message}",ex);
 
                     }
 
                 }
             });
         }
-        public void AddPosDto(X2D1NoXlNoParlPosDto dto)
+        public void AddPosDto(List<X2D1NoXlNoParlPosDto> dtos)
         {
             try
             {
+                var dto = dtos.First();
                 lock (this)
                 {
+
                     var firstDto = handles.FirstOrDefault(m => m.TaskId == dto.TaskID);
                     if (firstDto == null)
                     {
                         firstDto = new X2D1PosHandle(dto.TaskID.Value, TakeRefTime);
                         handles.Add(firstDto);
                     }
-                    firstDto.Append(dto);
+                    firstDto.Append(dtos);
                 }
             }
             catch (Exception ex)
             {
-                Serilog.Log.Error(ex, $"【任务{dto.TaskID}】添加取参考信号流程异常,{ex.Message}");
+              LogHelper.Error($"【任务{dtos.First().TaskID}】添加取参考信号流程异常,{ex.Message}",ex).GetAwaiter();
 
             }
         }
@@ -108,7 +110,7 @@ namespace XdCxRhDW.App
             }
             catch (Exception ex)
             {
-                Serilog.Log.Error(ex, $"停止【任务{taskID}】取参考信号流程异常,{ex.Message}");
+                LogHelper.Error($"停止【任务{taskID}】取参考信号流程异常,{ex.Message}",ex).GetAwaiter();
 
             }
         }