ParticleAnalysis.cs 31 KB

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