ParticleAnalysis.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157
  1. 
  2. using OTSCommon.Model;
  3. using OTSIncAReportApp.DataOperation.DataAccess;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using static OTSIncAReportApp.OTSReport_Export;
  11. namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
  12. {
  13. /// <summary>
  14. /// 颗粒分析
  15. /// </summary>
  16. class ParticleAnalysis
  17. {
  18. /// <summary>
  19. /// 大分类
  20. /// </summary>
  21. /// <returns></returns>
  22. public DataTable GetLargeClassification(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  23. {
  24. DataTable data = GetDBData(m_mbszclass, m_otsreport_export);
  25. List<string> colid = new List<string>();
  26. //获取粒级表
  27. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  28. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  29. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  30. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  31. {
  32. if (sizestr.Split(',')[i].Length > 0)
  33. {
  34. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  35. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  36. colid.Add(d1.ToString() + "~" + d2.ToString());
  37. }
  38. }
  39. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  40. colid.Add(d.ToString() + "~MAX");
  41. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  42. DataTable ls_partsize_dt = new DataTable();
  43. ls_partsize_dt.TableName = "PartSize";
  44. ls_partsize_dt.Columns.Add("c1");
  45. ls_partsize_dt.Columns.Add("c2");
  46. ls_partsize_dt.Columns.Add("c3");
  47. ls_partsize_dt.Columns.Add("c4");
  48. ls_partsize_dt.Columns.Add("c5");
  49. ls_partsize_dt.Columns.Add("c6");
  50. ls_partsize_dt.Columns.Add("c7");
  51. ls_partsize_dt.Columns.Add("c8");
  52. ls_partsize_dt.Columns.Add("c9");
  53. DataRow dr = ls_partsize_dt.NewRow();
  54. for (int i = 1; i < 10; i++)
  55. {
  56. if (colid.Count < i)
  57. {
  58. dr["c" + i.ToString()] = "";
  59. }
  60. else
  61. {
  62. dr["c" + i.ToString()] = colid[i - 1];
  63. }
  64. }
  65. ls_partsize_dt.Rows.Add(dr);
  66. DataTable ls_Particel_dt = new DataTable();
  67. ls_Particel_dt.TableName = "Particel";
  68. ls_Particel_dt.Columns.Add("c1", typeof(double));
  69. ls_Particel_dt.Columns.Add("c2", typeof(double));
  70. ls_Particel_dt.Columns.Add("c3", typeof(double));
  71. ls_Particel_dt.Columns.Add("c4", typeof(double));
  72. ls_Particel_dt.Columns.Add("c5", typeof(double));
  73. ls_Particel_dt.Columns.Add("c6", typeof(double));
  74. ls_Particel_dt.Columns.Add("c7", typeof(double));
  75. ls_Particel_dt.Columns.Add("c8", typeof(double));
  76. ls_Particel_dt.Columns.Add("c9", typeof(double));
  77. ls_Particel_dt.Columns.Add("Name");
  78. ls_Particel_dt.Columns.Add("total", typeof(double));
  79. ls_Particel_dt.Columns.Add("TypeId");
  80. ls_Particel_dt.Columns.Add("Class");
  81. for (int i = 0; i < data.Rows.Count; i++)
  82. {
  83. DataRow dr2 = ls_Particel_dt.NewRow();
  84. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  85. dr2["Class"] = data.Rows[i]["Class"].ToString();
  86. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  87. for (int j = 1; j < 10; j++)
  88. {
  89. if (colid.Count >= j)
  90. {
  91. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  92. }
  93. }
  94. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  95. {
  96. dr2["total"] = "0"; //求合
  97. double d_total = 0;
  98. for (int j = 1; j < 10; j++)
  99. {
  100. if (colid.Count >= j)
  101. {
  102. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  103. }
  104. }
  105. dr2["total"] = d_total.ToString();
  106. }
  107. ls_Particel_dt.Rows.Add(dr2);
  108. }
  109. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  110. List<string> ClassName = new List<string>();
  111. DataTable getClass_dt = fielddata.GetAllClass();
  112. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  113. {
  114. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  115. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  116. ClassName.Add("NULL");
  117. else
  118. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  119. }
  120. //获取大分类信息
  121. DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
  122. return dt;
  123. }
  124. /// <summary>
  125. /// 小分类
  126. /// </summary>
  127. /// <returns></returns>
  128. public DataTable GetSubClassification(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  129. {
  130. DataTable data = GetDBData(m_mbszclass, m_otsreport_export);
  131. List<string> colid = new List<string>();
  132. //获取粒级表
  133. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  134. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  135. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  136. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  137. {
  138. if (sizestr.Split(',')[i].Length > 0)
  139. {
  140. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  141. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  142. colid.Add(d1.ToString() + "~" + d2.ToString());
  143. }
  144. }
  145. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  146. colid.Add(d.ToString() + "~MAX");
  147. //------------------------------------------------
  148. DataTable ls_partsize_dt = new DataTable();
  149. ls_partsize_dt.TableName = "PartSize";
  150. ls_partsize_dt.Columns.Add("c1");
  151. ls_partsize_dt.Columns.Add("c2");
  152. ls_partsize_dt.Columns.Add("c3");
  153. ls_partsize_dt.Columns.Add("c4");
  154. ls_partsize_dt.Columns.Add("c5");
  155. ls_partsize_dt.Columns.Add("c6");
  156. ls_partsize_dt.Columns.Add("c7");
  157. ls_partsize_dt.Columns.Add("c8");
  158. ls_partsize_dt.Columns.Add("c9");
  159. DataRow dr = ls_partsize_dt.NewRow();
  160. for (int i = 1; i < 10; i++)
  161. {
  162. if (colid.Count < i)
  163. {
  164. dr["c" + i.ToString()] = "";
  165. }
  166. else
  167. {
  168. dr["c" + i.ToString()] = colid[i - 1];
  169. }
  170. }
  171. ls_partsize_dt.Rows.Add(dr);
  172. DataTable ls_Particel_dt = new DataTable();
  173. ls_Particel_dt.TableName = "Particel";
  174. ls_Particel_dt.Columns.Add("c1", typeof(double));
  175. ls_Particel_dt.Columns.Add("c2", typeof(double));
  176. ls_Particel_dt.Columns.Add("c3", typeof(double));
  177. ls_Particel_dt.Columns.Add("c4", typeof(double));
  178. ls_Particel_dt.Columns.Add("c5", typeof(double));
  179. ls_Particel_dt.Columns.Add("c6", typeof(double));
  180. ls_Particel_dt.Columns.Add("c7", typeof(double));
  181. ls_Particel_dt.Columns.Add("c8", typeof(double));
  182. ls_Particel_dt.Columns.Add("c9", typeof(double));
  183. ls_Particel_dt.Columns.Add("Name");
  184. ls_Particel_dt.Columns.Add("total", typeof(double));
  185. ls_Particel_dt.Columns.Add("TypeId");
  186. ls_Particel_dt.Columns.Add("Class");
  187. for (int i = 0; i < data.Rows.Count; i++)
  188. {
  189. DataRow dr2 = ls_Particel_dt.NewRow();
  190. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  191. dr2["Class"] = data.Rows[i]["Class"].ToString();
  192. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  193. for (int j = 1; j < 10; j++)
  194. {
  195. if (colid.Count >= j)
  196. {
  197. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  198. }
  199. }
  200. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  201. {
  202. dr2["total"] = "0"; //求合
  203. double d_total = 0;
  204. for (int j = 1; j < 10; j++)
  205. {
  206. if (colid.Count >= j)
  207. {
  208. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  209. }
  210. }
  211. dr2["total"] = d_total.ToString();
  212. }
  213. ls_Particel_dt.Rows.Add(dr2);
  214. }
  215. return ls_Particel_dt;
  216. }
  217. /// <summary>
  218. /// 分类整合大小分类都有
  219. /// </summary>
  220. /// <returns></returns>
  221. public List<DataTable> GetClassificationConsolidationTable(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  222. {
  223. List<DataTable> datas = new List<DataTable>();
  224. DataTable data = GetDBData(m_mbszclass, m_otsreport_export);
  225. List<string> colid = new List<string>();
  226. //获取粒级表
  227. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  228. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  229. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  230. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  231. {
  232. if (sizestr.Split(',')[i].Length > 0)
  233. {
  234. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  235. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  236. colid.Add(d1.ToString() + "~" + d2.ToString());
  237. }
  238. }
  239. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  240. colid.Add(d.ToString() + "~MAX");
  241. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  242. //------------------------------------------------
  243. DataTable ls_partsize_dt = new DataTable();
  244. ls_partsize_dt.TableName = "PartSize";
  245. ls_partsize_dt.Columns.Add("c1");
  246. ls_partsize_dt.Columns.Add("c2");
  247. ls_partsize_dt.Columns.Add("c3");
  248. ls_partsize_dt.Columns.Add("c4");
  249. ls_partsize_dt.Columns.Add("c5");
  250. ls_partsize_dt.Columns.Add("c6");
  251. ls_partsize_dt.Columns.Add("c7");
  252. ls_partsize_dt.Columns.Add("c8");
  253. ls_partsize_dt.Columns.Add("c9");
  254. DataRow dr = ls_partsize_dt.NewRow();
  255. for (int i = 1; i < 10; i++)
  256. {
  257. if (colid.Count < i)
  258. {
  259. dr["c" + i.ToString()] = "";
  260. }
  261. else
  262. {
  263. dr["c" + i.ToString()] = colid[i - 1];
  264. }
  265. }
  266. ls_partsize_dt.Rows.Add(dr);
  267. DataTable ls_Particel_dt = new DataTable();
  268. ls_Particel_dt.TableName = "Particel";
  269. ls_Particel_dt.Columns.Add("c1", typeof(double));
  270. ls_Particel_dt.Columns.Add("c2", typeof(double));
  271. ls_Particel_dt.Columns.Add("c3", typeof(double));
  272. ls_Particel_dt.Columns.Add("c4", typeof(double));
  273. ls_Particel_dt.Columns.Add("c5", typeof(double));
  274. ls_Particel_dt.Columns.Add("c6", typeof(double));
  275. ls_Particel_dt.Columns.Add("c7", typeof(double));
  276. ls_Particel_dt.Columns.Add("c8", typeof(double));
  277. ls_Particel_dt.Columns.Add("c9", typeof(double));
  278. ls_Particel_dt.Columns.Add("Name");
  279. ls_Particel_dt.Columns.Add("total", typeof(double));
  280. ls_Particel_dt.Columns.Add("TypeId");
  281. ls_Particel_dt.Columns.Add("Class");
  282. for (int i = 0; i < data.Rows.Count; i++)
  283. {
  284. DataRow dr2 = ls_Particel_dt.NewRow();
  285. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  286. dr2["Class"] = data.Rows[i]["Class"].ToString();
  287. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  288. for (int j = 1; j < 10; j++)
  289. {
  290. if (colid.Count >= j)
  291. {
  292. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  293. }
  294. }
  295. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  296. {
  297. dr2["total"] = "0"; //求合
  298. double d_total = 0;
  299. for (int j = 1; j < 10; j++)
  300. {
  301. if (colid.Count >= j)
  302. {
  303. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  304. }
  305. }
  306. dr2["total"] = d_total.ToString();
  307. }
  308. ls_Particel_dt.Rows.Add(dr2);
  309. }
  310. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  311. List<string> ClassName = new List<string>();
  312. DataTable getClass_dt = fielddata.GetAllClass();
  313. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  314. {
  315. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
  316. && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
  317. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  318. ClassName.Add("Default");
  319. else
  320. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  321. }
  322. //获取大分类信息
  323. DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
  324. DataTable data2 = classIfIcationSort(ls_Particel_dt, ClassName, dt);
  325. datas.Add(ls_partsize_dt.Copy());
  326. datas.Add(data2.Copy());
  327. return datas;
  328. }
  329. /// <summary>
  330. /// 判断是否有大分类,有为true
  331. /// </summary>
  332. /// <param name="m_otsreport_export"></param>
  333. /// <returns></returns>
  334. public bool IsThereAMajorClassification(OTSReport_Export m_otsreport_export)
  335. {
  336. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  337. DataTable getClass_dt = fielddata.GetAllClass();
  338. List<string> ClassName = new List<string>();
  339. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  340. {
  341. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
  342. && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
  343. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  344. ClassName.Add("Default");
  345. else
  346. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  347. }
  348. if (ClassName.Count < 2)
  349. {
  350. return false;
  351. }
  352. else
  353. {
  354. return true;
  355. }
  356. }
  357. /// <summary>
  358. /// 大分类chart数据
  359. /// </summary>
  360. /// <param name="m_mbszclass"></param>
  361. /// <param name="m_otsreport_export"></param>
  362. /// <returns></returns>
  363. public DataTable GetChartDataCalss(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  364. {
  365. DataTable data = GetDBData(m_mbszclass, m_otsreport_export);
  366. List<string> colid = new List<string>();
  367. //获取粒级表
  368. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  369. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  370. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  371. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  372. {
  373. if (sizestr.Split(',')[i].Length > 0)
  374. {
  375. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  376. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  377. colid.Add(d1.ToString() + "~" + d2.ToString());
  378. }
  379. }
  380. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  381. colid.Add(d.ToString() + "~MAX");
  382. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  383. //------------------------------------------------
  384. DataTable ls_partsize_dt = new DataTable();
  385. ls_partsize_dt.TableName = "PartSize";
  386. ls_partsize_dt.Columns.Add("c1");
  387. ls_partsize_dt.Columns.Add("c2");
  388. ls_partsize_dt.Columns.Add("c3");
  389. ls_partsize_dt.Columns.Add("c4");
  390. ls_partsize_dt.Columns.Add("c5");
  391. ls_partsize_dt.Columns.Add("c6");
  392. ls_partsize_dt.Columns.Add("c7");
  393. ls_partsize_dt.Columns.Add("c8");
  394. ls_partsize_dt.Columns.Add("c9");
  395. DataRow dr = ls_partsize_dt.NewRow();
  396. for (int i = 1; i < 10; i++)
  397. {
  398. if (colid.Count < i)
  399. {
  400. dr["c" + i.ToString()] = "";
  401. }
  402. else
  403. {
  404. dr["c" + i.ToString()] = colid[i - 1];
  405. }
  406. }
  407. ls_partsize_dt.Rows.Add(dr);
  408. DataTable ls_Particel_dt = new DataTable();
  409. ls_Particel_dt.TableName = "Particel";
  410. ls_Particel_dt.Columns.Add("c1", typeof(double));
  411. ls_Particel_dt.Columns.Add("c2", typeof(double));
  412. ls_Particel_dt.Columns.Add("c3", typeof(double));
  413. ls_Particel_dt.Columns.Add("c4", typeof(double));
  414. ls_Particel_dt.Columns.Add("c5", typeof(double));
  415. ls_Particel_dt.Columns.Add("c6", typeof(double));
  416. ls_Particel_dt.Columns.Add("c7", typeof(double));
  417. ls_Particel_dt.Columns.Add("c8", typeof(double));
  418. ls_Particel_dt.Columns.Add("c9", typeof(double));
  419. ls_Particel_dt.Columns.Add("Name");
  420. ls_Particel_dt.Columns.Add("total", typeof(double));
  421. ls_Particel_dt.Columns.Add("TypeId");
  422. ls_Particel_dt.Columns.Add("Class");
  423. for (int i = 0; i < data.Rows.Count; i++)
  424. {
  425. DataRow dr2 = ls_Particel_dt.NewRow();
  426. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  427. dr2["Class"] = data.Rows[i]["Class"].ToString();
  428. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  429. for (int j = 1; j < 10; j++)
  430. {
  431. if (colid.Count >= j)
  432. {
  433. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  434. }
  435. }
  436. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  437. {
  438. dr2["total"] = "0"; //求合
  439. double d_total = 0;
  440. for (int j = 1; j < 10; j++)
  441. {
  442. if (colid.Count >= j)
  443. {
  444. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  445. }
  446. }
  447. dr2["total"] = d_total.ToString();
  448. }
  449. ls_Particel_dt.Rows.Add(dr2);
  450. }
  451. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  452. List<string> ClassName = new List<string>();
  453. DataTable getClass_dt = fielddata.GetAllClass();
  454. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  455. {
  456. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  457. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  458. ClassName.Add("NULL");
  459. else
  460. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  461. }
  462. //颗粒尺寸数据(例 1.5有多少,2.0有多少)
  463. DataTable colid_data = new DataTable();
  464. colid_data.Columns.Add("name");
  465. colid_data.Columns.Add("quantity", typeof(double));
  466. for (int i = 0; i < ls_Particel_dt.Columns.Count; i++)
  467. {
  468. if (ls_Particel_dt.Columns[i].ColumnName == "c" + (i + 1).ToString())
  469. {
  470. if (i < colid.Count)
  471. {
  472. DataRow dr1 = colid_data.NewRow();
  473. dr1["name"] = colid[i].ToString();
  474. int quantity = 0;
  475. for (int a = 0; a < ls_Particel_dt.Rows.Count; a++)
  476. {
  477. quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString());
  478. }
  479. dr1["quantity"] = quantity.ToString();
  480. colid_data.Rows.Add(dr1);
  481. }
  482. }
  483. }
  484. return colid_data;
  485. }
  486. /// <summary>
  487. /// 小分类chart数据
  488. /// </summary>
  489. /// <param name="m_mbszclass"></param>
  490. /// <param name="m_otsreport_export"></param>
  491. /// <returns></returns>
  492. public DataTable GetChartDataSubdivision(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  493. {
  494. DataTable data = GetDBData(m_mbszclass, m_otsreport_export);
  495. List<string> colid = new List<string>();
  496. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  497. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  498. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  499. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  500. {
  501. if (sizestr.Split(',')[i].Length > 0)
  502. {
  503. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  504. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  505. colid.Add(d1.ToString() + "~" + d2.ToString());
  506. }
  507. }
  508. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  509. colid.Add(d.ToString() + "~MAX");
  510. //------------------------------------------------
  511. DataTable ls_partsize_dt = new DataTable();
  512. ls_partsize_dt.TableName = "PartSize";
  513. ls_partsize_dt.Columns.Add("c1");
  514. ls_partsize_dt.Columns.Add("c2");
  515. ls_partsize_dt.Columns.Add("c3");
  516. ls_partsize_dt.Columns.Add("c4");
  517. ls_partsize_dt.Columns.Add("c5");
  518. ls_partsize_dt.Columns.Add("c6");
  519. ls_partsize_dt.Columns.Add("c7");
  520. ls_partsize_dt.Columns.Add("c8");
  521. ls_partsize_dt.Columns.Add("c9");
  522. DataRow dr = ls_partsize_dt.NewRow();
  523. for (int i = 1; i < 10; i++)
  524. {
  525. if (colid.Count < i)
  526. {
  527. dr["c" + i.ToString()] = "";
  528. }
  529. else
  530. {
  531. dr["c" + i.ToString()] = colid[i - 1];
  532. }
  533. }
  534. ls_partsize_dt.Rows.Add(dr);
  535. DataTable ls_Particel_dt = new DataTable();
  536. ls_Particel_dt.TableName = "Particel";
  537. ls_Particel_dt.Columns.Add("c1", typeof(double));
  538. ls_Particel_dt.Columns.Add("c2", typeof(double));
  539. ls_Particel_dt.Columns.Add("c3", typeof(double));
  540. ls_Particel_dt.Columns.Add("c4", typeof(double));
  541. ls_Particel_dt.Columns.Add("c5", typeof(double));
  542. ls_Particel_dt.Columns.Add("c6", typeof(double));
  543. ls_Particel_dt.Columns.Add("c7", typeof(double));
  544. ls_Particel_dt.Columns.Add("c8", typeof(double));
  545. ls_Particel_dt.Columns.Add("c9", typeof(double));
  546. ls_Particel_dt.Columns.Add("Name");
  547. ls_Particel_dt.Columns.Add("total", typeof(double));
  548. ls_Particel_dt.Columns.Add("TypeId");
  549. ls_Particel_dt.Columns.Add("Class");
  550. for (int i = 0; i < data.Rows.Count; i++)
  551. {
  552. DataRow dr2 = ls_Particel_dt.NewRow();
  553. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  554. dr2["Class"] = data.Rows[i]["Class"].ToString();
  555. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  556. for (int j = 1; j < 10; j++)
  557. {
  558. if (colid.Count >= j)
  559. {
  560. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  561. }
  562. }
  563. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  564. {
  565. dr2["total"] = "0"; //求合
  566. double d_total = 0;
  567. for (int j = 1; j < 10; j++)
  568. {
  569. if (colid.Count >= j)
  570. {
  571. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  572. }
  573. }
  574. dr2["total"] = d_total.ToString();
  575. }
  576. ls_Particel_dt.Rows.Add(dr2);
  577. }
  578. return ls_Particel_dt;
  579. }
  580. public DataTable ParticleResults(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  581. {
  582. DataTable data = GetDBData(m_mbszclass, m_otsreport_export);
  583. List<string> colid = new List<string>();
  584. //获取粒级表
  585. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  586. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  587. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  588. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  589. {
  590. if (sizestr.Split(',')[i].Length > 0)
  591. {
  592. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  593. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  594. colid.Add(d1.ToString() + "~" + d2.ToString());
  595. }
  596. }
  597. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  598. colid.Add(d.ToString() + "~MAX");
  599. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  600. //------------------------------------------------
  601. DataTable ls_partsize_dt = new DataTable();
  602. ls_partsize_dt.TableName = "PartSize";
  603. ls_partsize_dt.Columns.Add("c1");
  604. ls_partsize_dt.Columns.Add("c2");
  605. ls_partsize_dt.Columns.Add("c3");
  606. ls_partsize_dt.Columns.Add("c4");
  607. ls_partsize_dt.Columns.Add("c5");
  608. ls_partsize_dt.Columns.Add("c6");
  609. ls_partsize_dt.Columns.Add("c7");
  610. ls_partsize_dt.Columns.Add("c8");
  611. ls_partsize_dt.Columns.Add("c9");
  612. ls_partsize_dt.Columns.Add("c10");
  613. DataRow dr = ls_partsize_dt.NewRow();
  614. for (int i = 1; i < 10; i++)
  615. {
  616. if (colid.Count < i)
  617. {
  618. dr["c" + i.ToString()] = "";
  619. }
  620. else
  621. {
  622. dr["c" + i.ToString()] = colid[i - 1];
  623. }
  624. }
  625. ls_partsize_dt.Rows.Add(dr);
  626. DataTable ls_Particel_dt = new DataTable();
  627. ls_Particel_dt.TableName = "Particel";
  628. ls_Particel_dt.Columns.Add("c1");
  629. ls_Particel_dt.Columns.Add("c2");
  630. ls_Particel_dt.Columns.Add("c3");
  631. ls_Particel_dt.Columns.Add("c4");
  632. ls_Particel_dt.Columns.Add("c5");
  633. ls_Particel_dt.Columns.Add("c6");
  634. ls_Particel_dt.Columns.Add("c7");
  635. ls_Particel_dt.Columns.Add("c8");
  636. ls_Particel_dt.Columns.Add("c9");
  637. ls_Particel_dt.Columns.Add("c10");
  638. ls_Particel_dt.Columns.Add("Name");
  639. ls_Particel_dt.Columns.Add("total");
  640. ls_Particel_dt.Columns.Add("TypeId");
  641. for (int i = 0; i < data.Rows.Count; i++)
  642. {
  643. DataRow dr2 = ls_Particel_dt.NewRow();
  644. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  645. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  646. for (int j = 1; j < 11; j++)
  647. {
  648. if (colid.Count >= j)
  649. {
  650. double de = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  651. if (de == 0)
  652. dr2["c" + j.ToString()] = " ";
  653. else
  654. dr2["c" + j.ToString()] = de.ToString();
  655. }
  656. }
  657. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  658. {
  659. dr2["total"] = " "; //求合
  660. double d_total = 0;
  661. for (int j = 1; j < 11; j++)
  662. {
  663. if (colid.Count >= j)
  664. {
  665. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  666. }
  667. }
  668. if (d_total == 0)
  669. {
  670. continue;
  671. dr2["total"] = " ";
  672. }
  673. else
  674. dr2["total"] = d_total.ToString();
  675. }
  676. ls_Particel_dt.Rows.Add(dr2);
  677. }
  678. return ls_Particel_dt;
  679. }
  680. public DataTable TypeRange(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  681. {
  682. List<string> colid = new List<string>();
  683. //获取粒级表
  684. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  685. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  686. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  687. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  688. {
  689. if (sizestr.Split(',')[i].Length > 0)
  690. {
  691. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  692. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  693. colid.Add(d1.ToString() + "~" + d2.ToString());
  694. }
  695. }
  696. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  697. colid.Add(d.ToString() + "~MAX");
  698. DataTable ls_partsize_dt = new DataTable();
  699. ls_partsize_dt.TableName = "PartSize";
  700. ls_partsize_dt.Columns.Add("c1");
  701. ls_partsize_dt.Columns.Add("c2");
  702. ls_partsize_dt.Columns.Add("c3");
  703. ls_partsize_dt.Columns.Add("c4");
  704. ls_partsize_dt.Columns.Add("c5");
  705. ls_partsize_dt.Columns.Add("c6");
  706. ls_partsize_dt.Columns.Add("c7");
  707. ls_partsize_dt.Columns.Add("c8");
  708. ls_partsize_dt.Columns.Add("c9");
  709. ls_partsize_dt.Columns.Add("c10");
  710. ls_partsize_dt.Columns.Add("c11");
  711. ls_partsize_dt.Columns.Add("c12");
  712. DataRow dr = ls_partsize_dt.NewRow();
  713. for (int i = 1; i < 13; i++)
  714. {
  715. if (colid.Count < i)
  716. {
  717. dr["c" + i.ToString()] = "";
  718. }
  719. else
  720. {
  721. dr["c" + i.ToString()] = colid[i - 1];
  722. }
  723. }
  724. ls_partsize_dt.Rows.Add(dr);
  725. return ls_partsize_dt;
  726. }
  727. private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List<string> ClassName)
  728. {
  729. DataTable dt_Class = dataTable.Copy();
  730. dt_Class.Clear();
  731. dt_Class.TableName = "Particel";
  732. dt_Class.Columns.Remove("Name");
  733. dt_Class.Columns.Remove("TypeId");
  734. for (int i = 0; i < ClassName.Count; i++)
  735. {
  736. //保留当前循环中大类物质,去除其他物质
  737. DataTable dt = dataTable.Copy();
  738. dt.Clear();
  739. for (int a = 0; a < dataTable.Rows.Count; a++)
  740. {
  741. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  742. {
  743. dt.Rows.Add(dataTable.Rows[a].ItemArray);
  744. }
  745. }
  746. if (dt.Rows.Count == 0)
  747. continue;
  748. DataTable dt_2 = new DataTable();
  749. dt_2 = dataTable.Copy();
  750. dt_2.Clear();
  751. DataRow row = dt_2.NewRow();
  752. dt_2.Rows.Add(row);
  753. for (int a = 0; a < dt.Columns.Count; a++)
  754. {
  755. if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class" && dt.Columns[a].ToString() != "TypeId")
  756. {
  757. bool bl = false;
  758. for (int b = 0; b < dt.Rows.Count; b++)
  759. {
  760. if (!dt.Rows[b].IsNull(dt.Columns[a].ToString()))
  761. {
  762. bl = true;
  763. }
  764. }
  765. if (bl)
  766. {
  767. dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString());
  768. }
  769. }
  770. }
  771. dt_2.Columns.Remove("Name");
  772. dt_2.Columns.Remove("TypeId");
  773. dt_2.Rows[0]["Class"] = ClassName[i];
  774. dt_Class.Rows.Add(dt_2.Rows[0].ItemArray);
  775. }
  776. return dt_Class;
  777. }
  778. private DataTable classIfIcationSort(DataTable dataTable, List<string> ClassName, DataTable data)
  779. {
  780. DataTable dt = new DataTable();
  781. dt = dataTable.Copy();
  782. dt.Clear();
  783. dt.TableName = "Particel_subdivision";
  784. //循环list中每个类型
  785. for (int i = 0; i < ClassName.Count(); i++)
  786. {
  787. DataTable data1 = dt.Copy();
  788. data1.Clear();
  789. data1.Rows.Add();
  790. for (int a = 0; a < data.Rows.Count; a++)
  791. {
  792. if (data.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  793. {
  794. for (int b = 1; b < 10; b++)
  795. {
  796. data1.Rows[0]["c" + b.ToString()] = data.Rows[a]["c" + b.ToString()];
  797. }
  798. data1.Rows[0]["total"] = data.Rows[a]["total"];
  799. data1.Rows[0]["Class"] = data.Rows[a]["Class"];
  800. dt.Rows.Add(data1.Rows[0].ItemArray);
  801. }
  802. }
  803. DataTable dt_1 = new DataTable();
  804. dt_1 = dt.Copy();
  805. dt_1.Clear();
  806. //循环DataTable中每个分类的数据
  807. for (int a = 0; a < dataTable.Rows.Count; a++)
  808. {
  809. if (!string.IsNullOrWhiteSpace(ClassName[i].ToString()))
  810. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  811. {
  812. dataTable.Rows[a]["Class"] = "";
  813. dt_1.Rows.Add(dataTable.Rows[a].ItemArray);
  814. }
  815. }
  816. //将颗粒数量排序(从大到小)
  817. DataView dv = dt_1.DefaultView;
  818. dv.Sort = "total DESC";
  819. DataTable dt_1_sort = dv.ToTable();
  820. for (int a = 0; a < dt_1_sort.Rows.Count; a++)
  821. {
  822. dt.Rows.Add(dt_1_sort.Rows[a].ItemArray);
  823. }
  824. }
  825. dt.Columns.Remove("TypeId");
  826. return dt;
  827. }
  828. private DataTable InvalidRemoval(DataTable dt)
  829. {
  830. DataTable dataTable = dt.Copy();
  831. dataTable.Clear();
  832. for (int i = 0; i < dt.Rows.Count; i++)
  833. {
  834. if (Convert.ToInt32(dt.Rows[i]["TypeId"])>10 )
  835. {
  836. dataTable.Rows.Add(dt.Rows[i].ItemArray);
  837. }
  838. }
  839. return dataTable;
  840. }
  841. private void SelectParticleData(out DataTable dt, OTSReport_Export m_otsreport_export)
  842. {
  843. List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
  844. #region Datatable数据表格式
  845. DataTable dtUelect = new DataTable();
  846. dtUelect.Columns.Add("fieldid");
  847. dtUelect.Columns.Add("particleid");
  848. dtUelect.Columns.Add("AveGray");
  849. dtUelect.Columns.Add("RectLeft");
  850. dtUelect.Columns.Add("RectTop");
  851. dtUelect.Columns.Add("RectWidth");
  852. dtUelect.Columns.Add("RectHeight");
  853. dtUelect.Columns.Add("Area");
  854. dtUelect.Columns.Add("PosX");
  855. dtUelect.Columns.Add("PosY");
  856. dtUelect.Columns.Add("TypeId");
  857. dtUelect.Columns.Add("SegmentNum");
  858. dtUelect.Columns.Add("SEMPosX");
  859. dtUelect.Columns.Add("SEMPosY");
  860. dtUelect.Columns.Add("XrayId");
  861. dtUelect.Columns.Add("DMAX");
  862. dtUelect.Columns.Add("DMIN");
  863. dtUelect.Columns.Add("DPERP");
  864. dtUelect.Columns.Add("PERIMETER");
  865. dtUelect.Columns.Add("ORIENTATION");
  866. dtUelect.Columns.Add("DINSCR");
  867. dtUelect.Columns.Add("DMEAN");
  868. dtUelect.Columns.Add("DELONG");
  869. dtUelect.Columns.Add("DFERET");
  870. dtUelect.Columns.Add("TypeName");
  871. dtUelect.Columns.Add("TypeColor");
  872. #endregion
  873. for (int i = 0; i < selectParticles.Count; i++)
  874. {
  875. 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);
  876. }
  877. dt = dtUelect.Copy();
  878. }
  879. private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
  880. {
  881. DataTable dt_Partick = new DataTable();
  882. dt_Partick.Columns.Add("TypeId");
  883. dt_Partick.Columns.Add("TypeName");
  884. dt_Partick.Columns.Add("TypeColor");
  885. dt_Partick.Columns.Add("con");
  886. dt_Partick.Columns.Add("ar");
  887. dt_Partick.Columns.Add("max");
  888. dt_Partick.Columns.Add("Area", typeof(double));
  889. dt_Partick.Columns.Add("GroupName");
  890. List<string> typeName = new List<string>();
  891. for (int i = 0; i < data.Rows.Count; i++)
  892. {
  893. typeName.Add(data.Rows[i]["TypeId"].ToString());
  894. }
  895. typeName = typeName.Distinct().ToList();
  896. for (int i = 0; i < typeName.Count; i++)
  897. {
  898. DataTable dt = dt_Partick.Clone();
  899. for (int j = 0; j < data.Rows.Count; j++)
  900. {
  901. if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
  902. {
  903. DataRow row = dt.NewRow();
  904. row["TypeId"] = data.Rows[j]["TypeId"];
  905. row["TypeName"] = data.Rows[j]["TypeName"];
  906. row["TypeColor"] = data.Rows[j]["TypeColor"];
  907. row["Area"] = data.Rows[j]["Area"];
  908. dt.Rows.Add(row);
  909. }
  910. }
  911. DataRow dr = dt_Partick.NewRow();
  912. dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
  913. dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
  914. dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
  915. dr["con"] = dt.Rows.Count;
  916. dr["ar"] = dt.Compute("min(Area)", "");
  917. dr["max"] = dt.Compute("Max(Area)", "");
  918. dr["Area"] = dt.Compute("SUM(Area)", "");
  919. dt_Partick.Rows.Add(dr);
  920. }
  921. for (int i = 0; i < dt_Partick.Rows.Count; i++)
  922. {
  923. for (int j = 0; j < table.Rows.Count; j++)
  924. {
  925. if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
  926. {
  927. dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
  928. break;
  929. }
  930. }
  931. }
  932. return dt_Partick;
  933. }
  934. private string getWhere(string max, string min, string col, string partic)
  935. {
  936. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  937. }
  938. private DataTable GetDBData(c_TemplateClass m_mbszclass , OTSReport_Export m_otsreport_export)
  939. {
  940. DataTable m_bt_DBData = new DataTable();
  941. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
  942. List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
  943. //获取粒级表
  944. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_mbszclass.M_KLFXJG.str_cb_klcc_ljb.ToString();
  945. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  946. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  947. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  948. {
  949. if (sizestr.Split(',')[i].Length > 0)
  950. {
  951. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  952. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  953. colid.Add(d1.ToString() + "~" + d2.ToString());
  954. }
  955. }
  956. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  957. colid.Add(d.ToString() + "~MAX");
  958. for (int i = 0; i < colid.Count; i++)
  959. {
  960. m_bt_DBData.Columns.Add(colid[i].ToString());
  961. }
  962. DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
  963. DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
  964. DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
  965. //选择颗粒信息
  966. DataTable data;
  967. SelectParticleData(out data, m_otsreport_export);
  968. //选择颗粒整理成表
  969. DataTable Partic_dt = new DataTable();
  970. if (data.Rows.Count > 0)
  971. {
  972. Partic_dt = GetParticleListForParticlSize(data, dtp);
  973. }
  974. List<string> vs = new List<string>() { "DMAX", "DMIN", "FERET", "Area" };
  975. string po = vs[m_otsreport_export.m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs];
  976. switch (po)
  977. {
  978. case "DMAX":
  979. po = "DMAX";
  980. break;
  981. case "DMIN":
  982. po = "DMIN";
  983. break;
  984. case "ECD":
  985. po = "Area";
  986. break;
  987. case "FERET":
  988. po = "DFERET";
  989. break;
  990. }
  991. //如果是全部颗粒(0)
  992. if (m_mbszclass.M_SY.int_xzkl == 0)
  993. {
  994. for (int i = 0; i < dt.Rows.Count; i++)
  995. {
  996. DataRow dr = m_bt_DBData.NewRow();
  997. dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
  998. dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
  999. dr["con"] = dt.Rows[i]["con"].ToString();
  1000. if (dt.Rows[i]["GroupName"].ToString() == "")
  1001. dr["Class"] = "Default";
  1002. else
  1003. dr["Class"] = dt.Rows[i]["GroupName"].ToString();
  1004. //continue;
  1005. dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
  1006. for (int a = 6; a < colid.Count; a++)
  1007. {
  1008. string d1 = colid[a].Split('~')[0];
  1009. string d2 = colid[a].Split('~')[1];
  1010. if (d2 == "MAX")
  1011. {
  1012. d2 = "999";
  1013. }
  1014. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
  1015. dr[colid[a]] = datas.Count();
  1016. }
  1017. for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
  1018. {
  1019. if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
  1020. {
  1021. dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
  1022. }
  1023. }
  1024. m_bt_DBData.Rows.Add(dr);
  1025. }
  1026. }
  1027. else//选择颗粒(1)
  1028. {
  1029. for (int i = 0; i < Partic_dt.Rows.Count; i++)
  1030. {
  1031. DataRow dr = m_bt_DBData.NewRow();
  1032. dr["TypeName"] = Partic_dt.Rows[i]["TypeName"].ToString();
  1033. dr["TypeId"] = Partic_dt.Rows[i]["TypeId"].ToString();
  1034. dr["con"] = Partic_dt.Rows[i]["con"].ToString();
  1035. dr["Class"] = Partic_dt.Rows[i]["GroupName"].ToString();
  1036. dr["Largest"] = Math.Round(Convert.ToDouble(Partic_dt.Rows[i]["max"]), 2);
  1037. for (int a = 6; a < colid.Count; a++)
  1038. {
  1039. string d1 = colid[a].Split('~')[0];
  1040. string d2 = colid[a].Split('~')[1];
  1041. if (d2 == "MAX")
  1042. {
  1043. d2 = "999";
  1044. }
  1045. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, Partic_dt.Rows[i]["TypeId"].ToString()));
  1046. dr[colid[a]] = datas.Count();
  1047. }
  1048. dr["ar"] = Partic_dt.Rows[i]["Area"];
  1049. m_bt_DBData.Rows.Add(dr);
  1050. }
  1051. }
  1052. //去除物质分类(非夹杂物分类)
  1053. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass.Count; a++)
  1054. {
  1055. for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
  1056. {
  1057. if (m_bt_DBData.Rows[i]["TypeName"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass[a].ToString())
  1058. {
  1059. m_bt_DBData.Rows.RemoveAt(i);
  1060. }
  1061. }
  1062. }
  1063. return m_bt_DBData;
  1064. }
  1065. }
  1066. }