Quellcode durchsuchen

1.功率和缺口的导入功能关联道岔台账 2.功率和缺口算法接入数据库

wrinkle17 vor 2 Monaten
Ursprung
Commit
f5d057ca12

+ 3 - 36
DPTools/DevFrmMain.Designer.cs

@@ -729,7 +729,6 @@
             this.gridColumn74 = new DevExpress.XtraGrid.Columns.GridColumn();
             this.repositoryItemCheckEdit4 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
             this.panelControl5 = new DevExpress.XtraEditors.PanelControl();
-            this.DWGLcheckEdit = new DevExpress.XtraEditors.CheckEdit();
             this.DWGLdelBtn = new DevExpress.XtraEditors.SimpleButton();
             this.DWGLimportfileBtn = new DevExpress.XtraEditors.SimpleButton();
             this.DWGLanalysisBtn = new DevExpress.XtraEditors.SimpleButton();
@@ -749,7 +748,6 @@
             this.gridColumn75 = new DevExpress.XtraGrid.Columns.GridColumn();
             this.repositoryItemCheckEdit5 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit();
             this.panelControl6 = new DevExpress.XtraEditors.PanelControl();
-            this.DWQKcheckEdit = new DevExpress.XtraEditors.CheckEdit();
             this.DWQKdelBtn = new DevExpress.XtraEditors.SimpleButton();
             this.DWQKimportfileBtn = new DevExpress.XtraEditors.SimpleButton();
             this.DWQKanalysisBtn = new DevExpress.XtraEditors.SimpleButton();
@@ -824,14 +822,12 @@
             ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckEdit4)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.panelControl5)).BeginInit();
             this.panelControl5.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.DWGLcheckEdit.Properties)).BeginInit();
             this.xtraTabPageQK.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.gridControl5)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.gridView5)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckEdit5)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.panelControl6)).BeginInit();
             this.panelControl6.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.DWQKcheckEdit.Properties)).BeginInit();
             this.SuspendLayout();
             // 
             // xrDesignRibbonController1
@@ -5432,7 +5428,6 @@
             // 
             // panelControl5
             // 
-            this.panelControl5.Controls.Add(this.DWGLcheckEdit);
             this.panelControl5.Controls.Add(this.DWGLdelBtn);
             this.panelControl5.Controls.Add(this.DWGLimportfileBtn);
             this.panelControl5.Controls.Add(this.DWGLanalysisBtn);
@@ -5442,18 +5437,6 @@
             this.panelControl5.Size = new System.Drawing.Size(1325, 48);
             this.panelControl5.TabIndex = 12;
             // 
-            // DWGLcheckEdit
-            // 
-            this.DWGLcheckEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.DWGLcheckEdit.Location = new System.Drawing.Point(1084, 16);
-            this.DWGLcheckEdit.Margin = new System.Windows.Forms.Padding(2);
-            this.DWGLcheckEdit.MenuManager = this.xrDesignRibbonController1;
-            this.DWGLcheckEdit.Name = "DWGLcheckEdit";
-            this.DWGLcheckEdit.Properties.Caption = "浏览文件夹";
-            this.DWGLcheckEdit.Size = new System.Drawing.Size(97, 19);
-            this.DWGLcheckEdit.TabIndex = 17;
-            this.DWGLcheckEdit.Visible = false;
-            // 
             // DWGLdelBtn
             // 
             this.DWGLdelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -5467,7 +5450,7 @@
             // DWGLimportfileBtn
             // 
             this.DWGLimportfileBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.DWGLimportfileBtn.Location = new System.Drawing.Point(993, 15);
+            this.DWGLimportfileBtn.Location = new System.Drawing.Point(1132, 15);
             this.DWGLimportfileBtn.Name = "DWGLimportfileBtn";
             this.DWGLimportfileBtn.Size = new System.Drawing.Size(75, 23);
             this.DWGLimportfileBtn.TabIndex = 0;
@@ -5647,7 +5630,6 @@
             // 
             // panelControl6
             // 
-            this.panelControl6.Controls.Add(this.DWQKcheckEdit);
             this.panelControl6.Controls.Add(this.DWQKdelBtn);
             this.panelControl6.Controls.Add(this.DWQKimportfileBtn);
             this.panelControl6.Controls.Add(this.DWQKanalysisBtn);
@@ -5657,18 +5639,6 @@
             this.panelControl6.Size = new System.Drawing.Size(1325, 48);
             this.panelControl6.TabIndex = 17;
             // 
-            // DWQKcheckEdit
-            // 
-            this.DWQKcheckEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.DWQKcheckEdit.Location = new System.Drawing.Point(1084, 16);
-            this.DWQKcheckEdit.Margin = new System.Windows.Forms.Padding(2);
-            this.DWQKcheckEdit.MenuManager = this.xrDesignRibbonController1;
-            this.DWQKcheckEdit.Name = "DWQKcheckEdit";
-            this.DWQKcheckEdit.Properties.Caption = "浏览文件夹";
-            this.DWQKcheckEdit.Size = new System.Drawing.Size(99, 19);
-            this.DWQKcheckEdit.TabIndex = 18;
-            this.DWQKcheckEdit.Visible = false;
-            // 
             // DWQKdelBtn
             // 
             this.DWQKdelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -5682,7 +5652,7 @@
             // DWQKimportfileBtn
             // 
             this.DWQKimportfileBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.DWQKimportfileBtn.Location = new System.Drawing.Point(993, 15);
+            this.DWQKimportfileBtn.Location = new System.Drawing.Point(1132, 15);
             this.DWQKimportfileBtn.Name = "DWQKimportfileBtn";
             this.DWQKimportfileBtn.Size = new System.Drawing.Size(75, 23);
             this.DWQKimportfileBtn.TabIndex = 0;
@@ -5697,6 +5667,7 @@
             this.DWQKanalysisBtn.TabIndex = 5;
             this.DWQKanalysisBtn.Text = "分析算法";
             this.DWQKanalysisBtn.ToolTip = "未定义";
+            this.DWQKanalysisBtn.Click += new System.EventHandler(this.DWQKanalysisBtn_Click);
             // 
             // xtraTabPageDWZS
             // 
@@ -5790,14 +5761,12 @@
             ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckEdit4)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.panelControl5)).EndInit();
             this.panelControl5.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.DWGLcheckEdit.Properties)).EndInit();
             this.xtraTabPageQK.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.gridControl5)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.gridView5)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckEdit5)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.panelControl6)).EndInit();
             this.panelControl6.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.DWQKcheckEdit.Properties)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -6175,8 +6144,6 @@
         private DevExpress.XtraEditors.SimpleButton deleteQKdata;
         private DevExpress.XtraEditors.SimpleButton importGLData;
         private DevExpress.XtraEditors.SimpleButton simpleButton1;
-        private DevExpress.XtraEditors.CheckEdit DWGLcheckEdit;
-        private DevExpress.XtraEditors.CheckEdit DWQKcheckEdit;
         private DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroup12;
         private DevExpress.XtraGrid.GridControl gridControl4;
         private DevExpress.XtraGrid.Views.Grid.GridView gridView4;

+ 11 - 7
DPTools/DevFrmMain.cs

@@ -757,26 +757,24 @@ namespace Uninpho.Tools
             //判断tab页是否已经创建,如果已创建直接显示
             tabtools.addTabmenu(xtraTabControl1, strDXtabname);
         }
-        //导入文件
+
+        //导入功率文件
         private void DWGLopenfileBtn_Click(object sender, EventArgs e)
         {
             List<int> indexid = new List<int>();
             List<string> indexzt = new List<string>();
             DWCommon.getSFZT(gridView4, ref indexid, ref indexzt);
 
-            ImportGLdatamanageForm frm = new ImportGLdatamanageForm(DWGLcheckEdit.Checked, gridView4,"gl");
+            ImportGLdatamanageForm frm = new ImportGLdatamanageForm(gridView4, "gl");
             frm.StartPosition = FormStartPosition.CenterParent;
             if (frm.ShowDialog(this) == DialogResult.OK)
             {
-
             }
-            //DWCommon.OpenFile("txt", DWGLcheckEdit.Checked, gridView4);
 
             List<T_dwfile_account> gl_dataList = DataAnalysisToPG.getDwfile("txt", indexid, indexzt) as List<T_dwfile_account>;
             this.gridControl4.DataSource = gl_dataList;
             DWCommon.repushSFZT(gridView4, indexid);
 
-          
         }
         //功率数据管理删除行
         private void DWGLdelBtn_Click(object sender, EventArgs e)
@@ -829,14 +827,15 @@ namespace Uninpho.Tools
             //判断tab页是否已经创建,如果已创建直接显示
             tabtools.addTabmenu(xtraTabControl1, strDXtabname);
         }
-        //导入文件
+
+        //导入缺口文件
         private void DWQKopenfileBtn_Click(object sender, EventArgs e)
         {
             List<int> indexid = new List<int>();
             List<string> indexzt = new List<string>();
             DWQKCommon.getSFZT(gridView5, ref indexid, ref indexzt);
 
-            ImportGLdatamanageForm frm = new ImportGLdatamanageForm(DWQKcheckEdit.Checked, gridView5,"qk");
+            ImportGLdatamanageForm frm = new ImportGLdatamanageForm(gridView5,"qk");
             frm.StartPosition = FormStartPosition.CenterParent;
             if (frm.ShowDialog(this) == DialogResult.OK)
             {
@@ -1049,5 +1048,10 @@ namespace Uninpho.Tools
         {
             new DataAnalysisClass("功率", gridView4.GetSelectedRows(), ref gridControl4, ref gridView4);
         }
+
+        private void DWQKanalysisBtn_Click(object sender, EventArgs e)
+        {
+            new DataAnalysisClass("缺口", gridView5.GetSelectedRows(), ref gridControl5, ref gridView5);
+        }
     }
 }

+ 4 - 4
DPTools/DevFrmMain.resx

@@ -1766,7 +1766,7 @@
 </value>
   </data>
   <metadata name="ribbonMiniToolbar1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>149, 55</value>
+    <value>281, 55</value>
   </metadata>
   <metadata name="xrDesignDockManager1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>888, 17</value>
@@ -2111,10 +2111,10 @@
     <value>1214, 17</value>
   </metadata>
   <metadata name="popupMenu2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>1377, 17</value>
+    <value>17, 55</value>
   </metadata>
   <metadata name="popupMenu3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 55</value>
+    <value>149, 55</value>
   </metadata>
   <data name="barButtonItem15.Glyph" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
@@ -2158,6 +2158,6 @@
 </value>
   </data>
   <metadata name="pageSetupDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>319, 55</value>
+    <value>451, 55</value>
   </metadata>
 </root>

+ 6 - 4
DPTools/Uninpho.Railway.Tools.csproj

@@ -234,9 +234,11 @@
     <Reference Include="Package_turnout_identify_wrf">
       <HintPath>libs\matlabSuanFa\Package_turnout_identify_wrf.dll</HintPath>
     </Reference>
-    <Reference Include="Sub_module_power_analysis, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>bin\Debug\Sub_module_power_analysis.dll</HintPath>
+    <Reference Include="sub_module_power_analysis">
+      <HintPath>libs\matlabSuanFa\sub_module_power_analysis.dll</HintPath>
+    </Reference>
+    <Reference Include="sub_module_quekou_analysis">
+      <HintPath>libs\matlabSuanFa\sub_module_quekou_analysis.dll</HintPath>
     </Reference>
     <Reference Include="System">
       <Private>True</Private>
@@ -277,7 +279,6 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="components\DataAnalysis\DWAnalysisAlgorithmcs.cs" />
     <Compile Include="components\DataAnalysis\DWQKCommon.cs" />
     <Compile Include="components\DataAnalysis\DWCommon.cs" />
     <Compile Include="components\DataAnalysis\DataAnalysisClass.cs" />
@@ -650,6 +651,7 @@
     </EmbeddedResource>
     <EmbeddedResource Include="DevFrmMain.resx">
       <DependentUpon>DevFrmMain.cs</DependentUpon>
+      <SubType>Designer</SubType>
     </EmbeddedResource>
     <EmbeddedResource Include="FrmMain.resx">
       <DependentUpon>FrmMain.cs</DependentUpon>

+ 2 - 1
DPTools/components/DWForm/ImportGLdatamanageForm.Designer.cs

@@ -104,6 +104,7 @@
             // 
             // xianlumingText
             // 
+            this.xianlumingText.EditValue = "";
             this.xianlumingText.Location = new System.Drawing.Point(143, 57);
             this.xianlumingText.Name = "xianlumingText";
             this.xianlumingText.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
@@ -156,7 +157,7 @@
         private DevExpress.XtraEditors.LabelControl labelControl7;
         private System.Windows.Forms.TextBox txtindir;
         private DevExpress.XtraEditors.LabelControl labelControl1;
-        private DevExpress.XtraEditors.ComboBoxEdit xianlumingText;
         private DevExpress.XtraEditors.ComboBoxEdit zhanmingText;
+        public DevExpress.XtraEditors.ComboBoxEdit xianlumingText;
     }
 }

+ 46 - 26
DPTools/components/DWForm/ImportGLdatamanageForm.cs

@@ -21,42 +21,52 @@ namespace Uninpho.Tools.components.DWForm
 {
     public partial class ImportGLdatamanageForm : DevExpress.XtraEditors.XtraForm
     {
-        bool ch;
+     
         GridView grid;
         string lx;
-        public ImportGLdatamanageForm(bool ischecked, GridView GV,string type)
+        public ImportGLdatamanageForm(GridView GV,string type)
         {
             InitializeComponent();
-             ch = ischecked;
+          
              grid = GV;
-            lx = type;
-
-
+            lx = type;           
         }
       
        /// 浏览文件目录
         private void simpleButton2_Click(object sender, EventArgs e)
         {
-            if(lx=="gl")
+            if (xianlumingText.Text==""||zhanmingText.Text=="")
             {
-            DWCommon.OpenFile("txt", ch, grid);
-            txtindir.Text = DWCommon.lj;
+                XtraMessageBox.Show("请选择线路和车站", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
             }
-            else if(lx=="qk")
+            else
             {
-                DWQKCommon.OpenFile("txt", ch, grid);
-                txtindir.Text = DWQKCommon.lj;
+                if (lx == "gl")
+                {
+                    DWCommon.OpenFile("txt", grid, xianlumingText.Text, zhanmingText.Text);
+                    txtindir.Text = DWCommon.lj;
+                }
+                else if (lx == "qk")
+                {
+                    DWQKCommon.OpenFile("txt", grid, xianlumingText.Text, zhanmingText.Text);
+                    txtindir.Text = DWQKCommon.lj;
+                }
             }
-
-
-            //txtindir.Text = DWGLCommon.lj;
-
+           
 
         }
 
         /// 导入数据
         private void newCreateBtnSon_Click(object sender, EventArgs e)
         {
+            if (lx == "gl")
+            {
+                DWCommon.AddFile();
+            }
+            else if (lx == "qk")
+            {
+                DWQKCommon.AddFile();
+            }
             this.Close();
         }
 
@@ -64,12 +74,19 @@ namespace Uninpho.Tools.components.DWForm
         ///取消
         private void NewcancelBtn_Click(object sender, EventArgs e)
         {
-            this.Close();//记得改,现在取不取消都是导入成功
+            if (lx == "gl")
+            {
+                DWCommon.CancelAddFile();
+            }
+            else if (lx == "qk")
+            {
+                DWQKCommon.CancelAddFile();
+            }
+          
+            this.Close();
         }
 
         ///关联数据库
-        /// 电务/缺口
-        List<T_dwfile_account> dwglData = new List<T_dwfile_account>();
       
         private void xianlumingText_SelectedIndexChanged(object sender, EventArgs e)
         {
@@ -77,14 +94,17 @@ namespace Uninpho.Tools.components.DWForm
         }
 
         ///初始界面加载
+        /// 
+        List<T_daocha_account> daochaData = new List<T_daocha_account>();
+
         private void ImportGLdatamanageForm_Load(object sender, EventArgs e)
         {
-            dwglData = DBOperation.Operation.DataAnalysisToPG.QueryDWGLALL();
+            daochaData = DBOperation.Operation.DataAnalysisToPG.QueryDCTZALL();
             //整理线路名集合
-            var listtgXLMALL = dwglData.GroupBy(c => c.Xianlu).Select(c => c.First()).ToList();
+            var listtgXLMALL = daochaData.GroupBy(c => c.Xlm).Select(c => c.First()).ToList();
             foreach (var item in listtgXLMALL)
             {
-                xianlumingText.Properties.Items.Add(item.Xianlu);
+                xianlumingText.Properties.Items.Add(item.Xlm);
             }
         }
 
@@ -92,17 +112,17 @@ namespace Uninpho.Tools.components.DWForm
         private void xianlumingText_EditValueChanged(object sender, EventArgs e)
         {
             zhanmingText.Properties.Items.Clear();
-            var isInputTrueXLM = dwglData.FindAll(delegate (T_dwfile_account dwgl)
+            var isInputTrueXLM = daochaData.FindAll(delegate (T_daocha_account dc)
             {
-                return dwgl.Xianlu == xianlumingText.Text;
+                return dc.Xlm == xianlumingText.Text;
             });
             //线路名
             if (isInputTrueXLM.Count != 0)
             {
-                var listtg = isInputTrueXLM.GroupBy(c => c.Chezhan).Select(c => c.First()).ToList();
+                var listtg = isInputTrueXLM.GroupBy(c => c.Czm).Select(c => c.First()).ToList();
                 foreach (var item in listtg)
                 {
-                    zhanmingText.Properties.Items.Add(item.Chezhan);
+                    zhanmingText.Properties.Items.Add(item.Czm);
                 }
                 zhanmingText.Enabled = true;
             }

+ 16 - 2
DPTools/components/DataAnalysis/AnalysisAlgorithmcs.cs

@@ -12,6 +12,7 @@ using MathWorks.MATLAB.NET.Arrays;
 using JHWX = Package_geo_change_analysis_for_turnout;//微小算法
 using System.Windows.Forms;
 using GL = sub_module_power_analysis;//功率算法
+using QK = sub_module_quekou_analysis;//缺口算法
 
 namespace Uninpho.Tools.components.DataAnalysis
 {
@@ -183,8 +184,21 @@ namespace Uninpho.Tools.components.DataAnalysis
             MWArray[] agrsIn = new MWArray[] { fname_dir0, fname0};
             MWArray[] agrsOut = new MWArray[10];
 
-            glfx.sub_power_analysis_main(1, ref agrsOut, agrsIn);//只输出一个cell表
-            //Console.WriteLine("算法输出:" + agrsOut[0]);
+            glfx.sub_power_analysis_main(2, ref agrsOut, agrsIn);//输出两个cell表
+            //Console.WriteLine("算法输出:" + agrsOut[1]);
+            return agrsOut;
+        }
+
+        /// 缺口算法
+        public static MWArray[] QKFX(string fname_dir0, string fname0, string xianlu, string chezhan, string filename)
+        {
+            QK.Class1 qkfx = new QK.Class1();
+
+            MWArray[] agrsIn = new MWArray[] { fname_dir0, fname0 };
+            MWArray[] agrsOut = new MWArray[7];
+
+            qkfx.sub_quekou_data_analysis(2, ref agrsOut, agrsIn);//输出两个cell表
+            //Console.WriteLine("算法输出:" + agrsOut[1]);
             return agrsOut;
         }
     }

+ 0 - 18
DPTools/components/DataAnalysis/DWAnalysisAlgorithmcs.cs

@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.InteropServices;
-
-namespace Uninpho.Tools.components.DataAnalysis
-{
-    class DWAnalysisAlgorithmcs
-    {
-        [DllImport("sub_module_power_analysis.dll")]
-        public static extern void EC_ClosePort(uint hdl_port);
-
-
-
-    }
-}

+ 26 - 272
DPTools/components/DataAnalysis/DWCommon.cs

@@ -17,63 +17,16 @@ namespace Uninpho.Tools.components.DataAnalysis
   
     class DWCommon
     {
-        /// <summary>
-        /// 高速还是低速
-        /// 0:高速  1:低速  2:全选
-        /// </summary>
-        public static int gdsBool = 0;
-        /// <summary>
-        /// 是否进行里程修正
-        /// </summary>
-        public static bool xzlcBool = true;
-        /// <summary>
-        /// 检测车
-        /// </summary>
-        public static List<string> jccList = new List<string>();
+        
         public static string lj;
+
+        public static List<T_dwfile_account> filelist = new List<T_dwfile_account>();
         /// <summary>
         /// 打开文件夹公共函数
         /// </summary>
-        public static void OpenFile(string houzhui,bool ischecked,GridView GV)
+        public static void OpenFile(string houzhui,GridView GV,string xianluming,string chezhan)
         {
-            List<T_dwfile_account> filelist = new List<T_dwfile_account>();
-            //批量
-            //if (ischecked)
-            //{
-
-            //    var dialog = new FolderBrowserDialog();
-            //    if (dialog.ShowDialog() == DialogResult.OK)
-            //    {
-            //        DirectoryInfo DirInfo = new DirectoryInfo(dialog.SelectedPath);
-            //        houzhui = "." + houzhui;
-            //        var files = from f in DirInfo.EnumerateFiles()
-            //                    where houzhui.Contains(f.Extension.ToLower())
-            //                    select f;
-
-            //        // Show results.
-            //        foreach (var f in files)
-            //        {
-            //            T_dwfile_account tfa= GLFileNameSplit1(f.FullName);
-
-            //            var isfile = DataAnalysisToPG.DWQueryToPGByNameFile(tfa.Filename) as List<T_dwfile_account>;
-            //            if (isfile.Count == 0)
-            //            {
-            //                filelist.Add(tfa);
-            //            }
-            //            else
-            //            {
-            //                if (XtraMessageBox.Show("检测到数据库内存在同名数据:\n" + tfa.Filename+",\n是否覆盖数据库内数据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
-            //                {
-            //                    filejiancedel(tfa);
-            //                    filelist.Add(tfa);
-            //                }
-            //            }
-            //        }
-            //        DataAnalysisToPG.GLInsertToPG(filelist);
-            //    }
-            //}
-            //else
-            //{
+              
             var dialog = new OpenFileDialog();
                 dialog.Multiselect = true;
                 dialog.Title = "请选择文件夹";
@@ -84,11 +37,11 @@ namespace Uninpho.Tools.components.DataAnalysis
 
                     for (int i = 0; i < file.Length; i++)
                     {
-                        T_dwfile_account tfa = GLFileNameSplit1(file[i]);
+                        T_dwfile_account tfa = GLFileNameSplit1(file[i], xianluming, chezhan);
                        //获取数据后
                         var isfile = DataAnalysisToPG.DWQueryToPGByNameFile(tfa.Filename) as List<T_dwfile_account>;
                          lj = file[i]; //传路径
-                        if (isfile.Count == 0)
+                        if (isfile.Count == 0 )
                         {
                             filelist.Add(tfa);
                         }
@@ -102,29 +55,35 @@ namespace Uninpho.Tools.components.DataAnalysis
                         }
 
                     }
-                    DataAnalysisToPG.GLInsertToPG(filelist);
+                    
                 }
-            //}
+        }
 
+        public static void AddFile()
+        {
+            DataAnalysisToPG.GLInsertToPG(filelist);
+            filelist.Clear();
+        }
 
+        public static void CancelAddFile()
+        {
+            filelist.Clear();
         }
-    
+
 
         /// 清理数据库同名数据
         private static void filejiancedel(T_dwfile_account file)
         {
           
             //清除算法表
-            //List<T_dwfile_account> whichupdata = (List<T_dwfile_account>)DataAnalysisToPG.DWQueryToPGByNameFile(file.Filename);
-            //DataAnalysisToPG.DelToPGLGLBX(whichupdata);
-            //DataAnalysisToPG.DelToDWGL(file);
-
+            List<T_dwfile_account> whichupdata = (List<T_dwfile_account>)DataAnalysisToPG.DWQueryToPGByNameFile(file.Filename);         
+            DataAnalysisToPG.DelToDWGL(file);
             DataAnalysisToPG.DelToDW(file);//清除功率表
              
         }
 
         /// 解析电务功率数据
-        private static T_dwfile_account GLFileNameSplit1(string filename)
+        private static T_dwfile_account GLFileNameSplit1(string filename, string xianluming, string chezhan)
         {
             string ysname = Path.GetFileName(filename);
             string wjdx = Math.Round((new FileInfo(filename).Length / 1024.0 / 1024.0),2) + " MB";//文件大小
@@ -146,7 +105,8 @@ namespace Uninpho.Tools.components.DataAnalysis
                       
                         string quxianxuhao = parts[2];//曲线序号
                         string caijikaishishijian = parts[3];//采集开始时间
-                        string caijihaoqianshijian = parts[4];//采集毫秒时间                        string fangxiabiaoji = parts[5];//点数
+                        string caijihaoqianshijian = parts[4];//采集毫秒时间                        
+                        string fangxiabiaoji = parts[5];//点数
                         string dianshu = parts[6]; //点数
                         string gonglv = parts[7];//功率
                         string fangcha = parts[8];//方差
@@ -173,8 +133,8 @@ namespace Uninpho.Tools.components.DataAnalysis
             return new T_dwfile_account()
             {
               //下次把车站线路写活
-                Xianlu = "襄渝线",
-                Chezhan = "三汇坝",
+                Xianlu = xianluming,
+                Chezhan = chezhan,
                 Starttime = minStartTime,
                 Endtime = maxStartTime,
                 Filename = ysname,
@@ -186,213 +146,7 @@ namespace Uninpho.Tools.components.DataAnalysis
             };
         }
        
-        /// <summary>
-        /// 解析方向
-        /// </summary>
-        private static string getZF(string ZF)
-        {
-            string zf = ZF.Split('_')[0];
-            if (zf == "0")
-            {
-                return "反向";
-            }
-            else
-            {
-                return "正向";
-            }
-        }
-        /// <summary>
-        /// 解析时间
-        /// </summary>
-        private static string getYMDHMS(string ymd,string hms)
-        {
-            //如果这里以后修改,轮轨力输入检测日期那块也要改!!!
-            Char[] ymdcha = ymd.ToCharArray();//年月日
-            Char[] hmscha = hms.ToCharArray();//时分秒
-            string year = ymdcha[4].ToString() + ymdcha[5].ToString() + ymdcha[6].ToString() + ymdcha[7].ToString();
-            string mouth = ymdcha[2].ToString() + ymdcha[3].ToString();
-            string day = ymdcha[0].ToString() + ymdcha[1].ToString();
-            string hour = hmscha[0].ToString() + hmscha[1].ToString();
-            string minite = hmscha[2].ToString() + hmscha[3].ToString();
-            string second = hmscha[4].ToString() + hmscha[5].ToString();
-            return year+ "年"  +mouth + "月" + day + "日" + hour + "时" + minite + "分" + second + "秒";
-        }
-        private static string getYMDHMS(string ymd)
-        {
-            //如果这里以后修改,轮轨力输入检测日期那块也要改!!!
-            Char[] ymdcha = ymd.ToCharArray();//年月日
-            string year = ymdcha[0].ToString() + ymdcha[3].ToString();
-            string mouth = ymdcha[6].ToString() + ymdcha[7].ToString();
-            string day = ymdcha[4].ToString() + ymdcha[5].ToString();
-            return year + "年" + mouth + "月" + day + "日";
-        }
-        /// <summary>
-        /// 解析行别和线路编号
-        /// </summary>
-        private static string[] HBXLSplit(string arr0)
-        {
-            Char[] cha = arr0.ToCharArray();
-            string hb = "", xl = "";
-            for (int i = 0; i < cha.Length; i++)
-            {
-                if (i != cha.Length-1)
-                {
-                    xl += cha[i];
-                }
-                else
-                {
-                    if (cha[i] == 'X')
-                    {
-                        hb = "下";
-                    }
-                    else if (cha[i] == 'S')
-                    {
-                        hb = "上";
-
-                    }
-                    else
-                    {
-                        hb = "未知";
-                    }
-                }
-            }
-            return new string[] {xl,hb };
-        }
-        /// <summary>
-        /// 表前加序号
-        /// </summary>
-        /// <param name="e"></param>
-        public static void addXuHao(DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
-        {
-            if (e.Info.Kind == DevExpress.Utils.Drawing.IndicatorKind.Header)
-            {
-                e.Appearance.DrawBackground(e.Cache, e.Bounds);
-                e.Appearance.DrawString(e.Cache, "  序号", e.Bounds);
-              
-                e.Handled = true;
-            }
-            e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
-            if (e.Info.IsRowIndicator)
-            {
-                if (e.RowHandle >= 0)
-                {
-                    e.Info.DisplayText = (e.RowHandle + 1).ToString().Trim();
-                }
-                else if (e.RowHandle < 0 && e.RowHandle > -1000)
-                {
-                    e.Info.DisplayText = "G" + e.RowHandle.ToString();
-                }
-            }
-        }
-        
-        /// <summary>
-        /// 自动化初始化
-        /// </summary>
-        public static void initZDHFun(BarButtonItem barButtonItem)
-        {
-            initFile(zdhSetClass.path, zdhSetClass.initStr);
-            StreamReader sr = new StreamReader(zdhSetClass.path);
-            while (!sr.EndOfStream)
-            {
-                string[] str = sr.ReadLine().Split('灬');
-                if (str[0] == "Interval")
-                {
-                    zdhSetClass.Interval = Convert.ToInt32(str[1]);
-                    continue;
-                }
-                else if (str[0] == "folder")
-                {
-                    if (Directory.Exists(str[1]))
-                    {
-                        zdhSetClass.folder = str[1];
-                    }
-                    continue;
-                }
-                else if (str[0] == "startdate")
-                {
-                    zdhSetClass.startdate = str[1];
-                    continue;
-                }
-                else if (str[0] == "taskName")
-                {
-                    zdhSetClass.taskName = str[1];
-                    continue;
-                }
-                else if (str[0] == "isStartZDH")
-                {
-                    zdhSetClass.isStartZDH = Convert.ToInt32(str[1]);
-                    continue;
-                }
-            }
-            DirectoryInitNoDelNoHidde(zdhSetClass.folder + "geoData");
-            DirectoryInitNoDelNoHidde(zdhSetClass.folder + "bnyData");
-
-            if (zdhSetClass.isStartZDH == 0)
-            {
-                barButtonItem.ImageUri.Uri = "Prev"; //Refresh // Prev
-                barButtonItem.Caption = "开启自动化";
-            }
-            else
-            {
-                barButtonItem.ImageUri.Uri = "Refresh"; //Refresh // Prev
-                barButtonItem.Caption = "重启自动化";
-            }
-        }
-        /// <summary>
-        /// 创建文件
-        /// </summary>
-        public static void initFile(string path,string data)
-        {
-            if (!File.Exists(path))
-            {
-                File.WriteAllText(path, data);
-            }
-        }
-        /// <summary>
-        /// 复制文件
-        /// </summary>
-        /// <param name="filename">原始文件路径</param>
-        /// <param name="newfilename">目的地文件路径</param>
-        public static void FileCopy(string filename,string newfilename)
-        {
-            if (File.Exists(filename))
-            {
-                if (File.Exists(newfilename))
-                {
-                    File.Delete(newfilename);
-                }
-                File.Copy(filename, newfilename);
-            }
-        }
-        /// <summary>
-        /// 按文件夹删除(删除临时文件夹)
-        /// </summary>
-        /// <param name="DirectoryPath">文件夹路径</param>
-        public static void DirectoryInit(string DirectoryPath)
-        {
-            if (Directory.Exists(DirectoryPath))
-            {
-                Directory.Delete(DirectoryPath, true); //删除文件夹及内容
-            }
-            DirectoryInfo di = Directory.CreateDirectory(DirectoryPath);
-            di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
-        }
-        public static void DirectoryInitNoDel(string DirectoryPath)
-        {
-            if (!Directory.Exists(DirectoryPath))
-            {
-                DirectoryInfo di = Directory.CreateDirectory(DirectoryPath);
-                di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
-            }
-        }
-        public static void DirectoryInitNoDelNoHidde(string DirectoryPath)
-        {
-            if (!Directory.Exists(DirectoryPath))
-            {
-                DirectoryInfo di = Directory.CreateDirectory(DirectoryPath);
-                di.Attributes = FileAttributes.Directory;
-            }
-        }
+      
         /// <summary>
         /// 刷新后恢复选中
         /// </summary>

+ 22 - 228
DPTools/components/DataAnalysis/DWQKCommon.cs

@@ -17,26 +17,15 @@ namespace Uninpho.Tools.components.DataAnalysis
   
     class DWQKCommon
     {
-        /// <summary>
-        /// 高速还是低速
-        /// 0:高速  1:低速  2:全选
-        /// </summary>
-        public static int gdsBool = 0;
-        /// <summary>
-        /// 是否进行里程修正
-        /// </summary>
-        public static bool xzlcBool = true;
-        /// <summary>
-        /// 检测车
-        /// </summary>
-        public static List<string> jccList = new List<string>();
+     
         public static string lj;
+        public static List<T_dwqkfile_account> filelist = new List<T_dwqkfile_account>();
         /// <summary>
         /// 打开文件夹公共函数
         /// </summary>
-        public static void OpenFile(string houzhui,bool ischecked,GridView GV)
+        public static void OpenFile(string houzhui,GridView GV,string xianluming, string chezhan)
         {
-            List<T_dwqkfile_account> filelist = new List<T_dwqkfile_account>();
+           
            
             var dialog = new OpenFileDialog();
                 dialog.Multiselect = true;
@@ -48,7 +37,7 @@ namespace Uninpho.Tools.components.DataAnalysis
 
                     for (int i = 0; i < file.Length; i++)
                     {
-                        T_dwqkfile_account tfa = GLFileNameSplit1(file[i]);
+                        T_dwqkfile_account tfa = GLFileNameSplit1(file[i], xianluming, chezhan);
                        //获取数据后
                         var isfile = DataAnalysisToPG.DWQKQueryToPGByNameFile(tfa.Filename) as List<T_dwqkfile_account>;
                          lj = file[i]; //传路径
@@ -66,13 +55,24 @@ namespace Uninpho.Tools.components.DataAnalysis
                         }
 
                     }
-                    DataAnalysisToPG.QKInsertToPG(filelist);
+                   
                 }
            
 
 
         }
-    
+
+        public static void AddFile()
+        {
+            DataAnalysisToPG.QKInsertToPG(filelist);
+            filelist.Clear();
+        }
+
+        public static void CancelAddFile()
+        {
+            filelist.Clear();
+        }
+
 
         /// 清理数据库同名数据
         private static void filejiancedel(T_dwqkfile_account file)
@@ -84,7 +84,7 @@ namespace Uninpho.Tools.components.DataAnalysis
         }
 
         /// 解析电务功率数据
-        private static T_dwqkfile_account GLFileNameSplit1(string filename)
+        private static T_dwqkfile_account GLFileNameSplit1(string filename,string xianluming, string chezhan)
         {
             string ysname = Path.GetFileName(filename);
             string wjdx = Math.Round((new FileInfo(filename).Length / 1024.0 / 1024.0),2) + " MB";//文件大小
@@ -127,8 +127,8 @@ namespace Uninpho.Tools.components.DataAnalysis
             return new T_dwqkfile_account()
             {
               //下次把车站线路写活
-                Xianlu = "襄渝线",
-                Chezhan = "三汇坝",
+                Xianlu = xianluming,
+                Chezhan = chezhan,
                 Starttime = minStartTime,
                 Endtime = maxStartTime,
                 Filename = ysname,
@@ -140,213 +140,7 @@ namespace Uninpho.Tools.components.DataAnalysis
             };
         }
        
-        /// <summary>
-        /// 解析方向
-        /// </summary>
-        private static string getZF(string ZF)
-        {
-            string zf = ZF.Split('_')[0];
-            if (zf == "0")
-            {
-                return "反向";
-            }
-            else
-            {
-                return "正向";
-            }
-        }
-        /// <summary>
-        /// 解析时间
-        /// </summary>
-        private static string getYMDHMS(string ymd,string hms)
-        {
-            //如果这里以后修改,轮轨力输入检测日期那块也要改!!!
-            Char[] ymdcha = ymd.ToCharArray();//年月日
-            Char[] hmscha = hms.ToCharArray();//时分秒
-            string year = ymdcha[4].ToString() + ymdcha[5].ToString() + ymdcha[6].ToString() + ymdcha[7].ToString();
-            string mouth = ymdcha[2].ToString() + ymdcha[3].ToString();
-            string day = ymdcha[0].ToString() + ymdcha[1].ToString();
-            string hour = hmscha[0].ToString() + hmscha[1].ToString();
-            string minite = hmscha[2].ToString() + hmscha[3].ToString();
-            string second = hmscha[4].ToString() + hmscha[5].ToString();
-            return year+ "年"  +mouth + "月" + day + "日" + hour + "时" + minite + "分" + second + "秒";
-        }
-        private static string getYMDHMS(string ymd)
-        {
-            //如果这里以后修改,轮轨力输入检测日期那块也要改!!!
-            Char[] ymdcha = ymd.ToCharArray();//年月日
-            string year = ymdcha[0].ToString() + ymdcha[3].ToString();
-            string mouth = ymdcha[6].ToString() + ymdcha[7].ToString();
-            string day = ymdcha[4].ToString() + ymdcha[5].ToString();
-            return year + "年" + mouth + "月" + day + "日";
-        }
-        /// <summary>
-        /// 解析行别和线路编号
-        /// </summary>
-        private static string[] HBXLSplit(string arr0)
-        {
-            Char[] cha = arr0.ToCharArray();
-            string hb = "", xl = "";
-            for (int i = 0; i < cha.Length; i++)
-            {
-                if (i != cha.Length-1)
-                {
-                    xl += cha[i];
-                }
-                else
-                {
-                    if (cha[i] == 'X')
-                    {
-                        hb = "下";
-                    }
-                    else if (cha[i] == 'S')
-                    {
-                        hb = "上";
-
-                    }
-                    else
-                    {
-                        hb = "未知";
-                    }
-                }
-            }
-            return new string[] {xl,hb };
-        }
-        /// <summary>
-        /// 表前加序号
-        /// </summary>
-        /// <param name="e"></param>
-        public static void addXuHao(DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
-        {
-            if (e.Info.Kind == DevExpress.Utils.Drawing.IndicatorKind.Header)
-            {
-                e.Appearance.DrawBackground(e.Cache, e.Bounds);
-                e.Appearance.DrawString(e.Cache, "  序号", e.Bounds);
-              
-                e.Handled = true;
-            }
-            e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
-            if (e.Info.IsRowIndicator)
-            {
-                if (e.RowHandle >= 0)
-                {
-                    e.Info.DisplayText = (e.RowHandle + 1).ToString().Trim();
-                }
-                else if (e.RowHandle < 0 && e.RowHandle > -1000)
-                {
-                    e.Info.DisplayText = "G" + e.RowHandle.ToString();
-                }
-            }
-        }
-        
-        /// <summary>
-        /// 自动化初始化
-        /// </summary>
-        public static void initZDHFun(BarButtonItem barButtonItem)
-        {
-            initFile(zdhSetClass.path, zdhSetClass.initStr);
-            StreamReader sr = new StreamReader(zdhSetClass.path);
-            while (!sr.EndOfStream)
-            {
-                string[] str = sr.ReadLine().Split('灬');
-                if (str[0] == "Interval")
-                {
-                    zdhSetClass.Interval = Convert.ToInt32(str[1]);
-                    continue;
-                }
-                else if (str[0] == "folder")
-                {
-                    if (Directory.Exists(str[1]))
-                    {
-                        zdhSetClass.folder = str[1];
-                    }
-                    continue;
-                }
-                else if (str[0] == "startdate")
-                {
-                    zdhSetClass.startdate = str[1];
-                    continue;
-                }
-                else if (str[0] == "taskName")
-                {
-                    zdhSetClass.taskName = str[1];
-                    continue;
-                }
-                else if (str[0] == "isStartZDH")
-                {
-                    zdhSetClass.isStartZDH = Convert.ToInt32(str[1]);
-                    continue;
-                }
-            }
-            DirectoryInitNoDelNoHidde(zdhSetClass.folder + "geoData");
-            DirectoryInitNoDelNoHidde(zdhSetClass.folder + "bnyData");
-
-            if (zdhSetClass.isStartZDH == 0)
-            {
-                barButtonItem.ImageUri.Uri = "Prev"; //Refresh // Prev
-                barButtonItem.Caption = "开启自动化";
-            }
-            else
-            {
-                barButtonItem.ImageUri.Uri = "Refresh"; //Refresh // Prev
-                barButtonItem.Caption = "重启自动化";
-            }
-        }
-        /// <summary>
-        /// 创建文件
-        /// </summary>
-        public static void initFile(string path,string data)
-        {
-            if (!File.Exists(path))
-            {
-                File.WriteAllText(path, data);
-            }
-        }
-        /// <summary>
-        /// 复制文件
-        /// </summary>
-        /// <param name="filename">原始文件路径</param>
-        /// <param name="newfilename">目的地文件路径</param>
-        public static void FileCopy(string filename,string newfilename)
-        {
-            if (File.Exists(filename))
-            {
-                if (File.Exists(newfilename))
-                {
-                    File.Delete(newfilename);
-                }
-                File.Copy(filename, newfilename);
-            }
-        }
-        /// <summary>
-        /// 按文件夹删除(删除临时文件夹)
-        /// </summary>
-        /// <param name="DirectoryPath">文件夹路径</param>
-        public static void DirectoryInit(string DirectoryPath)
-        {
-            if (Directory.Exists(DirectoryPath))
-            {
-                Directory.Delete(DirectoryPath, true); //删除文件夹及内容
-            }
-            DirectoryInfo di = Directory.CreateDirectory(DirectoryPath);
-            di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
-        }
-        public static void DirectoryInitNoDel(string DirectoryPath)
-        {
-            if (!Directory.Exists(DirectoryPath))
-            {
-                DirectoryInfo di = Directory.CreateDirectory(DirectoryPath);
-                di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
-            }
-        }
-        public static void DirectoryInitNoDelNoHidde(string DirectoryPath)
-        {
-            if (!Directory.Exists(DirectoryPath))
-            {
-                DirectoryInfo di = Directory.CreateDirectory(DirectoryPath);
-                di.Attributes = FileAttributes.Directory;
-            }
-        }
+     
         /// <summary>
         /// 刷新后恢复选中
         /// </summary>

+ 203 - 30
DPTools/components/DataAnalysis/DataAnalysisClass.cs

@@ -55,7 +55,7 @@ namespace Uninpho.Tools.components.DataAnalysis
             if (iszhengc)
             {
                 bool boo = true;
-                if (type != "微小" && type != "功率")
+                if (type != "微小" && type != "功率" && type != "缺口")
                 {
                     SuanFaFrom frm = new SuanFaFrom();
                     frm.StartPosition = FormStartPosition.CenterParent;
@@ -84,7 +84,7 @@ namespace Uninpho.Tools.components.DataAnalysis
             }
             else
             {
-                if (type == "功率")
+                if (type == "功率"|| type == "缺口")
                 {
                     for (int i = 0; i < selectrow.Length; i++)
                     {
@@ -110,8 +110,15 @@ namespace Uninpho.Tools.components.DataAnalysis
                                         b = false;
                                     }
                                 }
-
-                                DataAnalysisToPG.DelUpdataDataDWGL(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type);                    
+                                if(type == "功率")
+                            {
+                                DataAnalysisToPG.DelUpdataDataDWGL(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type);
+                            }
+                            else
+                            {
+                                DataAnalysisToPG.DelUpdataDataDWQK(GV.GetRowCellValue(selectrow[i], "Id").ToString(), type);
+                            }
+                                               
                         }                       
                     }
                 }
@@ -271,8 +278,40 @@ namespace Uninpho.Tools.components.DataAnalysis
                 }
 
             }
-                //提示
-                if (boo)
+
+            else if (type == "缺口")
+            {
+                for (int i = 0; i < selectrow.Length; i++)
+                {
+                    boo = true;
+                    GV.SetRowCellValue(selectrow[i], "Taskstatus", "正在执行" + type + "算法...");
+                    T_dwqkfile_account whichfile = (T_dwqkfile_account)DataAnalysisToPG.QueryToPGByIdQK(Convert.ToInt32(GV.GetRowCellValue(selectrow[i], "Id").ToString().Trim()));
+                    try
+                    {
+                        await Task.Run(() =>
+                        {
+                           QK_new(whichfile);
+                        });
+                    }
+                    catch (Exception ex)
+                    {
+                        boo = false;
+                        throw;
+                    }
+                    if (boo)
+                    {
+                        GV.SetRowCellValue(selectrow[i], "Taskstatus", type + "算法执行完毕");
+                    }
+                    else
+                    {
+                        GV.SetRowCellValue(selectrow[i], "Taskstatus", "算法执行失败");
+                    }
+
+                }
+
+            }
+            //提示
+            if (boo)
             {
                 XtraMessageBox.Show(type + "算法执行完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
@@ -838,13 +877,11 @@ namespace Uninpho.Tools.components.DataAnalysis
 
         /// 功率算法
         public void GL_new(T_dwfile_account whichfile)
-        {
-            //List<T_daocha_account> daochabiao = (List<T_daocha_account>)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray());
-            //List<T_quxian_account> quxianbiao = (List<T_quxian_account>)DataAnalysisToPG.QueryQXTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray());
+        {         
             string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\";
             string fname0 = Path.GetFileName(whichfile.Srlj);
-            Console.Write(fname_dir0);
-            Console.Write(fname0);
+            //Console.Write(fname_dir0);
+            //Console.Write(fname0);
 
             string xianlu = whichfile.Xianlu;
             string chezhan = whichfile.Chezhan;
@@ -853,8 +890,7 @@ namespace Uninpho.Tools.components.DataAnalysis
             try
             {
                 var data = AnalysisAlgorithmcs.GLFX(fname_dir0, fname0, xianlu, chezhan, filename);
-                readGLFX(data, whichfile);
-                //readGLFX_TEST(data, whichfile);
+                readGLFX(data, whichfile);              
             }
             catch (Exception ex)
             {
@@ -868,38 +904,64 @@ namespace Uninpho.Tools.components.DataAnalysis
         {
             try
             {
-                MWCellArray output1 = agrsOut[0] as MWCellArray;
+                MWCellArray output1 = agrsOut[0] as MWCellArray;//数据
+                MWCellArray output2 = agrsOut[1] as MWCellArray;//时间
                 var table_data = output1.ToArray();
-
-                //// 打印原始数据结构
-                //Console.WriteLine("数据类型: " + table_data.GetType());
-                //Console.WriteLine("数据维度: " + (table_data as Array).Rank);
-
+                var table_date = (object[,])output2.ToArray();
+                
                 List<T_glanalysis_account> GLobjs = new List<T_glanalysis_account>();
 
                 // 假设是二维数组,从第2行开始
-                for (int i = 2; i < (table_data as Array).GetLength(0); i++)
+                for (int i = 1; i < (table_data as Array).GetLength(0); i++)
                 {
                     T_glanalysis_account gldata = new T_glanalysis_account();
 
-                    // 安全地获取每列数据
-                    gldata.Curvenumber = SafeExtractInt(table_data, i, 2);
-                    gldata.Time = SafeExtractDecimal(table_data, i, 3);
-                    gldata.Directionalmarker = SafeExtractInt(table_data, i, 4);
-                    gldata.Curvetype = SafeExtractInt(table_data, i, 5);
-                    gldata.Totalwork = SafeExtractDecimal(table_data, i, 6);
-                    gldata.Changerate = SafeExtractDecimal(table_data, i, 7);
-                    gldata.Offsetvalue = SafeExtractDecimal(table_data, i, 8);
-                    gldata.Powervariance = SafeExtractDecimal(table_data, i, 9);
-
                     gldata.Filename = whichfile.Filename;
                     gldata.Xianlu = whichfile.Xianlu;
                     gldata.Chezhan = whichfile.Chezhan;
 
+                    // 安全地获取每列数据
+                    gldata.Curvenumber = SafeExtractInt(table_data, i, 2);                  
+                    gldata.Directionalmarker = SafeExtractInt(table_data, i, 3);
+                    gldata.Curvetype = SafeExtractInt(table_data, i, 4);
+                    gldata.Totalwork = SafeExtractDecimal(table_data, i, 5);
+                    gldata.Changerate = SafeExtractDecimal(table_data, i, 6);
+                    gldata.Offsetvalue = SafeExtractDecimal(table_data, i, 7);
+                    gldata.Powervariance = SafeExtractDecimal(table_data, i, 8);
+
+                    // 解析时间
+                    try
+                    {
+                        // 检查时间是否为空
+                        if (table_date[i, 0] is char[,])
+                        {
+                            string timeString = Char2String((char[,])table_date[i, 0]);
+                            if (!string.IsNullOrEmpty(timeString))
+                            {
+                                DateTime parsedTime = DateTime.Parse(timeString); // 解析为 DateTime
+                                gldata.Time = parsedTime.ToString("yyyy-MM-dd HH:mm:ss"); // 格式化为字符串
+                            }
+                            else
+                            {
+                                gldata.Time = null; // 或者设置为默认值
+                            }
+                        }
+                        else
+                        {
+                            gldata.Time = null; // 或者设置为默认值
+                        }
+                    }
+                    catch (FormatException ex)
+                    {
+                        Console.WriteLine($"时间解析失败: {ex.Message}");
+                        gldata.Time = null; // 或者设置为默认值
+                    }
+
                     GLobjs.Add(gldata);
                 }
 
                 //Console.WriteLine("解析完成,共 " + GLobjs.Count + " 条记录");
+              
                 DataAnalysisToPG.updataTaskstatus(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" });
                 DataAnalysisToPG.InsertGLFXDataToPG(GLobjs);
               
@@ -973,6 +1035,117 @@ namespace Uninpho.Tools.components.DataAnalysis
             }
         }
 
+        ///
+        /// 缺口算法
+        public void QK_new(T_dwqkfile_account whichfile)
+        {
+            string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\";
+            string fname0 = Path.GetFileName(whichfile.Srlj);
+            //Console.Write(fname_dir0);
+            //Console.Write(fname0);
+
+            string xianlu = whichfile.Xianlu;
+            string chezhan = whichfile.Chezhan;
+            string filename = whichfile.Filename;
+
+            try
+            {
+                var data = AnalysisAlgorithmcs.QKFX(fname_dir0, fname0, xianlu, chezhan, filename);
+                readQKFX(data, whichfile);
+            }
+            catch (Exception ex)
+            {
+                XtraMessageBox.Show("文件:" + whichfile.Filename + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
+                throw;
+            }
+        }
+
+        /// 读缺口分析数据     
+        private void readQKFX(MWArray[] agrsOut, T_dwqkfile_account whichfile)
+        {
+            try
+            {
+                MWCellArray output1 = agrsOut[0] as MWCellArray;//数据
+                MWCellArray output2 = agrsOut[1] as MWCellArray;//时间
+                var table_data = output1.ToArray();
+                var table_date = (object[,])output2.ToArray();
+
+                List<T_qkanalysis_account> QKobjs = new List<T_qkanalysis_account>();
+
+                // 假设是二维数组,从第2行开始
+                for (int i = 1; i < (table_data as Array).GetLength(0); i++)
+                {
+                    T_qkanalysis_account qkdata = new T_qkanalysis_account();
+
+                    qkdata.Filename = whichfile.Filename;
+                    qkdata.Xianlu = whichfile.Xianlu;
+                    qkdata.Chezhan = whichfile.Chezhan;
+
+                    // 安全地获取每列数据
+                    qkdata.Gapnumber = SafeExtractInt(table_data, i, 0);
+                    qkdata.Gaptype = SafeExtractInt(table_data, i, 1);
+
+                    qkdata.Movechange = SafeExtractDecimal(table_data, i, 3);
+                    qkdata.Change = SafeExtractDecimal(table_data, i, 4);
+                    qkdata.Passchange = SafeExtractDecimal(table_data, i, 5);
+
+                    // 解析时间
+                    try
+                    {
+                        if (table_date[i, 0] is char[,])
+                        {
+                            string timeString = Char2String((char[,])table_date[i, 0]);
+                            if (!string.IsNullOrEmpty(timeString))
+                            {
+                                DateTime parsedTime;
+                                // 尝试解析两种格式
+                                if (DateTime.TryParseExact(timeString, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedTime))
+                                {
+                                    qkdata.Time = parsedTime.ToString("yyyy-MM-dd HH:mm:ss"); // 格式化为字符串
+                                }
+                                else if (DateTime.TryParseExact(timeString, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedTime))
+                                {
+                                    qkdata.Time = parsedTime.ToString("yyyy-MM-dd HH:mm:ss"); // 格式化为字符串
+                                }
+                                else
+                                {
+                                    qkdata.Time = null; // 或者设置为默认值
+                                }
+                            }
+                            else
+                            {
+                                qkdata.Time = null; // 或者设置为默认值
+                            }
+                        }
+                        else
+                        {
+                            qkdata.Time = null; // 或者设置为默认值
+                        }
+                    }
+                    catch (FormatException ex)
+                    {
+                        Console.WriteLine($"时间解析失败: {ex.Message}");
+                        qkdata.Time = null; // 或者设置为默认值
+                    }
+
+                    QKobjs.Add(qkdata);
+                }
+
+                //Console.WriteLine("解析完成,共 " + GLobjs.Count + " 条记录");
+
+                DataAnalysisToPG.updataTaskstatusQK(new string[] { whichfile.Id.ToString(), type + "算法执行完毕" });
+                DataAnalysisToPG.InsertQKFXDataToPG(QKobjs);
+
+            }
+            catch (Exception ex)
+            {
+                //Console.WriteLine("解析出错: " + ex.Message);
+                // Console.WriteLine("堆栈跟踪: " + ex.StackTrace);
+            }
+        }
+        
+        ///
+
         /// <summary>
         /// 
         /// </summary>

BIN
DPTools/libs/matlabSuanFa/sub_module_power_analysis.dll


BIN
DPTools/libs/matlabSuanFa/sub_module_quekou_analysis.dll


+ 1 - 1
Uninpho.DBOperation/Model/T_glanalysis_account.cs

@@ -9,7 +9,7 @@ namespace Uninpho.DBOperation.Model
         public int Id { get; set; }
         public string Xianlu { get; set; }
         public string Chezhan { get; set; }
-        public decimal Time { get; set; }
+        public string Time { get; set; }
         public string Filename { get; set; }
         public int Curvetype { get; set; }
         public decimal Totalwork { get; set; }

+ 21 - 0
Uninpho.DBOperation/Model/T_qkanalysis_account.cs

@@ -0,0 +1,21 @@
+using SqlSugar;
+using System;
+
+namespace Uninpho.DBOperation.Model
+{
+      public class T_qkanalysis_account
+    {
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public int Id { get; set; }
+        public string Xianlu { get; set; }
+        public string Chezhan { get; set; }
+        public string Time { get; set; }
+        public string Filename { get; set; }
+        public int Gaptype { get; set; }
+        public decimal Movechange { get; set; }
+        public decimal Change { get; set; }
+        public decimal Passchange { get; set; }
+        public int Gapnumber { get; set; }
+      
+    }
+}

+ 50 - 7
Uninpho.DBOperation/Operation/DataAnalysisToPG.cs

@@ -117,6 +117,7 @@ namespace Uninpho.DBOperation.Operation
         /// <summary>
         /// 更新任务状态
         /// </summary>
+        /// 功率
         public static void updataTaskstatus(string[] Yswjm)
         {
             NpgsqlConnection conn = new NpgsqlConnection();
@@ -128,7 +129,21 @@ namespace Uninpho.DBOperation.Operation
             comm.ExecuteNonQuery();
             conn.Close();
         }
-
+        /// <summary>
+        /// 缺口
+        /// </summary>
+        /// <param name="Yswjm"></param>
+        public static void updataTaskstatusQK(string[] Yswjm)
+        {
+            NpgsqlConnection conn = new NpgsqlConnection();
+            conn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["dbConnection"] as string;
+            NpgsqlCommand comm = new NpgsqlCommand();
+            comm.Connection = conn;
+            conn.Open();
+            comm.CommandText = "UPDATE \"t_dwqkfile_account\" SET taskstatus = '" + Yswjm[1] + "' WHERE id =" + Yswjm[0];
+            comm.ExecuteNonQuery();
+            conn.Close();
+        }
         public static void updataRWZT(string[] Yswjm)
         {
             NpgsqlConnection conn = new NpgsqlConnection();
@@ -291,12 +306,18 @@ namespace Uninpho.DBOperation.Operation
                 db.Insertable(updateObjs).ExecuteCommand();
         }
         /// <summary>
-        /// 道岔功率分析表添加新数据
+        /// 道岔 功率 分析表添加新数据
         /// </summary>
         public static void InsertGLFXDataToPG(List<T_glanalysis_account> updateObjs)
         {
             db.Insertable(updateObjs).ExecuteCommand();
         }
+        /// 道岔 缺口 分析表添加新数据
+        /// </summary>
+        public static void InsertQKFXDataToPG(List<T_qkanalysis_account> updateObjs)
+        {
+            db.Insertable(updateObjs).ExecuteCommand();
+        }
         /// <summary>
         /// 轮轨力表添加新数据
         /// </summary>
@@ -416,13 +437,20 @@ namespace Uninpho.DBOperation.Operation
         public static void DelUpdataDataDWGL(string yswjm, string type)
         {
             T_dwfile_account file = db.SqlQueryable<T_dwfile_account>("select * from \"t_dwfile_account\" where id = " + yswjm).ToList()[0];
-           if (type == "功率")
-            {
+          
                 List<T_glanalysis_account> whichupdata = (List<T_glanalysis_account>)QueryToPGByNameGL(yswjm);
                 DelToPGGL(file);
-            }
+            
         }
 
+        public static void DelUpdataDataDWQK(string yswjm, string type)
+        {
+            T_dwqkfile_account file = db.SqlQueryable<T_dwqkfile_account>("select * from \"t_dwqkfile_account\" where id = " + yswjm).ToList()[0];
+           
+                List<T_qkanalysis_account> whichupdata = (List<T_qkanalysis_account>)QueryToPGByNameQK(yswjm);
+                DelToPGQK(file);
+            
+        }
 
 
         /// <summary>
@@ -497,6 +525,10 @@ namespace Uninpho.DBOperation.Operation
         {
             db.Deleteable<T_glanalysis_account>().Where(it => it.Filename == updateObjs.Id.ToString()).ExecuteCommand();
         }
+        public static void DelToPGQK(T_dwqkfile_account updateObjs)
+        {
+            db.Deleteable<T_qkanalysis_account>().Where(it => it.Filename == updateObjs.Id.ToString()).ExecuteCommand();
+        }
         /// <summary>
         /// 删除几何波形表数据
         /// </summary>
@@ -540,11 +572,11 @@ namespace Uninpho.DBOperation.Operation
             }
             conn.Close();
         }
-        /// 删除电务功率 算法结果数据 //还未创建对应库
+        /// 删除电务功率 算法结果数据 
         /// </summary>
         public static void DelToDWGL(T_dwfile_account updateObjs)
         {
-            //db.Deleteable<T_lunguili_account>().Where(it => it.Filename_lgl == updateObjs.Id.ToString()).ExecuteCommand();
+            db.Deleteable<T_glanalysis_account>().Where(it => it.Filename == updateObjs.Filename).ExecuteCommand();
         }
         /// <summary>
         /// 删除查询ID暂时添加的波形条数
@@ -600,6 +632,11 @@ namespace Uninpho.DBOperation.Operation
         {
             return db.Queryable<T_dwfile_account>().Where(it => it.Id == id_).Single();
         }
+        ///按id查询QK
+        public static Object QueryToPGByIdQK(int id_)
+        {
+            return db.Queryable<T_dwqkfile_account>().Where(it => it.Id == id_).Single();
+        }
         /// <summary>
         /// 按文件名查询文件
         /// </summary>
@@ -672,6 +709,12 @@ namespace Uninpho.DBOperation.Operation
         {
             return db.Queryable<T_glanalysis_account>().Where(it => it.Filename == yswjm).ToList();
         }
+        /// 算法按文件名查询QK
+        /// </summary>
+        public static Object QueryToPGByNameQK(string yswjm)
+        {
+            return db.Queryable<T_qkanalysis_account>().Where(it => it.Filename == yswjm).ToList();
+        }
 
         /// <summary>
         /// 查询几何提取算法线路里程值

+ 1 - 0
Uninpho.DBOperation/Uninpho.DBOperation.csproj

@@ -78,6 +78,7 @@
     <Compile Include="Model\Assist_quxian.cs" />
     <Compile Include="Model\Assist_xxxwcsvdata.cs" />
     <Compile Include="Model\T_daocha_account.cs" />
+    <Compile Include="Model\T_qkanalysis_account.cs" />
     <Compile Include="Model\T_glanalysis_account.cs" />
     <Compile Include="Model\T_dwqkfile_account.cs" />
     <Compile Include="Model\T_dwfile_account .cs" />