Browse Source

导出拼接颗粒功能未完成

zhangjiaxin 2 months ago
parent
commit
8f6595c851
1 changed files with 197 additions and 13 deletions
  1. 197 13
      OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/BasicData.cs

+ 197 - 13
OTSIncAReportApp/1-UI/OTSReportExport/DataIntegration/BasicData.cs

@@ -1,10 +1,13 @@
 
+using DevExpress.Charts.Native;
 using DevExpress.Office.Drawing;
 using NPOI.Util;
 using OTSCommon.DBOperate;
+using OTSCommon.DBOperate.Model;
 using OTSIncAReportApp._2_CommonFunction.CommonClass;
 using OTSIncAReportApp.DataOperation.DataAccess;
 using OTSIncAReportApp.OTSRstMgrFunction;
+using OTSIncAReportGrids;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -36,12 +39,16 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
         private string FilePath = "";
 
         private string VDA19String = "5,15,25,50,100,150,200,400,600,1000";
-        /// <summary>
-        /// 获取粒级表
-        /// </summary>
-        public void SetParticlesizeTable(OTSReport_Export m_otsreport_export)
+
+		//DataTable particlesAll;
+		//DataTable userSTDDbData;
+		/// <summary>
+		/// 获取粒级表
+		/// </summary>
+		public void SetParticlesizeTable(OTSReport_Export m_otsreport_export)
         {
-            colid_Below7.Clear();
+
+			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;
@@ -88,9 +95,43 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
             }
             
         }
-       
-        public void SetDBData(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
+
+		/// <summary>
+		/// 获取拼接颗粒信息
+		/// </summary>
+		/// <returns></returns>
+		public DataTable ObtainInformationOnSplicedParticles(OTSReport_Export m_otsreport_export)
         {
+            DataTable userSTDDbData = new DataTable();
+            DataTable particlesAll;
+			ParticlesGridDevidePage particlesGridDevide = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
+			var systype = m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype;
+			if (systype == OTS_SysType_ID.TCCleannessA || systype == OTS_SysType_ID.BatteryCleannessA)
+			{
+				string str_STDDbName = resfile.GetSTDName();
+				particlesGridDevide.userSTDDb = new UserSTDDbAccess(str_STDDbName, resfile.FilePath + "\\");
+				if (particlesGridDevide.userSTDDb.GetSqlHelper() != null)
+				{
+					userSTDDbData = particlesGridDevide.userSTDDb.GetSubAttributeFromDatabase();
+				}
+				else
+				{
+					userSTDDbData = null;
+				}
+			}
+			particlesGridDevide.Particledata = new ParticleData(resfile.FilePath);
+			DataTable qparticlesAll = particlesGridDevide.Particledata.GetInfoForPartucleDevidePage_mergeParticles("");
+            particlesAll = SplicingParticleElementFilling(qparticlesAll, particlesGridDevide, userSTDDbData);
+
+            return particlesAll;
+		}
+
+
+
+		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", "GroupId", "con" };
@@ -142,11 +183,53 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
                 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;
+
+            DataTable particlesAll = ObtainInformationOnSplicedParticles(m_otsreport_export);//拼接颗粒信息
+
+			#region 分割出需要删除的拼接前的颗粒
+			List<string> listPicture = new List<string>();
+			List<string> listPosition = new List<string>();
+			for (int i = 0; i < particlesAll.Rows.Count; i++)
+			{
+				string detailedLocation = particlesAll.Rows[i]["SubParticles"].ToString();
+				string[] fruits = detailedLocation.Split(',');
+				for (int a = 0; a < fruits.Length; a++)
+				{
+					string[] fruit = fruits[a].Split(':');
+					listPicture.Add(fruit[0]);
+					listPosition.Add(fruit[1]);
+				}
+			}
+			#endregion
+
+
+			#region 清除拼接前的颗粒
+
+			for (int i = dtp.Rows.Count - 1; i >= 0; i--)
+			{
+                for (int a = 0; a < listPicture.Count; a++)
+                {
+                    if (dtp.Rows[i]["FieldId"].ToString() == listPicture[a].ToString() && dtp.Rows[i]["XrayId"].ToString() == listPosition[a].ToString())
+                    {
+						dtp.Rows.RemoveAt(i);
+					}
+                }
+			}
+			#endregion
+
+			#region 添加拼接颗粒
+
+
+			#endregion
+
+
+			string po = ComputeMode;
             switch (po)
             {
                 case "DMAX":
@@ -506,12 +589,113 @@ namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
 			#endregion
 
 		}
-        /// <summary>
-        /// 获取夹杂物组信息
-        /// </summary>
-        /// <returns></returns>
+		/// <summary>
+		/// 拼接颗粒元素填充
+		/// </summary>
+		/// <param name="data"></param>
+		/// <returns></returns>
+		private DataTable SplicingParticleElementFilling(DataTable a_particlesAll, ParticlesGridDevidePage particlesGridDevide, DataTable userSTDDbData)
+        {
+			a_particlesAll.Columns.Add("Hardness");
+			a_particlesAll.Columns.Add("Density");
+			a_particlesAll.Columns.Add("Electrical_conductivity");
+
+			if (userSTDDbData.Rows.Count > 0)
+			{
+				for (int i = 0; i < a_particlesAll.Rows.Count; i++)
+				{
+					DataRow[] dr = userSTDDbData.Select("STDId=" + a_particlesAll.Rows[i]["TypeId"].ToString());
+					if (dr.Length > 0)
+					{
+						a_particlesAll.Rows[i]["Hardness"] = dr[0]["Hardness"].ToString();
+						a_particlesAll.Rows[i]["Density"] = dr[0]["Density"].ToString();
+						a_particlesAll.Rows[i]["Electrical_conductivity"] = dr[0]["Electrical_conductivity"].ToString();
+					}
+					else
+					{
+						a_particlesAll.Rows[i]["Hardness"] = "";
+						a_particlesAll.Rows[i]["Density"] = "";
+						a_particlesAll.Rows[i]["Electrical_conductivity"] = "";
+					}
+				}
+			}
+			else
+			{
+				for (int i = 0; i < a_particlesAll.Rows.Count; i++)
+				{
+					a_particlesAll.Rows[i]["Hardness"] = "";
+					a_particlesAll.Rows[i]["Density"] = "";
+					a_particlesAll.Rows[i]["Electrical_conductivity"] = "";
+				}
+			}
+
+
+			DataTable elementchemistry = particlesGridDevide.Particledata.GetElementChemistry();
+			for (int i = 0; i < a_particlesAll.Rows.Count; i++)
+			{
+				string str = "XRayId = " + a_particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + a_particlesAll.Rows[i]["fieldid"].ToString();
+				DataRow[] drs = elementchemistry.Select(str);
+				string ConcatenatedString = "";
+				for (int j = 0; j < drs.Length; j++)
+				{
+					ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
+				}
+				a_particlesAll.Rows[i]["Element"] = ConcatenatedString;
+			}
+			a_particlesAll.Columns.Add("XRayDataCount");
+			DataTable XRayData = particlesGridDevide.Particledata.GetXRayData();
+			for (int i = 0; i < a_particlesAll.Rows.Count; i++)
+			{
+				string subt = a_particlesAll.Rows[i]["SubParticles"].ToString();
+				if (subt == "")
+				{
+					a_particlesAll.Rows[i]["XRayDataCount"] = 0;
+					string str = " XrayIndex= " + a_particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + a_particlesAll.Rows[i]["fieldid"].ToString();
+					DataRow[] drs = XRayData.Select(str);
+					uint xraycount = 0;
+					if (drs != null)
+					{
+						if (drs.Length > 0)
+						{
+							uint[] Analysis_xray = new uint[2000];
+							for (int j = 0; j < 2000; j++)
+							{
+								Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
+							}
+							for (int j = 0; j < 2000; j++)
+							{
+								xraycount += Analysis_xray[j];
+							}
+							a_particlesAll.Rows[i]["XRayDataCount"] = xraycount;
+						}
+					}
+				}
+				else
+				{
+
+					a_particlesAll.Rows[i]["XRayDataCount"] = 0;
+					DataRow dgvr = a_particlesAll.Rows[i];
+					uint[] Search_xray = new uint[2000];
+					uint[] Analysis_xray = new uint[2000];
+					particlesGridDevide.Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Search_xray, out Analysis_xray);
+					uint xraycount = 0;
+					for (int j = 0; j < 2000; j++)
+					{
+						xraycount += Analysis_xray[j];
+					}
+					a_particlesAll.Rows[i]["XRayDataCount"] = xraycount;
+				}
+			}
+			return a_particlesAll;
+        }
+
+
+		/// <summary>
+		/// 获取夹杂物组信息
+		/// </summary>
+		/// <returns></returns>
 
-        public List<string> GetGroupInformation()
+		public List<string> GetGroupInformation()
         {
             return GroupInformation;
 		}