Преглед изворни кода

修改参考参估结果展示

wyq пре 3 месеци
родитељ
комит
41c68c8946

+ 0 - 2
DW5S.App/ExtensionsDev/GridControlEx.cs

@@ -421,7 +421,6 @@ public static class GridControlEx
                 if (!succeed) return;
             }
             var view = grid.MainView as GridView;
-            view.DeleteSelectedRows();
             view.RefreshData();
 
         });
@@ -447,7 +446,6 @@ public static class GridControlEx
                 if (!succeed) return;
             }
             var view = grid.MainView as GridView;
-            view.DeleteSelectedRows();
             view.RefreshData();
 
         });

+ 2 - 0
DW5S.App/ExtensionsDev/SearchLookUpEditExtension.cs

@@ -73,6 +73,7 @@ namespace ExtensionsDev
 
         public static SearchLookUpEdit SetData<T>(this SearchLookUpEdit ctrl, List<T> data, string displayField, string valueField = "This")
         {
+            ctrl.EditValue = null;
             ctrl.Properties.ValueMember = valueField;
             ctrl.Properties.KeyMember = valueField;
             ctrl.Properties.DisplayMember = displayField;
@@ -86,6 +87,7 @@ namespace ExtensionsDev
         }
         public static SearchLookUpEdit SetData<T>(this SearchLookUpEdit ctrl, Func<Task<IEnumerable<T>>> onGetDataAsync, string displayField, string valueField = "This")
         {
+            ctrl.EditValue = null;
             ctrl.Properties.ValueMember = valueField;
             ctrl.Properties.KeyMember = valueField;
             ctrl.Properties.DisplayMember = displayField;

+ 31 - 4
DW5S.App/UserControl/CtrlRefCgRes.Designer.cs

@@ -30,6 +30,7 @@ namespace DW5S.App.UserControl
         private void InitializeComponent()
         {
             layoutControl1 = new DevExpress.XtraLayout.LayoutControl();
+            ctrlPage1 = new CtrlPage();
             gridCg = new DevExpress.XtraGrid.GridControl();
             gridView1 = new DevExpress.XtraGrid.Views.Grid.GridView();
             txtTimeCho = new DevExpress.XtraEditors.ImageComboBoxEdit();
@@ -48,6 +49,7 @@ namespace DW5S.App.UserControl
             layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem();
             layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
             emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
+            layoutControlItem5 = new DevExpress.XtraLayout.LayoutControlItem();
             ((System.ComponentModel.ISupportInitialize)layoutControl1).BeginInit();
             layoutControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)gridCg).BeginInit();
@@ -68,10 +70,12 @@ namespace DW5S.App.UserControl
             ((System.ComponentModel.ISupportInitialize)layoutControlItem1).BeginInit();
             ((System.ComponentModel.ISupportInitialize)layoutControlItem4).BeginInit();
             ((System.ComponentModel.ISupportInitialize)emptySpaceItem1).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)layoutControlItem5).BeginInit();
             SuspendLayout();
             // 
             // layoutControl1
             // 
+            layoutControl1.Controls.Add(ctrlPage1);
             layoutControl1.Controls.Add(gridCg);
             layoutControl1.Controls.Add(txtTimeCho);
             layoutControl1.Controls.Add(txtStartTime);
@@ -87,12 +91,21 @@ namespace DW5S.App.UserControl
             layoutControl1.TabIndex = 7;
             layoutControl1.Text = "layoutControl2";
             // 
+            // ctrlPage1
+            // 
+            ctrlPage1.Location = new System.Drawing.Point(2, 435);
+            ctrlPage1.Margin = new System.Windows.Forms.Padding(0);
+            ctrlPage1.MinimumSize = new System.Drawing.Size(100, 26);
+            ctrlPage1.Name = "ctrlPage1";
+            ctrlPage1.Size = new System.Drawing.Size(1196, 28);
+            ctrlPage1.TabIndex = 8;
+            // 
             // gridCg
             // 
             gridCg.Location = new System.Drawing.Point(2, 26);
             gridCg.MainView = gridView1;
             gridCg.Name = "gridCg";
-            gridCg.Size = new System.Drawing.Size(1196, 437);
+            gridCg.Size = new System.Drawing.Size(1196, 405);
             gridCg.TabIndex = 7;
             gridCg.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { gridView1 });
             // 
@@ -149,7 +162,6 @@ namespace DW5S.App.UserControl
             // 
             // txtSat
             // 
-            txtSat.EditValue = 1;
             txtSat.Location = new System.Drawing.Point(31, 2);
             txtSat.Name = "txtSat";
             txtSat.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) });
@@ -183,7 +195,7 @@ namespace DW5S.App.UserControl
             // 
             layoutControlGroup1.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
             layoutControlGroup1.GroupBordersVisible = false;
-            layoutControlGroup1.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] { layoutControlItem2, layoutControlItem3, itemStart, itemEnd, layoutControlItem6, layoutControlItem1, layoutControlItem4, emptySpaceItem1 });
+            layoutControlGroup1.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] { layoutControlItem2, layoutControlItem3, itemStart, itemEnd, layoutControlItem6, layoutControlItem1, layoutControlItem4, emptySpaceItem1, layoutControlItem5 });
             layoutControlGroup1.Name = "Root";
             layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0);
             layoutControlGroup1.Size = new System.Drawing.Size(1200, 465);
@@ -195,7 +207,7 @@ namespace DW5S.App.UserControl
             layoutControlItem2.Location = new System.Drawing.Point(0, 24);
             layoutControlItem2.MinSize = new System.Drawing.Size(104, 24);
             layoutControlItem2.Name = "layoutControlItem2";
-            layoutControlItem2.Size = new System.Drawing.Size(1200, 441);
+            layoutControlItem2.Size = new System.Drawing.Size(1200, 409);
             layoutControlItem2.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
             layoutControlItem2.TextSize = new System.Drawing.Size(0, 0);
             layoutControlItem2.TextVisible = false;
@@ -307,6 +319,18 @@ namespace DW5S.App.UserControl
             emptySpaceItem1.Size = new System.Drawing.Size(60, 24);
             emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0);
             // 
+            // layoutControlItem5
+            // 
+            layoutControlItem5.Control = ctrlPage1;
+            layoutControlItem5.Location = new System.Drawing.Point(0, 433);
+            layoutControlItem5.MaxSize = new System.Drawing.Size(0, 32);
+            layoutControlItem5.MinSize = new System.Drawing.Size(104, 32);
+            layoutControlItem5.Name = "layoutControlItem5";
+            layoutControlItem5.Size = new System.Drawing.Size(1200, 32);
+            layoutControlItem5.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
+            layoutControlItem5.TextSize = new System.Drawing.Size(0, 0);
+            layoutControlItem5.TextVisible = false;
+            // 
             // CtrlRefCgRes
             // 
             AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@@ -335,6 +359,7 @@ namespace DW5S.App.UserControl
             ((System.ComponentModel.ISupportInitialize)layoutControlItem1).EndInit();
             ((System.ComponentModel.ISupportInitialize)layoutControlItem4).EndInit();
             ((System.ComponentModel.ISupportInitialize)emptySpaceItem1).EndInit();
+            ((System.ComponentModel.ISupportInitialize)layoutControlItem5).EndInit();
             ResumeLayout(false);
         }
 
@@ -358,5 +383,7 @@ namespace DW5S.App.UserControl
         private DevExpress.XtraEditors.SimpleButton btnDraw;
         private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
         private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1;
+        private CtrlPage ctrlPage1;
+        private DevExpress.XtraLayout.LayoutControlItem layoutControlItem5;
     }
 }

+ 49 - 42
DW5S.App/UserControl/CtrlRefCgRes.cs

@@ -1,4 +1,5 @@
-using DW5S.Entity;
+using DW5S.DTO;
+using DW5S.Entity;
 using DW5S.Repostory;
 using DW5S.ViewModel;
 using DxHelper;
@@ -20,14 +21,17 @@ namespace DW5S.App.UserControl
         public CtrlRefCgRes()
         {
             InitializeComponent();
+            this.layoutControl1.UseDefault();
+            this.ctrlPage1.Compact = false;
+            this.ctrlPage1.AlignRight = true;
+            this.ctrlPage1.ShowGoto = true;
         }
 
         private async void CtrlRefCgRes_Load(object sender, EventArgs e)
         {
             try
             {
-
-                layoutControl1.UseDefault();
+                ctrlPage1.SetOnQuery(LoadPageData);
                 txtStartTime.UseDefault();
                 txtEndTime.UseDefault();
                 gridCg.UseDefault(list).UseMultiSelect().UseRowNumber().UseDeleteAsync<RefCgResViewModel>(DelCg);
@@ -36,17 +40,8 @@ namespace DW5S.App.UserControl
                 var unitOfWork = IocContainer.UnitOfWork;
                 var repsSat = unitOfWork.Of<SatInfo>();
                 satList.AddRange(await repsSat.GetAllAsync(p => p.UpdateTime));
-
-                this.txtSat.UseDefault().SetData(satList.To<List<SatViewModel>>(), nameof(SatViewModel.Sat)).UseDoubleClickToSelectAll();
-                //ctrlPaging.CurrentPageChanged += async (int currentPage) =>
-                //{
-
-                //};
-                //ctrlPaging.PageCountChanged += async (int pageCount) =>
-                //{
-
-                //};
-
+                this.txtSat.UseDefault().SetData(satList.To<List<SatViewModel>>(), displayField: nameof(SatViewModel.Sat)).UseDoubleClickToSelectAll();
+               
             }
             catch (Exception ex)
             {
@@ -56,14 +51,17 @@ namespace DW5S.App.UserControl
             }
         }
 
+
         private async Task<bool> DelCg(List<RefCgResViewModel> selectedRes)
         {
             try
             {
                 var unitOfWork = IocContainer.UnitOfWork;
                 var repsCg = unitOfWork.OfLong<RefCgRes>();
-                await repsCg.DeleteAsync(selectedRes.To<List<RefCgRes>>());
+                var count = await repsCg.DeleteAsync(selectedRes.To<List<RefCgRes>>());
                 await unitOfWork.SaveAsync();
+                ctrlPage1.RefreshData();
+                IocContainer.Logger.Information($"删除选中参考参估结果,共删除了{count}条星历记录");
                 return true;
             }
             catch (Exception ex)
@@ -92,7 +90,7 @@ namespace DW5S.App.UserControl
             }
         }
 
-        private async void btnSearch_Click(object sender, EventArgs e)
+        private void btnSearch_Click(object sender, EventArgs e)
         {
             if (txtTimeCho.SelectedText == "自定义")
             {
@@ -117,21 +115,25 @@ namespace DW5S.App.UserControl
                     return;
                 }
             }
-            list = await searchPos();
-            this.gridCg.DataSource = list;
-            gridView1.BestFitColumns();
-            GC.Collect();
+            ctrlPage1.RefreshData();
+
+
         }
-        private async Task<List<RefCgResViewModel>> searchPos()
+        private async Task<PageData> LoadPageData(PageQueryDto arg)
         {
+            int? satId = ((SatViewModel)txtSat.EditValue)?.Id;
+            var unitOfWork = IocContainer.UnitOfWork;
+            var repsCg = unitOfWork.OfLong<RefCgRes>();
+            var queryable = repsCg.AsQueryable();
             try
             {
-                bool hasSat = txtSat.EditValue != null;
 
-                var unitOfWork = IocContainer.UnitOfWork;
-                var repsCg = unitOfWork.OfLong<RefCgRes>();
                 DateTime start = DateTime.MinValue;
                 DateTime end = DateTime.MinValue;
+                if (satId!=null)
+                {
+                    queryable = queryable.Where(p => p.SatInfoId == satId);
+                }
                 if (txtTimeCho.Text == "自定义")
                 {
                     start = txtStartTime.DateTime;
@@ -139,35 +141,40 @@ namespace DW5S.App.UserControl
                 }
                 else
                 {
-                    var queryableRefCg = repsCg.AsQueryable();
-                    if (hasSat)
-                        queryableRefCg = queryableRefCg.Where(p => p.SatInfoId == ((SatInfo)txtSat.EditValue).Id);
-
-                    var max = queryableRefCg.MaxBy(p => p.SigTime);
-                    if (max == null) return new List<RefCgResViewModel>();
-                    end = max.SigTime;
-                    start = end.AddHours(-(int)txtTimeCho.EditValue);
+                    
+                    var max = queryable.OrderByDescending(p => p.SigTime).FirstOrDefault();
+                    if (max != null)
+                    {
+                        end = max.SigTime;
+                        start = end.AddHours(-(int)txtTimeCho.EditValue);
+                    }
+                }
+               
+                if (start != DateTime.MinValue)
+                {
+                    queryable = queryable.Where(w => w.SigTime >= start);
                 }
-                if (end == DateTime.MinValue)
+                if (end != DateTime.MinValue)
                 {
-                    return new List<RefCgResViewModel>();//没有数据不查询
+                    queryable = queryable.Where(w => w.SigTime <= end);
                 }
-                var queryable = repsCg.AsQueryable();
-                if (hasSat)
-                    queryable = queryable.Where(p => p.SatInfoId == ((SatInfo)txtSat.EditValue).Id);
-                queryable = queryable.Where(w => w.SigTime >= start && w.SigTime <= end)
+                queryable = queryable
                       .Include(w => w.SatInfo)
                       .Include(w => w.RefTxInfo)
-                      .OrderByDescending(o => o.SigTime);
-                var cgRes = await queryable.ToListAsync();
-                return cgRes.To<List<RefCgResViewModel>>();
+                      .OrderByDescending(o => o.SigTime)
+                      .ThenBy(p => p.SatInfo.SatCode);
             }
             catch (Exception ex)
             {
                 IocContainer.Logger.Error(ex, "参考参估结果查询异常");
                 MsgBoxHelper.ShowError("参考参估结果查询异常");
             }
-            return new List<RefCgResViewModel>();
+            var pageData = await repsCg.GetPageData(arg, queryable);
+            list.Clear();
+            list.AddRange(pageData.Data.To<List<RefCgResViewModel>>());
+            gridView1.RefreshData();
+            gridView1.BestFitColumns();
+            return pageData;
         }
 
         private void btnDraw_Click(object sender, EventArgs e)

+ 5 - 12
DW5S.App/UserControl/CtrlXl.cs

@@ -1,22 +1,15 @@
 using DevExpress.XtraEditors;
-using DevExpress.XtraScheduler;
+using DW5S.App.CorTools;
+using DW5S.DTO;
+using DW5S.Entity;
+using DW5S.Repostory;
+using DW5S.ViewModel;
 using DxHelper;
 using ExtensionsDev;
 using System;
 using System.Collections.Generic;
-
-using System.Diagnostics;
 using System.Linq;
 using System.Threading.Tasks;
-using System.Windows.Forms;
-using DW5S.App.CorTools;
-using DW5S.DTO;
-using DW5S.Entity;
-using DW5S.Repostory;
-using Serilog;
-using static DevExpress.Xpo.Helpers.AssociatedCollectionCriteriaHelper;
-using DW5S.Service;
-using DW5S.ViewModel;
 using XdCxRhDW5S.ViewModel;
 
 namespace DW5S.App.UserControl

+ 0 - 2
DW5S.ViewModel/RefCgResViewModel.cs

@@ -47,7 +47,6 @@ namespace DW5S.ViewModel
         public int SatInfoId { get; set; }
 
         [Display(AutoGenerateField = false)]
-        [JsonIgnore]
         public virtual SatInfo SatInfo { get; set; }
 
 
@@ -62,7 +61,6 @@ namespace DW5S.ViewModel
 
 
         [Display(AutoGenerateField = false)]
-        [JsonIgnore]
         public virtual TxInfo RefTxInfo { get; set; }
         /// <summary>
         /// 参考站名称