|
@@ -17,6 +17,7 @@ using DPP_YH_Core.Extensions;
|
|
|
using XdCxRhDW.App.Model;
|
|
|
using System.Diagnostics;
|
|
|
using System.Configuration;
|
|
|
+using System.Data.Entity.Infrastructure;
|
|
|
|
|
|
namespace XdCxRhDW.App.Controllers
|
|
|
{
|
|
@@ -637,142 +638,157 @@ namespace XdCxRhDW.App.Controllers
|
|
|
[HttpPost]
|
|
|
public async Task<AjaxResult<PosResDto>> PosX2D1NoXlNoParAsync(X2D1NoXlNoParlPosDto dto)
|
|
|
{
|
|
|
- TaskInfo runTask;
|
|
|
- using (RHDWContext db = new RHDWContext())
|
|
|
+ try
|
|
|
{
|
|
|
- if (dto.TaskID == null)
|
|
|
+ TaskInfo runTask;
|
|
|
+ using (RHDWContext db = new RHDWContext())
|
|
|
{
|
|
|
- runTask = await db.TaskInfos.FirstOrDefaultAsync(p => p.TaskType == EnumTaskType.Group
|
|
|
- && p.PosType == EnumPosType.X2D1 && p.TaskState == EnumTaskState.Running);
|
|
|
- if (runTask == null)
|
|
|
+ if (dto.TaskID == null)
|
|
|
{
|
|
|
- Serilog.Log.Warning($"接收到两星一地无参定位(无星历)参数,由于找不到执行中的任务忽略本次定位");
|
|
|
- return Error<PosResDto>($"多模式融合定位平台没有启动两星一地定位任务");
|
|
|
+ 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)
|
|
|
+ else
|
|
|
{
|
|
|
- Serilog.Log.Warning($"找不到任务,ID={dto.TaskID}");
|
|
|
- return Error<PosResDto>($"找不到ID={dto.TaskID}的任务");
|
|
|
+ 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.GetLatestAsync(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.GetLatestAsync(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}的星历进行推算");
|
|
|
- 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星历出错");
|
|
|
- }
|
|
|
- using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
|
|
|
- {
|
|
|
- var StationRes = db.StationRes.Add(new StationRes()
|
|
|
+ var xl1 = await XlRepository.GetLatestAsync(dto.MainCode, dto.SigTime);
|
|
|
+ if (xl1 == null)
|
|
|
{
|
|
|
- SatTxLon = dto.SatTxLon,
|
|
|
- SatTxLat = dto.SatTxLat,
|
|
|
- CdbTxLon = dto.CdbTxLon,
|
|
|
- CdbTxLat = dto.CdbTxLat,
|
|
|
- });
|
|
|
-
|
|
|
- var ckRes = new CheckRes()
|
|
|
+ Serilog.Log.Error($"系统缺少编号{dto.MainCode}卫星的星历!");
|
|
|
+ return Error<PosResDto>($"系统缺少编号{dto.MainCode}卫星的星历!");
|
|
|
+ }
|
|
|
+ Serilog.Log.Information($"卫星{dto.MainCode}使用发布时刻为{xl1.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
|
|
|
+ var xl2 = await XlRepository.GetLatestAsync(dto.AdjaCode, dto.SigTime);
|
|
|
+ if (xl2 == null)
|
|
|
{
|
|
|
- FileName = dto.CheckRes?.FileName,
|
|
|
- SmpStart = dto.CheckRes?.SmpStart,
|
|
|
- SmpCount = dto.CheckRes?.SmpCount,
|
|
|
- PosCheckType = (EnumPosCheckType?)dto.CheckRes?.PosCheckType,
|
|
|
- ModRate = dto.CheckRes?.ModRate,
|
|
|
- ModType = dto.CheckRes?.ModType,
|
|
|
- UserName = dto.CheckRes?.UserName,
|
|
|
- FfcHz = dto.CheckRes?.FfcHz,
|
|
|
- Snr = dto.CheckRes?.Snr
|
|
|
- };
|
|
|
- db.CheckRes.Add(ckRes);
|
|
|
-
|
|
|
- var cgRes = db.CgRes.Add(new CgRes()
|
|
|
+ Serilog.Log.Error($"系统缺少编号{dto.AdjaCode}卫星的星历!");
|
|
|
+ return Error<PosResDto>($"系统缺少编号{dto.AdjaCode}卫星的星历!");
|
|
|
+ }
|
|
|
+ Serilog.Log.Information($"卫星{dto.AdjaCode}使用发布时刻为{xl2.TimeUTC:yyyyMMddHHmmss}的星历进行推算");
|
|
|
+ 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)
|
|
|
{
|
|
|
- SigTime = dto.SigTime,
|
|
|
- Dto1 = Math.Round(dto.SxDto, 10),
|
|
|
- Dfo1 = Math.Round(dto.SxDfo, 10),
|
|
|
- Snr1 = Math.Round(dto.SxSnr, 1),
|
|
|
- DtoCdb = Math.Round(dto.XdDto, 10),
|
|
|
- DfoCdb = Math.Round(dto.XdDfo, 10),
|
|
|
- SnrCdb = Math.Round(dto.XdSnr, 1),
|
|
|
- StationResID = StationRes.ID,
|
|
|
- MainCode = dto.MainCode,
|
|
|
- Adja1Code = dto.AdjaCode,
|
|
|
- MainXlTime = ephMain.data.TleTime,
|
|
|
- Adja1XlTime = ephAdja.data.TleTime,
|
|
|
- TaskID = runTask.ID,
|
|
|
- MainX = ephMain.data.X,
|
|
|
- MainY = ephMain.data.Y,
|
|
|
- MainZ = ephMain.data.Z,
|
|
|
- Adja1X = ephAdja.data.X,
|
|
|
- Adja1Y = ephAdja.data.Y,
|
|
|
- Adja1Z = ephAdja.data.Z,
|
|
|
- MainVx = ephMain.data.VX,
|
|
|
- MainVy = ephMain.data.VY,
|
|
|
- MainVz = ephMain.data.VZ,
|
|
|
- Adja1Vx = ephAdja.data.VX,
|
|
|
- Adja1Vy = ephAdja.data.VY,
|
|
|
- Adja1Vz = ephAdja.data.VZ,
|
|
|
- TarFreqUp = dto.FreqUp,
|
|
|
- TarFreqDown = dto.FreqDown,
|
|
|
- });
|
|
|
- double[] res;
|
|
|
- if (ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"] != null
|
|
|
- && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "false"
|
|
|
- && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "0")
|
|
|
+ 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)
|
|
|
{
|
|
|
- res = PosApi.X2D1_PosNoRef_ZL(cgRes, StationRes);
|
|
|
+ Serilog.Log.Error($"推算卫星{dto.AdjaCode}的ECEF星历出错.{ephAdja.msg}");
|
|
|
+ return Error<PosResDto>($"推算卫星{dto.AdjaCode}的ECEF星历出错");
|
|
|
}
|
|
|
- else
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
|
|
|
{
|
|
|
- res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
|
|
|
+ var StationRes = db.StationRes.Add(new StationRes()
|
|
|
+ {
|
|
|
+ SatTxLon = dto.SatTxLon,
|
|
|
+ SatTxLat = dto.SatTxLat,
|
|
|
+ CdbTxLon = dto.CdbTxLon,
|
|
|
+ CdbTxLat = dto.CdbTxLat,
|
|
|
+ });
|
|
|
+
|
|
|
+ var ckRes = new CheckRes()
|
|
|
+ {
|
|
|
+ FileName = dto.CheckRes?.FileName,
|
|
|
+ SmpStart = dto.CheckRes?.SmpStart,
|
|
|
+ SmpCount = dto.CheckRes?.SmpCount,
|
|
|
+ PosCheckType = (EnumPosCheckType?)dto.CheckRes?.PosCheckType,
|
|
|
+ ModRate = dto.CheckRes?.ModRate,
|
|
|
+ ModType = dto.CheckRes?.ModType,
|
|
|
+ UserName = dto.CheckRes?.UserName,
|
|
|
+ FfcHz = dto.CheckRes?.FfcHz,
|
|
|
+ Snr = dto.CheckRes?.Snr
|
|
|
+ };
|
|
|
+ db.CheckRes.Add(ckRes);
|
|
|
+
|
|
|
+ var cgRes = db.CgRes.Add(new CgRes()
|
|
|
+ {
|
|
|
+ SigTime = dto.SigTime,
|
|
|
+ Dto1 = Math.Round(dto.SxDto, 10),
|
|
|
+ Dfo1 = Math.Round(dto.SxDfo, 10),
|
|
|
+ Snr1 = Math.Round(dto.SxSnr, 1),
|
|
|
+ DtoCdb = Math.Round(dto.XdDto, 10),
|
|
|
+ DfoCdb = Math.Round(dto.XdDfo, 10),
|
|
|
+ SnrCdb = Math.Round(dto.XdSnr, 1),
|
|
|
+ StationResID = StationRes.ID,
|
|
|
+ MainCode = dto.MainCode,
|
|
|
+ Adja1Code = dto.AdjaCode,
|
|
|
+ MainXlTime = ephMain.data.TleTime,
|
|
|
+ Adja1XlTime = ephAdja.data.TleTime,
|
|
|
+ TaskID = runTask.ID,
|
|
|
+ MainX = ephMain.data.X,
|
|
|
+ MainY = ephMain.data.Y,
|
|
|
+ MainZ = ephMain.data.Z,
|
|
|
+ Adja1X = ephAdja.data.X,
|
|
|
+ Adja1Y = ephAdja.data.Y,
|
|
|
+ Adja1Z = ephAdja.data.Z,
|
|
|
+ MainVx = ephMain.data.VX,
|
|
|
+ MainVy = ephMain.data.VY,
|
|
|
+ MainVz = ephMain.data.VZ,
|
|
|
+ Adja1Vx = ephAdja.data.VX,
|
|
|
+ Adja1Vy = ephAdja.data.VY,
|
|
|
+ Adja1Vz = ephAdja.data.VZ,
|
|
|
+ TarFreqUp = dto.FreqUp,
|
|
|
+ TarFreqDown = dto.FreqDown,
|
|
|
+ });
|
|
|
+ double[] res;
|
|
|
+ if (ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"] != null
|
|
|
+ && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "false"
|
|
|
+ && ConfigurationManager.AppSettings["UseNewPosX2D1NoRef"].ToLower() != "0")
|
|
|
+ {
|
|
|
+ res = PosApi.X2D1_PosNoRef_ZL(cgRes, StationRes);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ res = PosApi.X2D1_PosNoRef(cgRes, StationRes, dto.CalcConfidence);
|
|
|
+ }
|
|
|
+ PosRes posRes = new PosRes()
|
|
|
+ {
|
|
|
+ FreqUpHz = (long)cgRes.TarFreqUp.Value,
|
|
|
+ SigTime = dto.SigTime,
|
|
|
+ TaskInfoID = runTask.ID,
|
|
|
+ CgResID = cgRes.ID,
|
|
|
+ CheckResID = ckRes.ID,
|
|
|
+ PosLon = res[0],
|
|
|
+ PosLat = res[1],
|
|
|
+ MirrLon = res[3],
|
|
|
+ MirrLat = res[4],
|
|
|
+ Confidence = (int)res[6],
|
|
|
+ PosResType = EnumPosResType.X2D1NoRef,
|
|
|
+ };
|
|
|
+ if (dto.TheoryDfoCalc && posRes.PosLon != 999)
|
|
|
+ posRes.TargetState = TheoryDtoDfoApi.TheoryDfo(cgRes, StationRes, posRes, SysConfig.Config.YDPZThreshold);
|
|
|
+ posRes = db.PosRes.Add(posRes);
|
|
|
+ await db.SaveChangesAsync();
|
|
|
+ Messenger.Defalut.Pub("新增定位点", MapModel(posRes));
|
|
|
+ return Success(MapDto(posRes));
|
|
|
}
|
|
|
- PosRes posRes = new PosRes()
|
|
|
+ }
|
|
|
+ catch (DbUpdateException ex)
|
|
|
+ {
|
|
|
+ string errMsg;
|
|
|
+ using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime, true))
|
|
|
{
|
|
|
- FreqUpHz = (long)cgRes.TarFreqUp.Value,
|
|
|
- SigTime = dto.SigTime,
|
|
|
- TaskInfoID = runTask.ID,
|
|
|
- CgResID = cgRes.ID,
|
|
|
- CheckResID = ckRes.ID,
|
|
|
- PosLon = res[0],
|
|
|
- PosLat = res[1],
|
|
|
- MirrLon = res[3],
|
|
|
- MirrLat = res[4],
|
|
|
- Confidence = (int)res[6],
|
|
|
- PosResType = EnumPosResType.X2D1NoRef,
|
|
|
- };
|
|
|
- if (dto.TheoryDfoCalc && posRes.PosLon != 999)
|
|
|
- posRes.TargetState = TheoryDtoDfoApi.TheoryDfo(cgRes, StationRes, posRes, SysConfig.Config.YDPZThreshold);
|
|
|
- posRes = db.PosRes.Add(posRes);
|
|
|
- await db.SaveChangesAsync();
|
|
|
- Messenger.Defalut.Pub("新增定位点", MapModel(posRes));
|
|
|
- return Success(MapDto(posRes));
|
|
|
+ errMsg = db.CheckTableField();
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(errMsg))
|
|
|
+ throw new Exception(errMsg);
|
|
|
+ else
|
|
|
+ throw;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|