123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
-
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.OTSRstMgrFunction;
- 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 = "";
- List<string> colid = new List<string>();
- List<string> colid_Below7 = new List<string>();
- private DataTable BData = new DataTable();
- private DataTable AllClass = new DataTable();
- private DataTable AllElement = new DataTable();
- private bool IsShereAClassificationGroup = false;
- private ResultFile resfile;
- private string FilePath = "";
- /// <summary>
- /// 获取粒级表
- /// </summary>
- public void SetParticlesizeTable(OTSReport_Export m_otsreport_export)
- {
- colid_Below7.Clear();
- //获取粒级表
- 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();
- for (int i = 0; i < SizeChart.Split(',').Length; i++)
- {
- if (SizeChart.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(SizeChart.Split(',')[i]);
- //double d2 = Convert.ToDouble(SizeChart.Split(',')[i + 1]);
- colid.Add("≥"+ d1.ToString() /*+ "~" + d2.ToString()*/);
- }
- }
- for (int i = 0; i < SizeChart.Split(',').Length - 1; i++)
- {
- if (SizeChart.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(SizeChart.Split(',')[i]);
- double d2 = Convert.ToDouble(SizeChart.Split(',')[i + 1]);
- colid_Below7.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(SizeChart.Split(',')[SizeChart.Split(',').Length - 1]);
- colid_Below7.Add(d.ToString() + "~MAX");
- //double d = Convert.ToDouble(SizeChart.Split(',')[SizeChart.Split(',').Length - 1]);
- //colid.Add(d.ToString() + "~MAX");
- }
- /// <summary>
- /// 获取粒级表
- /// </summary>
- /// <returns></returns>
- public List<string> GetParticlesizeTable()
- {
- if(colid.Count>7)
- {
- return colid;
- }else
- {
- return colid_Below7;
- }
-
- }
-
- 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.GetWorkingResultId()].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();
- bool blBelow7 = false;
- if (sizestr.Split(',').Length>7)
- {
- for (int i = 0; i < sizestr.Split(',').Length; 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()*/);
- }
- }
- blBelow7 = true;
- }
- else
- {
- 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");
- blBelow7 = false;
- }
-
- //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);
- if(blBelow7)
- {
- for (int a = 6; a < colid.Count; a++)
- {
- string d1 = colid[a].Split('≥')[1];
- string d2;
- if (a == colid.Count - 1)
- {
- d2 = "999";
- }
- else
- {
- d2 = colid[a + 1].Split('≥')[1];
- }
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
- dr[colid[a]] = datas.Count();
- }
- }
- else
- {
- 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_Serial.Count; a++)
- {
- for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
- {
- if (m_bt_DBData.Rows[i]["TypeId"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial[a].ToString())
- {
- m_bt_DBData.Rows.RemoveAt(i);
- }
- }
- }
- if (m_mbszclass.list_str_MainPriority_Serial.Count == 0)
- {
- BData = m_bt_DBData.Copy();
- return;
- }
- DataTable datass = m_bt_DBData.Clone();
- string str = m_otsreport_export.m_mbszclass.M_SY.StandardLibraryName;
- OTSCommon.DBOperate.SqLiteHelper sh;
- string fullPath = GetFilePath() + "\\" + str;
- string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + str;
- if (System.IO.File.Exists(fullPath))
- {
- sh = new OTSCommon.DBOperate.SqLiteHelper("data source='" + fullPath + "'");
- }
- else if (System.IO.File.Exists(fullPath2))
- {
- sh = new OTSCommon.DBOperate.SqLiteHelper("data source='" + fullPath2 + "'");
- }
- else
- {
- sh = null;
-
- }
- DataTable dt_stl = sh.ExecuteQuery("select * from ClassifySTD");
- DataTable LargeClassificationTable = sh.ExecuteQuery("select * from STDGroups");
- for (int i = 0; i < m_mbszclass.list_str_MainPriority_Serial.Count; i++)
- {
- bool bl = false;
- for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
- {
- if (m_bt_DBData.Rows[a]["TypeId"].ToString() == m_mbszclass.list_str_MainPriority_Serial[i])
- {
- datass.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
- bl = true;
- continue;
- }
- }
- if (!bl)
- {
- DataTable dta = m_bt_DBData.Clone();
- // 添加一个空行
- DataRow newRow = dta.NewRow();
- dta.Rows.Add(newRow);
- 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")
- {
- for (int c = 0; c < LargeClassificationTable.Rows.Count; c++)
- {
- if (LargeClassificationTable.Rows[c]["id"].ToString() == dt_stl.Rows[i]["GroupId"].ToString())
- {
- dta.Rows[0][b] = LargeClassificationTable.Rows[c]["name"].ToString();
- }
- }
- }
- else
- if (dta.Columns[b].ColumnName == "TypeId")
- {
- dta.Rows[0][b] = m_mbszclass.list_str_MainPriority_Serial[i];
- }
- 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.GetWorkingResultId()].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;
- }
- public void IsResultFilesList(OTSReport_Export m_otsreport_export)
- {
- resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
- }
- /// <summary>
- /// 获取标准库名称
- /// </summary>
- /// <returns></returns>
- public string GetResfile()
- {
- return resfile.GetSTDName();
- }
- public void IsFilePath(OTSReport_Export m_otsreport_export)
- {
- FilePath= m_otsreport_export.m_ReportApp.m_rstDataMgr.CurResultFile.FilePath;
- }
- /// <summary>
- /// 得到文件路径
- /// </summary>
- /// <returns></returns>
- public string GetFilePath()
- {
- return FilePath;
- }
- #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
- }
- }
|