Ver Fonte

优化报告导出代码,去除重复代码

zhangjiaxin há 11 meses atrás
pai
commit
69c783d4a0

+ 302 - 0
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/BasicData.cs

@@ -0,0 +1,302 @@
+using OTSCommon.Model;
+using OTSIncAReportApp.DataOperation.DataAccess;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static OTSIncAReportApp.OTSReport_Export;
+
+namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
+{
+    class BasicData
+    {
+        ParticleData fielddata;
+        private string SizeChart = "";
+        private DataTable BData = new DataTable();
+        private DataTable AllClass = new DataTable();
+        private DataTable AllElement = new DataTable();
+        private bool IsShereAClassificationGroup = false;
+        /// <summary>
+        /// 获取粒级表
+        /// </summary>
+        public void SetParticlesizeTable(OTSReport_Export m_otsreport_export)
+        {
+            //获取粒级表
+            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
+                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
+            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
+            SizeChart = ds.Tables[0].Rows[0]["Sizes"].ToString();
+        }
+        /// <summary>
+        /// 获取粒级表
+        /// </summary>
+        /// <returns></returns>
+        public string GetParticlesizeTable()
+        {
+            return SizeChart;
+        }
+
+        public void SetDBData(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
+        {
+            DataTable m_bt_DBData = new DataTable();
+            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
+            List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
+            //获取粒级表
+            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
+                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
+            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
+            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+            for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
+            {
+                if (sizestr.Split(',')[i].Length > 0)
+                {
+                    double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
+                    double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
+                    colid.Add(d1.ToString() + "~" + d2.ToString());
+                }
+            }
+            double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
+            colid.Add(d.ToString() + "~MAX");
+
+            for (int i = 0; i < colid.Count; i++)
+            {
+                m_bt_DBData.Columns.Add(colid[i].ToString());
+            }
+
+            DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
+            DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
+            DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
+
+            string po = ComputeMode;
+            switch (po)
+            {
+                case "DMAX":
+                    po = "DMAX";
+                    break;
+                case "DMIN":
+                    po = "DMIN";
+                    break;
+                case "ECD":
+                    po = "Area";
+                    break;
+                case "FERET":
+                    po = "DFERET";
+                    break;
+            }
+
+
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                DataRow dr = m_bt_DBData.NewRow();
+                dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
+                dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
+                dr["con"] = dt.Rows[i]["con"].ToString();
+
+                if (dt.Rows[i]["GroupName"].ToString() == "")
+                    dr["Class"] = "Default";
+                else
+                    dr["Class"] = dt.Rows[i]["GroupName"].ToString();
+                //continue;
+                dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
+                for (int a = 6; a < colid.Count; a++)
+                {
+                    string d1 = colid[a].Split('~')[0];
+                    string d2 = colid[a].Split('~')[1];
+                    if (d2 == "MAX")
+                    {
+                        d2 = "999";
+                    }
+                    DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
+                    dr[colid[a]] = datas.Count();
+                }
+                for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
+                {
+                    if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
+                    {
+                        dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
+                    }
+                }
+                m_bt_DBData.Rows.Add(dr);
+            }
+
+
+
+            //去除物质分类(非夹杂物分类)
+            for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
+            {
+                for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
+                {
+                    if (m_bt_DBData.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
+                    {
+                        m_bt_DBData.Rows.RemoveAt(i);
+                    }
+                }
+            }
+
+            if (m_mbszclass.list_str_MainPriority.Count == 0)
+            {
+                BData = m_bt_DBData.Copy();
+                return;
+            }
+
+            DataTable datass = m_bt_DBData.Clone();
+
+            for (int i = 0; i < m_mbszclass.list_str_MainPriority.Count; i++)
+            {
+                bool bl = false;
+                for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
+                {
+                    if (m_bt_DBData.Rows[a]["TypeName"].ToString() == m_mbszclass.list_str_MainPriority[i])
+                    {
+                        datass.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
+                        bl = true;
+                        continue;
+                    }
+                }
+                if (!bl)
+                {
+                    DataTable dta = m_bt_DBData.Clone();
+                    if (m_bt_DBData.Rows.Count != 0)
+                    {
+                        dta.Rows.Add(m_bt_DBData.Rows[0].ItemArray);
+                        for (int b = 0; b < dta.Columns.Count; b++)
+                        {
+                            if (dta.Columns[b].ColumnName == "TypeName")
+                            {
+                                dta.Rows[0][b] = m_mbszclass.list_str_MainPriority[i];
+                            }
+                            else if (dta.Columns[b].ColumnName == "Class")
+                            {
+                                dta.Rows[0][b] = "Default";
+                            }
+                            else
+                            {
+                                dta.Rows[0][b] = 0;
+                            }
+                        }
+
+                        datass.Rows.Add(dta.Rows[0].ItemArray);
+                    }
+
+
+                }
+            }
+            BData = datass.Copy();
+            //return datass;
+        }
+        /// <summary>
+        /// 获取读取数据库并过滤颗粒
+        /// </summary>
+        /// <returns></returns>
+        public DataTable GetDBData()
+        {
+            return BData;
+        }
+
+        public void SetAllClass()
+        {
+            AllClass = fielddata.GetAllClass();
+        }
+        
+        /// <summary>
+        /// 获取全部大类
+        /// </summary>
+        /// <returns></returns>
+        public DataTable GetAllClass()
+        {
+            return AllClass;
+        }
+        /// <summary>
+        /// 定义ParticleData类
+        /// </summary>
+        public void newParticleData(OTSReport_Export m_otsreport_export)
+        {
+            fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
+        }
+        public ParticleData getParticleData()
+        {
+            return fielddata;
+        }
+        public void SetAllElement()
+        {
+            AllElement = fielddata.GetAllElement();
+        }
+        /// <summary>
+        /// 获取全部元素
+        /// </summary>
+        /// <returns></returns>
+        public DataTable GetAllElement()
+        {
+            return AllElement;
+        }
+        /// <summary>
+        /// 判断是否有大分类,有为true
+        /// </summary>
+        /// <param name="m_otsreport_export"></param>
+        /// <returns></returns>
+        public void IsThereAMajorClassification()
+        {
+            DataTable getClass_dt = fielddata.GetAllClass();
+            List<string> ClassName = new List<string>();
+            bool bl = false;
+            for (int i = 0; i < getClass_dt.Rows.Count; i++)
+            {
+                if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
+                && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
+                    if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
+                    {
+                        if (!bl)
+                        {
+                            ClassName.Add("Default");
+                            bl = true;
+                        }
+                    }
+                    else
+                    {
+                        if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
+                        {
+                            ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
+                        }
+                    }
+            }
+
+            if (ClassName.Count < 2)
+            {
+                IsShereAClassificationGroup= false;
+            }
+            else
+            {
+                IsShereAClassificationGroup= true;
+            }
+        }
+        public bool GetIsThereAMajorClassification()
+        {
+            return IsShereAClassificationGroup;
+        }
+        #region 内部函数
+        private string getWhere(string max, string min, string col, string partic)
+        {
+            return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
+        }
+        private DataTable InvalidRemoval(DataTable dt)
+        {
+            DataTable dataTable = dt.Copy();
+            dataTable.Clear();
+
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 10)
+                {
+                    dataTable.Rows.Add(dt.Rows[i].ItemArray);
+                }
+            }
+            return dataTable;
+        }
+        #endregion
+
+
+
+    }
+}

+ 5 - 283
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/ElementalAnalysis.cs

@@ -22,13 +22,10 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
         /// <param name="m_mbszclass"></param>
         /// <param name="m_otsreport_export"></param>
         /// <returns></returns>
-        public List<DataTable> GetElementData(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export,string ComputeMode)
+        public List<DataTable> GetElementData(BasicData basicData, OTSReport_Export m_otsreport_export)
         {
-            DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
-
+            DataTable data = basicData.GetDBData();
             //根据sql条件,查询获取颗粒信息数据
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
-
             DataTable AllAnalysisDetails = new DataTable();
             AllAnalysisDetails.TableName = "ElementValue";
             AllAnalysisDetails.Columns.Add("Name");
@@ -47,7 +44,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
 
             //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
             List<string> ClassName = new List<string>();
-            DataTable getClass_dt = fielddata.GetAllClass();
+            DataTable getClass_dt = basicData.GetAllClass();
             bool bl = false;
             for (int i = 0; i < getClass_dt.Rows.Count; i++)
             {
@@ -63,25 +60,20 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
                     }
                     else
                     {
-                        //if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
-                        //{
                             ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
-                        //}
                     }
             }
 
             //统计元素物质大类的元素信息和面积占比
-            DataTable dt_ElementalSubstance = ElementalSubstance(AllAnalysisDetails, ClassName, fielddata);
+            DataTable dt_ElementalSubstance = ElementalSubstance(AllAnalysisDetails, ClassName, basicData.getParticleData());
             //统计元素并按照Class Name自定义列表进行排序,大类中的小类元素信息按照面积从大到小排序
-            DataTable dt_ElementSorting = ElementSorting(AllAnalysisDetails, ClassName, fielddata);
+            DataTable dt_ElementSorting = ElementSorting(AllAnalysisDetails, ClassName, basicData.getParticleData());
             //生成最后导出时物质元素成分表
             DataTable dt = MaterialElementComposition(dt_ElementalSubstance, 13, m_otsreport_export);//导出14个元素成分信息
                                                                                                      //生成最后导出时物质元素细分表
             DataTable dtname = new DataTable();
             DataTable dtData = new DataTable();
             SubdivisionOfMaterialElements(dt_ElementSorting, 13, ClassName, dt, out dtname, out dtData);
-            //allElement_dt = dt_ElementSorting.Copy();
-
             List<DataTable> datas = new List<DataTable>();
             datas.Add(dtname);
             datas.Add(dtData);
@@ -89,255 +81,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             return datas;
 
         }
-        private DataTable GetDBData(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export,string ComputeMode)
-        {
-
-            DataTable m_bt_DBData = new DataTable();
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
-            List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
-            //获取粒级表
-            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
-                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
-            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
-            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
-            for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
-            {
-                if (sizestr.Split(',')[i].Length > 0)
-                {
-                    double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
-                    double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
-                    colid.Add(d1.ToString() + "~" + d2.ToString());
-                }
-            }
-            double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
-            colid.Add(d.ToString() + "~MAX");
-
-            for (int i = 0; i < colid.Count; i++)
-            {
-                m_bt_DBData.Columns.Add(colid[i].ToString());
-            }
-
-            DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
-            DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
-            DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
-           
-            string po = ComputeMode;
-          
-
-
-            for (int i = 0; i < dt.Rows.Count; i++)
-                {
-                    DataRow dr = m_bt_DBData.NewRow();
-                    dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
-                    dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
-                    dr["con"] = dt.Rows[i]["con"].ToString();
-
-                    if (dt.Rows[i]["GroupName"].ToString() == "")
-                        dr["Class"] = "Default";
-                    else
-                        dr["Class"] = dt.Rows[i]["GroupName"].ToString();
-                    //continue;
-                    dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
-                    for (int a = 6; a < colid.Count; a++)
-                    {
-                        string d1 = colid[a].Split('~')[0];
-                        string d2 = colid[a].Split('~')[1];
-                        if (d2 == "MAX")
-                        {
-                            d2 = "999";
-                        }
-                        DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
-                        dr[colid[a]] = datas.Count();
-                    }
-                    for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
-                    {
-                        if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
-                        {
-                            dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
-                        }
-                    }
-                    m_bt_DBData.Rows.Add(dr);
-                }
-           
-           
-
-
-            //去除物质分类(非夹杂物分类)
-            for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
-            {
-                for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
-                {
-                    if (m_bt_DBData.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
-                    {
-                        m_bt_DBData.Rows.RemoveAt(i);
-                    }
-                }
-            }
-            if (m_mbszclass.list_str_MainPriority.Count==0)
-            {
-                return m_bt_DBData;
-            }
-            DataTable datass = m_bt_DBData.Clone();
-
-            for (int i = 0; i < m_mbszclass.list_str_MainPriority.Count; i++)
-            {
-                bool bl = false;
-                for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
-                {
-                    if (m_bt_DBData.Rows[a]["TypeName"].ToString() == m_mbszclass.list_str_MainPriority[i])
-                    {
-                        datass.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
-                        bl = true;
-                        continue;
-                    }
-                }
-                if (!bl)
-                {
-                    DataTable dta = m_bt_DBData.Clone();
-                    if (m_bt_DBData.Rows.Count!=0)
-                    {
-                        dta.Rows.Add(m_bt_DBData.Rows[0].ItemArray);
-                        for (int b = 0; b < dta.Columns.Count; b++)
-                        {
-                            if (dta.Columns[b].ColumnName == "TypeName")
-                            {
-                                dta.Rows[0][b] = m_mbszclass.list_str_MainPriority[i];
-                            }
-                            else if (dta.Columns[b].ColumnName == "Class")
-                            {
-                                dta.Rows[0][b] = "Default";
-                            }
-                            else
-                            {
-                                dta.Rows[0][b] = 0;
-                            }
-                        }
-
-                        datass.Rows.Add(dta.Rows[0].ItemArray);
-                    }
-                
-                }
-            }
-            return datass;
-        }
-        private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
-        {
-            DataTable dt_Partick = new DataTable();
-            dt_Partick.Columns.Add("TypeId");
-            dt_Partick.Columns.Add("TypeName");
-            dt_Partick.Columns.Add("TypeColor");
-            dt_Partick.Columns.Add("con");
-            dt_Partick.Columns.Add("ar");
-            dt_Partick.Columns.Add("max");
-            dt_Partick.Columns.Add("Area", typeof(double));
-            dt_Partick.Columns.Add("GroupName");
-            List<string> typeName = new List<string>();
-            for (int i = 0; i < data.Rows.Count; i++)
-            {
-                typeName.Add(data.Rows[i]["TypeId"].ToString());
-            }
-            typeName = typeName.Distinct().ToList();
-
-            for (int i = 0; i < typeName.Count; i++)
-            {
-                DataTable dt = dt_Partick.Clone();
-                for (int j = 0; j < data.Rows.Count; j++)
-                {
-                    if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
-                    {
-                        DataRow row = dt.NewRow();
-                        row["TypeId"] = data.Rows[j]["TypeId"];
-                        row["TypeName"] = data.Rows[j]["TypeName"];
-                        row["TypeColor"] = data.Rows[j]["TypeColor"];
-                        row["Area"] = data.Rows[j]["Area"];
-                        dt.Rows.Add(row);
-                    }
-                }
-                DataRow dr = dt_Partick.NewRow();
-                dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
-                dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
-                dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
-                dr["con"] = dt.Rows.Count;
-                dr["ar"] = dt.Compute("min(Area)", "");
-                dr["max"] = dt.Compute("Max(Area)", "");
-                dr["Area"] = dt.Compute("SUM(Area)", "");
-                dt_Partick.Rows.Add(dr);
-            }
-            for (int i = 0; i < dt_Partick.Rows.Count; i++)
-            {
-                for (int j = 0; j < table.Rows.Count; j++)
-                {
-                    if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
-                    {
-                        dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
-                        break;
-                    }
-                }
-            }
-            return dt_Partick;
-        }
-    
-        private DataTable InvalidRemoval(DataTable dt)
-        {
-            DataTable dataTable = dt.Copy();
-            dataTable.Clear();
-
-            for (int i = 0; i < dt.Rows.Count; i++)
-            {
-                if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 10)
-                {
-                    dataTable.Rows.Add(dt.Rows[i].ItemArray);
-                }
-            }
-            return dataTable;
-        }
-
-        private string getWhere(string max, string min, string col, string partic)
-        {
-            return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
-        }
-        /// <summary>
-        /// 判断是否有大分类,有为true
-        /// </summary>
-        /// <param name="m_otsreport_export"></param>
-        /// <returns></returns>
-        public bool IsThereAMajorClassification(OTSReport_Export m_otsreport_export)
-        {
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
-            DataTable getClass_dt = fielddata.GetAllClass();
-            List<string> ClassName = new List<string>();
-            bool bl = false;
-            for (int i = 0; i < getClass_dt.Rows.Count; i++)
-            {
-                if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
-                && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
-                    if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
-                    {
-                        if (!bl)
-                        {
-                            ClassName.Add("Default");
-                            bl = true;
-                        }
-                    }
-                    else
-                    {
-                        if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
-                        {
-                            ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
-                        }
-                    }
-            }
-
-            if (ClassName.Count < 2)
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-
         private bool SubdivisionOfMaterialElements(DataTable a_ElementalSubstance, int NumberOfColumns, List<string> ClassName, DataTable data, out DataTable dt1, out DataTable dt2)
         {
 
@@ -628,26 +371,5 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             return sum;
         }
-
-        /// <summary>
-        /// 参数归一化
-        /// </summary>
-        /// <param name="a_mi">总数</param>
-        /// <param name="m">传参</param>
-        /// <returns></returns>
-        public string ParameterNormalization(double a_mi, double m)
-        {
-            double ColVal = Convert.ToDouble(m / a_mi * 100);
-            if (ColVal == 0)
-            {
-                return "";
-            }
-            else
-            {
-
-                return Math.Round(ColVal, 2).ToString();
-            }
-
-        }
     }
 }

+ 7 - 106
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/InclusionProportion.cs

@@ -20,13 +20,12 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
         /// </summary>
         /// <param name="str"></param>
         /// <param name="dt"></param>
-        public DataTable GetINCAtable(string str,  OTSReport_Export m_otsreport_export, c_TemplateClass m_mbszclass)
+        public DataTable GetINCAtable(BasicData basicData, string str,  c_TemplateClass m_mbszclass)
         {
             //根据sql条件,查询获取颗粒信息数据
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
             //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
             List<string> ClassName = new List<string>();
-            DataTable getClass_dt = fielddata.GetAllClass();
+            DataTable getClass_dt = basicData.GetAllClass();
             bool bl = false;
             for (int i = 0; i < getClass_dt.Rows.Count; i++)
             {
@@ -49,7 +48,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
                     }
             }
             //夹杂物面积比添加大类
-            DataTable RawParticleData = InclusionAreaRatio_2(str, m_otsreport_export, m_mbszclass);
+            DataTable RawParticleData = InclusionAreaRatio_2(str, basicData, m_mbszclass);
             //夹杂物面积比计算大类占比
             ProportionOfParticleArea(RawParticleData, ClassName, str, out DataTable dt);
             return dt;
@@ -299,48 +298,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             return ConSolidateInvalid(dataTable);
         }
 
-        /// <summary>
-        /// 判断是否有大分类,有为true
-        /// </summary>
-        /// <param name="m_otsreport_export"></param>
-        /// <returns></returns>
-        public bool IsThereAMajorClassification(OTSReport_Export m_otsreport_export)
-        {
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
-            DataTable getClass_dt = fielddata.GetAllClass();
-            List<string> ClassName = new List<string>();
-            bool bl = false;
-            for (int i = 0; i < getClass_dt.Rows.Count; i++)
-            {
-                if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
-                && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
-                    if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
-                    {
-                        if (!bl)
-                        {
-                            ClassName.Add("Default");
-                            bl = true;
-                        }
-                    }
-                    else
-                    {
-                        if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
-                        {
-                            ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
-                        }
-                    }
-            }
-
-            if (ClassName.Count < 2)
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-
         private DataTable ConSolidateInvalid(DataTable dt)
         {
 
@@ -359,71 +316,15 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             return dt_no_invalid;
         }
-        private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
-        {
-            DataTable dt_Partick = new DataTable();
-            dt_Partick.Columns.Add("TypeId");
-            dt_Partick.Columns.Add("TypeName");
-            dt_Partick.Columns.Add("TypeColor");
-            dt_Partick.Columns.Add("con");
-            dt_Partick.Columns.Add("ar");
-            dt_Partick.Columns.Add("max");
-            dt_Partick.Columns.Add("Area", typeof(double));
-            dt_Partick.Columns.Add("GroupName");
-            List<string> typeName = new List<string>();
-            for (int i = 0; i < data.Rows.Count; i++)
-            {
-                typeName.Add(data.Rows[i]["TypeId"].ToString());
-            }
-            typeName = typeName.Distinct().ToList();
-
-            for (int i = 0; i < typeName.Count; i++)
-            {
-                DataTable dt = dt_Partick.Clone();
-                for (int j = 0; j < data.Rows.Count; j++)
-                {
-                    if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
-                    {
-                        DataRow row = dt.NewRow();
-                        row["TypeId"] = data.Rows[j]["TypeId"];
-                        row["TypeName"] = data.Rows[j]["TypeName"];
-                        row["TypeColor"] = data.Rows[j]["TypeColor"];
-                        row["Area"] = data.Rows[j]["Area"];
-                        dt.Rows.Add(row);
-                    }
-                }
-                DataRow dr = dt_Partick.NewRow();
-                dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
-                dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
-                dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
-                dr["con"] = dt.Rows.Count;
-                dr["ar"] = dt.Compute("min(Area)", "");
-                dr["max"] = dt.Compute("Max(Area)", "");
-                dr["Area"] = dt.Compute("SUM(Area)", "");
-                dt_Partick.Rows.Add(dr);
-            }
-            for (int i = 0; i < dt_Partick.Rows.Count; i++)
-            {
-                for (int j = 0; j < table.Rows.Count; j++)
-                {
-                    if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
-                    {
-                        dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
-                        break;
-                    }
-                }
-            }
-            return dt_Partick;
-        }
       
 
-        private DataTable InclusionAreaRatio_2(string str, OTSReport_Export m_otsreport_export, c_TemplateClass m_mbszclass)
+        private DataTable InclusionAreaRatio_2(string str, BasicData basicData,  c_TemplateClass m_mbszclass)
         {
 
             //根据sql条件,查询获取颗粒信息数据
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
+            //ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
 
-            DataTable m_bt_DBData = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
+            DataTable m_bt_DBData = InvalidRemoval(basicData.getParticleData().GetAreaByAllIncA(""));
 
             DataTable AreaInformationOfAllElements;
             if (m_mbszclass.list_str_MainPriority.Count==0)
@@ -480,7 +381,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
 
             List<string> ClassName = new List<string>();
-            DataTable getClass_dt = fielddata.GetAllClass();
+            DataTable getClass_dt = basicData.GetAllClass();
             bool bl = false;
             for (int i = 0; i < getClass_dt.Rows.Count; i++)
             {

+ 17 - 246
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/ParticleAnalysis.cs

@@ -20,15 +20,12 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
         /// 大分类
         /// </summary>
         /// <returns></returns>
-        public DataTable GetLargeClassification(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export,string ComputeMode)
+        public DataTable GetLargeClassification(BasicData basicData)
         {
-            DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
+            DataTable data = basicData.GetDBData();
             List<string> colid = new List<string>();
             //获取粒级表
-            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
-                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
-            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
-            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+            string sizestr = basicData.GetParticlesizeTable();
             for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
             {
                 if (sizestr.Split(',')[i].Length > 0)
@@ -40,7 +37,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
             colid.Add(d.ToString() + "~MAX");
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
             DataTable ls_partsize_dt = new DataTable();
             ls_partsize_dt.TableName = "PartSize";
             ls_partsize_dt.Columns.Add("c1");
@@ -114,7 +110,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
             List<string> ClassName = new List<string>();
-            DataTable getClass_dt = fielddata.GetAllClass();
+            DataTable getClass_dt = basicData.GetAllClass();
             for (int i = 0; i < getClass_dt.Rows.Count; i++)
             {
                 if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
@@ -132,16 +128,13 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
         /// 小分类
         /// </summary>
         /// <returns></returns>
-        public DataTable GetSubClassification(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
+        public DataTable GetSubClassification(BasicData basicData)
         {
 
-            DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
+            DataTable data = basicData.GetDBData();
             List<string> colid = new List<string>();
             //获取粒级表
-            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
-                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
-            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
-            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+            string sizestr = basicData.GetParticlesizeTable();
             for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
             {
                 if (sizestr.Split(',')[i].Length > 0)
@@ -234,18 +227,13 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
         /// 分类整合大小分类都有
         /// </summary>
         /// <returns></returns>
-        public List<DataTable>  GetClassificationConsolidationTable(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode, string a_PartSizeFile)
+        public List<DataTable>  GetClassificationConsolidationTable(BasicData basicData)
         {
             List<DataTable> datas = new List<DataTable>();
-
-            DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
-
+            DataTable data = basicData.GetDBData();
             List<string> colid = new List<string>();
             //获取粒级表
-            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
-                 a_PartSizeFile;
-            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
-            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+            string sizestr = basicData.GetParticlesizeTable();
 
             for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
             {
@@ -258,8 +246,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
             colid.Add(d.ToString() + "~MAX");
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
-
             //------------------------------------------------
             DataTable ls_partsize_dt = new DataTable();
             ls_partsize_dt.TableName = "PartSize";
@@ -290,7 +276,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
 
             DataTable ls_Particel_dt = new DataTable();
             ls_Particel_dt.TableName = "Particel";
-
             ls_Particel_dt.Columns.Add("c1", typeof(double));
             ls_Particel_dt.Columns.Add("c2", typeof(double));
             ls_Particel_dt.Columns.Add("c3", typeof(double));
@@ -336,7 +321,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
             List<string> ClassName = new List<string>();
-            DataTable getClass_dt = fielddata.GetAllClass();
+            DataTable getClass_dt = basicData.GetAllClass();
             bool bl = false;
             for (int i = 0; i < getClass_dt.Rows.Count; i++)
             {
@@ -352,10 +337,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
                     }
                     else
                     {
-                        //if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
-                        //{
                             ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
-                        //}
                     }
             }
 
@@ -366,62 +348,20 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             datas.Add(data2.Copy());
             return datas;
         }
-        /// <summary>
-        /// 判断是否有大分类,有为true
-        /// </summary>
-        /// <param name="m_otsreport_export"></param>
-        /// <returns></returns>
-        public bool IsThereAMajorClassification(OTSReport_Export m_otsreport_export)
-        {
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
-            DataTable getClass_dt = fielddata.GetAllClass();
-            List<string> ClassName = new List<string>();
-            bool bl = false;
-            for (int i = 0; i < getClass_dt.Rows.Count; i++)
-            {
-                if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
-                && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
-                    if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
-                    {
-                        if (!bl)
-                        {
-                            ClassName.Add("Default");
-                            bl = true;
-                        }
-                    }
-                    else
-                    {
-                        if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
-                        {
-                            ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
-                        }
-                    }
-            }
 
-            if (ClassName.Count < 2)
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
         /// <summary>
         /// 大分类chart数据
         /// </summary>
         /// <param name="m_mbszclass"></param>
         /// <param name="m_otsreport_export"></param>
         /// <returns></returns>
-        public DataTable GetChartDataCalss(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
+        public DataTable GetChartDataCalss(BasicData basicData)
         {
-            DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
+            DataTable data =basicData.GetDBData();
             List<string> colid = new List<string>();
             //获取粒级表
-            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
-                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
-            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
-            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+            
+            string sizestr = basicData.GetParticlesizeTable();
 
             for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
             {
@@ -434,7 +374,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
             colid.Add(d.ToString() + "~MAX");
-            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
+            //ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
 
             //------------------------------------------------
             DataTable ls_partsize_dt = new DataTable();
@@ -512,7 +452,7 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
             List<string> ClassName = new List<string>();
-            DataTable getClass_dt = fielddata.GetAllClass();
+            DataTable getClass_dt = basicData.GetAllClass();
             for (int i = 0; i < getClass_dt.Rows.Count; i++)
             {
                 if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
@@ -548,111 +488,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             return colid_data;
          
         }
-        /// <summary>
-        /// 小分类chart数据
-        /// </summary>
-        /// <param name="m_mbszclass"></param>
-        /// <param name="m_otsreport_export"></param>
-        /// <returns></returns>
-        public DataTable GetChartDataSubdivision(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
-        {
-            DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
-            List<string> colid = new List<string>();
-            string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
-                 m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
-            DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
-            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
-
-            for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
-            {
-                if (sizestr.Split(',')[i].Length > 0)
-                {
-                    double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
-                    double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
-                    colid.Add(d1.ToString() + "~" + d2.ToString());
-                }
-            }
-            double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
-            colid.Add(d.ToString() + "~MAX");
-            //------------------------------------------------
-            DataTable ls_partsize_dt = new DataTable();
-            ls_partsize_dt.TableName = "PartSize";
-            ls_partsize_dt.Columns.Add("c1");
-            ls_partsize_dt.Columns.Add("c2");
-            ls_partsize_dt.Columns.Add("c3");
-            ls_partsize_dt.Columns.Add("c4");
-            ls_partsize_dt.Columns.Add("c5");
-            ls_partsize_dt.Columns.Add("c6");
-            ls_partsize_dt.Columns.Add("c7");
-            ls_partsize_dt.Columns.Add("c8");
-            ls_partsize_dt.Columns.Add("c9");
-
-            DataRow dr = ls_partsize_dt.NewRow();
-            for (int i = 1; i < 10; i++)
-            {
-                if (colid.Count < i)
-                {
-                    dr["c" + i.ToString()] = "";
-                }
-                else
-                {
-                    dr["c" + i.ToString()] = colid[i - 1];
-                }
-            }
-            ls_partsize_dt.Rows.Add(dr);
-
-
-            DataTable ls_Particel_dt = new DataTable();
-            ls_Particel_dt.TableName = "Particel";
-            ls_Particel_dt.Columns.Add("c1", typeof(double));
-            ls_Particel_dt.Columns.Add("c2", typeof(double));
-            ls_Particel_dt.Columns.Add("c3", typeof(double));
-            ls_Particel_dt.Columns.Add("c4", typeof(double));
-            ls_Particel_dt.Columns.Add("c5", typeof(double));
-            ls_Particel_dt.Columns.Add("c6", typeof(double));
-            ls_Particel_dt.Columns.Add("c7", typeof(double));
-            ls_Particel_dt.Columns.Add("c8", typeof(double));
-            ls_Particel_dt.Columns.Add("c9", typeof(double));
-            ls_Particel_dt.Columns.Add("Name");
-            ls_Particel_dt.Columns.Add("total", typeof(double));
-            ls_Particel_dt.Columns.Add("TypeId");
-            ls_Particel_dt.Columns.Add("Class");
-
-            for (int i = 0; i < data.Rows.Count; i++)
-            {
-                DataRow dr2 = ls_Particel_dt.NewRow();
-                dr2["Name"] = data.Rows[i]["TypeName"].ToString();
-                dr2["Class"] = data.Rows[i]["Class"].ToString();
-                dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
-                for (int j = 1; j < 10; j++)
-                {
-                    if (colid.Count >= j)
-                    {
-                        dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
-                    }
-                }
-                if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
-                {
-                    dr2["total"] = "0"; //求合
-                    double d_total = 0;
-
-                    for (int j = 1; j < 10; j++)
-                    {
-                        if (colid.Count >= j)
-                        {
-                            d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
-                        }
-                    }
-                    dr2["total"] = d_total.ToString();
-                }
-                ls_Particel_dt.Rows.Add(dr2);
-            }
-
-            return ls_Particel_dt;
-       
-        }
-
-
         public DataTable ParticleResults(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
         {
             DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
@@ -765,7 +600,6 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             return ls_Particel_dt;
         }
-
         public DataTable TypeRange(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
         {
             List<string> colid = new List<string>();
@@ -939,71 +773,10 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             return dataTable;
         }
-
-       
-
-        private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
-        {
-            DataTable dt_Partick = new DataTable();
-            dt_Partick.Columns.Add("TypeId");
-            dt_Partick.Columns.Add("TypeName");
-            dt_Partick.Columns.Add("TypeColor");
-            dt_Partick.Columns.Add("con");
-            dt_Partick.Columns.Add("ar");
-            dt_Partick.Columns.Add("max");
-            dt_Partick.Columns.Add("Area", typeof(double));
-            dt_Partick.Columns.Add("GroupName");
-            List<string> typeName = new List<string>();
-            for (int i = 0; i < data.Rows.Count; i++)
-            {
-                typeName.Add(data.Rows[i]["TypeId"].ToString());
-            }
-            typeName = typeName.Distinct().ToList();
-
-            for (int i = 0; i < typeName.Count; i++)
-            {
-                DataTable dt = dt_Partick.Clone();
-                for (int j = 0; j < data.Rows.Count; j++)
-                {
-                    if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
-                    {
-                        DataRow row = dt.NewRow();
-                        row["TypeId"] = data.Rows[j]["TypeId"];
-                        row["TypeName"] = data.Rows[j]["TypeName"];
-                        row["TypeColor"] = data.Rows[j]["TypeColor"];
-                        row["Area"] = data.Rows[j]["Area"];
-                        dt.Rows.Add(row);
-                    }
-                }
-                DataRow dr = dt_Partick.NewRow();
-                dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
-                dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
-                dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
-                dr["con"] = dt.Rows.Count;
-                dr["ar"] = dt.Compute("min(Area)", "");
-                dr["max"] = dt.Compute("Max(Area)", "");
-                dr["Area"] = dt.Compute("SUM(Area)", "");
-                dt_Partick.Rows.Add(dr);
-            }
-            for (int i = 0; i < dt_Partick.Rows.Count; i++)
-            {
-                for (int j = 0; j < table.Rows.Count; j++)
-                {
-                    if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
-                    {
-                        dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
-                        break;
-                    }
-                }
-            }
-            return dt_Partick;
-        }
-
         private string getWhere(string max, string min, string col, string partic)
         {
             return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
         }
-
         private DataTable GetDBData(c_TemplateClass m_mbszclass , OTSReport_Export m_otsreport_export,string ComputeMode)
         {
 
@@ -1165,7 +938,5 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             return datass;
         }
 
-
-  
     }
 }

+ 20 - 97
OTSIncAReportApp/1-UI/OTSReportExport/Template/DataTemplate.cs

@@ -34,7 +34,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         private string ComputeMode = "";//计算方式
         private string ComputeModeName = "";//计算方式
         private string PartSizeFile = "";//粒级文件
-
+        BasicData basicData = new BasicData();
 
         System.Collections.Hashtable table;
         public OTS_DEVReport(OTSReport_Export in_export, c_TemplateClass a_Template, frmReportApp a_frmReportApp , Hashtable a_table)
@@ -54,8 +54,6 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
                     TemplateList.Add(item["TemplateName"].ToString());
                 }
             }
-
-            //string con = a_frmReportApp.m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
             string con = "";
             DataSet ds1 = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
             DataTable dt1 = ds1.Tables["Member"];
@@ -69,24 +67,19 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
                 if (RegName == "PartSizeFile")
                 {
                     PartSizeFile = element["name"].ToString();
-                    //comboBox_PartiSizeFileFolder.SelectedIndex = comboBox_PartiSizeFileFolder.Items.IndexOf(element["name"].ToString());
                 }
 
                 if (RegName == "TRIO_CHART_TYPE")
                 {
                     po = element["strValue"].ToString();
-                    //cB_sjtmbwj.SelectedIndex = cB_sjtmbwj.Items.IndexOf(element["strValue"].ToString());
                 }
                 if (RegName == "SIZE_CAL_METHOD_TYPE")
                 {
                     po = element["strValue"].ToString();
-                    //cB_SIZE_CAL_METHOD_TYPE.SelectedIndex = cB_SIZE_CAL_METHOD_TYPE.Items.IndexOf(element["strValue"].ToString());
                 }
             }
 
 
-
-
             for (int i=0;i< dt1.Rows.Count;i++)
             {
                 if (dt1.Rows[i]["RegName"].ToString()== "SIZE_CAL_METHOD_TYPE")
@@ -94,8 +87,6 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
                     con = dt1.Rows[i]["strValue"].ToString();
                 }
             }
-         
-                
             switch (con)
             {
                 case "DMAX":
@@ -122,6 +113,8 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
                 ComputeModeName = con;
             }
             InitializeComponent();
+
+            
         }
         #region 接口
         /// <summary>
@@ -130,6 +123,14 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// <param name="languageData"></param>
         public void International_language(DataTable a_languageData)
         {
+            basicData = new BasicData();
+            basicData.SetDBData(TemplateClass,m_otsreport_export,ComputeMode);
+            basicData.SetParticlesizeTable(m_otsreport_export);
+            basicData.newParticleData(m_otsreport_export);
+            basicData.SetAllClass();
+            basicData.SetAllElement();
+            basicData.IsThereAMajorClassification();
+
             languageData = a_languageData.Copy();
             setXRLabelData(dev_ypbh_up, GetlanguageData(dev_ypbh_up.Name.ToString(), languageData, dev_ypbh_up.Text));//样品编号(中间的)
             setXRLabelData(dev_bgsj_up, GetlanguageData(dev_bgsj_up.Name.ToString(), languageData, dev_bgsj_up.Text));//报告时间(中间的)
@@ -533,20 +534,11 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             {
                 if (!string.IsNullOrWhiteSpace(dataTable.Rows[i]["Class"].ToString()))
                 {
-                    //vs.Add(i);
                     dataTable.Rows[i].Delete();
                 }
-
-                //dataTable.Rows[i].Delete();
             }
 
-            //for (int i=0;i<vs.Count;i++)
-            //{
-            //    dataTable.Rows[i].Delete();
-            //}
             dataTable.AcceptChanges();
-            //    dataTable.Rows[ls].Delete();
-            //    dataTable.AcceptChanges();
 
             return dataTable.Copy();
        
@@ -560,11 +552,10 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         {
             xrPageBreak1.Visible = true;
             ParticleAnalysis particleList = new ParticleAnalysis();
-            List<DataTable> CompositeData = particleList.GetClassificationConsolidationTable(TemplateClass, m_otsreport_export, ComputeMode, PartSizeFile);
-            DataTable classData= particleList.GetLargeClassification(TemplateClass, m_otsreport_export, ComputeMode);
-            DataTable subdivdeData = particleList.GetSubClassification(TemplateClass, m_otsreport_export, ComputeMode);
-            DataTable chartmax= particleList.GetChartDataCalss(TemplateClass, m_otsreport_export, ComputeMode);
-            //DataTable surface_dt2 = particleList.ParticleResults(TemplateClass, m_otsreport_export, ComputeMode);
+            List<DataTable> CompositeData = particleList.GetClassificationConsolidationTable(basicData);
+            DataTable classData= particleList.GetLargeClassification(basicData);
+            DataTable subdivdeData = particleList.GetSubClassification(basicData);
+            DataTable chartmax= particleList.GetChartDataCalss(basicData);
             DataTable surface_dt2 = CompositeData[1].Clone();
             for (int i=0;i< CompositeData[1].Rows.Count;i++)
             {
@@ -586,7 +577,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             #region 插入数据
             if(CompositeData[1].Rows.Count>0)
             {
-                if (particleList.IsThereAMajorClassification(m_otsreport_export))
+                if (basicData.GetIsThereAMajorClassification())
                 {
                     add_SetTableS(CompositeData, surface_dt2);
                 }
@@ -614,9 +605,6 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
                 xrLabel_size_IconQuestion_Class.Visible = true;
                 xrLabel_size_IconQuestion_Class.LocationF = new PointF(xrLabel_size_IconQuestion_Class.LocationF.X, NeueStartposition);
                 NeueStartposition = xrLabel_size_IconQuestion_Class.LocationF.Y + xrLabel_size_IconQuestion_Class.SizeF.Height + 10;
-                //DataView dv = subdivdeData.DefaultView;
-                //dv.Sort = "total DESC";
-                //DataTable dt_class_dt = dv.ToTable();
 
                 // 实例化饼图对象
                 Series pieSeriesClass = new Series("尺寸分类", ViewType.Pie);
@@ -646,23 +634,16 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             #endregion
             #region 细分chart图
 
-           
-
-
             xrChart_ParticelSizeSubdivision.Visible = false;
             if (a_pieSeries && surface_dt2.Rows.Count>0)
             {
-
                 DataView dv2 = surface_dt2.DefaultView;
                 dv2.Sort = "total DESC";
                 DataTable dt_subdivde_dt = dv2.ToTable();
-
                 xrChart_ParticelSizeSubdivision.Visible = true;
                 xrLabel_size_IconQuestion_Subdivision.Visible = true;
                 xrLabel_size_IconQuestion_Subdivision.LocationF = new PointF(xrLabel_size_IconQuestion_Subdivision.LocationF.X, NeueStartposition);
                 NeueStartposition = xrLabel_size_IconQuestion_Subdivision.LocationF.Y + xrLabel_size_IconQuestion_Subdivision.SizeF.Height + 1;
-                
-
                 // 实例化饼图对象
                 Series pieSeries = new Series("颗粒尺寸细化分类", ViewType.Pie);
                 pieSeries.ArgumentScaleType = ScaleType.Qualitative;
@@ -692,23 +673,6 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             #endregion
             #endregion
         }
-        private XRChart ParticleSpectrogramControl(DataTable dt)
-        {
-            XRChart xRChart = new XRChart();
-            // 添加数据系列
-            Series series = new Series("", ViewType.Line);
-            series.ArgumentDataMember = "XName"; // X轴数据
-            series.ValueDataMembers.AddRange(new string[] { "data", "Serial" }); // Y轴数据
-            // 绑定数据源
-            series.DataSource = dt; // 获取数据源的方法
-            xrChart1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
-            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.False;
-            LineSeriesView lineView = (LineSeriesView)series.View;
-            lineView.LineMarkerOptions.Size = 1;
-            xRChart.Series.Add(series);
-            xRChart.SizeF = new SizeF(560f, 115f);
-            return xRChart;
-        }
 
         private void HistogramChart(ParticleAnalysis particleList)
         {
@@ -961,54 +925,13 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         public void setElementAvgGrid()
         {
             ElementalAnalysis elementalAnalysis = new ElementalAnalysis();
-            List<DataTable> datas = elementalAnalysis.GetElementData(TemplateClass, m_otsreport_export, ComputeMode);
-            if (elementalAnalysis.IsThereAMajorClassification(m_otsreport_export))
+            List<DataTable> datas = elementalAnalysis.GetElementData(basicData, m_otsreport_export);
+            if (basicData.GetIsThereAMajorClassification())
                 add_SetElementAvgGridS(datas);
             else
                 add_SetElementAvgGrid(datas);
-            //xrTb_ElementAnalysis.Visible = true;
-
-            ////元素分析表————————
-            //setXRLabelData(xrTableCell30, GetlanguageData("xrCellElementArea", languageData));//元素分析表表头
-            //setXRLabelData(xrTableCell31, GetlanguageData("xrCellElementArea_details", languageData));//详情
-            //DataTable REORDER_data = REORDER(datas[2], "Name");
-            //for (int i = 0; i < REORDER_data.Rows.Count; i++)
-            //{
-            //    double quantity = 0;
-            //    for (int a = 4; a < REORDER_data.Columns.Count; a++)
-            //    {
-            //        if (REORDER_data.Rows[i][a].ToString() != "")
-            //        {
-            //            quantity = quantity + Convert.ToDouble(REORDER_data.Rows[i][a].ToString());
-            //        }
-            //    }
-            //    string str_data = "";
-            //    for (int a = 4; a < REORDER_data.Columns.Count; a++)
-            //    {
-            //        if (REORDER_data.Rows[i][a].ToString() != "")
-            //        {
-            //            str_data = str_data + REORDER_data.Columns[a].ColumnName.ToString() + "=" + elementalAnalysis.ParameterNormalization(quantity, Convert.ToDouble(REORDER_data.Rows[i][a].ToString())) + "%" + "  ";
-            //        }
-            //    }
-            //    xrTb_ElementAnalysis.Rows.Add(addElementalAnalysisRows(REORDER_data.Rows[i]["Name"].ToString(), str_data));
-            //}
-            //xrTb_ElementAnalysis.LocationF = new PointF(10f, NeueStartposition);
-            //NeueStartposition = xrTb_ElementAnalysis.LocationF.Y + xrTb_ElementAnalysis.SizeF.Height + 10;
         }
 
-        private XRTableRow addElementalAnalysisRows(string className, string data)
-        {
-            XRTableRow row = new XRTableRow();
-            XRTableCell tCell_class = new XRTableCell();
-            XRTableCell tCell_data = new XRTableCell();
-            tCell_class.Text = className;
-            tCell_class.WidthF = 116.29f;
-            tCell_data.Text = data;
-            tCell_data.WidthF = 551.71f;
-            row.Controls.Add(tCell_class);
-            row.Controls.Add(tCell_data);
-            return row;
-        }
         private XRTableRow AddInclusionIndex(DataTable a_data,string a_str)
         {
             XRTableRow row = new XRTableRow();
@@ -1122,8 +1045,8 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         public void setINCAtable()
         {
             InclusionProportion inclusionProportion = new InclusionProportion();
-            DataTable dt = inclusionProportion.GetINCAtable(FieldOfViewArea, m_otsreport_export, TemplateClass);
-            if (inclusionProportion.IsThereAMajorClassification(m_otsreport_export))
+            DataTable dt = inclusionProportion.GetINCAtable(basicData, FieldOfViewArea,  TemplateClass);
+            if (basicData.GetIsThereAMajorClassification())
                 add_SetINCAtableS(dt);
             else
                 add_SetINCAtable(dt);

+ 1 - 0
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -493,6 +493,7 @@
     <Compile Include="1-UI\OTSReportExport\ClassificationOrderAdjuster.Designer.cs">
       <DependentUpon>ClassificationOrderAdjuster.cs</DependentUpon>
     </Compile>
+    <Compile Include="1-UI\OTSReportExport\DataIntegration\BasicData.cs" />
     <Compile Include="1-UI\OTSReportExport\DataIntegration\ImageProcessor.cs" />
     <Compile Include="1-UI\Purity.cs">
       <SubType>Form</SubType>