ParticleAnalysis.cs 36 KB

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