ParticleAnalysis.cs 49 KB

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