BasicData.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. 
  2. using DevExpress.Charts.Native;
  3. using DevExpress.Office.Drawing;
  4. using NPOI.Util;
  5. using OTSCommon.DBOperate;
  6. using OTSCommon.DBOperate.Model;
  7. using OTSIncAReportApp._2_CommonFunction.CommonClass;
  8. using OTSIncAReportApp.DataOperation.DataAccess;
  9. using OTSIncAReportApp.OTSRstMgrFunction;
  10. using OTSIncAReportGrids;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Data;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. using static OTSDataType.otsdataconst;
  18. using static OTSIncAReportApp.OTSReport_Export;
  19. namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
  20. {
  21. public class BasicData
  22. {
  23. ParticleData fielddata;
  24. private string SizeChart = "";
  25. List<string> colid = new List<string>();
  26. List<string> colid_Below7 = new List<string>();
  27. List<string> GroupInformation = new List<string>();
  28. private List<DataTable> BData = new List<DataTable>();
  29. private List<DataTable> Measurements = new List<DataTable>();//测量结果数据列队
  30. private DataTable spliceMeasurements = new DataTable();//拼接测量结果数据列队
  31. private DataTable AllClass = new DataTable();
  32. private DataTable AllElement = new DataTable();
  33. private bool IsShereAClassificationGroup = false;
  34. private ResultFile resfile;
  35. private string FilePath = "";
  36. private string VDA19String = "5,15,25,50,100,150,200,400,600,1000";
  37. //DataTable particlesAll;
  38. //DataTable userSTDDbData;
  39. /// <summary>
  40. /// 获取粒级表
  41. /// </summary>
  42. public void SetParticlesizeTable(OTSReport_Export m_otsreport_export)
  43. {
  44. colid_Below7.Clear();
  45. //获取粒级表
  46. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  47. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  48. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  49. SizeChart = ds.Tables[0].Rows[0]["Sizes"].ToString();
  50. for (int i = 0; i < SizeChart.Split(',').Length; i++)
  51. {
  52. if (SizeChart.Split(',')[i].Length > 0)
  53. {
  54. double d1 = Convert.ToDouble(SizeChart.Split(',')[i]);
  55. //double d2 = Convert.ToDouble(SizeChart.Split(',')[i + 1]);
  56. colid.Add("≥"+ d1.ToString() /*+ "~" + d2.ToString()*/);
  57. }
  58. }
  59. for (int i = 0; i < SizeChart.Split(',').Length - 1; i++)
  60. {
  61. if (SizeChart.Split(',')[i].Length > 0)
  62. {
  63. double d1 = Convert.ToDouble(SizeChart.Split(',')[i]);
  64. double d2 = Convert.ToDouble(SizeChart.Split(',')[i + 1]);
  65. colid_Below7.Add(d1.ToString() + "~" + d2.ToString());
  66. }
  67. }
  68. double d = Convert.ToDouble(SizeChart.Split(',')[SizeChart.Split(',').Length - 1]);
  69. colid_Below7.Add(d.ToString() + "~MAX");
  70. //double d = Convert.ToDouble(SizeChart.Split(',')[SizeChart.Split(',').Length - 1]);
  71. //colid.Add(d.ToString() + "~MAX");
  72. }
  73. /// <summary>
  74. /// 获取粒级表
  75. /// </summary>
  76. /// <returns></returns>
  77. public List<string> GetParticlesizeTable()
  78. {
  79. if(colid.Count>7)
  80. {
  81. return colid;
  82. }else
  83. {
  84. return colid_Below7;
  85. }
  86. }
  87. /// <summary>
  88. /// 获取拼接颗粒信息
  89. /// </summary>
  90. /// <returns></returns>
  91. public DataTable ObtainInformationOnSplicedParticles(OTSReport_Export m_otsreport_export)
  92. {
  93. DataTable userSTDDbData = new DataTable();
  94. DataTable particlesAll;
  95. ParticlesGridDevidePage particlesGridDevide = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);
  96. var systype = m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype;
  97. if (systype == OTS_SysType_ID.TCCleannessA || systype == OTS_SysType_ID.BatteryCleannessA)
  98. {
  99. string str_STDDbName = resfile.GetSTDName();
  100. particlesGridDevide.userSTDDb = new UserSTDDbAccess(str_STDDbName, resfile.FilePath + "\\");
  101. if (particlesGridDevide.userSTDDb.GetSqlHelper() != null)
  102. {
  103. userSTDDbData = particlesGridDevide.userSTDDb.GetSubAttributeFromDatabase();
  104. }
  105. else
  106. {
  107. userSTDDbData = null;
  108. }
  109. }
  110. particlesGridDevide.Particledata = new ParticleData(resfile.FilePath);
  111. DataTable qparticlesAll = particlesGridDevide.Particledata.GetInfoForPartucleDevidePage_mergeParticles("");
  112. particlesAll = SplicingParticleElementFilling(qparticlesAll, particlesGridDevide, userSTDDbData);
  113. return particlesAll;
  114. }
  115. public void SetDBData(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
  116. {
  117. DataTable m_bt_DBData = new DataTable();
  118. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  119. List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "GroupId", "con" };
  120. //获取粒级表
  121. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  122. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  123. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  124. string sizestr = "";
  125. if (m_mbszclass.M_VDA19.IsVDA19)
  126. sizestr = VDA19String;
  127. else
  128. sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  129. bool blBelow7 = false;
  130. if (sizestr.Split(',').Length>7)
  131. {
  132. for (int i = 0; i < sizestr.Split(',').Length; i++)
  133. {
  134. if (sizestr.Split(',')[i].Length > 0)
  135. {
  136. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  137. //double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  138. colid.Add("≥" + d1.ToString() /*+ "~" + d2.ToString()*/);
  139. }
  140. }
  141. blBelow7 = true;
  142. }
  143. else
  144. {
  145. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  146. {
  147. if (sizestr.Split(',')[i].Length > 0)
  148. {
  149. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  150. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  151. colid.Add(d1.ToString() + "~" + d2.ToString());
  152. }
  153. }
  154. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  155. colid.Add(d.ToString() + "~MAX");
  156. blBelow7 = false;
  157. }
  158. for (int i = 0; i < colid.Count; i++)
  159. {
  160. m_bt_DBData.Columns.Add(colid[i].ToString());
  161. }
  162. DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
  163. DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
  164. DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
  165. spliceMeasurements= InvalidRemoval(fielddata.GetSpliceParticleAll(""));
  166. DataTable particlesAll = ObtainInformationOnSplicedParticles(m_otsreport_export);//拼接颗粒信息
  167. #region 分割出需要删除的拼接前的颗粒
  168. List<string> listPicture = new List<string>();
  169. List<string> listPosition = new List<string>();
  170. for (int i = 0; i < particlesAll.Rows.Count; i++)
  171. {
  172. string detailedLocation = particlesAll.Rows[i]["SubParticles"].ToString();
  173. string[] fruits = detailedLocation.Split(',');
  174. for (int a = 0; a < fruits.Length; a++)
  175. {
  176. string[] fruit = fruits[a].Split(':');
  177. listPicture.Add(fruit[0]);
  178. listPosition.Add(fruit[1]);
  179. }
  180. }
  181. #endregion
  182. #region 清除拼接前的颗粒
  183. for (int i = dtp.Rows.Count - 1; i >= 0; i--)
  184. {
  185. for (int a = 0; a < listPicture.Count; a++)
  186. {
  187. if (dtp.Rows[i]["FieldId"].ToString() == listPicture[a].ToString() && dtp.Rows[i]["XrayId"].ToString() == listPosition[a].ToString())
  188. {
  189. dtp.Rows.RemoveAt(i);
  190. }
  191. }
  192. }
  193. #endregion
  194. string po = ComputeMode;
  195. switch (po)
  196. {
  197. case "DMAX":
  198. po = "DMAX";
  199. break;
  200. case "DMIN":
  201. po = "DMIN";
  202. break;
  203. case "ECD":
  204. po = "Area";
  205. break;
  206. case "FERET":
  207. po = "DFERET";
  208. break;
  209. }
  210. for (int i = 0; i < dt.Rows.Count; i++)
  211. {
  212. DataRow dr = m_bt_DBData.NewRow();
  213. dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
  214. dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
  215. dr["con"] = dt.Rows[i]["con"].ToString();
  216. dr["GroupId"] = dt.Rows[i]["GroupId"].ToString();
  217. if (dt.Rows[i]["GroupName"].ToString() == "")
  218. dr["Class"] = "Default";
  219. else
  220. dr["Class"] = dt.Rows[i]["GroupName"].ToString();
  221. //continue;
  222. dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
  223. if(blBelow7)
  224. {
  225. for (int a = 7; a < colid.Count; a++)
  226. {
  227. string d1 = colid[a].Split('≥')[1];
  228. string d2;
  229. if (a == colid.Count - 1)
  230. {
  231. d2 = "9999999999999";
  232. }
  233. else
  234. {
  235. d2 = colid[a + 1].Split('≥')[1];
  236. }
  237. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
  238. dr[colid[a]] = datas.Count();
  239. }
  240. }
  241. else
  242. {
  243. for (int a = 7; a < colid.Count; a++)
  244. {
  245. string d1 = colid[a].Split('~')[0];
  246. string d2 = colid[a].Split('~')[1];
  247. if (d2 == "MAX")
  248. {
  249. d2 = "999999999";
  250. }
  251. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
  252. dr[colid[a]] = datas.Count();
  253. }
  254. }
  255. for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
  256. {
  257. if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
  258. {
  259. dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
  260. }
  261. }
  262. m_bt_DBData.Rows.Add(dr);
  263. }
  264. //去除物质分类(非夹杂物分类)//颗粒种类ID赛选
  265. //for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial.Count; a++)
  266. //{
  267. // for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
  268. // {
  269. // if (m_bt_DBData.Rows[i]["TypeId"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial[a].ToString())
  270. // {
  271. // m_bt_DBData.Rows.RemoveAt(i);
  272. // }
  273. // }
  274. //}
  275. //去除物质分类(非夹杂物分类)//颗粒种类名称赛选
  276. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
  277. {
  278. for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
  279. {
  280. if (m_bt_DBData.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
  281. {
  282. m_bt_DBData.Rows.RemoveAt(i);
  283. }
  284. }
  285. }
  286. GroupInformation = new List<string>();
  287. for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
  288. {
  289. bool bl = false;
  290. for (int a = 0; a < GroupInformation.Count; a++)
  291. {
  292. if (GroupInformation[a] == m_bt_DBData.Rows[i]["Class"].ToString())
  293. {
  294. bl = true;
  295. }
  296. }
  297. if (!bl)
  298. {
  299. GroupInformation.Add(m_bt_DBData.Rows[i]["Class"].ToString());
  300. }
  301. }
  302. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype == OTS_SysType_ID.IncA)
  303. {
  304. Measurements = new List<DataTable>();
  305. for (int i = 0; i < GroupInformation.Count; i++)
  306. {
  307. DataTable table = m_bt_DBData.Clone();
  308. for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
  309. {
  310. if (GroupInformation[i] == m_bt_DBData.Rows[a]["Class"].ToString())
  311. {
  312. table.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
  313. }
  314. }
  315. BData.Add(table);
  316. }
  317. //Measurements = BData.Copy();
  318. for (int i = 0; i < GroupInformation.Count; i++)
  319. {
  320. DataTable table = dtp.Clone();
  321. for (int a = 0; a < dtp.Rows.Count; a++)
  322. {
  323. if (GroupInformation[i] == dtp.Rows[a]["GroupName"].ToString())
  324. {
  325. table.Rows.Add(dtp.Rows[a].ItemArray);
  326. }
  327. }
  328. Measurements.Add(table);
  329. }
  330. return;
  331. }
  332. #region 判断是否使用指定选择组和规则
  333. bool bl1 = false;
  334. for (int i = 0; i < m_otsreport_export.m_mbszclass.RuleGroup.Rows.Count; i++)
  335. {
  336. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[i]["GroupId"].ToString() == "0")
  337. {
  338. bl1 = true;
  339. }
  340. }
  341. #endregion
  342. if (!bl1)
  343. {
  344. #region 筛选现有组
  345. List<string> strings = new List<string>();
  346. for (int i = 0; i < m_bt_DBData.Rows.Count; i++)
  347. {
  348. bool bl2 = false;
  349. for (int a = 0; a < strings.Count; a++)
  350. {
  351. if (m_bt_DBData.Rows[i]["GroupId"].ToString() == strings[a])
  352. {
  353. bl2 = true;
  354. }
  355. }
  356. if (!bl2)
  357. {
  358. strings.Add(m_bt_DBData.Rows[i]["GroupId"].ToString());
  359. }
  360. }
  361. #endregion
  362. List<DataTable> OutData = new List<DataTable>();
  363. for (int i = 0; i < strings.Count(); i++)
  364. {
  365. DataTable data = m_bt_DBData.Clone();
  366. for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
  367. {
  368. if (strings[i] == m_bt_DBData.Rows[a]["GroupId"].ToString())
  369. {
  370. data.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
  371. }
  372. }
  373. OutData.Add(data);
  374. }
  375. BData = OutData.Copy();
  376. Measurements = new List<DataTable>();
  377. for (int i = 0; i < GroupInformation.Count; i++)
  378. {
  379. DataTable table = dtp.Clone();
  380. for (int a = 0; a < dtp.Rows.Count; a++)
  381. {
  382. string strGroupId = "Default";
  383. if (dtp.Rows[a]["GroupName"].ToString() != "")
  384. {
  385. strGroupId = dtp.Rows[a]["GroupName"].ToString();
  386. }
  387. if (GroupInformation[i] == strGroupId)
  388. {
  389. table.Rows.Add(dtp.Rows[a].ItemArray);
  390. }
  391. }
  392. Measurements.Add(table);
  393. }
  394. return;
  395. }
  396. List<DataTable> SpecifyGroup = new List<DataTable>();
  397. for (int i = 0; i < m_otsreport_export.m_mbszclass.List_data.Count; i++)
  398. {
  399. DataTable data= m_bt_DBData.Clone();
  400. bool b3 = false;
  401. string str_class = "";
  402. for (int a = 0; a < m_otsreport_export.m_mbszclass.RuleGroup.Rows.Count; a++)
  403. {
  404. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["GroupId"].ToString() == m_otsreport_export.m_mbszclass.List_data[i].TableName)
  405. {
  406. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["display"].ToString() == "1")
  407. {
  408. str_class = m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["GroupName"].ToString();
  409. b3 = true;
  410. }
  411. }
  412. }
  413. data.TableName = m_otsreport_export.m_mbszclass.List_data[i].TableName;
  414. if (b3)
  415. {
  416. for (int a = 0; a < m_otsreport_export.m_mbszclass.List_data[i].Rows.Count; a++)
  417. {
  418. if (m_otsreport_export.m_mbszclass.List_data[i].Rows[a]["display"].ToString() == "1")
  419. {
  420. DataTable data1 = m_bt_DBData.Clone();
  421. DataRow row = data.NewRow();
  422. row["TypeName"] = m_otsreport_export.m_mbszclass.List_data[i].Rows[a]["StrName"];
  423. row["ar"] = 0;
  424. row["TypeId"] = m_otsreport_export.m_mbszclass.List_data[i].Rows[a]["STDId"];
  425. row["GroupId"] = m_otsreport_export.m_mbszclass.List_data[i].Rows[a]["GroupId"];
  426. row["con"] = 0;
  427. row["Largest"] = 0;
  428. row["Class"] = str_class;
  429. for (int j = 7; j < data.Columns.Count; j++)
  430. {
  431. row[j] = 0;
  432. }
  433. bool b2 = false;
  434. for (int j = 0; j < m_bt_DBData.Rows.Count; j++)
  435. {
  436. if (m_otsreport_export.m_mbszclass.List_data[i].Rows[a]["STDId"].ToString() == m_bt_DBData.Rows[j]["TypeId"].ToString())
  437. {
  438. data1.Rows.Add(m_bt_DBData.Rows[j].ItemArray);
  439. b2 = true;
  440. }
  441. }
  442. if (b2)
  443. {
  444. data.Rows.Add(data1.Rows[0].ItemArray);
  445. }
  446. else
  447. {
  448. data.Rows.Add(row);
  449. }
  450. }
  451. }
  452. }
  453. SpecifyGroup.Add(data);
  454. }
  455. BData = SpecifyGroup.Copy();
  456. #region 测量结果颗粒组队列
  457. List<DataTable> datas1 = new List<DataTable>();
  458. ResultFile rstf = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
  459. UserSTDDbAccess dbAccess = new UserSTDDbAccess(rstf.GetSTDName(),rstf.FilePath);
  460. List<string> stringsa = dbAccess.ObtainParticleCategory(m_otsreport_export, this);
  461. for (int i = 0; i < stringsa.Count; i++)
  462. {
  463. DataTable data = dtp.Clone();
  464. for (int a = 0; a < dtp.Rows.Count; a++)
  465. {
  466. if (Convert.ToInt64(dtp.Rows[i]["TypeId"]) > 10)
  467. {
  468. string strGroupName = "Default";
  469. if (dtp.Rows[a]["GroupName"].ToString() != "")
  470. {
  471. strGroupName = dtp.Rows[a]["GroupName"].ToString();
  472. }
  473. if (stringsa[i].ToString() == strGroupName)
  474. {
  475. data.Rows.Add(dtp.Rows[a].ItemArray);
  476. }
  477. }
  478. }
  479. datas1.Add(data);
  480. }
  481. Measurements = new List<DataTable>();
  482. for (int i = 0; i < m_otsreport_export.m_mbszclass.List_data.Count; i++)
  483. {
  484. bool b3 = false;
  485. string str_class = "";
  486. for (int a = 0; a < m_otsreport_export.m_mbszclass.RuleGroup.Rows.Count; a++)
  487. {
  488. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["GroupId"].ToString() == m_otsreport_export.m_mbszclass.List_data[i].TableName)
  489. {
  490. if (m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["display"].ToString() == "1")
  491. {
  492. str_class = m_otsreport_export.m_mbszclass.RuleGroup.Rows[a]["GroupName"].ToString();
  493. b3 = true;
  494. }
  495. }
  496. }
  497. if (b3)
  498. {
  499. DataTable table = datas1[i].Clone();
  500. for (int a = 0; a < datas1[i].Rows.Count; a++)
  501. {
  502. for (int b = 0; b < m_otsreport_export.m_mbszclass.List_data[i].Rows.Count; b++)
  503. {
  504. if (m_otsreport_export.m_mbszclass.List_data[i].Rows[b]["display"].ToString() == "1")
  505. {
  506. if (datas1[i].Rows[a]["TypeId"].ToString() == m_otsreport_export.m_mbszclass.List_data[i].Rows[b]["STDId"].ToString())
  507. {
  508. table.Rows.Add(datas1[i].Rows[a].ItemArray);
  509. }
  510. }
  511. }
  512. }
  513. Measurements.Add(table);
  514. }
  515. }
  516. #endregion
  517. }
  518. /// <summary>
  519. /// 拼接颗粒元素填充
  520. /// </summary>
  521. /// <param name="data"></param>
  522. /// <returns></returns>
  523. private DataTable SplicingParticleElementFilling(DataTable a_particlesAll, ParticlesGridDevidePage particlesGridDevide, DataTable userSTDDbData)
  524. {
  525. a_particlesAll.Columns.Add("Hardness");
  526. a_particlesAll.Columns.Add("Density");
  527. a_particlesAll.Columns.Add("Electrical_conductivity");
  528. if (userSTDDbData.Rows.Count > 0)
  529. {
  530. for (int i = 0; i < a_particlesAll.Rows.Count; i++)
  531. {
  532. DataRow[] dr = userSTDDbData.Select("STDId=" + a_particlesAll.Rows[i]["TypeId"].ToString());
  533. if (dr.Length > 0)
  534. {
  535. a_particlesAll.Rows[i]["Hardness"] = dr[0]["Hardness"].ToString();
  536. a_particlesAll.Rows[i]["Density"] = dr[0]["Density"].ToString();
  537. a_particlesAll.Rows[i]["Electrical_conductivity"] = dr[0]["Electrical_conductivity"].ToString();
  538. }
  539. else
  540. {
  541. a_particlesAll.Rows[i]["Hardness"] = "";
  542. a_particlesAll.Rows[i]["Density"] = "";
  543. a_particlesAll.Rows[i]["Electrical_conductivity"] = "";
  544. }
  545. }
  546. }
  547. else
  548. {
  549. for (int i = 0; i < a_particlesAll.Rows.Count; i++)
  550. {
  551. a_particlesAll.Rows[i]["Hardness"] = "";
  552. a_particlesAll.Rows[i]["Density"] = "";
  553. a_particlesAll.Rows[i]["Electrical_conductivity"] = "";
  554. }
  555. }
  556. DataTable elementchemistry = particlesGridDevide.Particledata.GetElementChemistry();
  557. for (int i = 0; i < a_particlesAll.Rows.Count; i++)
  558. {
  559. string str = "XRayId = " + a_particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + a_particlesAll.Rows[i]["fieldid"].ToString();
  560. DataRow[] drs = elementchemistry.Select(str);
  561. string ConcatenatedString = "";
  562. for (int j = 0; j < drs.Length; j++)
  563. {
  564. ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
  565. }
  566. a_particlesAll.Rows[i]["Element"] = ConcatenatedString;
  567. }
  568. a_particlesAll.Columns.Add("XRayDataCount");
  569. DataTable XRayData = particlesGridDevide.Particledata.GetXRayData();
  570. for (int i = 0; i < a_particlesAll.Rows.Count; i++)
  571. {
  572. string subt = a_particlesAll.Rows[i]["SubParticles"].ToString();
  573. if (subt == "")
  574. {
  575. a_particlesAll.Rows[i]["XRayDataCount"] = 0;
  576. string str = " XrayIndex= " + a_particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + a_particlesAll.Rows[i]["fieldid"].ToString();
  577. DataRow[] drs = XRayData.Select(str);
  578. uint xraycount = 0;
  579. if (drs != null)
  580. {
  581. if (drs.Length > 0)
  582. {
  583. uint[] Analysis_xray = new uint[2000];
  584. for (int j = 0; j < 2000; j++)
  585. {
  586. Analysis_xray[j] = BitConverter.ToUInt32((byte[])drs[0][2], j * 4);
  587. }
  588. for (int j = 0; j < 2000; j++)
  589. {
  590. xraycount += Analysis_xray[j];
  591. }
  592. a_particlesAll.Rows[i]["XRayDataCount"] = xraycount;
  593. }
  594. }
  595. }
  596. else
  597. {
  598. a_particlesAll.Rows[i]["XRayDataCount"] = 0;
  599. DataRow dgvr = a_particlesAll.Rows[i];
  600. uint[] Search_xray = new uint[2000];
  601. uint[] Analysis_xray = new uint[2000];
  602. particlesGridDevide.Particledata.GetXrayByParticleTagIDAndFieldID_ForMergeParticle(Convert.ToInt32(dgvr["particleId"]), Convert.ToInt32(dgvr["fieldid"]), out Analysis_xray);
  603. uint xraycount = 0;
  604. for (int j = 0; j < 2000; j++)
  605. {
  606. xraycount += Analysis_xray[j];
  607. }
  608. a_particlesAll.Rows[i]["XRayDataCount"] = xraycount;
  609. }
  610. }
  611. return a_particlesAll;
  612. }
  613. /// <summary>
  614. /// 获取夹杂物组信息
  615. /// </summary>
  616. /// <returns></returns>
  617. public List<string> GetGroupInformation()
  618. {
  619. return GroupInformation;
  620. }
  621. /// <summary>
  622. /// 获取读取数据库并过滤颗粒
  623. /// </summary>
  624. /// <returns></returns>
  625. public List<DataTable> GetDBData()
  626. {
  627. return BData;
  628. }
  629. /// <summary>
  630. /// 获取读取数据库并过滤颗粒
  631. /// </summary>
  632. /// <returns></returns>
  633. public List<DataTable> etDBData()
  634. {
  635. return BData;
  636. }
  637. public void SetAllClass()
  638. {
  639. AllClass = fielddata.GetAllClass();
  640. }
  641. /// <summary>
  642. /// 获取全部大类
  643. /// </summary>
  644. /// <returns></returns>
  645. public DataTable GetAllClass()
  646. {
  647. return AllClass;
  648. }
  649. /// <summary>
  650. ///测量结果数据列队
  651. /// </summary>
  652. /// <returns></returns>
  653. public List<DataTable> GetMeasurements()
  654. {
  655. return Measurements;
  656. }
  657. /// <summary>
  658. ///拼接测量结果数据列队
  659. /// </summary>
  660. /// <returns></returns>
  661. public DataTable GetSpliceMeasurements()
  662. {
  663. return spliceMeasurements;
  664. }
  665. /// <summary>
  666. /// 定义ParticleData类
  667. /// </summary>
  668. public void newParticleData(OTSReport_Export m_otsreport_export)
  669. {
  670. fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  671. }
  672. public ParticleData getParticleData()
  673. {
  674. return fielddata;
  675. }
  676. public void SetAllElement()
  677. {
  678. AllElement = fielddata.GetAllElement();
  679. }
  680. /// <summary>
  681. /// 获取全部元素
  682. /// </summary>
  683. /// <returns></returns>
  684. public DataTable GetAllElement()
  685. {
  686. return AllElement;
  687. }
  688. /// <summary>
  689. /// 判断是否有大分类,有为true
  690. /// </summary>
  691. /// <param name="m_otsreport_export"></param>
  692. /// <returns></returns>
  693. public void IsThereAMajorClassification(BasicData basicData, OTSReport_Export m_otsreport_export)
  694. {
  695. //List<string> ClassName = ObtainParticleCategory(m_otsreport_export, basicData);
  696. List<string> ClassName = new List<string>();
  697. for (int i = 0; i < BData.Count; i++)
  698. {
  699. if (BData[i].Rows.Count != 0)
  700. {
  701. ClassName.Add(i.ToString());
  702. }
  703. }
  704. if (ClassName.Count < 2)
  705. {
  706. IsShereAClassificationGroup= false;
  707. }
  708. else
  709. {
  710. IsShereAClassificationGroup= true;
  711. }
  712. }
  713. public bool GetIsThereAMajorClassification()
  714. {
  715. return IsShereAClassificationGroup;
  716. }
  717. public void IsResultFilesList(OTSReport_Export m_otsreport_export)
  718. {
  719. resfile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()];
  720. }
  721. /// <summary>
  722. /// 获取标准库名称
  723. /// </summary>
  724. /// <returns></returns>
  725. public string GetResfile()
  726. {
  727. string str_libraryName = "";
  728. bool endsWithDb = resfile.GetSTDName().EndsWith(".db", StringComparison.OrdinalIgnoreCase);
  729. if (endsWithDb)
  730. {
  731. str_libraryName = resfile.GetSTDName();
  732. }
  733. else
  734. {
  735. str_libraryName = resfile.GetSTDName() + ".db";
  736. }
  737. return str_libraryName;
  738. }
  739. public void IsFilePath(OTSReport_Export m_otsreport_export)
  740. {
  741. FilePath= m_otsreport_export.m_ReportApp.m_rstDataMgr.CurResultFile.FilePath;
  742. }
  743. /// <summary>
  744. /// 得到文件路径
  745. /// </summary>
  746. /// <returns></returns>
  747. public string GetFilePath()
  748. {
  749. return FilePath;
  750. }
  751. #region 内部函数
  752. private string getWhere(string max, string min, string col, string partic)
  753. {
  754. if (col == "Area")
  755. {
  756. return col + ">=" + ((Convert.ToDouble(min) / 2) * (Convert.ToDouble(min) / 2) * Math.PI).ToString() + " and " + col + "<" + ((Convert.ToDouble(max) / 2) * (Convert.ToDouble(max) / 2) * Math.PI).ToString() + " and TypeId=" + partic;
  757. }
  758. else
  759. {
  760. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  761. }
  762. }
  763. private DataTable InvalidRemoval(DataTable dt)
  764. {
  765. DataTable dataTable = dt.Copy();
  766. dataTable.Clear();
  767. for (int i = 0; i < dt.Rows.Count; i++)
  768. {
  769. if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 10)
  770. {
  771. dataTable.Rows.Add(dt.Rows[i].ItemArray);
  772. }
  773. }
  774. return dataTable;
  775. }
  776. #endregion
  777. }
  778. }