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 ParticleAnalysis { /// /// 大分类 /// /// public DataTable GetLargeClassification(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export) { DataTable data = GetDBData(m_mbszclass, m_otsreport_export); List colid = new List(); //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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"); 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"); 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); } //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序 List ClassName = new List(); DataTable getClass_dt = fielddata.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") if (getClass_dt.Rows[i]["GroupName"].ToString() == "") ClassName.Add("NULL"); else ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString()); } //获取大分类信息 DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName); return dt; } /// /// 小分类 /// /// public DataTable GetSubClassification(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export) { DataTable data = GetDBData(m_mbszclass, m_otsreport_export); List colid = new List(); //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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 List GetClassificationConsolidationTable(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export) { List datas = new List(); DataTable data = GetDBData(m_mbszclass, m_otsreport_export); List colid = new List(); //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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"); 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"); 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); } //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序 List ClassName = new List(); DataTable getClass_dt = fielddata.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" && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified") if (getClass_dt.Rows[i]["GroupName"].ToString() == "") ClassName.Add("Default"); else ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString()); } //获取大分类信息 DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName); DataTable data2 = classIfIcationSort(ls_Particel_dt, ClassName, dt); datas.Add(ls_partsize_dt.Copy()); datas.Add(data2.Copy()); return datas; } /// /// 判断是否有大分类,有为true /// /// /// 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 ClassName = new List(); 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() == "") ClassName.Add("Default"); else ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString()); } if (ClassName.Count < 2) { return false; } else { return true; } } /// /// 大分类chart数据 /// /// /// /// public DataTable GetChartDataCalss(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export) { DataTable data = GetDBData(m_mbszclass, m_otsreport_export); List colid = new List(); //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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"); 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"); 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); } //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序 List ClassName = new List(); DataTable getClass_dt = fielddata.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") if (getClass_dt.Rows[i]["GroupName"].ToString() == "") ClassName.Add("NULL"); else ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString()); } //颗粒尺寸数据(例 1.5有多少,2.0有多少) DataTable colid_data = new DataTable(); colid_data.Columns.Add("name"); colid_data.Columns.Add("quantity", typeof(double)); for (int i = 0; i < ls_Particel_dt.Columns.Count; i++) { if (ls_Particel_dt.Columns[i].ColumnName == "c" + (i + 1).ToString()) { if (i < colid.Count) { DataRow dr1 = colid_data.NewRow(); dr1["name"] = colid[i].ToString(); int quantity = 0; for (int a = 0; a < ls_Particel_dt.Rows.Count; a++) { quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString()); } dr1["quantity"] = quantity.ToString(); colid_data.Rows.Add(dr1); } } } return colid_data; } /// /// 小分类chart数据 /// /// /// /// public DataTable GetChartDataSubdivision(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export) { DataTable data = GetDBData(m_mbszclass, m_otsreport_export); List colid = new List(); string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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) { DataTable data = GetDBData(m_mbszclass, m_otsreport_export); List colid = new List(); //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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"); 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"); 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"); ls_partsize_dt.Columns.Add("c10"); 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"); ls_Particel_dt.Columns.Add("c2"); ls_Particel_dt.Columns.Add("c3"); ls_Particel_dt.Columns.Add("c4"); ls_Particel_dt.Columns.Add("c5"); ls_Particel_dt.Columns.Add("c6"); ls_Particel_dt.Columns.Add("c7"); ls_Particel_dt.Columns.Add("c8"); ls_Particel_dt.Columns.Add("c9"); ls_Particel_dt.Columns.Add("c10"); ls_Particel_dt.Columns.Add("Name"); ls_Particel_dt.Columns.Add("total"); ls_Particel_dt.Columns.Add("TypeId"); for (int i = 0; i < data.Rows.Count; i++) { DataRow dr2 = ls_Particel_dt.NewRow(); dr2["Name"] = data.Rows[i]["TypeName"].ToString(); dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号 for (int j = 1; j < 11; j++) { if (colid.Count >= j) { double de = Convert.ToDouble(data.Rows[i][colid[j - 1]]); if (de == 0) dr2["c" + j.ToString()] = " "; else dr2["c" + j.ToString()] = de.ToString(); } } if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0) { dr2["total"] = " "; //求合 double d_total = 0; for (int j = 1; j < 11; j++) { if (colid.Count >= j) { d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]); } } if (d_total == 0) { continue; dr2["total"] = " "; } else dr2["total"] = d_total.ToString(); } ls_Particel_dt.Rows.Add(dr2); } return ls_Particel_dt; } public DataTable TypeRange(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export) { List colid = new List(); //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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"); ls_partsize_dt.Columns.Add("c10"); ls_partsize_dt.Columns.Add("c11"); ls_partsize_dt.Columns.Add("c12"); DataRow dr = ls_partsize_dt.NewRow(); for (int i = 1; i < 13; i++) { if (colid.Count < i) { dr["c" + i.ToString()] = ""; } else { dr["c" + i.ToString()] = colid[i - 1]; } } ls_partsize_dt.Rows.Add(dr); return ls_partsize_dt; } private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List ClassName) { DataTable dt_Class = dataTable.Copy(); dt_Class.Clear(); dt_Class.TableName = "Particel"; dt_Class.Columns.Remove("Name"); dt_Class.Columns.Remove("TypeId"); for (int i = 0; i < ClassName.Count; i++) { //保留当前循环中大类物质,去除其他物质 DataTable dt = dataTable.Copy(); dt.Clear(); for (int a = 0; a < dataTable.Rows.Count; a++) { if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString()) { dt.Rows.Add(dataTable.Rows[a].ItemArray); } } if (dt.Rows.Count == 0) continue; DataTable dt_2 = new DataTable(); dt_2 = dataTable.Copy(); dt_2.Clear(); DataRow row = dt_2.NewRow(); dt_2.Rows.Add(row); for (int a = 0; a < dt.Columns.Count; a++) { if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class" && dt.Columns[a].ToString() != "TypeId") { bool bl = false; for (int b = 0; b < dt.Rows.Count; b++) { if (!dt.Rows[b].IsNull(dt.Columns[a].ToString())) { bl = true; } } if (bl) { dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString()); } } } dt_2.Columns.Remove("Name"); dt_2.Columns.Remove("TypeId"); dt_2.Rows[0]["Class"] = ClassName[i]; dt_Class.Rows.Add(dt_2.Rows[0].ItemArray); } return dt_Class; } private DataTable classIfIcationSort(DataTable dataTable, List ClassName, DataTable data) { DataTable dt = new DataTable(); dt = dataTable.Copy(); dt.Clear(); dt.TableName = "Particel_subdivision"; //循环list中每个类型 for (int i = 0; i < ClassName.Count(); i++) { DataTable data1 = dt.Copy(); data1.Clear(); data1.Rows.Add(); for (int a = 0; a < data.Rows.Count; a++) { if (data.Rows[a]["Class"].ToString() == ClassName[i].ToString()) { for (int b = 1; b < 10; b++) { data1.Rows[0]["c" + b.ToString()] = data.Rows[a]["c" + b.ToString()]; } data1.Rows[0]["total"] = data.Rows[a]["total"]; data1.Rows[0]["Class"] = data.Rows[a]["Class"]; dt.Rows.Add(data1.Rows[0].ItemArray); } } DataTable dt_1 = new DataTable(); dt_1 = dt.Copy(); dt_1.Clear(); //循环DataTable中每个分类的数据 for (int a = 0; a < dataTable.Rows.Count; a++) { if (!string.IsNullOrWhiteSpace(ClassName[i].ToString())) if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString()) { dataTable.Rows[a]["Class"] = ""; dt_1.Rows.Add(dataTable.Rows[a].ItemArray); } } //将颗粒数量排序(从大到小) DataView dv = dt_1.DefaultView; dv.Sort = "total DESC"; DataTable dt_1_sort = dv.ToTable(); for (int a = 0; a < dt_1_sort.Rows.Count; a++) { dt.Rows.Add(dt_1_sort.Rows[a].ItemArray); } } dt.Columns.Remove("TypeId"); return dt; } 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 void SelectParticleData(out DataTable dt, OTSReport_Export m_otsreport_export) { List selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles(); #region Datatable数据表格式 DataTable dtUelect = new DataTable(); dtUelect.Columns.Add("fieldid"); dtUelect.Columns.Add("particleid"); dtUelect.Columns.Add("AveGray"); dtUelect.Columns.Add("RectLeft"); dtUelect.Columns.Add("RectTop"); dtUelect.Columns.Add("RectWidth"); dtUelect.Columns.Add("RectHeight"); dtUelect.Columns.Add("Area"); dtUelect.Columns.Add("PosX"); dtUelect.Columns.Add("PosY"); dtUelect.Columns.Add("TypeId"); dtUelect.Columns.Add("SegmentNum"); dtUelect.Columns.Add("SEMPosX"); dtUelect.Columns.Add("SEMPosY"); dtUelect.Columns.Add("XrayId"); dtUelect.Columns.Add("DMAX"); dtUelect.Columns.Add("DMIN"); dtUelect.Columns.Add("DPERP"); dtUelect.Columns.Add("PERIMETER"); dtUelect.Columns.Add("ORIENTATION"); dtUelect.Columns.Add("DINSCR"); dtUelect.Columns.Add("DMEAN"); dtUelect.Columns.Add("DELONG"); dtUelect.Columns.Add("DFERET"); dtUelect.Columns.Add("TypeName"); dtUelect.Columns.Add("TypeColor"); #endregion for (int i = 0; i < selectParticles.Count; i++) { dtUelect.Rows.Add(selectParticles[i].FieldId, selectParticles[i].ParticleId, selectParticles[i].AveGray, selectParticles[i].RectLeft, selectParticles[i].RectTop, selectParticles[i].RectWidth, selectParticles[i].RectHeight, selectParticles[i].Area, selectParticles[i].PosX, selectParticles[i].PosX, selectParticles[i].TypeId, /*selectParticles[i].ElementNum,*/ selectParticles[i].SegmentNum, selectParticles[i].SEMPosX, selectParticles[i].SEMPosY, selectParticles[i].ParticleId, selectParticles[i].DMAX, selectParticles[i].DMIN, selectParticles[i].DPERP, selectParticles[i].PERIMETER, selectParticles[i].ORIENTATION, selectParticles[i].DINSCR, selectParticles[i].DMEAN, selectParticles[i].DELONG, selectParticles[i].DFERET, selectParticles[i].TypeName, selectParticles[i].TypeColor); } dt = dtUelect.Copy(); } 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 typeName = new List(); 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) { 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 colid = new List() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" }; //获取粒级表 string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString(); 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("")); //选择颗粒信息 DataTable data; SelectParticleData(out data, m_otsreport_export); //选择颗粒整理成表 DataTable Partic_dt = new DataTable(); if (data.Rows.Count > 0) { Partic_dt = GetParticleListForParticlSize(data, dtp); } List vs = new List() { "DMAX", "DMIN", "FERET", "Area" }; string po = vs[m_otsreport_export.m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs]; switch (po) { case "DMAX": po = "DMAX"; break; case "DMIN": po = "DMIN"; break; case "ECD": po = "Area"; break; case "FERET": po = "DFERET"; break; } //如果是全部颗粒(0) if (m_mbszclass.M_SY.int_xzkl == 0) { 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); } } else//选择颗粒(1) { for (int i = 0; i < Partic_dt.Rows.Count; i++) { DataRow dr = m_bt_DBData.NewRow(); dr["TypeName"] = Partic_dt.Rows[i]["TypeName"].ToString(); dr["TypeId"] = Partic_dt.Rows[i]["TypeId"].ToString(); dr["con"] = Partic_dt.Rows[i]["con"].ToString(); dr["Class"] = Partic_dt.Rows[i]["GroupName"].ToString(); dr["Largest"] = Math.Round(Convert.ToDouble(Partic_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, Partic_dt.Rows[i]["TypeId"].ToString())); dr[colid[a]] = datas.Count(); } dr["ar"] = Partic_dt.Rows[i]["Area"]; 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); } } } return m_bt_DBData; } } }