Prechádzať zdrojové kódy

颗粒列表优化改进3.0版--修改sql语句,颗粒元素及含量拼接改为内存处理,此版本大幅优化速度!

CXS 3 rokov pred
rodič
commit
b822c6f8dc

+ 22 - 6
OTSIncAReportApp/Control_Grids/ParticlesGridDevidePage.cs

@@ -191,9 +191,7 @@ namespace OTSIncAReportGrids
 
             ProgressStart();
 
-            //多次测试发现 读取数据库时间耗时长,但读取条数目对读取数据库时长影响不大,故此处直接读取所有数据库信息,以取代多次连接数据库方式,优化分页速度
-            particlesAll = new DataTable();
-            particlesAll = Particledata.GetInfoForPartucleDevidePage2(condition);
+            UpdateTable();
 
             cbB_PageSize.Items.Add("20");
             cbB_PageSize.Items.Add("100");
@@ -206,6 +204,25 @@ namespace OTSIncAReportGrids
         }
 
         #region 自定义方法
+        void UpdateTable()
+        {
+            //多次测试发现 读取数据库时间耗时长,但读取条数目对读取数据库时长影响不大,故此处直接读取所有数据库信息,以取代多次连接数据库方式,优化分页速度
+            particlesAll = new DataTable();
+            particlesAll = Particledata.GetInfoForPartucleDevidePage3(condition);
+            DataTable elementchemistry = Particledata.GetElementChemistry();
+
+            for (int i = 0; i < particlesAll.Rows.Count; i++)
+            {
+                string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
+                DataRow[] drs = elementchemistry.Select(str);
+                string ConcatenatedString = "";
+                for (int j = 0; j < drs.Length; j++)
+                {
+                    ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
+                }
+                particlesAll.Rows[i]["Element"] = ConcatenatedString;
+            }
+        }
 
         /// <summary>
         /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
@@ -400,7 +417,6 @@ namespace OTSIncAReportGrids
             keyValues.Add("ParticleImage", table["str5"].ToString());
             keyValues.Add("SEMPosX", "SEMPosX");
             keyValues.Add("SEMPosY", "SEMPosY");
-
             for (int i = 0; i < strs.Count(); i++)
             {
                 if (strs[i] == "Area")
@@ -1219,8 +1235,8 @@ namespace OTSIncAReportGrids
             {
                 ProgressStart();
             }
-            particlesAll = new DataTable();
-            particlesAll = Particledata.GetInfoForPartucleDevidePage2(condition);
+
+            UpdateTable();
 
             lnkFirst_Click(null, null);
             SetDataGridViewStyle();

+ 24 - 0
OTSIncAReportApp/DataOperation/DataAccess/ParticleData.cs

@@ -433,6 +433,30 @@ namespace OTSIncAReportApp.DataOperation.DataAccess
             return DT;
         }
 
+        public DataTable GetInfoForPartucleDevidePage3(string condition)
+        {
+            string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX as 'SEMPosX',FieldPosY as 'SEMPosY',ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,ElementNum,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,'' as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " + condition;
+            DataTable DT = new DataTable();
+            DT = dbHelper.ExecuteQuery(sqliteString);
+            return DT;
+        }
+
+        public DataTable GetInfoForPartucleDevidePage4(string condition)
+        {
+            string sqliteString = "select (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = INcAData.XRayId and fieldid = INcAData.fieldid  ) as Element from INcAData where xrayid > -1 " + condition;
+            DataTable DT = new DataTable();
+            DT = dbHelper.ExecuteQuery(sqliteString);
+            return DT;
+        }
+
+        public DataTable GetElementChemistry()
+        {
+            string sqliteString = "select * from ElementChemistry";
+            DataTable DT = new DataTable();
+            DT = dbHelper.ExecuteQuery(sqliteString);
+            return DT;
+        }
+
         public Bitmap GetBitmapForBig(string sub, double xs, string path)
         {
             string vs = "," + sub.Replace(':', '-') + ",";