gongqiuhong il y a 1 an
Parent
commit
da83ef1522

+ 1 - 0
XdCxRhDW.App/UserControl/CtrlCgRes.Designer.cs

@@ -149,6 +149,7 @@ namespace XdCxRhDW.App.UserControl
             this.btnSearch.StyleController = this.layoutControl1;
             this.btnSearch.TabIndex = 9;
             this.btnSearch.Text = "查询";
+            this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
             // 
             // txtTask
             // 

+ 70 - 16
XdCxRhDW.App/UserControl/CtrlCgRes.cs

@@ -18,6 +18,7 @@ using System.Linq;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
+using System.Web.UI.WebControls;
 using System.Windows.Controls;
 using System.Windows.Documents;
 using System.Windows.Forms;
@@ -29,18 +30,41 @@ namespace XdCxRhDW.App.UserControl
 {
     public partial class CtrlCgRes : DevExpress.XtraEditors.XtraUserControl
     {
+        List<CgRes> list = new List<CgRes>();
         public CtrlCgRes()
         {
             InitializeComponent();
             layoutControl1.UseDefault();
             txtStartTime.UseDefault();
             txtEndTime.UseDefault();
-            gridCg.Init<CgRes>().AddMenu("删除", SvgHelper.CreateClose(), async () =>
+            gridCg.Init<CgRes>().UseMultiSelect().AddMenu("删除", SvgHelper.CreateClose(), async () =>
             {
                 try
                 {
 
-
+                    if (XtraMessageBox.Show("确认删除参估?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
+                        return;
+                    var idsGrid = gridView1.GetSelectedRows();
+                    List<CgRes> selectedRes=new List<CgRes>();
+                    foreach ( var row in idsGrid)
+                    {
+                        selectedRes.Add(gridView1.GetRow(row ) as CgRes);
+                    }
+                    var groupItems = selectedRes.GroupBy(p => p.SigTime.ToString("yyyyMMdd"));
+                    foreach (var groupItem in groupItems)
+                    {
+                        var ids = groupItem.Select(m => m.ID).ToList();
+                        using (RHDWPartContext db = RHDWPartContext.GetContext(groupItem.First().SigTime))
+                        {
+                            List<CgRes> list = await db.CgRes.Where(p => ids.Contains(p.ID)).ToListAsync();
+                            db.CgRes.RemoveRange(list);
+                            await db.SaveChangesAsync();
+                        }
+                    }
+                    var seltedIds = selectedRes.Select(s => s.ID);
+                    list.RemoveAll(r=> seltedIds.Contains(r.ID));
+                    //dataSourceCg();
+                    gridView1.RefreshData();
                 }
                 catch (Exception ex)
                 {
@@ -54,7 +78,6 @@ namespace XdCxRhDW.App.UserControl
         {
             try
             {
-              
                 List<TaskInfo> tskList = new List<TaskInfo>();
                 using (RHDWContext db = new RHDWContext())
                 {
@@ -70,14 +93,8 @@ namespace XdCxRhDW.App.UserControl
             }
         }
 
-        private async void txtTimeCho_SelectedIndexChanged(object sender, EventArgs e)
+        private void txtTimeCho_SelectedIndexChanged(object sender, EventArgs e)
         {
-            this.gridCg.DataSource = new List<PosRes>();
-            if (txtTask.EditValue == null)
-            {
-                return;
-            }
-
             switch (txtTimeCho.Text)
             {
                 case "最近1小时":
@@ -87,7 +104,6 @@ namespace XdCxRhDW.App.UserControl
                 case "最近3天":
                     layoutControlItemStartTime.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                     layoutControlItemEndTime.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
-                    this.gridCg.DataSource = await searchPos();
                     break;
                 case "自定义":
                     layoutControlItemStartTime.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
@@ -117,8 +133,8 @@ namespace XdCxRhDW.App.UserControl
                         {
                             using (RHDWPartContext db = RHDWPartContext.GetContext(dayFile))
                             {
-                                if (db.CgRes.Any(p => p.TaskID == ((CgRes)txtTask.EditValue).ID))
-                                    end = await db.CgRes.Where(p => p.TaskID == ((CgRes)txtTask.EditValue).ID).MaxAsync(p => p.SigTime);
+                                if (db.CgRes.Any(p => p.TaskID == ((TaskInfo)txtTask.EditValue).ID))
+                                    end = await db.CgRes.Where(p => p.TaskID == ((TaskInfo)txtTask.EditValue).ID).MaxAsync(p => p.SigTime);
                             }
                             if (end != DateTime.MinValue)
                             {
@@ -140,7 +156,7 @@ namespace XdCxRhDW.App.UserControl
                 {
                     using (RHDWPartContext db = RHDWPartContext.GetContext(endDay))
                     {
-                        var cgRes = await db.CgRes.Where(w => w.SigTime >= start && w.SigTime <= end && w.TaskID == ((CgRes)txtTask.EditValue).ID).OrderByDescending(o => o.SigTime).ToListAsync();
+                        var cgRes = await db.CgRes.Where(w => w.SigTime >= start && w.SigTime <= end && w.TaskID == ((TaskInfo)txtTask.EditValue).ID).OrderByDescending(o => o.SigTime).ToListAsync();
                         list.AddRange(cgRes);
                     }
                     endDay = endDay.AddDays(-1);
@@ -151,10 +167,48 @@ namespace XdCxRhDW.App.UserControl
             catch (TaskCanceledException) { }//屏蔽掉取消查询的异常
             catch (Exception ex)
             {
-                Serilog.Log.Error(ex, "定位结果查询异常");
-                MsgBoxHelper.ShowError("定位结果查询异常");
+                Serilog.Log.Error(ex, "参估结果查询异常");
+                MsgBoxHelper.ShowError("参估结果查询异常");
             }
             return new List<CgRes>();
         }
+
+        private void btnSearch_Click(object sender, EventArgs e)
+        {
+             dataSourceCg();
+        }
+        private async void dataSourceCg()
+        {
+            if (txtTask.EditValue == null)
+            {
+                MsgBoxHelper.ShowError("请选择任务");
+                return;
+            }
+            if (txtTimeCho.SelectedText == "自定义")
+            {
+                if (txtStartTime.EditValue == null)
+                {
+                    DxHelper.MsgBoxHelper.ShowError($"请选择信号开始时间!");
+                    return;
+                }
+                if (txtEndTime.EditValue == null)
+                {
+                    DxHelper.MsgBoxHelper.ShowError($"请选择信号结束时间!");
+                    return;
+                }
+                if (txtStartTime.DateTime > txtEndTime.DateTime)
+                {
+                    DxHelper.MsgBoxHelper.ShowError($"开始时间不能大于结束时间!");
+                    return;
+                }
+                if ((txtEndTime.DateTime - txtStartTime.DateTime).TotalDays > 10)
+                {
+                    MsgBoxHelper.ShowWarning("时间跨度不能超过10天!");
+                    return;
+                }
+            }
+            list = await searchPos();
+            this.gridCg.DataSource = list;
+        }
     }
 }

+ 1 - 1
XdCxRhDW.Repostory/Model/CgRes.cs

@@ -30,7 +30,7 @@ namespace XdCxRhDW.Repostory.Model
         /// 站点ID
         /// </summary>
         [Display(Name = "任务ID")]
-        public long TaskID { get; set; }
+        public int TaskID { get; set; }
 
         /// <summary>
         /// 站点信息

+ 19 - 3
XdCxRhDW.WebApi/Controllers/PosController.cs

@@ -74,6 +74,7 @@ namespace XdCxRhDW.App.WebAPI
                     YbMainDto = dto.MainYbDto,
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -172,6 +173,7 @@ namespace XdCxRhDW.App.WebAPI
                     YbMainDto = dto.MainYbDto,
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -251,6 +253,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -366,6 +369,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -435,6 +439,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -484,7 +489,7 @@ namespace XdCxRhDW.App.WebAPI
             }
             using (RHDWPartContext db = RHDWPartContext.GetContext(dto.SigTime))
             {
-               var xlInfoList = await XlCache.GetAllAsync();
+                var xlInfoList = await XlCache.GetAllAsync();
 
                 var mainXl = xlInfoList.Where(w => w.SatCode == dto.MainCode);
                 var minTime = mainXl.Min(m => Math.Abs((m.TimeBJ - dto.SigTime).TotalSeconds));
@@ -545,6 +550,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -624,6 +630,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -743,6 +750,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -823,6 +831,7 @@ namespace XdCxRhDW.App.WebAPI
                     MainCode = dto.MainCode,
                     Adja1Code = dto.Adja1Code,
                     Adja2Code = dto.Adja2Code,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -959,6 +968,7 @@ namespace XdCxRhDW.App.WebAPI
                     MainCode = dto.MainCode,
                     Adja1Code = dto.Adja1Code,
                     Adja2Code = dto.Adja2Code,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -1031,6 +1041,7 @@ namespace XdCxRhDW.App.WebAPI
                     MainCode = dto.MainCode,
                     Adja1Code = dto.Adja1Code,
                     Adja2Code = dto.Adja2Code,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -1089,7 +1100,7 @@ namespace XdCxRhDW.App.WebAPI
 
                 var mainXl = xlInfoList.Where(w => w.SatCode == dto.MainCode);
                 var minTime = mainXl.Min(m => Math.Abs((m.TimeBJ - dto.SigTime).TotalSeconds));
-                var xlInfo1 = mainXl.Where(w => Math.Abs((w.TimeBJ - dto.SigTime).TotalSeconds) == minTime).FirstOrDefault(); 
+                var xlInfo1 = mainXl.Where(w => Math.Abs((w.TimeBJ - dto.SigTime).TotalSeconds) == minTime).FirstOrDefault();
                 if (xlInfo1 == null)
                 {
                     Serilog.Log.Error($"未找到卫星[{dto.MainCode}]的双行根数星历");
@@ -1162,6 +1173,7 @@ namespace XdCxRhDW.App.WebAPI
                     MainCode = dto.MainCode,
                     Adja1Code = dto.Adja1Code,
                     Adja2Code = dto.Adja2Code,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -1245,6 +1257,7 @@ namespace XdCxRhDW.App.WebAPI
                     MainCode = dto.MainCode,
                     Adja1Code = dto.Adja1Code,
                     Adja2Code = dto.Adja2Code,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -1312,7 +1325,7 @@ namespace XdCxRhDW.App.WebAPI
 
                 var mainXl = xlInfoList.Where(w => w.SatCode == dto.MainCode);
                 var minTime = mainXl.Min(m => Math.Abs((m.TimeBJ - dto.SigTime).TotalSeconds));
-                var xlInfo1 = mainXl.Where(w => Math.Abs((w.TimeBJ - dto.SigTime).TotalSeconds) == minTime).FirstOrDefault(); 
+                var xlInfo1 = mainXl.Where(w => Math.Abs((w.TimeBJ - dto.SigTime).TotalSeconds) == minTime).FirstOrDefault();
                 if (xlInfo1 == null)
                 {
                     Serilog.Log.Error($"未找到卫星[{dto.MainCode}]的双行根数星历");
@@ -1394,6 +1407,7 @@ namespace XdCxRhDW.App.WebAPI
                     MainCode = dto.MainCode,
                     Adja1Code = dto.Adja1Code,
                     Adja2Code = dto.Adja2Code,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,
@@ -1483,6 +1497,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = dto.MainX,
                     MainY = dto.MainY,
                     MainZ = dto.MainZ,
@@ -1605,6 +1620,7 @@ namespace XdCxRhDW.App.WebAPI
                     StationResID = StationRes.ID,
                     MainCode = dto.MainCode,
                     Adja1Code = dto.AdjaCode,
+                    TaskID = runTask.ID,
                     MainX = ephMain.data.X,
                     MainY = ephMain.data.Y,
                     MainZ = ephMain.data.Z,