ParticleAnalysis.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. 
  2. using OTSIncAReportApp.DataOperation.DataAccess;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using static OTSIncAReportApp.OTSReport_Export;
  10. namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
  11. {
  12. /// <summary>
  13. /// 颗粒分析
  14. /// </summary>
  15. class ParticleAnalysis
  16. {
  17. /// <summary>
  18. /// 大分类
  19. /// </summary>
  20. /// <returns></returns>
  21. public DataTable GetLargeClassification(BasicData basicData)
  22. {
  23. DataTable data = basicData.GetDBData();
  24. //获取粒级表
  25. List<string> colid = basicData.GetParticlesizeTable();
  26. DataTable ls_partsize_dt = new DataTable();
  27. ls_partsize_dt.TableName = "PartSize";
  28. for (int i = 0; i < colid.Count; i++)
  29. {
  30. ls_partsize_dt.Columns.Add("c" + (i + 1).ToString());
  31. }
  32. DataTable ls_Particel_dt = new DataTable();
  33. ls_Particel_dt.TableName = "Particel";
  34. DataRow dr = ls_partsize_dt.NewRow();
  35. int colidCount = 1;
  36. for (int i = 0; i < colid.Count; i++)
  37. {
  38. if (colid.Count < i)
  39. {
  40. dr["c" + (i + 1).ToString()] = "";
  41. }
  42. else
  43. {
  44. dr["c" + (i + 1).ToString()] = colid[i];
  45. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  46. colidCount++;
  47. }
  48. }
  49. ls_partsize_dt.Rows.Add(dr);
  50. ls_Particel_dt.Columns.Add("Name");
  51. ls_Particel_dt.Columns.Add("total", typeof(double));
  52. ls_Particel_dt.Columns.Add("TypeId");
  53. ls_Particel_dt.Columns.Add("Class");
  54. for (int i = 0; i < data.Rows.Count; i++)
  55. {
  56. DataRow dr2 = ls_Particel_dt.NewRow();
  57. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  58. dr2["Class"] = data.Rows[i]["Class"].ToString();
  59. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  60. for (int j = 1; j < colidCount; j++)
  61. {
  62. if (colid.Count >= j)
  63. {
  64. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  65. }
  66. }
  67. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  68. {
  69. dr2["total"] = "0"; //求合
  70. double d_total = 0;
  71. for (int j = 1; j < colidCount; j++)
  72. {
  73. if (colid.Count >= j)
  74. {
  75. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  76. }
  77. }
  78. dr2["total"] = d_total.ToString();
  79. }
  80. ls_Particel_dt.Rows.Add(dr2);
  81. }
  82. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  83. List<string> ClassName = new List<string>();
  84. DataTable getClass_dt = basicData.GetAllClass();
  85. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  86. {
  87. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  88. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  89. ClassName.Add("NULL");
  90. else
  91. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  92. }
  93. //获取大分类信息
  94. DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
  95. return dt;
  96. }
  97. /// <summary>
  98. /// 小分类
  99. /// </summary>
  100. /// <returns></returns>
  101. public DataTable GetSubClassification(BasicData basicData)
  102. {
  103. DataTable data = basicData.GetDBData();
  104. //获取粒级表
  105. List<string> colid = new List<string>();
  106. colid = basicData.GetParticlesizeTable();
  107. //------------------------------------------------
  108. DataTable ls_partsize_dt = new DataTable();
  109. ls_partsize_dt.TableName = "PartSize";
  110. for (int i=0;i< colid.Count;i++)
  111. {
  112. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  113. }
  114. DataRow dr = ls_partsize_dt.NewRow();
  115. DataTable ls_Particel_dt = new DataTable();
  116. ls_Particel_dt.TableName = "Particel";
  117. int colidCount = 1;
  118. for (int i = 0; i < colid.Count; i++)
  119. {
  120. if (colid.Count < i)
  121. {
  122. dr["c" + (i + 1).ToString()] = "";
  123. }
  124. else
  125. {
  126. dr["c" + (i + 1).ToString()] = colid[i];
  127. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  128. colidCount++;
  129. }
  130. }
  131. ls_Particel_dt.Columns.Add("Name");
  132. ls_Particel_dt.Columns.Add("total", typeof(double));
  133. ls_Particel_dt.Columns.Add("TypeId");
  134. ls_Particel_dt.Columns.Add("Class");
  135. for (int i = 0; i < data.Rows.Count; i++)
  136. {
  137. DataRow dr2 = ls_Particel_dt.NewRow();
  138. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  139. dr2["Class"] = data.Rows[i]["Class"].ToString();
  140. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  141. for (int j = 1; j < colidCount; j++)
  142. {
  143. if (colid.Count >= j)
  144. {
  145. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  146. }
  147. }
  148. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  149. {
  150. dr2["total"] = "0"; //求合
  151. double d_total = 0;
  152. for (int j = 1; j < colidCount; j++)
  153. {
  154. if (colid.Count >= j)
  155. {
  156. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  157. }
  158. }
  159. dr2["total"] = d_total.ToString();
  160. }
  161. ls_Particel_dt.Rows.Add(dr2);
  162. }
  163. return ls_Particel_dt;
  164. }
  165. /// <summary>
  166. /// 分类整合大小分类都有
  167. /// </summary>
  168. /// <returns></returns>
  169. public List<DataTable> GetClassificationConsolidationTable(BasicData basicData)
  170. {
  171. List<DataTable> datas = new List<DataTable>();
  172. DataTable data = basicData.GetDBData();
  173. //获取粒级表
  174. List<string> colid = new List<string>();
  175. colid = basicData.GetParticlesizeTable();
  176. //------------------------------------------------
  177. DataTable ls_partsize_dt = new DataTable();
  178. ls_partsize_dt.TableName = "PartSize";
  179. for(int i=0;i< colid.Count;i++)
  180. {
  181. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  182. }
  183. DataRow dr = ls_partsize_dt.NewRow();
  184. DataTable ls_Particel_dt = new DataTable();
  185. ls_Particel_dt.TableName = "Particel";
  186. int colidCount = 1;
  187. for (int i = 0; i < colid.Count; i++)
  188. {
  189. if (colid.Count < i)
  190. {
  191. dr["c" + (i+1).ToString()] = "";
  192. }
  193. else
  194. {
  195. dr["c" + (i + 1).ToString()] = colid[i];
  196. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  197. colidCount++;
  198. }
  199. }
  200. ls_partsize_dt.Rows.Add(dr);
  201. ls_Particel_dt.Columns.Add("Name");
  202. ls_Particel_dt.Columns.Add("total", typeof(double));
  203. ls_Particel_dt.Columns.Add("TypeId");
  204. ls_Particel_dt.Columns.Add("Class");
  205. for (int i = 0; i < data.Rows.Count; i++)
  206. {
  207. DataRow dr2 = ls_Particel_dt.NewRow();
  208. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  209. dr2["Class"] = data.Rows[i]["Class"].ToString();
  210. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  211. for (int j = 1; j < colidCount; j++)
  212. {
  213. if (colid.Count >= j)
  214. {
  215. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  216. }
  217. }
  218. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  219. {
  220. dr2["total"] = "0"; //求合
  221. double d_total = 0;
  222. for (int j = 1; j < colidCount; j++)
  223. {
  224. if (colid.Count >= j)
  225. {
  226. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  227. }
  228. }
  229. dr2["total"] = d_total.ToString();
  230. }
  231. ls_Particel_dt.Rows.Add(dr2);
  232. }
  233. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  234. List<string> ClassName = new List<string>();
  235. DataTable getClass_dt = basicData.GetAllClass();
  236. bool bl = false;
  237. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  238. {
  239. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
  240. && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
  241. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  242. {
  243. if (!bl)
  244. {
  245. ClassName.Add("Default");
  246. bl = true;
  247. }
  248. }
  249. else
  250. {
  251. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  252. }
  253. }
  254. //获取大分类信息
  255. DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
  256. DataTable data2 = classIfIcationSort(ls_Particel_dt, ClassName, dt, colidCount);
  257. datas.Add(ls_partsize_dt.Copy());
  258. datas.Add(data2.Copy());
  259. return datas;
  260. }
  261. /// <summary>
  262. /// 大分类chart数据
  263. /// </summary>
  264. /// <param name="m_mbszclass"></param>
  265. /// <param name="m_otsreport_export"></param>
  266. /// <returns></returns>
  267. public DataTable GetChartDataCalss(BasicData basicData)
  268. {
  269. DataTable data =basicData.GetDBData();
  270. //获取粒级表
  271. List<string> colid = basicData.GetParticlesizeTable();
  272. //------------------------------------------------
  273. DataTable ls_partsize_dt = new DataTable();
  274. ls_partsize_dt.TableName = "PartSize";
  275. for (int i = 0; i < colid.Count; i++)
  276. {
  277. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  278. }
  279. DataTable ls_Particel_dt = new DataTable();
  280. ls_Particel_dt.TableName = "Particel";
  281. DataRow dr = ls_partsize_dt.NewRow();
  282. int colidCount = 1;
  283. for (int i = 0; i < colid.Count; i++)
  284. {
  285. if (colid.Count < i)
  286. {
  287. dr["c" + (i + 1).ToString()] = "";
  288. }
  289. else
  290. {
  291. dr["c" + (i + 1).ToString()] = colid[i];
  292. ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
  293. colidCount++;
  294. }
  295. }
  296. ls_partsize_dt.Rows.Add(dr);
  297. ls_Particel_dt.Columns.Add("Name");
  298. ls_Particel_dt.Columns.Add("total", typeof(double));
  299. ls_Particel_dt.Columns.Add("TypeId");
  300. ls_Particel_dt.Columns.Add("Class");
  301. for (int i = 0; i < data.Rows.Count; i++)
  302. {
  303. DataRow dr2 = ls_Particel_dt.NewRow();
  304. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  305. dr2["Class"] = data.Rows[i]["Class"].ToString();
  306. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  307. for (int j = 1; j < colidCount; j++)
  308. {
  309. if (colid.Count >= j)
  310. {
  311. dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  312. }
  313. }
  314. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  315. {
  316. dr2["total"] = "0"; //求合
  317. double d_total = 0;
  318. for (int j = 1; j < colidCount; j++)
  319. {
  320. if (colid.Count >= j)
  321. {
  322. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  323. }
  324. }
  325. dr2["total"] = d_total.ToString();
  326. }
  327. ls_Particel_dt.Rows.Add(dr2);
  328. }
  329. //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
  330. List<string> ClassName = new List<string>();
  331. DataTable getClass_dt = basicData.GetAllClass();
  332. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  333. {
  334. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid")
  335. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  336. ClassName.Add("NULL");
  337. else
  338. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  339. }
  340. //颗粒尺寸数据(例 1.5有多少,2.0有多少)
  341. DataTable colid_data = new DataTable();
  342. colid_data.Columns.Add("name");
  343. colid_data.Columns.Add("quantity", typeof(double));
  344. for (int i = 0; i < ls_Particel_dt.Columns.Count; i++)
  345. {
  346. if (ls_Particel_dt.Columns[i].ColumnName == "c" + (i + 1).ToString())
  347. {
  348. if (i < colid.Count)
  349. {
  350. DataRow dr1 = colid_data.NewRow();
  351. dr1["name"] = colid[i].ToString();
  352. int quantity = 0;
  353. for (int a = 0; a < ls_Particel_dt.Rows.Count; a++)
  354. {
  355. quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString());
  356. }
  357. dr1["quantity"] = quantity.ToString();
  358. colid_data.Rows.Add(dr1);
  359. }
  360. }
  361. }
  362. return colid_data;
  363. }
  364. public DataTable ParticleResults(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
  365. {
  366. DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
  367. List<string> colid = new List<string>();
  368. //获取粒级表
  369. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  370. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  371. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  372. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  373. for (int i = 0; i < sizestr.Split(',').Length; i++)
  374. {
  375. if (sizestr.Split(',')[i].Length > 0)
  376. {
  377. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  378. colid.Add("≥" + d1.ToString() );
  379. }
  380. }
  381. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  382. //------------------------------------------------
  383. DataTable ls_partsize_dt = new DataTable();
  384. ls_partsize_dt.TableName = "PartSize";
  385. for(int i=0;i< colid.Count;i++)
  386. {
  387. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  388. }
  389. DataRow dr = ls_partsize_dt.NewRow();
  390. DataTable ls_Particel_dt = new DataTable();
  391. ls_Particel_dt.TableName = "Particel";
  392. int colidCount = 1;
  393. for (int i = 0; i < colid.Count; i++)
  394. {
  395. dr["c" + (i+1).ToString()] = colid[i];
  396. ls_Particel_dt.Columns.Add("c"+ (i + 1).ToString());
  397. colidCount++;
  398. }
  399. ls_partsize_dt.Rows.Add(dr);
  400. ls_Particel_dt.Columns.Add("Name");
  401. ls_Particel_dt.Columns.Add("total");
  402. ls_Particel_dt.Columns.Add("TypeId");
  403. for (int i = 0; i < data.Rows.Count; i++)
  404. {
  405. DataRow dr2 = ls_Particel_dt.NewRow();
  406. dr2["Name"] = data.Rows[i]["TypeName"].ToString();
  407. dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
  408. for (int j = 1; j < colidCount; j++)
  409. {
  410. if (colid.Count >= j)
  411. {
  412. double de = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
  413. if (de == 0)
  414. dr2["c" + j.ToString()] = " ";
  415. else
  416. dr2["c" + j.ToString()] = de.ToString();
  417. }
  418. }
  419. if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
  420. {
  421. dr2["total"] = " "; //求合
  422. double d_total = 0;
  423. for (int j = 1; j < colidCount; j++)
  424. {
  425. if (colid.Count >= j)
  426. {
  427. d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
  428. }
  429. }
  430. if (d_total == 0)
  431. {
  432. continue;
  433. dr2["total"] = " ";
  434. }
  435. else
  436. dr2["total"] = d_total.ToString();
  437. }
  438. ls_Particel_dt.Rows.Add(dr2);
  439. }
  440. return ls_Particel_dt;
  441. }
  442. public DataTable TypeRange(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
  443. {
  444. List<string> colid = new List<string>();
  445. //获取粒级表
  446. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  447. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  448. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  449. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  450. for (int i = 0; i < sizestr.Split(',').Length; i++)
  451. {
  452. if (sizestr.Split(',')[i].Length > 0)
  453. {
  454. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  455. colid.Add("≥" + d1.ToString());
  456. }
  457. }
  458. DataTable ls_partsize_dt = new DataTable();
  459. ls_partsize_dt.TableName = "PartSize";
  460. for (int i=0;i< colid.Count;i++)
  461. {
  462. ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
  463. }
  464. DataRow dr = ls_partsize_dt.NewRow();
  465. for (int i = 0; i < colid.Count; i++)
  466. {
  467. dr["c" + (i+1).ToString()] = colid[i];
  468. }
  469. ls_partsize_dt.Rows.Add(dr);
  470. return ls_partsize_dt;
  471. }
  472. private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List<string> ClassName)
  473. {
  474. DataTable dt_Class = dataTable.Copy();
  475. dt_Class.Clear();
  476. dt_Class.TableName = "Particel";
  477. dt_Class.Columns.Remove("Name");
  478. for (int i = 0; i < ClassName.Count; i++)
  479. {
  480. //保留当前循环中大类物质,去除其他物质
  481. DataTable dt = dataTable.Copy();
  482. dt.Clear();
  483. for (int a = 0; a < dataTable.Rows.Count; a++)
  484. {
  485. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  486. {
  487. dt.Rows.Add(dataTable.Rows[a].ItemArray);
  488. }
  489. }
  490. if (dt.Rows.Count == 0)
  491. continue;
  492. DataTable dt_2 = new DataTable();
  493. dt_2 = dataTable.Copy();
  494. dt_2.Clear();
  495. DataRow row = dt_2.NewRow();
  496. dt_2.Rows.Add(row);
  497. for (int a = 0; a < dt.Columns.Count; a++)
  498. {
  499. if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class" && dt.Columns[a].ToString() != "TypeId")
  500. {
  501. bool bl = false;
  502. for (int b = 0; b < dt.Rows.Count; b++)
  503. {
  504. if (!dt.Rows[b].IsNull(dt.Columns[a].ToString()))
  505. {
  506. bl = true;
  507. }
  508. }
  509. if (bl)
  510. {
  511. dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString());
  512. }
  513. }
  514. }
  515. dt_2.Columns.Remove("Name");
  516. dt_2.Rows[0]["Class"] = ClassName[i];
  517. dt_Class.Rows.Add(dt_2.Rows[0].ItemArray);
  518. }
  519. return dt_Class;
  520. }
  521. private DataTable classIfIcationSort(DataTable dataTable, List<string> ClassName, DataTable data,int colidCount)
  522. {
  523. DataTable dt = new DataTable();
  524. dt = dataTable.Copy();
  525. dt.Clear();
  526. dt.TableName = "Particel_subdivision";
  527. //循环list中每个类型
  528. for (int i = 0; i < ClassName.Count(); i++)
  529. {
  530. DataTable data1 = dt.Copy();
  531. data1.Clear();
  532. data1.Rows.Add();
  533. for (int a = 0; a < data.Rows.Count; a++)
  534. {
  535. if (data.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  536. {
  537. for (int b = 1; b < colidCount; b++)
  538. {
  539. data1.Rows[0]["c" + b.ToString()] = data.Rows[a]["c" + b.ToString()];
  540. }
  541. data1.Rows[0]["total"] = data.Rows[a]["total"];
  542. data1.Rows[0]["Class"] = data.Rows[a]["Class"];
  543. dt.Rows.Add(data1.Rows[0].ItemArray);
  544. }
  545. }
  546. DataTable dt_1 = new DataTable();
  547. dt_1 = dt.Copy();
  548. dt_1.Clear();
  549. //循环DataTable中每个分类的数据
  550. for (int a = 0; a < dataTable.Rows.Count; a++)
  551. {
  552. if (!string.IsNullOrWhiteSpace(ClassName[i].ToString()))
  553. if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
  554. {
  555. dataTable.Rows[a]["Class"] = "";
  556. dt_1.Rows.Add(dataTable.Rows[a].ItemArray);
  557. }
  558. }
  559. //将颗粒数量排序(从大到小)
  560. DataView dv = dt_1.DefaultView;
  561. dv.Sort = "total DESC";
  562. DataTable dt_1_sort = dv.ToTable();
  563. for (int a = 0; a < dt_1_sort.Rows.Count; a++)
  564. {
  565. dt.Rows.Add(dt_1_sort.Rows[a].ItemArray);
  566. }
  567. }
  568. return dt;
  569. }
  570. private DataTable InvalidRemoval(DataTable dt)
  571. {
  572. DataTable dataTable = dt.Copy();
  573. dataTable.Clear();
  574. for (int i = 0; i < dt.Rows.Count; i++)
  575. {
  576. if (Convert.ToInt32(dt.Rows[i]["TypeId"])>10 )
  577. {
  578. dataTable.Rows.Add(dt.Rows[i].ItemArray);
  579. }
  580. }
  581. return dataTable;
  582. }
  583. private string getWhere(string max, string min, string col, string partic)
  584. {
  585. return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
  586. }
  587. private DataTable GetDBData(c_TemplateClass m_mbszclass , OTSReport_Export m_otsreport_export,string ComputeMode)
  588. {
  589. DataTable m_bt_DBData = new DataTable();
  590. ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
  591. List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
  592. //获取粒级表
  593. string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
  594. m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
  595. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
  596. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  597. for (int i = 0; i < sizestr.Split(',').Length ; i++)
  598. {
  599. if (sizestr.Split(',')[i].Length > 0)
  600. {
  601. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  602. colid.Add("≥" + d1.ToString() );
  603. }
  604. }
  605. for (int i = 0; i < colid.Count; i++)
  606. {
  607. m_bt_DBData.Columns.Add(colid[i].ToString());
  608. }
  609. DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
  610. DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
  611. DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
  612. string po = ComputeMode;
  613. switch (po)
  614. {
  615. case "DMAX":
  616. po = "DMAX";
  617. break;
  618. case "DMIN":
  619. po = "DMIN";
  620. break;
  621. case "ECD":
  622. po = "Area";
  623. break;
  624. case "FERET":
  625. po = "DFERET";
  626. break;
  627. }
  628. for (int i = 0; i < dt.Rows.Count; i++)
  629. {
  630. DataRow dr = m_bt_DBData.NewRow();
  631. dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
  632. dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
  633. dr["con"] = dt.Rows[i]["con"].ToString();
  634. if (dt.Rows[i]["GroupName"].ToString() == "")
  635. dr["Class"] = "Default";
  636. else
  637. dr["Class"] = dt.Rows[i]["GroupName"].ToString();
  638. //continue;
  639. dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
  640. for (int a = 6; a < colid.Count; a++)
  641. {
  642. string d2;
  643. if (a== colid.Count-1)
  644. {
  645. d2 = "999";
  646. }
  647. else
  648. {
  649. d2 = colid[a+1].Split('≥')[1];
  650. }
  651. string d1 = colid[a].Split('≥')[1];
  652. DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
  653. dr[colid[a]] = datas.Count();
  654. }
  655. for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
  656. {
  657. if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
  658. {
  659. dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
  660. }
  661. }
  662. m_bt_DBData.Rows.Add(dr);
  663. }
  664. //去除物质分类(非夹杂物分类)
  665. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial.Count; a++)
  666. {
  667. for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
  668. {
  669. if (m_bt_DBData.Rows[i]["TypeId"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial[a].ToString())
  670. {
  671. m_bt_DBData.Rows.RemoveAt(i);
  672. }
  673. }
  674. }
  675. if (m_mbszclass.list_str_MainPriority_Serial.Count==0)
  676. {
  677. return m_bt_DBData;
  678. }
  679. DataTable datass = m_bt_DBData.Clone();
  680. for (int i=0;i< m_mbszclass.list_str_MainPriority_Serial.Count;i++)
  681. {
  682. bool bl = false;
  683. for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
  684. {
  685. if (m_bt_DBData.Rows[a]["TypeId"].ToString() == m_mbszclass.list_str_MainPriority_Serial[i])
  686. {
  687. datass.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
  688. bl = true;
  689. continue;
  690. }
  691. }
  692. if(!bl)
  693. {
  694. DataTable dta= m_bt_DBData.Clone();
  695. if (m_bt_DBData.Rows.Count != 0)
  696. {
  697. dta.Rows.Add(m_bt_DBData.Rows[0].ItemArray);
  698. for (int b = 0; b < dta.Columns.Count; b++)
  699. {
  700. if (dta.Columns[b].ColumnName == "TypeName")
  701. {
  702. dta.Rows[0][b] = m_mbszclass.list_str_MainPriority[i];
  703. }
  704. else if (dta.Columns[b].ColumnName == "Class")
  705. {
  706. dta.Rows[0][b] = "Default";
  707. }
  708. else
  709. {
  710. dta.Rows[0][b] = 0;
  711. }
  712. }
  713. datass.Rows.Add(dta.Rows[0].ItemArray);
  714. }
  715. }
  716. }
  717. return datass;
  718. }
  719. }
  720. }