ParticleAnalysis.cs 39 KB

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